1 Summary: Package that uses webapps configuration
2 Summary(pl): Pakiet u¿ywaj±cy konfiguracji aplikacji WWW
7 Group: Applications/WWW
8 #Source0: %{name}-%{version}.tar.gz
11 BuildRequires: rpmbuild(macros) >= 1.268
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}
22 #%define _appdir %{_datadir}/%{_webapp}
24 # in case _sysconfdir is not in webapps dir, run this replace pattern
25 # before copy-pasting to your spec: :%s#%{_sysconfdir}#%{_webapps}/%{_webapp}#g
28 This .spec is for demonstrating triggers used for linking webapp
29 configuration to webserver config dir.
32 Ten plik .spec s³u¿y do pokazania triggerów s³u¿±cych do pod³±czania
33 konfiguracji aplikacji WWW do katalogu konfiguracyjnego serwera WWW.
38 cat > apache.conf <<'EOF'
39 Alias /%{name} /usr/share/%{name}
40 <Directory /usr/share/%{name}>
46 rm -rf $RPM_BUILD_ROOT
47 install -d $RPM_BUILD_ROOT%{_sysconfdir}
48 #install -d $RPM_BUILD_ROOT{%{_sysconfdir},%{_appdir}}
50 #install %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/apache.conf
51 install apache.conf $RPM_BUILD_ROOT%{_sysconfdir}/apache.conf
52 install apache.conf $RPM_BUILD_ROOT%{_sysconfdir}/httpd.conf
53 install apache.conf $RPM_BUILD_ROOT%{_sysconfdir}/lighttpd.conf
55 # %webapp_* macros usage extracted from /usr/lib/rpm/macros.build:
58 # %%webapp_register HTTPD WEBAPP
59 # %%webapp_unregister HTTPD WEBAPP
62 %webapp_register apache %{_webapp}
65 %webapp_unregister apache %{_webapp}
67 %triggerin -- apache < 2.2.0, apache-base
68 %webapp_register httpd %{_webapp}
70 %triggerun -- apache < 2.2.0, apache-base
71 %webapp_unregister httpd %{_webapp}
73 %triggerin -- lighttpd
74 %webapp_register lighttpd %{_webapp}
76 %triggerun -- lighttpd
77 %webapp_unregister lighttpd %{_webapp}
79 %if 00000000000000000000000000000000000
80 # SAMPLE TRIGGER FOR MIGRATION PURPOSES
81 %triggerpostun -- %{name} < 1.3.9-1.4
82 # rescue app configs. issue this in old config dir to get a list:
83 # rpm -qfl .|grep `pwd`/|awk -F/ '{print $NF}'|egrep -v 'apache|httpd'|xargs
84 for i in config.inc.php; do
85 if [ -f /etc/%{name}/$i.rpmsave ]; then
86 mv -f %{_sysconfdir}/$i{,.rpmnew}
87 mv -f /etc/%{name}/$i.rpmsave %{_sysconfdir}/$i
91 # nuke very-old config location (this mostly for Ra)
92 if [ -f /etc/httpd/httpd.conf ]; then
93 sed -i -e "/^Include.*%{name}.conf/d" /etc/httpd/httpd.conf
97 # migrate from httpd (apache2) config dir
98 if [ -f /etc/httpd/%{name}.conf.rpmsave ]; then
99 cp -f %{_sysconfdir}/httpd.conf{,.rpmnew}
100 mv -f /etc/httpd/%{name}.conf.rpmsave %{_sysconfdir}/httpd.conf
104 # migrate from apache-config macros
105 if [ -f /etc/%{name}/apache.conf.rpmsave ]; then
106 if [ -d /etc/apache/webapps.d ]; then
107 cp -f %{_sysconfdir}/apache.conf{,.rpmnew}
108 cp -f /etc/%{name}/apache.conf.rpmsave %{_sysconfdir}/apache.conf
111 if [ -d /etc/httpd/webapps.d ]; then
112 cp -f %{_sysconfdir}/httpd.conf{,.rpmnew}
113 cp -f /etc/%{name}/apache.conf.rpmsave %{_sysconfdir}/httpd.conf
115 rm -f /etc/%{name}/apache.conf.rpmsave
118 # same but without separate %{_sysconfdir} for package
119 if [ -f /etc/apache-%{name}.conf.rpmsave ]; then
120 if [ -d /etc/apache/webapps.d ]; then
121 cp -f %{_sysconfdir}/apache.conf{,.rpmnew}
122 cp -f /etc/apache-%{name}.conf.rpmsave %{_sysconfdir}/apache.conf
125 if [ -d /etc/httpd/webapps.d ]; then
126 cp -f %{_sysconfdir}/httpd.conf{,.rpmnew}
127 cp -f /etc/apache-%{name}.conf.rpmsave %{_sysconfdir}/httpd.conf
129 rm -f /etc/apache-%{name}.conf.rpmsave
132 # update htpasswd path
133 #sed -i -e 's,/etc/%{name},%{_webapps}/%{_webapp},' %{_webapps}/%{_webapp}/{apache,httpd}.conf
135 # migrating from earlier apache-config?
136 if [ -L /etc/apache/conf.d/99_%{name}.conf ] || [ -L /etc/httpd/httpd.conf/99_%{name}.conf ]; then
137 if [ -L /etc/apache/conf.d/99_%{name}.conf ]; then
138 rm -f /etc/apache/conf.d/99_%{name}.conf
141 if [ -L /etc/httpd/httpd.conf/99_%{name}.conf ]; then
142 rm -f /etc/httpd/httpd.conf/99_%{name}.conf
146 # no earlier registration. assume migration from Ra
147 if [ -d /etc/apache/webapps.d ]; then
150 if [ -d /etc/httpd/webapps.d ]; then
155 if [ "$apache_reload" ]; then
156 /usr/sbin/webapp register apache %{_webapp}
157 %service -q apache reload
159 if [ "$httpd_reload" ]; then
160 /usr/sbin/webapp register httpd %{_webapp}
161 %service -q httpd reload
163 %endif # END OF SAMPLE TRIGGER
166 rm -rf $RPM_BUILD_ROOT
169 %defattr(644,root,root,755)
170 %dir %attr(750,root,http) %{_sysconfdir}
171 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/apache.conf
172 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/httpd.conf
173 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/lighttpd.conf
174 %attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/*.php