1.1 --- a/chiliproj/chiliproj.spec Sun Mar 31 17:55:10 2013 +0200 1.2 +++ b/chiliproj/chiliproj.spec Mon Apr 01 19:50:38 2013 +0200 1.3 @@ -22,6 +22,8 @@ 1.4 ## 1.5 1.6 # FIXME: GEM_HOME=$HOME/.gem RAILS_ENV=production PATH=$PATH:%{l_prefix}/lib/ruby/gems/1.9.1/bin bundle install --without test development mysql postgres rmagick 1.7 +# FIXME: Reduce %post by removing RAILS_ENV=production 1.8 +# FIXME: Consider using imagemagick for Gantt? 1.9 # FIXME: bundle exec rails s 1.10 # FIXME: w3m http://localhost:3000/ 1.11 # FIXME: log in with Login: admin and Password: admin 1.12 @@ -64,7 +66,7 @@ 1.13 Class: EVAL 1.14 Group: Calendar 1.15 License: GPL 1.16 -Version: 20130328 1.17 +Version: 20130401 1.18 Release: 20120800 1.19 1.20 # list of sources 1.21 @@ -253,7 +255,8 @@ 1.22 RUBY_VERSION=`%{l_prefix}/bin/gem which rubygems | sed -e 's;.*/\([^/]*\)/rubygems\.rb$;\1;'` 1.23 export GEM_HOME=$RPM_BUILD_ROOT%{l_prefix}/lib/chiliproj/gems/$RUBY_VERSION 1.24 %{l_shtool} mkdir -f -p -m 755 $GEM_HOME 1.25 - %{l_shtool} mkdir -f -p public/plugin_assets 1.26 + %{l_shtool} mkdir -f -p $RPM_BUILD_ROOT%{l_prefix}/lib/chiliproj/public/plugin_assets 1.27 + %{l_shtool} mkdir -f -p $RPM_BUILD_ROOT%{l_prefix}/var/chiliproj 1.28 %{l_tar} cf - . | %{l_tar} xf - -C $RPM_BUILD_ROOT%{l_prefix}/lib/chiliproj 1.29 %{l_prefix}/bin/gem install --local %{SOURCE3} 1.30 %{l_prefix}/bin/gem install --local %{SOURCE4} 1.31 @@ -282,30 +285,26 @@ 1.32 1.33 # install configuration 1.34 ( cd $RPM_BUILD_ROOT%{l_prefix}/lib/chiliproj 1.35 - %{l_shtool} mkdir -f -p -m 755 .bundle 1.36 cp %{SOURCE Gemfile.lock} . 1.37 echo 'gem "thin"' >>Gemfile 1.38 cp config/configuration.yml.example config/configuration.yml 1.39 cp config/additional_environment.rb.example config/additional_environment.rb 1.40 echo "ENV['GEM_PATH'] = '%{l_prefix}/lib/ruby/gems/$RUBY_VERSION:%{l_prefix}/lib/chiliproj/gems/$RUBY_VERSION'" >>config/additional_environment.rb 1.41 - #echo 'config.action_controller.session = { :key => "_chiliproject_session", :secret => "54bbf51a99cbce2a8881af4fa0fa23895e071f8c8c4773e76b09388135bd9d3671534bf4db20c9f3" }' >>config/additional_environment.rb 1.42 + %{l_shtool} mkdir -f -p -m 755 .bundle # prime bundler with configuration 1.43 + echo 'BUNDLE_WITHOUT: test:de:development:postgres:mysql:rmagick' >.bundle/config 1.44 cat >config/database.yml <<EOF 1.45 production: 1.46 adapter: sqlite3 1.47 database: db/prod.sqlite 1.48 EOF 1.49 - # try this block with --- 1.50 - cat >.bundle/config <<EOF 1.51 ---- 1.52 -BUNDLE_WITHOUT: test:de:development:postgres:mysql:rmagick 1.53 -EOF 1.54 ) || exit $? 1.55 1.56 # install run command script 1.57 %{l_shtool} mkdir -f -p -m 755 \ 1.58 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d 1.59 %{l_shtool} install -c -m 755 %{l_value -s -a} \ 1.60 - -e 's;@l_gempath@;$RPM_BUILD_ROOT%{l_prefix}/lib/ruby/gems/$RUBY_VERSION;g' \ 1.61 + -e "s;@l_chilipath@;%{l_prefix}/lib/chiliproj;" \ 1.62 + -e "s;@l_gempath@;%{l_prefix}/lib/ruby/gems/$RUBY_VERSION;" \ 1.63 %{SOURCE rc.chiliproj} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/ 1.64 1.65 # clean up white spaces 1.66 @@ -314,18 +313,20 @@ 1.67 # problem with typical name 'files', existing in this case 1.68 %{l_rpmtool} files -v -oaltfiles -r$RPM_BUILD_ROOT \ 1.69 %{l_files_std} \ 1.70 - '%config %{l_prefix}/lib/chiliproj/config/*' 1.71 - #'%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/files' \ 1.72 - #'%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/files/*' \ 1.73 - #'%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/log' \ 1.74 - #'%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/log/*' \ 1.75 - #'%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/tmp' \ 1.76 - #'%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/tmp/*' \ 1.77 - #'%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/public/plugin_assets' \ 1.78 - #'%attr(-,%{l_nusr},%{l_ngrp}) %{l_prefix}/lib/chiliproj/public/plugin_assets/*' 1.79 + '%config %{l_prefix}/lib/chiliproj/config/*' \ 1.80 + '%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/files' \ 1.81 + '%attr(664,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/files/*' \ 1.82 + '%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/log' \ 1.83 + '%attr(664,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/log/*' \ 1.84 + '%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/tmp' \ 1.85 + '%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/tmp/*' \ 1.86 + '%attr(664,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/tmp/test/*' \ 1.87 + '%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/public/plugin_assets' \ 1.88 + '%attr(664,%{l_nusr},%{l_ngrp}) %{l_prefix}/lib/chiliproj/public/plugin_assets/*' \ 1.89 + '%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/var/chiliproj' 1.90 1.91 %files -f altfiles 1.92 - # problem with typical name 'files', existing in this case 1.93 + # problem with typical name 'files' which preexists 1.94 1.95 %clean 1.96 1.97 @@ -334,21 +335,49 @@ 1.98 RUBY_VERSION=`%{l_prefix}/bin/gem which rubygems | sed -e 's;.*/\([^/]*\)/rubygems\.rb$;\1;'` 1.99 ( cd $RPM_INSTALL_PREFIX/lib/chiliproj 1.100 # install session 1.101 + echo 'Creating ChiliProject session key...' 1.102 $RPM_INSTALL_PREFIX/lib/ruby/gems/$RUBY_VERSION/bin/bundle \ 1.103 exec rake generate_session_store 1.104 # create initial database 1.105 + echo 'Creating ChiliProject initial database...' 1.106 RAILS_ENV=production \ 1.107 $RPM_INSTALL_PREFIX/lib/ruby/gems/$RUBY_VERSION/bin/bundle \ 1.108 - exec rake db:migrate 1.109 + exec rake db:migrate >/dev/null 1.110 # insert default configuration into database 1.111 + echo 'Populating ChiliProject initial database...' 1.112 echo 'en' | \ 1.113 RAILS_ENV=production \ 1.114 $RPM_INSTALL_PREFIX/lib/ruby/gems/$RUBY_VERSION/bin/bundle \ 1.115 - exec rake redmine:load_default_data 1.116 + exec rake redmine:load_default_data >/dev/null 1.117 + # correct permissions of generated files 1.118 + chown %{l_nusr}:%{l_mgrp} \ 1.119 + $RPM_INSTALL_PREFIX/lib/chiliproj/log/production.log \ 1.120 + $RPM_INSTALL_PREFIX/lib/chiliproj/config/initializers/session_store.rb \ 1.121 + $RPM_INSTALL_PREFIX/lib/chiliproj/db/* \ 1.122 + $RPM_INSTALL_PREFIX/lib/chiliproj/db/*/* 1.123 +chown opsw-n db db/* db/migrate/* 1.124 + chmod 0664 \ 1.125 + $RPM_INSTALL_PREFIX/lib/chiliproj/log/production.log \ 1.126 + $RPM_INSTALL_PREFIX/lib/chiliproj/config/initializers/session_store.rb \ 1.127 + $RPM_INSTALL_PREFIX/lib/chiliproj/db/* \ 1.128 + $RPM_INSTALL_PREFIX/lib/chiliproj/db/*/* 1.129 ) || exit $? 1.130 fi 1.131 - if [ $1 -eq 2 ]; then 1.132 - # after upgrade 1.133 - echo NOOP 1.134 - fi 1.135 + # after upgrade, restart service 1.136 + [ $1 -eq 2 ] || exit 0 1.137 + eval `%{l_rc} chiliproj status 2>/dev/null` 1.138 + [ ".$chiliproj_active" = .yes ] && %{l_rc} chiliproj restart 1.139 + exit 0 1.140 1.141 +%preun 1.142 + # before erase, stop service and remove log files 1.143 + [ $1 -eq 0 ] || exit 0 1.144 + %{l_rc} chiliproj stop 2>/dev/null 1.145 + rm -rf $RPM_INSTALL_PREFIX/lib/chiliproj/db 2>/dev/null || true 1.146 + rm -rf $RPM_INSTALL_PREFIX/lib/chiliproj/public 2>/dev/null || true 1.147 + rm -rf $RPM_INSTALL_PREFIX/lib/chiliproj/config/initializers 2>/dev/null || true 1.148 + rm -rf $RPM_INSTALL_PREFIX/lib/chiliproj/log 2>/dev/null || true 1.149 + rm -f $RPM_INSTALL_PREFIX/var/chiliproj/*.log 2>/dev/null || true 1.150 + rm -f $RPM_INSTALL_PREFIX/var/chiliproj/*.pid 2>/dev/null || true 1.151 + exit 0 1.152 +