1 Summary: Package that uses webapps configuration
2 Summary(pl): Pakiet u¿ywaj±cy konfiguracji aplikacji WWW
8 #Source0: %{name}-%{version}.tar.gz
11 BuildRequires: rpmbuild(macros) >= 1.264
14 Requires(triggerpostun): sed >= 4.0
17 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
19 %define _webapps /etc/webapps
20 %define _webapp %{name}
21 %define _sysconfdir %{_webapps}/%{_webapp}
23 # in case _sysconfdir is not in webapps dir, run this replace pattern
24 # before copy-pasting to your spec: :%s#%{_sysconfdir}#%{_webapps}/%{_webapp}#g
27 This .spec is for demonstrating triggers used for linking webapp
28 configuration to webserver config dir.
31 Ten plik .spec s³u¿y do pokazania triggerów s³u¿±cych do pod³±czania
32 konfiguracji aplikacji WWW do katalogu konfiguracyjnego serwera WWW.
35 cat > config.conf <<EOF
36 # This is sample config
40 rm -rf $RPM_BUILD_ROOT
41 install -d $RPM_BUILD_ROOT%{_sysconfdir}
43 #install %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/apache.conf
44 install config.conf $RPM_BUILD_ROOT%{_sysconfdir}/apache.conf
45 install config.conf $RPM_BUILD_ROOT%{_sysconfdir}/httpd.conf
46 install config.conf $RPM_BUILD_ROOT%{_sysconfdir}/lighttpd.conf
48 # %webapp_* macros usage extracted from /usr/lib/rpm/macros.build:
51 # %%webapp_register HTTPD WEBAPP
52 # %%webapp_unregister HTTPD WEBAPP
55 %webapp_register apache %{_webapp}
58 %webapp_unregister apache %{_webapp}
60 %triggerin -- apache >= 2.0.0
61 %webapp_register httpd %{_webapp}
63 %triggerun -- apache >= 2.0.0
64 %webapp_unregister httpd %{_webapp}
66 %triggerin -- lighttpd
67 %webapp_register lighttpd %{_webapp}
69 %triggerun -- lighttpd
70 %webapp_unregister lighttpd %{_webapp}
72 %if 00000000000000000000000000000000000
73 # SAMPLE TRIGGER FOR MIGRATION PURPOSES
74 %triggerpostun -- %{name} < 1.3.9-1.4
75 # rescue app configs. issue this in old config dir to get a list:
76 # rpm -qfl .|grep `pwd`/|awk -F/ '{print $NF}'|egrep -v 'apache|httpd'|xargs
77 for i in config.inc.php; do
78 if [ -f /etc/%{name}/$i.rpmsave ]; then
79 mv -f %{_sysconfdir}/$i{,.rpmnew}
80 mv -f /etc/%{name}/$i.rpmsave %{_sysconfdir}/$i
84 # nuke very-old config location (this mostly for Ra)
85 if [ -f /etc/httpd/httpd.conf ]; then
86 sed -i -e "/^Include.*%{name}.conf/d" /etc/httpd/httpd.conf
90 # migrate from httpd (apache2) config dir
91 if [ -f /etc/httpd/%{name}.conf.rpmsave ]; then
92 cp -f %{_sysconfdir}/httpd.conf{,.rpmnew}
93 mv -f /etc/httpd/%{name}.conf.rpmsave %{_sysconfdir}/httpd.conf
97 # migrate from apache-config macros
98 if [ -f /etc/%{name}/apache.conf.rpmsave ]; then
99 if [ -d /etc/apache/webapps.d ]; then
100 cp -f %{_sysconfdir}/apache.conf{,.rpmnew}
101 cp -f /etc/%{name}/apache.conf.rpmsave %{_sysconfdir}/apache.conf
104 if [ -d /etc/httpd/webapps.d ]; then
105 cp -f %{_sysconfdir}/httpd.conf{,.rpmnew}
106 cp -f /etc/%{name}/apache.conf.rpmsave %{_sysconfdir}/httpd.conf
108 rm -f /etc/%{name}/apache.conf.rpmsave
111 # same but without separate %{_sysconfdir} for package
112 if [ -f /etc/apache-%{name}.conf.rpmsave ]; then
113 if [ -d /etc/apache/webapps.d ]; then
114 cp -f %{_sysconfdir}/apache.conf{,.rpmnew}
115 cp -f /etc/apache-%{name}.conf.rpmsave %{_sysconfdir}/apache.conf
118 if [ -d /etc/httpd/webapps.d ]; then
119 cp -f %{_sysconfdir}/httpd.conf{,.rpmnew}
120 cp -f /etc/apache-%{name}.conf.rpmsave %{_sysconfdir}/httpd.conf
122 rm -f /etc/apache-%{name}.conf.rpmsave
125 # place new config location, as trigger puts config only on first install, do it here.
127 if [ -d /etc/apache/webapps.d ]; then
128 /usr/sbin/webapp register apache %{_webapp}
132 if [ -d /etc/httpd/webapps.d ]; then
133 /usr/sbin/webapp register httpd %{_webapp}
136 # or if we're migrating from %apache_install macros we can depend on symlinks in conf.d/http.conf dirs
137 # place new config location, as trigger puts config only on first install, do it here.
139 if [ -L /etc/apache/conf.d/99_%{name}.conf ]; then
140 rm -f /etc/apache/conf.d/99_%{name}.conf
141 /usr/sbin/webapp register apache %{_webapp}
145 if [ -L /etc/httpd/httpd.conf/99_%{name}.conf ]; then
146 rm -f /etc/httpd/httpd.conf/99_%{name}.conf
147 /usr/sbin/webapp register httpd %{_webapp}
151 if [ "$httpd_reload" ]; then
152 if [ -f /var/lock/subsys/httpd ]; then
153 /etc/rc.d/init.d/httpd reload 1>&2
156 if [ "$apache_reload" ]; then
157 if [ -f /var/lock/subsys/apache ]; then
158 /etc/rc.d/init.d/apache reload 1>&2
161 %endif # END OF SAMPLE TRIGGER
164 rm -rf $RPM_BUILD_ROOT
167 %defattr(644,root,root,755)
168 %dir %attr(750,root,http) %{_sysconfdir}
169 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/apache.conf
170 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/httpd.conf
171 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/lighttpd.conf
172 %attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/*.php