]>
Commit | Line | Data |
---|---|---|
ff60f2d3 | 1 | Summary: Package that uses webapps configuration |
ce39d734 | 2 | Summary(pl.UTF-8): Pakiet używający konfiguracji aplikacji WWW |
ff60f2d3 ER |
3 | Name: template-webapp |
4 | Version: 0.2 | |
d9acef23 | 5 | Release: 0.7 |
5ba5cc7a | 6 | License: GPL |
1b5d0c9a | 7 | Group: Applications/WWW |
1ddef0d1 ER |
8 | #Source0: %{name}-%{version}.tar.gz |
9 | # Source0-md5: - | |
10 | #URL: - | |
b53f8131 | 11 | BuildRequires: rpmbuild(macros) >= 1.268 |
ff60f2d3 | 12 | Requires: webapps |
f0a6249d ER |
13 | %if %{with trigger} |
14 | Requires(triggerpostun): sed >= 4.0 | |
15 | %endif | |
367a5ad4 | 16 | # see SOURCES/webapps.README for description and complete listing |
b65061da ER |
17 | #Requires: webserver(access) |
18 | #Requires: webserver(alias) | |
19 | #Requires: webserver(auth) | |
ff3ba9b3 | 20 | #Requires: webserver(cgi) |
367a5ad4 | 21 | #Requires: webserver(indexfile) |
9407df51 ER |
22 | BuildArch: noarch |
23 | BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) | |
24 | ||
ff60f2d3 | 25 | %define _webapps /etc/webapps |
c1b7608a | 26 | %define _webapp %{name} |
ff60f2d3 | 27 | %define _sysconfdir %{_webapps}/%{_webapp} |
e4a4f082 | 28 | #%define _appdir %{_datadir}/%{_webapp} |
87b72dfa | 29 | |
38caece8 ER |
30 | # in case _sysconfdir is not in webapps dir, run this replace pattern |
31 | # before copy-pasting to your spec: :%s#%{_sysconfdir}#%{_webapps}/%{_webapp}#g | |
32 | ||
9407df51 | 33 | %description |
d9acef23 ER |
34 | This .spec is for demonstrating triggers used for linking webapp |
35 | configuration to webserver config dir. | |
9407df51 | 36 | |
9be49f18 JR |
37 | %description -l pl.UTF-8 |
38 | Ten plik .spec służy do pokazania triggerów służących do podłączania | |
cbe1381a | 39 | konfiguracji aplikacji WWW do katalogu konfiguracyjnego serwera WWW. |
832823fd | 40 | |
9407df51 | 41 | %prep |
c27fb8a9 ER |
42 | %setup -q |
43 | ||
66ac8cb1 | 44 | cat > apache.conf <<'EOF' |
98da39be ER |
45 | Alias /%{name} %{_appdir} |
46 | <Directory %{_appdir}> | |
c27fb8a9 ER |
47 | Allow from all |
48 | </Directory> | |
ff60f2d3 | 49 | EOF |
9407df51 ER |
50 | |
51 | %install | |
52 | rm -rf $RPM_BUILD_ROOT | |
53 | install -d $RPM_BUILD_ROOT%{_sysconfdir} | |
b82dcb99 | 54 | #install -d $RPM_BUILD_ROOT{%{_sysconfdir},%{_appdir}} |
498b0e06 | 55 | |
ff60f2d3 | 56 | #install %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/apache.conf |
c27fb8a9 ER |
57 | install apache.conf $RPM_BUILD_ROOT%{_sysconfdir}/apache.conf |
58 | install apache.conf $RPM_BUILD_ROOT%{_sysconfdir}/httpd.conf | |
949af850 | 59 | install lighttpd.conf $RPM_BUILD_ROOT%{_sysconfdir}/lighttpd.conf |
c1b7608a | 60 | |
ff60f2d3 | 61 | # %webapp_* macros usage extracted from /usr/lib/rpm/macros.build: |
4f853f24 ER |
62 | # |
63 | # Usage: | |
ff60f2d3 ER |
64 | # %%webapp_register HTTPD WEBAPP |
65 | # %%webapp_unregister HTTPD WEBAPP | |
4f853f24 | 66 | |
a5bcddf5 | 67 | %triggerin -- apache1 < 1.3.37-3, apache1-base |
ff60f2d3 | 68 | %webapp_register apache %{_webapp} |
9407df51 | 69 | |
a5bcddf5 | 70 | %triggerun -- apache1 < 1.3.37-3, apache1-base |
ff60f2d3 | 71 | %webapp_unregister apache %{_webapp} |
9407df51 | 72 | |
86e3a52e | 73 | %triggerin -- apache < 2.2.0, apache-base |
ff60f2d3 | 74 | %webapp_register httpd %{_webapp} |
9407df51 | 75 | |
86e3a52e | 76 | %triggerun -- apache < 2.2.0, apache-base |
ff60f2d3 ER |
77 | %webapp_unregister httpd %{_webapp} |
78 | ||
79 | %triggerin -- lighttpd | |
80 | %webapp_register lighttpd %{_webapp} | |
81 | ||
82 | %triggerun -- lighttpd | |
83 | %webapp_unregister lighttpd %{_webapp} | |
e2b18c9c | 84 | |
2a2d196e ER |
85 | %if 00000000000000000000000000000000000 |
86 | # SAMPLE TRIGGER FOR MIGRATION PURPOSES | |
87 | %triggerpostun -- %{name} < 1.3.9-1.4 | |
c1b7608a ER |
88 | # rescue app configs. issue this in old config dir to get a list: |
89 | # rpm -qfl .|grep `pwd`/|awk -F/ '{print $NF}'|egrep -v 'apache|httpd'|xargs | |
90 | for i in config.inc.php; do | |
38caece8 | 91 | if [ -f /etc/%{name}/$i.rpmsave ]; then |
c1b7608a | 92 | mv -f %{_sysconfdir}/$i{,.rpmnew} |
38caece8 | 93 | mv -f /etc/%{name}/$i.rpmsave %{_sysconfdir}/$i |
c1b7608a ER |
94 | fi |
95 | done | |
96 | ||
ad7e6e06 ER |
97 | # nuke very-old config location (this mostly for Ra) |
98 | if [ -f /etc/httpd/httpd.conf ]; then | |
99 | sed -i -e "/^Include.*%{name}.conf/d" /etc/httpd/httpd.conf | |
100 | httpd_reload=1 | |
101 | fi | |
102 | ||
103 | # migrate from httpd (apache2) config dir | |
104 | if [ -f /etc/httpd/%{name}.conf.rpmsave ]; then | |
38caece8 ER |
105 | cp -f %{_sysconfdir}/httpd.conf{,.rpmnew} |
106 | mv -f /etc/httpd/%{name}.conf.rpmsave %{_sysconfdir}/httpd.conf | |
ad7e6e06 ER |
107 | httpd_reload=1 |
108 | fi | |
109 | ||
ff60f2d3 ER |
110 | # migrate from apache-config macros |
111 | if [ -f /etc/%{name}/apache.conf.rpmsave ]; then | |
112 | if [ -d /etc/apache/webapps.d ]; then | |
38caece8 ER |
113 | cp -f %{_sysconfdir}/apache.conf{,.rpmnew} |
114 | cp -f /etc/%{name}/apache.conf.rpmsave %{_sysconfdir}/apache.conf | |
ff60f2d3 ER |
115 | fi |
116 | ||
117 | if [ -d /etc/httpd/webapps.d ]; then | |
38caece8 ER |
118 | cp -f %{_sysconfdir}/httpd.conf{,.rpmnew} |
119 | cp -f /etc/%{name}/apache.conf.rpmsave %{_sysconfdir}/httpd.conf | |
ff60f2d3 | 120 | fi |
1ddef0d1 | 121 | rm -f /etc/%{name}/apache.conf.rpmsave |
ff60f2d3 | 122 | fi |
1ddef0d1 | 123 | |
ff60f2d3 ER |
124 | # same but without separate %{_sysconfdir} for package |
125 | if [ -f /etc/apache-%{name}.conf.rpmsave ]; then | |
126 | if [ -d /etc/apache/webapps.d ]; then | |
38caece8 ER |
127 | cp -f %{_sysconfdir}/apache.conf{,.rpmnew} |
128 | cp -f /etc/apache-%{name}.conf.rpmsave %{_sysconfdir}/apache.conf | |
ff60f2d3 ER |
129 | fi |
130 | ||
131 | if [ -d /etc/httpd/webapps.d ]; then | |
38caece8 ER |
132 | cp -f %{_sysconfdir}/httpd.conf{,.rpmnew} |
133 | cp -f /etc/apache-%{name}.conf.rpmsave %{_sysconfdir}/httpd.conf | |
2a2d196e | 134 | fi |
1ddef0d1 | 135 | rm -f /etc/apache-%{name}.conf.rpmsave |
2a2d196e ER |
136 | fi |
137 | ||
19c6441b ER |
138 | # update htpasswd path |
139 | #sed -i -e 's,/etc/%{name},%{_webapps}/%{_webapp},' %{_webapps}/%{_webapp}/{apache,httpd}.conf | |
140 | ||
d83e9ac3 ER |
141 | # migrating from earlier apache-config? |
142 | if [ -L /etc/apache/conf.d/99_%{name}.conf ] || [ -L /etc/httpd/httpd.conf/99_%{name}.conf ]; then | |
143 | if [ -L /etc/apache/conf.d/99_%{name}.conf ]; then | |
144 | rm -f /etc/apache/conf.d/99_%{name}.conf | |
d83e9ac3 ER |
145 | apache_reload=1 |
146 | fi | |
147 | if [ -L /etc/httpd/httpd.conf/99_%{name}.conf ]; then | |
148 | rm -f /etc/httpd/httpd.conf/99_%{name}.conf | |
d83e9ac3 ER |
149 | httpd_reload=1 |
150 | fi | |
151 | else | |
152 | # no earlier registration. assume migration from Ra | |
153 | if [ -d /etc/apache/webapps.d ]; then | |
d83e9ac3 ER |
154 | apache_reload=1 |
155 | fi | |
156 | if [ -d /etc/httpd/webapps.d ]; then | |
d83e9ac3 ER |
157 | httpd_reload=1 |
158 | fi | |
38caece8 | 159 | fi |
ff60f2d3 | 160 | |
689fcaa1 | 161 | if [ "$apache_reload" ]; then |
76b5140d | 162 | /usr/sbin/webapp register apache %{_webapp} |
b53f8131 | 163 | %service -q apache reload |
ff60f2d3 | 164 | fi |
76b5140d ER |
165 | if [ "$httpd_reload" ]; then |
166 | /usr/sbin/webapp register httpd %{_webapp} | |
b53f8131 | 167 | %service -q httpd reload |
76b5140d | 168 | fi |
2a2d196e ER |
169 | %endif # END OF SAMPLE TRIGGER |
170 | ||
74ca4545 ER |
171 | %clean |
172 | rm -rf $RPM_BUILD_ROOT | |
173 | ||
e2b18c9c ER |
174 | %files |
175 | %defattr(644,root,root,755) | |
38caece8 ER |
176 | %dir %attr(750,root,http) %{_sysconfdir} |
177 | %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/apache.conf | |
178 | %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/httpd.conf | |
179 | %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/lighttpd.conf | |
180 | %attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/*.php |