]> git.pld-linux.org Git - projects/template-specs.git/blob - webapp.spec
- make template for common cases where sysconfdir is in webapps
[projects/template-specs.git] / webapp.spec
1 Summary:        Package that uses webapps configuration
2 Summary(pl):    Pakiet u¿ywaj±cy konfiguracji aplikacji WWW
3 Name:           template-webapp
4 Version:        0.2
5 Release:        0.7
6 License:        GPL
7 Group:          Development
8 #Source0:       %{name}-%{version}.tar.gz
9 # Source0-md5:  -
10 #URL:           -
11 BuildRequires:  rpmbuild(macros) >= 1.264
12 Requires:       webapps
13 %if %{with trigger}
14 Requires(triggerpostun):        sed >= 4.0
15 %endif
16 BuildArch:      noarch
17 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
18
19 %define         _webapps        /etc/webapps
20 %define         _webapp         %{name}
21 %define         _sysconfdir     %{_webapps}/%{_webapp}
22
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
25
26 %description
27 This .spec is for demonstrating triggers used for linking webapp
28 configuration to webserver config dir.
29
30 %description -l pl
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.
33
34 %prep
35 cat > config.conf <<EOF
36 # This is sample config
37 EOF
38
39 %install
40 rm -rf $RPM_BUILD_ROOT
41 install -d $RPM_BUILD_ROOT%{_sysconfdir}
42
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
47
48 # %webapp_* macros usage extracted from /usr/lib/rpm/macros.build:
49 #
50 # Usage:
51 #   %%webapp_register HTTPD WEBAPP
52 #   %%webapp_unregister HTTPD WEBAPP
53
54 %triggerin -- apache1
55 %webapp_register apache %{_webapp}
56
57 %triggerun -- apache1
58 %webapp_unregister apache %{_webapp}
59
60 %triggerin -- apache >= 2.0.0
61 %webapp_register httpd %{_webapp}
62
63 %triggerun -- apache >= 2.0.0
64 %webapp_unregister httpd %{_webapp}
65
66 %triggerin -- lighttpd
67 %webapp_register lighttpd %{_webapp}
68
69 %triggerun -- lighttpd
70 %webapp_unregister lighttpd %{_webapp}
71
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
81         fi
82 done
83
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
87         httpd_reload=1
88 fi
89
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
94         httpd_reload=1
95 fi
96
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
102         fi
103
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
107         fi
108         rm -f /etc/%{name}/apache.conf.rpmsave
109 fi
110
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
116         fi
117
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
121         fi
122         rm -f /etc/apache-%{name}.conf.rpmsave
123 fi
124
125 # place new config location, as trigger puts config only on first install, do it here.
126 # apache1
127 if [ -d /etc/apache/webapps.d ]; then
128         /usr/sbin/webapp register apache %{_webapp}
129         apache_reload=1
130 fi
131 # apache2
132 if [ -d /etc/httpd/webapps.d ]; then
133         /usr/sbin/webapp register httpd %{_webapp}
134         httpd_reload=1
135 fi
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.
138 # apache1
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}
142         apache_reload=1
143 fi
144 # apache2
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}
148         httpd_reload=1
149 fi
150
151 if [ "$httpd_reload" ]; then
152         if [ -f /var/lock/subsys/httpd ]; then
153                 /etc/rc.d/init.d/httpd reload 1>&2
154         fi
155 fi
156 if [ "$apache_reload" ]; then
157         if [ -f /var/lock/subsys/apache ]; then
158                 /etc/rc.d/init.d/apache reload 1>&2
159         fi
160 fi
161 %endif # END OF SAMPLE TRIGGER
162
163 %clean
164 rm -rf $RPM_BUILD_ROOT
165
166 %files
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
This page took 0.064416 seconds and 4 git commands to generate.