]> git.pld-linux.org Git - projects/template-specs.git/blob - webapp.spec
- tabs in preamble
[projects/template-specs.git] / webapp.spec
1 Summary:        Package that uses webapps configuration
2 Summary(pl.UTF-8):      Pakiet używający konfiguracji aplikacji WWW
3 Name:           template-webapp
4 Version:        0.2
5 Release:        0.7
6 License:        GPL
7 Group:          Applications/WWW
8 #Source0:       %{name}-%{version}.tar.gz
9 # Source0-md5:  -
10 #URL:           -
11 BuildRequires:  rpmbuild(macros) >= 1.268
12 Requires:       webapps
13 %if %{with trigger}
14 Requires(triggerpostun):        sed >= 4.0
15 %endif
16 # see SOURCES/webapps.README for description and complete listing
17 #Requires:      webserver(access)
18 #Requires:      webserver(alias)
19 #Requires:      webserver(auth)
20 #Requires:      webserver(cgi)
21 #Requires:      webserver(indexfile)
22 BuildArch:      noarch
23 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
24
25 %define         _webapps        /etc/webapps
26 %define         _webapp         %{name}
27 %define         _sysconfdir     %{_webapps}/%{_webapp}
28 #%define                _appdir         %{_datadir}/%{_webapp}
29
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
33 %description
34 This .spec is for demonstrating triggers used for linking webapp
35 configuration to webserver config dir.
36
37 %description -l pl.UTF-8
38 Ten plik .spec służy do pokazania triggerów służących do podłączania
39 konfiguracji aplikacji WWW do katalogu konfiguracyjnego serwera WWW.
40
41 %prep
42 %setup -q
43
44 cat > apache.conf <<'EOF'
45 Alias /%{name} %{_appdir}
46 <Directory %{_appdir}>
47         Allow from all
48 </Directory>
49 EOF
50
51 %install
52 rm -rf $RPM_BUILD_ROOT
53 install -d $RPM_BUILD_ROOT%{_sysconfdir}
54 #install -d $RPM_BUILD_ROOT{%{_sysconfdir},%{_appdir}}
55
56 #install %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/apache.conf
57 install apache.conf $RPM_BUILD_ROOT%{_sysconfdir}/apache.conf
58 install apache.conf $RPM_BUILD_ROOT%{_sysconfdir}/httpd.conf
59 install lighttpd.conf $RPM_BUILD_ROOT%{_sysconfdir}/lighttpd.conf
60
61 # %webapp_* macros usage extracted from /usr/lib/rpm/macros.build:
62 #
63 # Usage:
64 #   %%webapp_register HTTPD WEBAPP
65 #   %%webapp_unregister HTTPD WEBAPP
66
67 %triggerin -- apache1 < 1.3.37-3, apache1-base
68 %webapp_register apache %{_webapp}
69
70 %triggerun -- apache1 < 1.3.37-3, apache1-base
71 %webapp_unregister apache %{_webapp}
72
73 %triggerin -- apache < 2.2.0, apache-base
74 %webapp_register httpd %{_webapp}
75
76 %triggerun -- apache < 2.2.0, apache-base
77 %webapp_unregister httpd %{_webapp}
78
79 %triggerin -- lighttpd
80 %webapp_register lighttpd %{_webapp}
81
82 %triggerun -- lighttpd
83 %webapp_unregister lighttpd %{_webapp}
84
85 %if 00000000000000000000000000000000000
86 # SAMPLE TRIGGER FOR MIGRATION PURPOSES
87 %triggerpostun -- %{name} < 1.3.9-1.4
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
91         if [ -f /etc/%{name}/$i.rpmsave ]; then
92                 mv -f %{_sysconfdir}/$i{,.rpmnew}
93                 mv -f /etc/%{name}/$i.rpmsave %{_sysconfdir}/$i
94         fi
95 done
96
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
105         cp -f %{_sysconfdir}/httpd.conf{,.rpmnew}
106         mv -f /etc/httpd/%{name}.conf.rpmsave %{_sysconfdir}/httpd.conf
107         httpd_reload=1
108 fi
109
110 # migrate from apache-config macros
111 if [ -f /etc/%{name}/apache.conf.rpmsave ]; then
112         if [ -d /etc/apache/webapps.d ]; then
113                 cp -f %{_sysconfdir}/apache.conf{,.rpmnew}
114                 cp -f /etc/%{name}/apache.conf.rpmsave %{_sysconfdir}/apache.conf
115         fi
116
117         if [ -d /etc/httpd/webapps.d ]; then
118                 cp -f %{_sysconfdir}/httpd.conf{,.rpmnew}
119                 cp -f /etc/%{name}/apache.conf.rpmsave %{_sysconfdir}/httpd.conf
120         fi
121         rm -f /etc/%{name}/apache.conf.rpmsave
122 fi
123
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
127                 cp -f %{_sysconfdir}/apache.conf{,.rpmnew}
128                 cp -f /etc/apache-%{name}.conf.rpmsave %{_sysconfdir}/apache.conf
129         fi
130
131         if [ -d /etc/httpd/webapps.d ]; then
132                 cp -f %{_sysconfdir}/httpd.conf{,.rpmnew}
133                 cp -f /etc/apache-%{name}.conf.rpmsave %{_sysconfdir}/httpd.conf
134         fi
135         rm -f /etc/apache-%{name}.conf.rpmsave
136 fi
137
138 # update htpasswd path
139 #sed -i -e 's,/etc/%{name},%{_webapps}/%{_webapp},' %{_webapps}/%{_webapp}/{apache,httpd}.conf
140
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
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
149                 httpd_reload=1
150         fi
151 else
152         # no earlier registration. assume migration from Ra
153         if [ -d /etc/apache/webapps.d ]; then
154                 apache_reload=1
155         fi
156         if [ -d /etc/httpd/webapps.d ]; then
157                 httpd_reload=1
158         fi
159 fi
160
161 if [ "$apache_reload" ]; then
162         /usr/sbin/webapp register apache %{_webapp}
163         %service -q apache reload
164 fi
165 if [ "$httpd_reload" ]; then
166         /usr/sbin/webapp register httpd %{_webapp}
167         %service -q httpd reload
168 fi
169 %endif # END OF SAMPLE TRIGGER
170
171 %clean
172 rm -rf $RPM_BUILD_ROOT
173
174 %files
175 %defattr(644,root,root,755)
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
This page took 0.076519 seconds and 3 git commands to generate.