-Summary: Package that uses Apache configuration
-Summary(pl): Pakiet u¿ywaj±cy konfiguracji Apache'a
-Name: template-apache-package
-Version: 0.1
-Release: 0.7
-License: Public Domain
+Summary: Package that uses webapps configuration
+Summary(pl.UTF-8): Pakiet używający konfiguracji aplikacji WWW
+Name: template-webapp
+Version: 0.3
+Release: 0.3
+License: GPL
Group: Applications/WWW
+#Source0: %{name}-%{version}.tar.gz
+# Source0-md5: -
+#Source1: apache.conf
+#Source2: lighttpd.conf
+#URL: -
+BuildRequires: rpmbuild(macros) >= 1.268
+Requires: webapps
+# see packages/webapps/webapps.README for description and complete listing
+#Requires: webserver(access)
+#Requires: webserver(alias)
+#Requires: webserver(auth)
+#Requires: webserver(cgi)
+#Requires: webserver(expires)
+#Requires: webserver(indexfile)
+#Requires: webserver(mime)
+#Requires: webserver(php)
+#Requires: webserver(setenv)
BuildArch: noarch
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
-%define _apache1dir /etc/apache
-%define _apache2dir /etc/httpd
+%define _webapps /etc/webapps
+%define _webapp %{name}
+%define _sysconfdir %{_webapps}/%{_webapp}
+#%define _appdir %{_datadir}/%{_webapp}
+
+# in case _sysconfdir is not in webapps dir, run this replace pattern
+# before copy-pasting to your spec: :%s#%{_sysconfdir}#%{_webapps}/%{_webapp}#g
%description
-This spec is for demonstrating triggers used for linking package
-config to apache1/apache2 configuration dir.
+This .spec is for demonstrating triggers used for linking webapp
+configuration to webserver config dir.
-%description -l pl
-Ten spec s³u¿y do pokazania triggerów s³u¿±cych do pod³±czania
-konfiguracji pakietu do katalogu konfiguracyjnego apache1/apache2.
+%description -l pl.UTF-8
+Ten plik .spec służy do pokazania triggerów służących do podłączania
+konfiguracji aplikacji WWW do katalogu konfiguracyjnego serwera WWW.
%prep
+%setup -q
+
+cat > apache.conf <<'EOF'
+Alias /%{name} %{_appdir}
+<Directory %{_appdir}>
+ # Apache 2.x
+ <IfModule !mod_authz_core.c>
+ Order allow,deny
+ Allow from all
+ </IfModule>
+ # Apache 2.4
+ <IfModule mod_authz_core.c>
+ Require all granted
+ </IfModule>
+</Directory>
+EOF
+
+cat > lighttpd.conf <<'EOF'
+alias.url += (
+ "/%{name}" => "%{_appdir}",
+)
+EOF
%install
rm -rf $RPM_BUILD_ROOT
install -d $RPM_BUILD_ROOT%{_sysconfdir}
-cat >> $RPM_BUILD_ROOT%{_sysconfdir}/apache-%{name}.conf <<EOF
-# This is sample apache config
-EOF
+install -d $RPM_BUILD_ROOT{%{_sysconfdir},%{_appdir}}
+
+cp -a . $RPM_BUILD_ROOT%{_appdir}
+
+cp -p apache.conf $RPM_BUILD_ROOT%{_sysconfdir}/apache.conf
+cp -p apache.conf $RPM_BUILD_ROOT%{_sysconfdir}/httpd.conf
+cp -p lighttpd.conf $RPM_BUILD_ROOT%{_sysconfdir}/lighttpd.conf
+
+mv $RPM_BUILD_ROOT{%{_appdir},%{_sysconfdir}}/apache.conf
+mv $RPM_BUILD_ROOT{%{_appdir},%{_sysconfdir}}/lighttpd.conf
+cp -p $RPM_BUILD_ROOT%{_sysconfdir}/{apache,httpd}.conf
+
+cp -p %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/apache.conf
+cp -p %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/lighttpd.conf
+cp -p $RPM_BUILD_ROOT%{_sysconfdir}/{apache,httpd}.conf
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+# %webapp_* macros usage extracted from /usr/lib/rpm/macros.build:
+#
+# Usage:
+# %%webapp_register HTTPD WEBAPP
+# %%webapp_unregister HTTPD WEBAPP
+
+%triggerin -- apache1 < 1.3.37-3, apache1-base
+%webapp_register apache %{_webapp}
+
+%triggerun -- apache1 < 1.3.37-3, apache1-base
+%webapp_unregister apache %{_webapp}
+
+%triggerin -- apache < 2.2.0, apache-base
+%webapp_register httpd %{_webapp}
+
+%triggerun -- apache < 2.2.0, apache-base
+%webapp_unregister httpd %{_webapp}
+
+%triggerin -- lighttpd
+%webapp_register lighttpd %{_webapp}
-%triggerin -- apache1 >= 1.3.33-2
-%{?debug:set -x; echo "triggerin apache1 %{name}-%{version}-%{release} 1:[$1]; 2:[$2]"}
-if [ -d %{_apache1dir}/conf.d ]; then
- ln -sf %{_sysconfdir}/apache-%{name}.conf %{_apache1dir}/conf.d/99_%{name}.conf
- if [ -f /var/lock/subsys/apache ]; then
- /etc/rc.d/init.d/apache restart 1>&2
- fi
-fi
-
-%triggerun -- apache1 >= 1.3.33-2
-%{?debug:set -x; echo "triggerun apache1 %{name}-%{version}-%{release}: 1:[$1]; 2:[$2]"}
-# remove link if eighter of the packages are gone
-if [ "$1" = "0" ] || [ "$2" = "0" ]; then
- if [ -d %{_apache1dir}/conf.d ]; then
- rm -f %{_apache1dir}/conf.d/99_%{name}.conf
- if [ -f /var/lock/subsys/apache ]; then
- /etc/rc.d/init.d/apache restart 1>&2
- fi
- fi
-fi
-
-%triggerin -- apache >= 2.0.0
-%{?debug:set -x; echo "triggerin apache2 %{name}-%{version}-%{release}: 1:[$1]; 2:[$2]"}
-if [ -d %{_apache2dir}/httpd.conf ]; then
- ln -sf %{_sysconfdir}/apache-%{name}.conf %{_apache2dir}/httpd.conf/99_%{name}.conf
- if [ -f /var/lock/subsys/httpd ]; then
- /etc/rc.d/init.d/httpd restart 1>&2
- fi
-fi
-
-%triggerun -- apache >= 2.0.0
-%{?debug:set -x; echo "triggerun apache2 %{name}-%{version}-%{release}: 1:[$1]; 2:[$2]"}
-# remove link if eighter of the packages are gone
-if [ "$1" = "0" ] || [ "$2" = "0" ]; then
- if [ -d %{_apache2dir}/httpd.conf ]; then
- rm -f %{_apache2dir}/httpd.conf/99_%{name}.conf
- if [ -f /var/lock/subsys/httpd ]; then
- /etc/rc.d/init.d/httpd restart 1>&2
- fi
- fi
-fi
+%triggerun -- lighttpd
+%webapp_unregister lighttpd %{_webapp}
%files
%defattr(644,root,root,755)
-%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/apache-%{name}.conf
+%dir %attr(750,root,http) %{_sysconfdir}
+%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/apache.conf
+%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/httpd.conf
+%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/lighttpd.conf
+%attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/*.php
+%{_appdir}