Don't show unescaped blocked user name to prevent XSS attack
[opensuse:yast-web-client.git] / webclient / package / webyast-base-ui.spec
1 #
2 # spec file for package webyast-base-ui (Version 0.1.x)
3 #
4 # Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany.
5 # This file and all modifications and additions to the pristine
6 # package are under the same license as the package itself.
7 #
8 # Please submit bugfixes or comments via http://bugs.opensuse.org/
9 #
10
11
12 Name:           webyast-base-ui
13 Recommends:     WebYaST(org.opensuse.yast.modules.basesystem)
14 # bnc#634404
15 Recommends:     logrotate
16 Provides:       yast2-webclient = %{version}
17 Obsoletes:      yast2-webclient < %{version}
18 Requires:       ruby-fcgi, sqlite, syslog-ng, check-create-certificate
19 Requires:       webyast-branding
20 PreReq:         rubygem-rake, rubygem-sqlite3
21 PreReq:         rubygem-rails-2_3 >= 2.3.8
22 PreReq:         rubygem-gettext_rails
23 PreReq:         yast2-runlevel
24 Provides:       webyast-language-ui = 0.1.2
25 Obsoletes:      webyast-language-ui <= 0.1.2
26
27 %if 0%{?suse_version} == 0 || %suse_version > 1110
28 # 11.2 or newer
29
30 %if 0%{?suse_version} > 1120
31 # since 11.3, they are in a separate subpackage
32 Requires:       sysvinit-tools
33 %else
34 # Require startproc respecting -p, bnc#559534#c44
35 Requires:       sysvinit > 2.86-215.2
36 %endif
37 %else
38 # 11.1 or SLES11
39 Requires:       sysvinit > 2.86-195.3.1
40 %endif
41 Requires:       rubygem-passenger-nginx, rubygem-nokogiri
42 Requires:       nginx >= 1.0
43
44 License:        LGPL-2.1; Apache-2.0
45 Group:          Productivity/Networking/Web/Utilities
46 URL:            http://en.opensuse.org/Portal:WebYaST
47 Autoreqprov:    on
48 Version:        0.2.60
49 Release:        0
50 Summary:        WebYaST - base UI for system management
51 Source:         www.tar.bz2
52 Source2:        yastwc
53 Source4:        webyast-ui
54 Source5:        control_panel.yml
55 Source6:        webyast-ui.lr.conf
56 Source7:        nginx.conf
57 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
58 BuildRequires:  ruby
59 BuildRequires:  sqlite rubygem-sqlite3
60 BuildRequires:  rubygem-rails-2_3 >= 2.3.8
61 BuildRequires:  rubygem-gettext_rails, rubygem-yast2-webservice-tasks, rubygem-selenium-client
62 BuildRequires:  tidy, rubygem-haml, rubygem-nokogiri, rubygem-sass
63 BuildArch:      noarch
64 BuildRequires:  rubygem-test-unit rubygem-mocha
65 BuildRequires:  nginx >= 1.0
66 BuildRequires:  rubygem-passenger-nginx
67 #
68
69 %description
70 WebYaST - Provides core web client for WebYaST service.
71 Without plugins has only very limited configuration options.
72
73 Authors:
74 --------
75     Duncan Mac-Vicar Prett <dmacvicar@suse.de>
76     Bjoern Geuken <bgeuken@suse.de>
77     Stefan Schubert <schubi@opensuse.org>
78     Klaus Kaempf <kkaempf@opensuse.org>
79     Josef Reidinger <jreidinger@suse.cz>
80
81 %package testsuite
82 Group:    Productivity/Networking/Web/Utilities
83 Requires: %{name} = %{version}
84 Requires: rubygem-mocha rubygem-test-unit tidy
85 Summary:  Testsuite for webyast-base-ui package
86
87 %description testsuite
88 This package contains complete testsuite for webyast-base-ui package.
89 It is only needed for verifying the functionality of the package
90 and it is not needed at runtime.
91
92 %package branding-default
93 Group:    Productivity/Networking/Web/Utilities
94 Provides: webyast-branding
95 Requires: %{name} = %{version}
96 #Requires: rubygem-mocha rubygem-test-unit tidy
97 Summary:  Branding package for webyast-base-ui package
98
99 %description branding-default
100 This package contains css, icons and images for webyast-base-ui package.
101
102 %prep
103 %setup -q -n www
104
105 %build
106 env LANG=en rake makemo
107 rake sass:update
108 rake js:base
109 rm -r app/sass
110
111 %check
112 # run the testsuite
113 RAILS_ENV=test rake db:migrate
114 RAILS_ENV=test rake test
115
116 %install
117
118 #
119 # Install all web and frontend parts.
120 #
121 mkdir -p $RPM_BUILD_ROOT/%{webyast_ui_dir}/log
122 mkdir -p $RPM_BUILD_ROOT/%{webyast_ui_dir}/tmp
123 cp -a * $RPM_BUILD_ROOT/%{webyast_ui_dir}
124 rm -rf $RPM_BUILD_ROOT/%{webyast_ui_dir}/log/*
125 rm -rf $RPM_BUILD_ROOT/%{webyast_ui_dir}/po
126 rm -f $RPM_BUILD_ROOT/%{webyast_ui_dir}/COPYING
127
128 #
129 # init script
130 #
131 %{__install} -d -m 0755                            \
132     %{buildroot}%{_sbindir}
133
134 %{__install} -D -m 0755 %SOURCE2 \
135     %{buildroot}%{_sysconfdir}/init.d/%{webyast_ui_service}
136 %{__ln_s} -f %{_sysconfdir}/init.d/%{webyast_ui_service} %{buildroot}%{_sbindir}/rc%{webyast_ui_service}
137 #
138
139 # configure lighttpd/nginx web service
140 mkdir -p $RPM_BUILD_ROOT/etc/lighttpd/certs
141
142 # configure nginx web service
143 mkdir -p $RPM_BUILD_ROOT/etc/yastwc/
144 install -m 0644 %SOURCE7 $RPM_BUILD_ROOT/etc/yastwc/
145 # create symlinks to nginx config files
146 ln -s /etc/nginx/fastcgi.conf $RPM_BUILD_ROOT/etc/yastwc
147 ln -s /etc/nginx/fastcgi_params $RPM_BUILD_ROOT/etc/yastwc
148 ln -s /etc/nginx/koi-utf $RPM_BUILD_ROOT/etc/yastwc
149 ln -s /etc/nginx/koi-win $RPM_BUILD_ROOT/etc/yastwc
150 ln -s /etc/nginx/mime.types $RPM_BUILD_ROOT/etc/yastwc
151 ln -s /etc/nginx/scgi_params $RPM_BUILD_ROOT/etc/yastwc
152 ln -s /etc/nginx/uwsgi_params $RPM_BUILD_ROOT/etc/yastwc
153 ln -s /etc/nginx/win-utf $RPM_BUILD_ROOT/etc/yastwc
154
155 # firewall service definition, bnc#545627
156 mkdir -p $RPM_BUILD_ROOT/etc/sysconfig/SuSEfirewall2.d/services
157 install -m 0644 %SOURCE4 $RPM_BUILD_ROOT/etc/sysconfig/SuSEfirewall2.d/services
158
159 # logrotate configuration bnc#634404
160 mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d
161 install -m 0644 %SOURCE6 $RPM_BUILD_ROOT/etc/logrotate.d
162
163 #  create empty tmp directory
164 mkdir -p $RPM_BUILD_ROOT/%{webyast_ui_dir}/tmp
165 mkdir -p $RPM_BUILD_ROOT/%{webyast_ui_dir}/tmp/cache
166 mkdir -p $RPM_BUILD_ROOT/%{webyast_ui_dir}/tmp/pids
167 mkdir -p $RPM_BUILD_ROOT/%{webyast_ui_dir}/tmp/sessions
168 mkdir -p $RPM_BUILD_ROOT/%{webyast_ui_dir}/tmp/sockets
169
170 # install YAML config file
171 mkdir -p $RPM_BUILD_ROOT/etc/webyast/
172 cp %SOURCE5 $RPM_BUILD_ROOT/etc/webyast/
173
174 #create dummy update-script
175 mkdir -p %buildroot/var/adm/update-scripts
176 touch %buildroot/var/adm/update-scripts/%name-%version-%release-1
177
178 %clean
179 rm -rf $RPM_BUILD_ROOT
180
181 %pre
182 # services will not be restarted correctly if
183 # the package name will changed while the update
184 # So the service will be restarted by an update-script
185 # which will be called AFTER the installation
186 if /bin/rpm -q yast2-webclient > /dev/null ; then
187   echo "renaming yast2-webclient to webyast-base-ui"
188   if /sbin/yast runlevel summary service=yastwc 2>&1|grep " 3 "|grep yastwc >/dev/null ; then
189     echo "yastwc is inserted into the runlevel"
190     echo "#!/bin/sh" > %name-%version-%release-1
191     echo "/sbin/yast runlevel add service=yastwc" >> %name-%version-%release-1
192     echo "/usr/sbin/rcyastwc restart" >> %name-%version-%release-1
193   else
194     if /usr/sbin/rcyastwc status > /dev/null ; then
195       echo "yastwc is running"
196       echo "#!/bin/sh" > %name-%version-%release-1
197       echo "/usr/sbin/rcyastwc restart" >> %name-%version-%release-1
198     fi
199   fi
200 fi
201 #We are switching from lighttpd to nginx. So lighttpd has to be killed
202 #at first
203 if rpm -q --requires %{name}|grep lighttpd > /dev/null ; then
204   if /usr/sbin/rcyastwc status > /dev/null ; then
205     echo "yastws is running under lighttpd -> switching to nginx"
206     /usr/sbin/rcyastwc stop > /dev/null
207     echo "#!/bin/sh" > %name-%version-%release-1
208     echo "/usr/sbin/rcyastwc restart" >> %name-%version-%release-1
209   fi
210 fi
211 if [ -f %name-%version-%release-1 ] ; then
212   install -D -m 755 %name-%version-%release-1 /var/adm/update-scripts
213   rm %name-%version-%release-1
214   echo "Please check the service runlevels and restart WebYaST client with \"rcyastwc restart\" if the update has not been called with zypper,yast or packagekit"
215 fi
216 exit 0
217
218 %post
219 %fillup_and_insserv %{webyast_ui_service}
220
221 #
222 # create database
223 #
224 cd %{webyast_ui_dir}
225 RAILS_ENV=production rake db:migrate
226 chgrp %{webyast_ui_user} db db/*.sqlite* log log/*
227 chown %{webyast_ui_user} db db/*.sqlite* log log/*
228 chmod 700 log
229 chmod 755 db
230 chmod 600 db/*.sqlite* log/*
231
232 %preun
233 %stop_on_removal %{webyast_ui_service}
234
235 %postun
236 %restart_on_update %{webyast_ui_service}
237 %{insserv_cleanup}
238
239 # restart yastwc on nginx update (bnc#559534)
240 %triggerin -- nginx
241 %restart_on_update %{webyast_ui_service}
242
243 %files
244 %defattr(-,root,root)
245 %dir /etc/yastwc
246 %dir %{webyast_ui_dir}
247 %{webyast_ui_dir}/locale
248 %{webyast_ui_dir}/vendor
249 %{webyast_ui_dir}/app
250 %{webyast_ui_dir}/db
251 %{webyast_ui_dir}/doc
252 %{webyast_ui_dir}/lib
253 %{webyast_ui_dir}/public
254 %{webyast_ui_dir}/Rakefile
255 %{webyast_ui_dir}/README*
256 %{webyast_ui_dir}/INSTALL
257 %{webyast_ui_dir}/script
258 %{webyast_ui_dir}/config
259 %config %{webyast_ui_dir}/config/initializers/session_store.rb
260 %{webyast_ui_dir}/start.sh
261 %doc README* COPYING
262 %attr(-,%{webyast_ui_user},%{webyast_ui_user}) %{webyast_ui_dir}/log
263 %attr(-,%{webyast_ui_user},%{webyast_ui_user}) %{webyast_ui_dir}/tmp
264 %attr(-,%{webyast_ui_user},root) %{webyast_ui_dir}/public/javascripts
265 %config /etc/sysconfig/SuSEfirewall2.d/services/webyast-ui
266 %dir /etc/lighttpd
267 %dir /etc/lighttpd/certs
268 %config %{_sysconfdir}/init.d/%{webyast_ui_service}
269 %{_sbindir}/rc%{webyast_ui_service}
270 %dir /etc/webyast/
271 %config /etc/webyast/control_panel.yml
272
273 #nginx stuff
274 %config(noreplace) /etc/yastwc/nginx.conf
275 %config /etc/yastwc/fastcgi.conf
276 %config /etc/yastwc/fastcgi_params
277 %config /etc/yastwc/koi-utf
278 %config /etc/yastwc/koi-win
279 %config /etc/yastwc/mime.types
280 %config /etc/yastwc/scgi_params
281 %config /etc/yastwc/uwsgi_params
282 %config /etc/yastwc/win-utf
283
284 #logrotate configuration file
285 %config(noreplace) /etc/logrotate.d/webyast-ui.lr.conf
286
287 ### exclude css, icons and images 
288 %exclude %{webyast_ui_dir}/public/stylesheets
289 %exclude %{webyast_ui_dir}/public/icons
290 %exclude %{webyast_ui_dir}/public/images
291
292 %ghost %attr(755,root,root) /var/adm/update-scripts/%name-%version-%release-1
293
294 %files testsuite
295 %defattr(-,root,root)
296 %{webyast_ui_dir}/test
297
298 %files branding-default
299 %defattr(-,root,root)
300 ### include css, icons and images 
301 %{webyast_ui_dir}/public/stylesheets
302 %{webyast_ui_dir}/public/icons
303 %{webyast_ui_dir}/public/images
304
305
306 %changelog