]> git.pld-linux.org Git - projects/template-specs.git/blob - webapp.spec
- default apache config
[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:          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 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 #%define                _appdir         %{_datadir}/%{_webapp}
23
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
26
27 %description
28 This .spec is for demonstrating triggers used for linking webapp
29 configuration to webserver config dir.
30
31 %description -l pl
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.
34
35 %prep
36 %setup -q
37
38 cat >>apache.conf <'EOF'
39 Alias /%{name} /usr/share/%{name}
40 <Directory /usr/share/%{name}>
41         Allow from all
42 </Directory>
43 EOF
44
45 %install
46 rm -rf $RPM_BUILD_ROOT
47 install -d $RPM_BUILD_ROOT%{_sysconfdir}
48 #install -d $RPM_BUILD_ROOT{%{_sysconfdir},%{_appdir}}
49
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
54
55 # %webapp_* macros usage extracted from /usr/lib/rpm/macros.build:
56 #
57 # Usage:
58 #   %%webapp_register HTTPD WEBAPP
59 #   %%webapp_unregister HTTPD WEBAPP
60
61 %triggerin -- apache1
62 %webapp_register apache %{_webapp}
63
64 %triggerun -- apache1
65 %webapp_unregister apache %{_webapp}
66
67 %triggerin -- apache < 2.2.0, apache-base
68 %webapp_register httpd %{_webapp}
69
70 %triggerun -- apache < 2.2.0, apache-base
71 %webapp_unregister httpd %{_webapp}
72
73 %triggerin -- lighttpd
74 %webapp_register lighttpd %{_webapp}
75
76 %triggerun -- lighttpd
77 %webapp_unregister lighttpd %{_webapp}
78
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
88         fi
89 done
90
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
94         httpd_reload=1
95 fi
96
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
101         httpd_reload=1
102 fi
103
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
109         fi
110
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
114         fi
115         rm -f /etc/%{name}/apache.conf.rpmsave
116 fi
117
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
123         fi
124
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
128         fi
129         rm -f /etc/apache-%{name}.conf.rpmsave
130 fi
131
132 # update htpasswd path
133 #sed -i -e 's,/etc/%{name},%{_webapps}/%{_webapp},' %{_webapps}/%{_webapp}/{apache,httpd}.conf
134
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
139                 apache_reload=1
140         fi
141         if [ -L /etc/httpd/httpd.conf/99_%{name}.conf ]; then
142                 rm -f /etc/httpd/httpd.conf/99_%{name}.conf
143                 httpd_reload=1
144         fi
145 else
146         # no earlier registration. assume migration from Ra
147         if [ -d /etc/apache/webapps.d ]; then
148                 apache_reload=1
149         fi
150         if [ -d /etc/httpd/webapps.d ]; then
151                 httpd_reload=1
152         fi
153 fi
154
155 if [ "$apache_reload" ]; then
156         /usr/sbin/webapp register apache %{_webapp}
157         %service -q apache reload
158 fi
159 if [ "$httpd_reload" ]; then
160         /usr/sbin/webapp register httpd %{_webapp}
161         %service -q httpd reload
162 fi
163 %endif # END OF SAMPLE TRIGGER
164
165 %clean
166 rm -rf $RPM_BUILD_ROOT
167
168 %files
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
This page took 0.053119 seconds and 4 git commands to generate.