280 %{l_prefix}/bin/gem install --local %{SOURCE25} |
283 %{l_prefix}/bin/gem install --local %{SOURCE25} |
281 %{l_prefix}/bin/gem install --local %{SOURCE27} |
284 %{l_prefix}/bin/gem install --local %{SOURCE27} |
282 |
285 |
283 # install configuration |
286 # install configuration |
284 ( cd $RPM_BUILD_ROOT%{l_prefix}/lib/chiliproj |
287 ( cd $RPM_BUILD_ROOT%{l_prefix}/lib/chiliproj |
285 %{l_shtool} mkdir -f -p -m 755 .bundle |
|
286 cp %{SOURCE Gemfile.lock} . |
288 cp %{SOURCE Gemfile.lock} . |
287 echo 'gem "thin"' >>Gemfile |
289 echo 'gem "thin"' >>Gemfile |
288 cp config/configuration.yml.example config/configuration.yml |
290 cp config/configuration.yml.example config/configuration.yml |
289 cp config/additional_environment.rb.example config/additional_environment.rb |
291 cp config/additional_environment.rb.example config/additional_environment.rb |
290 echo "ENV['GEM_PATH'] = '%{l_prefix}/lib/ruby/gems/$RUBY_VERSION:%{l_prefix}/lib/chiliproj/gems/$RUBY_VERSION'" >>config/additional_environment.rb |
292 echo "ENV['GEM_PATH'] = '%{l_prefix}/lib/ruby/gems/$RUBY_VERSION:%{l_prefix}/lib/chiliproj/gems/$RUBY_VERSION'" >>config/additional_environment.rb |
291 #echo 'config.action_controller.session = { :key => "_chiliproject_session", :secret => "54bbf51a99cbce2a8881af4fa0fa23895e071f8c8c4773e76b09388135bd9d3671534bf4db20c9f3" }' >>config/additional_environment.rb |
293 %{l_shtool} mkdir -f -p -m 755 .bundle # prime bundler with configuration |
|
294 echo 'BUNDLE_WITHOUT: test:de:development:postgres:mysql:rmagick' >.bundle/config |
292 cat >config/database.yml <<EOF |
295 cat >config/database.yml <<EOF |
293 production: |
296 production: |
294 adapter: sqlite3 |
297 adapter: sqlite3 |
295 database: db/prod.sqlite |
298 database: db/prod.sqlite |
296 EOF |
299 EOF |
297 # try this block with --- |
|
298 cat >.bundle/config <<EOF |
|
299 --- |
|
300 BUNDLE_WITHOUT: test:de:development:postgres:mysql:rmagick |
|
301 EOF |
|
302 ) || exit $? |
300 ) || exit $? |
303 |
301 |
304 # install run command script |
302 # install run command script |
305 %{l_shtool} mkdir -f -p -m 755 \ |
303 %{l_shtool} mkdir -f -p -m 755 \ |
306 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d |
304 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d |
307 %{l_shtool} install -c -m 755 %{l_value -s -a} \ |
305 %{l_shtool} install -c -m 755 %{l_value -s -a} \ |
308 -e 's;@l_gempath@;$RPM_BUILD_ROOT%{l_prefix}/lib/ruby/gems/$RUBY_VERSION;g' \ |
306 -e "s;@l_chilipath@;%{l_prefix}/lib/chiliproj;" \ |
|
307 -e "s;@l_gempath@;%{l_prefix}/lib/ruby/gems/$RUBY_VERSION;" \ |
309 %{SOURCE rc.chiliproj} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/ |
308 %{SOURCE rc.chiliproj} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/ |
310 |
309 |
311 # clean up white spaces |
310 # clean up white spaces |
312 rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/chiliproj/gems/$RUBY_VERSION/gems/rdoc-*/test |
311 rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/chiliproj/gems/$RUBY_VERSION/gems/rdoc-*/test |
313 |
312 |
314 # problem with typical name 'files', existing in this case |
313 # problem with typical name 'files', existing in this case |
315 %{l_rpmtool} files -v -oaltfiles -r$RPM_BUILD_ROOT \ |
314 %{l_rpmtool} files -v -oaltfiles -r$RPM_BUILD_ROOT \ |
316 %{l_files_std} \ |
315 %{l_files_std} \ |
317 '%config %{l_prefix}/lib/chiliproj/config/*' |
316 '%config %{l_prefix}/lib/chiliproj/config/*' \ |
318 #'%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/files' \ |
317 '%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/files' \ |
319 #'%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/files/*' \ |
318 '%attr(664,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/files/*' \ |
320 #'%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/log' \ |
319 '%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/log' \ |
321 #'%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/log/*' \ |
320 '%attr(664,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/log/*' \ |
322 #'%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/tmp' \ |
321 '%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/tmp' \ |
323 #'%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/tmp/*' \ |
322 '%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/tmp/*' \ |
324 #'%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/public/plugin_assets' \ |
323 '%attr(664,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/tmp/test/*' \ |
325 #'%attr(-,%{l_nusr},%{l_ngrp}) %{l_prefix}/lib/chiliproj/public/plugin_assets/*' |
324 '%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/public/plugin_assets' \ |
|
325 '%attr(664,%{l_nusr},%{l_ngrp}) %{l_prefix}/lib/chiliproj/public/plugin_assets/*' \ |
|
326 '%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/var/chiliproj' |
326 |
327 |
327 %files -f altfiles |
328 %files -f altfiles |
328 # problem with typical name 'files', existing in this case |
329 # problem with typical name 'files' which preexists |
329 |
330 |
330 %clean |
331 %clean |
331 |
332 |
332 %post |
333 %post |
333 if [ $1 -eq 1 ]; then |
334 if [ $1 -eq 1 ]; then |
334 RUBY_VERSION=`%{l_prefix}/bin/gem which rubygems | sed -e 's;.*/\([^/]*\)/rubygems\.rb$;\1;'` |
335 RUBY_VERSION=`%{l_prefix}/bin/gem which rubygems | sed -e 's;.*/\([^/]*\)/rubygems\.rb$;\1;'` |
335 ( cd $RPM_INSTALL_PREFIX/lib/chiliproj |
336 ( cd $RPM_INSTALL_PREFIX/lib/chiliproj |
336 # install session |
337 # install session |
|
338 echo 'Creating ChiliProject session key...' |
337 $RPM_INSTALL_PREFIX/lib/ruby/gems/$RUBY_VERSION/bin/bundle \ |
339 $RPM_INSTALL_PREFIX/lib/ruby/gems/$RUBY_VERSION/bin/bundle \ |
338 exec rake generate_session_store |
340 exec rake generate_session_store |
339 # create initial database |
341 # create initial database |
|
342 echo 'Creating ChiliProject initial database...' |
340 RAILS_ENV=production \ |
343 RAILS_ENV=production \ |
341 $RPM_INSTALL_PREFIX/lib/ruby/gems/$RUBY_VERSION/bin/bundle \ |
344 $RPM_INSTALL_PREFIX/lib/ruby/gems/$RUBY_VERSION/bin/bundle \ |
342 exec rake db:migrate |
345 exec rake db:migrate >/dev/null |
343 # insert default configuration into database |
346 # insert default configuration into database |
|
347 echo 'Populating ChiliProject initial database...' |
344 echo 'en' | \ |
348 echo 'en' | \ |
345 RAILS_ENV=production \ |
349 RAILS_ENV=production \ |
346 $RPM_INSTALL_PREFIX/lib/ruby/gems/$RUBY_VERSION/bin/bundle \ |
350 $RPM_INSTALL_PREFIX/lib/ruby/gems/$RUBY_VERSION/bin/bundle \ |
347 exec rake redmine:load_default_data |
351 exec rake redmine:load_default_data >/dev/null |
|
352 # correct permissions of generated files |
|
353 chown %{l_nusr}:%{l_mgrp} \ |
|
354 $RPM_INSTALL_PREFIX/lib/chiliproj/log/production.log \ |
|
355 $RPM_INSTALL_PREFIX/lib/chiliproj/config/initializers/session_store.rb \ |
|
356 $RPM_INSTALL_PREFIX/lib/chiliproj/db/* \ |
|
357 $RPM_INSTALL_PREFIX/lib/chiliproj/db/*/* |
|
358 chown opsw-n db db/* db/migrate/* |
|
359 chmod 0664 \ |
|
360 $RPM_INSTALL_PREFIX/lib/chiliproj/log/production.log \ |
|
361 $RPM_INSTALL_PREFIX/lib/chiliproj/config/initializers/session_store.rb \ |
|
362 $RPM_INSTALL_PREFIX/lib/chiliproj/db/* \ |
|
363 $RPM_INSTALL_PREFIX/lib/chiliproj/db/*/* |
348 ) || exit $? |
364 ) || exit $? |
349 fi |
365 fi |
350 if [ $1 -eq 2 ]; then |
366 # after upgrade, restart service |
351 # after upgrade |
367 [ $1 -eq 2 ] || exit 0 |
352 echo NOOP |
368 eval `%{l_rc} chiliproj status 2>/dev/null` |
353 fi |
369 [ ".$chiliproj_active" = .yes ] && %{l_rc} chiliproj restart |
354 |
370 exit 0 |
|
371 |
|
372 %preun |
|
373 # before erase, stop service and remove log files |
|
374 [ $1 -eq 0 ] || exit 0 |
|
375 %{l_rc} chiliproj stop 2>/dev/null |
|
376 rm -rf $RPM_INSTALL_PREFIX/lib/chiliproj/db 2>/dev/null || true |
|
377 rm -rf $RPM_INSTALL_PREFIX/lib/chiliproj/public 2>/dev/null || true |
|
378 rm -rf $RPM_INSTALL_PREFIX/lib/chiliproj/config/initializers 2>/dev/null || true |
|
379 rm -rf $RPM_INSTALL_PREFIX/lib/chiliproj/log 2>/dev/null || true |
|
380 rm -f $RPM_INSTALL_PREFIX/var/chiliproj/*.log 2>/dev/null || true |
|
381 rm -f $RPM_INSTALL_PREFIX/var/chiliproj/*.pid 2>/dev/null || true |
|
382 exit 0 |
|
383 |