chiliproj/chiliproj.spec

Mon, 01 Apr 2013 20:12:48 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Mon, 01 Apr 2013 20:12:48 +0200
changeset 766
fd2bc92f4dee
parent 765
5be956b2db74
child 767
3ee660c5bc4f
permissions
-rw-r--r--

Correct run command stop logic and indicate installation success.

     1 ##
     2 ##  chiliproj.spec -- OpenPKG RPM Package Specification
     3 ##  Copyright (c) 2013 Michael Schloh von Bennewitz <michael@schloh.com>
     4 ##
     5 ##  Permission to use, copy, modify, and distribute this software for
     6 ##  any purpose with or without fee is hereby granted, provided that
     7 ##  the above copyright notice and this permission notice appear in all
     8 ##  copies.
     9 ##
    10 ##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
    11 ##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    12 ##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    13 ##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
    14 ##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    15 ##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    16 ##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
    17 ##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    18 ##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    19 ##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
    20 ##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    21 ##  SUCH DAMAGE.
    22 ##
    24 # 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
    25 # FIXME: Reduce %post by removing RAILS_ENV=production
    26 # FIXME: Consider using imagemagick for Gantt?
    27 # FIXME: bundle exec rails s
    28 # FIXME: w3m http://localhost:3000/
    29 # FIXME: log in with Login: admin and Password: admin
    31 #   package version
    32 %define       V_pref            427
    33 %define       V_rake            10.0.4
    34 %define       V_activesupport   2.3.18
    35 %define       V_rack            1.1.6
    36 %define       V_actionpack      2.3.18
    37 %define       V_actionmailer    2.3.18
    38 %define       V_activerecord    2.3.18
    39 %define       V_activeresource  2.3.18
    40 %define       V_rails           2.3.18
    41 %define       V_actsastaggable  2.1.0
    42 %define       V_coderay         1.0.9
    43 %define       V_daemons         1.1.9
    44 %define       V_eventmachine    1.0.3
    45 %define       V_gravatarify     3.0.0
    46 %define       V_i18n            0.4.2
    47 %define       V_json            1.7.7
    48 %define       V_liquid          2.3.0
    49 %define       V_mysql2          0.2.18
    50 %define       V_netldap         0.3.1
    51 %define       V_rdoc            4.0.1
    52 %define       V_rubyopenid      2.1.8
    53 %define       V_rubytree        0.5.3
    54 %define       V_sqlite3         1.3.7
    55 %define       V_thin            1.5.1
    56 %define       V_tzinfo          0.3.37
    57 %define       V_bundler         1.3.4
    59 #   package information
    60 Name:         chiliproj
    61 Summary:      Comprehensive Rails-based Project Manager
    62 URL:          http://www.chiliproject.org/
    63 Vendor:       Felix Schaefer et al.
    64 Packager:     Michael Schloh von Bennewitz
    65 Distribution: Europalab Networks Production
    66 Class:        EVAL
    67 Group:        Calendar
    68 License:      GPL
    69 Version:      20130401
    70 Release:      20120800
    72 #   list of sources
    73 Source0:      http://www.chiliproject.org/attachments/download/%{V_pref}/chiliproject-%{version}.tar.bz2
    74 Source1:      rc.chiliproj
    75 Source2:      Gemfile.lock
    76 Source3:      http://rubygems.org/downloads/rake-%{V_rake}.gem
    77 Source4:      http://rubygems.org/downloads/activesupport-%{V_activesupport}.gem
    78 Source5:      http://rubygems.org/downloads/rack-%{V_rack}.gem
    79 Source6:      http://rubygems.org/downloads/actionpack-%{V_actionpack}.gem
    80 Source7:      http://rubygems.org/downloads/actionmailer-%{V_actionmailer}.gem
    81 Source8:      http://rubygems.org/downloads/activerecord-%{V_activerecord}.gem
    82 Source9:      http://rubygems.org/downloads/activeresource-%{V_activeresource}.gem
    83 Source10:     http://rubygems.org/downloads/rails-%{V_rails}.gem
    84 Source11:     http://rubygems.org/downloads/acts-as-taggable-on-%{V_actsastaggable}.gem
    85 Source12:     http://rubygems.org/downloads/coderay-%{V_coderay}.gem
    86 Source13:     http://rubygems.org/downloads/daemons-%{V_daemons}.gem
    87 Source14:     http://rubygems.org/downloads/eventmachine-%{V_eventmachine}.gem
    88 Source15:     http://rubygems.org/downloads/gravatarify-%{V_gravatarify}.gem
    89 Source16:     http://rubygems.org/downloads/i18n-%{V_i18n}.gem
    90 Source17:     http://rubygems.org/downloads/json-%{V_json}.gem
    91 Source18:     http://rubygems.org/downloads/liquid-%{V_liquid}.gem
    92 Source19:     http://rubygems.org/downloads/mysql2-%{V_mysql2}.gem
    93 Source20:     http://rubygems.org/downloads/net-ldap-%{V_netldap}.gem
    94 Source21:     http://rubygems.org/downloads/rdoc-%{V_rdoc}.gem
    95 Source22:     http://rubygems.org/downloads/ruby-openid-%{V_rubyopenid}.gem
    96 Source23:     http://rubygems.org/downloads/rubytree-%{V_rubytree}.gem
    97 Source24:     http://rubygems.org/downloads/sqlite3-%{V_sqlite3}.gem
    98 Source25:     http://rubygems.org/downloads/thin-%{V_thin}.gem
    99 Source26:     http://rubygems.org/downloads/tzinfo-%{V_tzinfo}.gem
   100 Source27:     http://rubygems.org/downloads/bundler-%{V_bundler}.gem
   102 #   build information
   103 BuildPreReq:  OpenPKG, openpkg >= 20100101, ruby < 2.0.0, ruby-rails, ruby-thin
   104 PreReq:       OpenPKG, openpkg >= 20100101, ruby < 2.0.0, ruby-rails, ruby-thin
   106 %description
   107     ChiliProject is a web based project management system. It supports
   108     your team throughout the complete project life cycle, from setting
   109     up and discussing a project plan, over tracking issues and reporting
   110     work progress to collaboratively sharing knowledge.
   112 %track
   113     prog chiliproj:chiliproj = {
   114         version   = %{version}
   115         url       = http://www.chiliproject.org/attachments/download/
   116         regex     = (\d+)
   117         url       = http://www.chiliproject.org/attachments/download/__NEWVER__/
   118         regex     = chiliproject-(__VER__)\.tar.bz2
   119     }
   120     prog chiliproj:rake = {
   121         version   = %{V_rake}
   122         url       = http://rubygems.org/gems/rake
   123         regex     = rake-(__VER__)\.gem
   124     }
   125     prog chiliproj:activesupport = {
   126         version   = %{V_activesupport}
   127         url       = http://rubygems.org/gems/activesupport
   128         regex     = activesupport-(__VER__)\.gem
   129     }
   130     prog chiliproj:rack = {
   131         version   = %{V_rack}
   132         url       = http://rubygems.org/gems/rack
   133         regex     = rack-(__VER__)\.gem
   134     }
   135     prog chiliproj:actionpack = {
   136         version   = %{V_actionpack}
   137         url       = http://rubygems.org/gems/actionpack
   138         regex     = actionpack-(__VER__)\.gem
   139     }
   140     prog chiliproj:actionmailer = {
   141         version   = %{V_actionmailer}
   142         url       = http://rubygems.org/gems/actionmailer
   143         regex     = actionmailer-(__VER__)\.gem
   144     }
   145     prog chiliproj:activerecord = {
   146         version   = %{V_activerecord}
   147         url       = http://rubygems.org/gems/activerecord
   148         regex     = activerecord-(__VER__)\.gem
   149     }
   150     prog chiliproj:activeresource = {
   151         version   = %{V_activeresource}
   152         url       = http://rubygems.org/gems/activeresource
   153         regex     = activeresource-(__VER__)\.gem
   154     }
   155     prog chiliproj:rails = {
   156         version   = %{V_rails}
   157         url       = http://rubygems.org/gems/rails
   158         regex     = rails-(__VER__)\.gem
   159     }
   160     prog chiliproj:actsastaggable = {
   161         version   = %{V_actsastaggable}
   162         url       = http://rubygems.org/gems/acts-as-taggable-on
   163         regex     = acts-as-taggable-on-(__VER__)\.gem
   164     }
   165     prog chiliproj:coderay = {
   166         version   = %{V_coderay}
   167         url       = http://rubygems.org/gems/coderay
   168         regex     = coderay-(__VER__)\.gem
   169     }
   170     prog chiliproj:daemons = {
   171         version   = %{V_daemons}
   172         url       = http://rubygems.org/gems/daemons
   173         regex     = daemons-(__VER__)\.gem
   174     }
   175     prog chiliproj:eventmachine = {
   176         version   = %{V_eventmachine}
   177         url       = http://rubygems.org/gems/eventmachine
   178         regex     = eventmachine-(__VER__)\.gem
   179     }
   180     prog chiliproj:gravatarify = {
   181         version   = %{V_gravatarify}
   182         url       = http://rubygems.org/gems/gravatarify
   183         regex     = gravatarify-(__VER__)\.gem
   184     }
   185     prog chiliproj:i18n = {
   186         version   = %{V_i18n}
   187         url       = http://rubygems.org/gems/i18n
   188         regex     = i18n-(__VER__)\.gem
   189     }
   190     prog chiliproj:json = {
   191         version   = %{V_json}
   192         url       = http://rubygems.org/gems/json
   193         regex     = json-(__VER__)\.gem
   194     }
   195     prog chiliproj:liquid = {
   196         version   = %{V_liquid}
   197         url       = http://rubygems.org/gems/liquid
   198         regex     = liquid-(__VER__)\.gem
   199     }
   200     prog chiliproj:mysql2 = {
   201         version   = %{V_mysql2}
   202         url       = http://rubygems.org/gems/mysql2
   203         regex     = mysql2-(__VER__)\.gem
   204     }
   205     prog chiliproj:netldap = {
   206         version   = %{V_netldap}
   207         url       = http://rubygems.org/gems/net-ldap
   208         regex     = net-ldap-(__VER__)\.gem
   209     }
   210     prog chiliproj:rdoc = {
   211         version   = %{V_rdoc}
   212         url       = http://rubygems.org/gems/rdoc
   213         regex     = rdoc-(__VER__)\.gem
   214     }
   215     prog chiliproj:rubyopenid = {
   216         version   = %{V_rubyopenid}
   217         url       = http://rubygems.org/gems/ruby-openid
   218         regex     = ruby-openid-(__VER__)\.gem
   219     }
   220     prog chiliproj:rubytree = {
   221         version   = %{V_rubytree}
   222         url       = http://rubygems.org/gems/rubytree
   223         regex     = rubytree-(__VER__)\.gem
   224     }
   225     prog chiliproj:sqlite3 = {
   226         version   = %{V_sqlite3}
   227         url       = http://rubygems.org/gems/sqlite3
   228         regex     = sqlite3-(__VER__)\.gem
   229     }
   230     prog chiliproj:thin = {
   231         version   = %{V_thin}
   232         url       = http://rubygems.org/gems/thin
   233         regex     = thin-(__VER__)\.gem
   234     }
   235     prog chiliproj:tzinfo = {
   236         version   = %{V_tzinfo}
   237         url       = http://rubygems.org/gems/tzinfo
   238         regex     = tzinfo-(__VER__)\.gem
   239     }
   240     prog chiliproj:bundler = {
   241         version   = %{V_bundler}
   242         url       = http://rubygems.org/gems/bundler
   243         regex     = bundler-(__VER__)\.gem
   244     }
   246 %prep
   247     %setup -q -n chiliproject-%{version}
   248     %{l_shtool} subst \
   249         -e 's;# \(ENV\[.RAILS_ENV.\] ||= .production.\);\1;' \
   250         config/environment.rb
   252 %build
   254 %install
   255     RUBY_VERSION=`%{l_prefix}/bin/gem which rubygems | sed -e 's;.*/\([^/]*\)/rubygems\.rb$;\1;'`
   256     export GEM_HOME=$RPM_BUILD_ROOT%{l_prefix}/lib/chiliproj/gems/$RUBY_VERSION
   257     %{l_shtool} mkdir -f -p -m 755 $GEM_HOME
   258     %{l_shtool} mkdir -f -p $RPM_BUILD_ROOT%{l_prefix}/lib/chiliproj/public/plugin_assets
   259     %{l_shtool} mkdir -f -p $RPM_BUILD_ROOT%{l_prefix}/var/chiliproj
   260     %{l_tar} cf - . | %{l_tar} xf - -C $RPM_BUILD_ROOT%{l_prefix}/lib/chiliproj
   261     %{l_prefix}/bin/gem install --local %{SOURCE3}
   262     %{l_prefix}/bin/gem install --local %{SOURCE4}
   263     %{l_prefix}/bin/gem install --local %{SOURCE5}
   264     %{l_prefix}/bin/gem install --local %{SOURCE6}
   265     %{l_prefix}/bin/gem install --local %{SOURCE7}
   266     %{l_prefix}/bin/gem install --local %{SOURCE8}
   267     %{l_prefix}/bin/gem install --local %{SOURCE9}
   268     %{l_prefix}/bin/gem install --local %{SOURCE10}
   269     %{l_prefix}/bin/gem install --local %{SOURCE11}
   270     %{l_prefix}/bin/gem install --local %{SOURCE12}
   271     %{l_prefix}/bin/gem install --local %{SOURCE13}
   272     %{l_prefix}/bin/gem install --local %{SOURCE14}
   273     %{l_prefix}/bin/gem install --local %{SOURCE15}
   274     %{l_prefix}/bin/gem install --local %{SOURCE16}
   275     %{l_prefix}/bin/gem install --local %{SOURCE17}
   276     %{l_prefix}/bin/gem install --local %{SOURCE18}
   277     %{l_prefix}/bin/gem install --local %{SOURCE19}
   278     %{l_prefix}/bin/gem install --local %{SOURCE20}
   279     %{l_prefix}/bin/gem install --local %{SOURCE21}
   280     %{l_prefix}/bin/gem install --local %{SOURCE22}
   281     %{l_prefix}/bin/gem install --local %{SOURCE23}
   282     %{l_prefix}/bin/gem install --local %{SOURCE24}
   283     %{l_prefix}/bin/gem install --local %{SOURCE25}
   284     %{l_prefix}/bin/gem install --local %{SOURCE27}
   286     #   install configuration
   287     ( cd $RPM_BUILD_ROOT%{l_prefix}/lib/chiliproj
   288       cp %{SOURCE Gemfile.lock} .
   289       echo 'gem "thin"' >>Gemfile
   290       cp config/configuration.yml.example config/configuration.yml
   291       cp config/additional_environment.rb.example 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
   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
   295       cat >config/database.yml <<EOF
   296 production:
   297   adapter: sqlite3
   298   database: db/prod.sqlite
   299 EOF
   300     ) || exit $?
   302     #   install run command script
   303     %{l_shtool} mkdir -f -p -m 755 \
   304         $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
   305     %{l_shtool} install -c -m 755 %{l_value -s -a} \
   306         -e "s;@l_chilipath@;%{l_prefix}/lib/chiliproj;" \
   307         -e "s;@l_gempath@;%{l_prefix}/lib/ruby/gems/$RUBY_VERSION;" \
   308         %{SOURCE rc.chiliproj} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
   310     #   clean up white spaces
   311     rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/chiliproj/gems/$RUBY_VERSION/gems/rdoc-*/test
   313     #   problem with typical name 'files', existing in this case
   314     %{l_rpmtool} files -v -oaltfiles -r$RPM_BUILD_ROOT \
   315         %{l_files_std} \
   316         '%config %{l_prefix}/lib/chiliproj/config/*' \
   317         '%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/files' \
   318         '%attr(664,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/files/*' \
   319         '%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/log' \
   320         '%attr(664,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/log/*' \
   321         '%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/tmp' \
   322         '%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/tmp/*' \
   323         '%attr(664,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/tmp/test/*' \
   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'
   328 %files -f altfiles
   329     #   problem with typical name 'files' which preexists
   331 %clean
   333 %post
   334     if [ $1 -eq 1 ]; then
   335         RUBY_VERSION=`%{l_prefix}/bin/gem which rubygems | sed -e 's;.*/\([^/]*\)/rubygems\.rb$;\1;'`
   336         ( cd $RPM_INSTALL_PREFIX/lib/chiliproj
   337           #   install session
   338           echo 'Creating ChiliProject session key...'
   339           $RPM_INSTALL_PREFIX/lib/ruby/gems/$RUBY_VERSION/bin/bundle \
   340               exec rake generate_session_store
   341           #   create initial database
   342           echo 'Creating ChiliProject initial database...'
   343           RAILS_ENV=production \
   344               $RPM_INSTALL_PREFIX/lib/ruby/gems/$RUBY_VERSION/bin/bundle \
   345               exec rake db:migrate >/dev/null
   346           #   insert default configuration into database
   347           echo 'Populating ChiliProject initial database...'
   348           echo 'en' | \
   349               RAILS_ENV=production \
   350               $RPM_INSTALL_PREFIX/lib/ruby/gems/$RUBY_VERSION/bin/bundle \
   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/*/*
   364         ) || exit $?
   365         echo 'ChiliProject installation done.'
   366     fi
   367     #   after upgrade, restart service
   368     [ $1 -eq 2 ] || exit 0
   369     eval `%{l_rc} chiliproj status 2>/dev/null`
   370     [ ".$chiliproj_active" = .yes ] && %{l_rc} chiliproj restart
   371     exit 0
   373 %preun
   374     #   before erase, stop service and remove log files
   375     [ $1 -eq 0 ] || exit 0
   376     %{l_rc} chiliproj stop 2>/dev/null
   377     rm -rf $RPM_INSTALL_PREFIX/lib/chiliproj/db 2>/dev/null || true
   378     rm -rf $RPM_INSTALL_PREFIX/lib/chiliproj/public 2>/dev/null || true
   379     rm -rf $RPM_INSTALL_PREFIX/lib/chiliproj/config/initializers 2>/dev/null || true
   380     rm -rf $RPM_INSTALL_PREFIX/lib/chiliproj/log 2>/dev/null || true
   381     rm -f $RPM_INSTALL_PREFIX/var/chiliproj/*.log 2>/dev/null || true
   382     rm -f $RPM_INSTALL_PREFIX/var/chiliproj/*.pid 2>/dev/null || true
   383     exit 0

mercurial