]> git.pld-linux.org Git - projects/template-specs.git/blob - webapp.spec
- avoid leaving around .rpmsave files which have already been put to new place
[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         sample-webapp
21 %define         _sysconfdir     %{_webapps}/%{_webapp}
22
23 %description
24 This .spec is for demonstrating triggers used for linking webapp
25 configuration to webserver config dir.
26
27 %description -l pl
28 Ten plik .spec s³u¿y do pokazania triggerów s³u¿±cych do pod³±czania
29 konfiguracji aplikacji WWW do katalogu konfiguracyjnego serwera WWW.
30
31 %prep
32 cat > config.conf <<EOF
33 # This is sample config
34 EOF
35
36 %install
37 rm -rf $RPM_BUILD_ROOT
38 install -d $RPM_BUILD_ROOT%{_sysconfdir}
39
40 #install %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/apache.conf
41 install config.conf $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/apache.conf
42 install config.conf $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/httpd.conf
43 install config.conf $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/lighttpd.conf
44
45 # %webapp_* macros usage extracted from /usr/lib/rpm/macros.build:
46 #
47 # Usage:
48 #   %%webapp_register HTTPD WEBAPP
49 #   %%webapp_unregister HTTPD WEBAPP
50
51 %triggerin -- apache1
52 %webapp_register apache %{_webapp}
53
54 %triggerun -- apache1
55 %webapp_unregister apache %{_webapp}
56
57 %triggerin -- apache >= 2.0.0
58 %webapp_register httpd %{_webapp}
59
60 %triggerun -- apache >= 2.0.0
61 %webapp_unregister httpd %{_webapp}
62
63 %triggerin -- lighttpd
64 %webapp_register lighttpd %{_webapp}
65
66 %triggerun -- lighttpd
67 %webapp_unregister lighttpd %{_webapp}
68
69 %if 00000000000000000000000000000000000
70 # SAMPLE TRIGGER FOR MIGRATION PURPOSES
71 %triggerpostun -- %{name} < 1.3.9-1.4
72 # migrate from apache-config macros
73 if [ -f /etc/%{name}/apache.conf.rpmsave ]; then
74         if [ -d /etc/apache/webapps.d ]; then
75                 cp -f %{_webapps}/%{_webapp}/apache.conf{,.rpmnew}
76                 cp -f /etc/%{name}/apache.conf.rpmsave %{_webapps}/%{_webapp}/apache.conf
77         fi
78
79         if [ -d /etc/httpd/webapps.d ]; then
80                 cp -f %{_webapps}/%{_webapp}/httpd.conf{,.rpmnew}
81                 cp -f /etc/%{name}/apache.conf.rpmsave %{_webapps}/%{_webapp}/httpd.conf
82         fi
83         rm -f /etc/%{name}/apache.conf.rpmsave
84 fi
85
86 # same but without separate %{_sysconfdir} for package
87 if [ -f /etc/apache-%{name}.conf.rpmsave ]; then
88         if [ -d /etc/apache/webapps.d ]; then
89                 cp -f %{_webapps}/%{_webapp}/apache.conf{,.rpmnew}
90                 cp -f /etc/apache-%{name}.conf.rpmsave %{_webapps}/%{_webapp}/apache.conf
91         fi
92
93         if [ -d /etc/httpd/webapps.d ]; then
94                 cp -f %{_webapps}/%{_webapp}/httpd.conf{,.rpmnew}
95                 cp -f /etc/apache-%{name}.conf.rpmsave %{_webapps}/%{_webapp}/httpd.conf
96         fi
97         rm -f /etc/apache-%{name}.conf.rpmsave
98 fi
99
100 # migrate from httpd (apache2) config dir
101 if [ -f /etc/httpd/%{name}.conf.rpmsave ]; then
102         cp -f %{_webapps}/%{_webapp}/httpd.conf{,.rpmnew}
103         mv -f /etc/httpd/%{name}.conf.rpmsave %{_webapps}/%{_webapp}/httpd.conf
104         httpd_reload=1
105 fi
106
107 # nuke very-old config location (this mostly for Ra)
108 if [ -f /etc/httpd/httpd.conf ]; then
109         sed -i -e "/^Include.*%{name}.conf/d" /etc/httpd/httpd.conf
110         httpd_reload=1
111 fi
112
113 # place new config location, as trigger puts config only on first install, do it here.
114 # apache1
115 if [ -d /etc/apache/webapps.d ]; then
116         /usr/sbin/webapp register apache %{_webapp}
117         apache_reload=1
118 fi
119 # apache2
120 if [ -d /etc/httpd/webapps.d ]; then
121         /usr/sbin/webapp register httpd %{_webapp}
122         httpd_reload=1
123 fi
124
125 if [ "$httpd_reload" ]; the
126         if [ -f /var/lock/subsys/httpd ]; then
127                 /etc/rc.d/init.d/httpd reload 1>&2
128         fi
129 fi
130 if [ "$apache_reload" ]; the
131         if [ -f /var/lock/subsys/apache ]; then
132                 /etc/rc.d/init.d/apache reload 1>&2
133         fi
134 fi
135 %endif # END OF SAMPLE TRIGGER
136
137 %clean
138 rm -rf $RPM_BUILD_ROOT
139
140 %files
141 %defattr(644,root,root,755)
142 %dir %attr(750,root,http) %{_webapps}/%{_webapp}
143 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/apache.conf
144 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/httpd.conf
145 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/lighttpd.conf
146
147 #%attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_webapps}/%{_webapp}/*.php
This page took 0.066716 seconds and 4 git commands to generate.