chiliproj/chiliproj.spec

Tue, 02 Apr 2013 20:44:50 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 02 Apr 2013 20:44:50 +0200
changeset 767
3ee660c5bc4f
parent 766
fd2bc92f4dee
permissions
-rw-r--r--

Correct initial database generation and improve runcommand script logic.

     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: %{l_prefix}/lib/ruby/gems/1.9.1/bin/rake -T (or -D)
    26 # FIXME: Reduce %post by removing RAILS_ENV=production
    27 # FIXME: Consider using imagemagick for Gantt?
    28 # FIXME: bundle exec rails s
    29 # FIXME: w3m http://localhost:3000/
    30 # FIXME: log in with Login: admin and Password: admin
    32 #   package version
    33 %define       V_pref            427
    34 %define       V_rake            10.0.4
    35 %define       V_activesupport   2.3.18
    36 %define       V_rack            1.1.6
    37 %define       V_actionpack      2.3.18
    38 %define       V_actionmailer    2.3.18
    39 %define       V_activerecord    2.3.18
    40 %define       V_activeresource  2.3.18
    41 %define       V_rails           2.3.18
    42 %define       V_actsastaggable  2.1.0
    43 %define       V_coderay         1.0.9
    44 %define       V_daemons         1.1.9
    45 %define       V_eventmachine    1.0.3
    46 %define       V_gravatarify     3.0.0
    47 %define       V_i18n            0.4.2
    48 %define       V_json            1.7.7
    49 %define       V_liquid          2.3.0
    50 %define       V_mysql2          0.2.18
    51 %define       V_netldap         0.3.1
    52 %define       V_rdoc            4.0.1
    53 %define       V_rubyopenid      2.1.8
    54 %define       V_rubytree        0.5.3
    55 %define       V_sqlite3         1.3.7
    56 %define       V_thin            1.5.1
    57 %define       V_tzinfo          0.3.37
    58 %define       V_bundler         1.3.4
    60 #   package information
    61 Name:         chiliproj
    62 Summary:      Comprehensive Rails-based Project Manager
    63 URL:          http://www.chiliproject.org/
    64 Vendor:       Felix Schaefer et al.
    65 Packager:     Michael Schloh von Bennewitz
    66 Distribution: Europalab Networks Production
    67 Class:        EVAL
    68 Group:        Calendar
    69 License:      GPL
    70 Version:      20130401
    71 Release:      20120800
    73 #   list of sources
    74 Source0:      http://www.chiliproject.org/attachments/download/%{V_pref}/chiliproject-%{version}.tar.bz2
    75 Source1:      rc.chiliproj
    76 Source2:      Gemfile.lock
    77 Source3:      http://rubygems.org/downloads/rake-%{V_rake}.gem
    78 Source4:      http://rubygems.org/downloads/activesupport-%{V_activesupport}.gem
    79 Source5:      http://rubygems.org/downloads/rack-%{V_rack}.gem
    80 Source6:      http://rubygems.org/downloads/actionpack-%{V_actionpack}.gem
    81 Source7:      http://rubygems.org/downloads/actionmailer-%{V_actionmailer}.gem
    82 Source8:      http://rubygems.org/downloads/activerecord-%{V_activerecord}.gem
    83 Source9:      http://rubygems.org/downloads/activeresource-%{V_activeresource}.gem
    84 Source10:     http://rubygems.org/downloads/rails-%{V_rails}.gem
    85 Source11:     http://rubygems.org/downloads/acts-as-taggable-on-%{V_actsastaggable}.gem
    86 Source12:     http://rubygems.org/downloads/coderay-%{V_coderay}.gem
    87 Source13:     http://rubygems.org/downloads/daemons-%{V_daemons}.gem
    88 Source14:     http://rubygems.org/downloads/eventmachine-%{V_eventmachine}.gem
    89 Source15:     http://rubygems.org/downloads/gravatarify-%{V_gravatarify}.gem
    90 Source16:     http://rubygems.org/downloads/i18n-%{V_i18n}.gem
    91 Source17:     http://rubygems.org/downloads/json-%{V_json}.gem
    92 Source18:     http://rubygems.org/downloads/liquid-%{V_liquid}.gem
    93 Source19:     http://rubygems.org/downloads/mysql2-%{V_mysql2}.gem
    94 Source20:     http://rubygems.org/downloads/net-ldap-%{V_netldap}.gem
    95 Source21:     http://rubygems.org/downloads/rdoc-%{V_rdoc}.gem
    96 Source22:     http://rubygems.org/downloads/ruby-openid-%{V_rubyopenid}.gem
    97 Source23:     http://rubygems.org/downloads/rubytree-%{V_rubytree}.gem
    98 Source24:     http://rubygems.org/downloads/sqlite3-%{V_sqlite3}.gem
    99 Source25:     http://rubygems.org/downloads/thin-%{V_thin}.gem
   100 Source26:     http://rubygems.org/downloads/tzinfo-%{V_tzinfo}.gem
   101 Source27:     http://rubygems.org/downloads/bundler-%{V_bundler}.gem
   103 #   build information
   104 BuildPreReq:  OpenPKG, openpkg >= 20100101, ruby < 2.0.0, ruby-rails, ruby-thin
   105 PreReq:       OpenPKG, openpkg >= 20100101, ruby < 2.0.0, ruby-rails, ruby-thin
   107 %description
   108     ChiliProject is a web based project management system. It supports
   109     your team throughout the complete project life cycle, from setting
   110     up and discussing a project plan, over tracking issues and reporting
   111     work progress to collaboratively sharing knowledge.
   113 %track
   114     prog chiliproj:chiliproj = {
   115         version   = %{version}
   116         url       = http://www.chiliproject.org/attachments/download/
   117         regex     = (\d+)
   118         url       = http://www.chiliproject.org/attachments/download/__NEWVER__/
   119         regex     = chiliproject-(__VER__)\.tar.bz2
   120     }
   121     prog chiliproj:rake = {
   122         version   = %{V_rake}
   123         url       = http://rubygems.org/gems/rake
   124         regex     = rake-(__VER__)\.gem
   125     }
   126     prog chiliproj:activesupport = {
   127         version   = %{V_activesupport}
   128         url       = http://rubygems.org/gems/activesupport
   129         regex     = activesupport-(__VER__)\.gem
   130     }
   131     prog chiliproj:rack = {
   132         version   = %{V_rack}
   133         url       = http://rubygems.org/gems/rack
   134         regex     = rack-(__VER__)\.gem
   135     }
   136     prog chiliproj:actionpack = {
   137         version   = %{V_actionpack}
   138         url       = http://rubygems.org/gems/actionpack
   139         regex     = actionpack-(__VER__)\.gem
   140     }
   141     prog chiliproj:actionmailer = {
   142         version   = %{V_actionmailer}
   143         url       = http://rubygems.org/gems/actionmailer
   144         regex     = actionmailer-(__VER__)\.gem
   145     }
   146     prog chiliproj:activerecord = {
   147         version   = %{V_activerecord}
   148         url       = http://rubygems.org/gems/activerecord
   149         regex     = activerecord-(__VER__)\.gem
   150     }
   151     prog chiliproj:activeresource = {
   152         version   = %{V_activeresource}
   153         url       = http://rubygems.org/gems/activeresource
   154         regex     = activeresource-(__VER__)\.gem
   155     }
   156     prog chiliproj:rails = {
   157         version   = %{V_rails}
   158         url       = http://rubygems.org/gems/rails
   159         regex     = rails-(__VER__)\.gem
   160     }
   161     prog chiliproj:actsastaggable = {
   162         version   = %{V_actsastaggable}
   163         url       = http://rubygems.org/gems/acts-as-taggable-on
   164         regex     = acts-as-taggable-on-(__VER__)\.gem
   165     }
   166     prog chiliproj:coderay = {
   167         version   = %{V_coderay}
   168         url       = http://rubygems.org/gems/coderay
   169         regex     = coderay-(__VER__)\.gem
   170     }
   171     prog chiliproj:daemons = {
   172         version   = %{V_daemons}
   173         url       = http://rubygems.org/gems/daemons
   174         regex     = daemons-(__VER__)\.gem
   175     }
   176     prog chiliproj:eventmachine = {
   177         version   = %{V_eventmachine}
   178         url       = http://rubygems.org/gems/eventmachine
   179         regex     = eventmachine-(__VER__)\.gem
   180     }
   181     prog chiliproj:gravatarify = {
   182         version   = %{V_gravatarify}
   183         url       = http://rubygems.org/gems/gravatarify
   184         regex     = gravatarify-(__VER__)\.gem
   185     }
   186     prog chiliproj:i18n = {
   187         version   = %{V_i18n}
   188         url       = http://rubygems.org/gems/i18n
   189         regex     = i18n-(__VER__)\.gem
   190     }
   191     prog chiliproj:json = {
   192         version   = %{V_json}
   193         url       = http://rubygems.org/gems/json
   194         regex     = json-(__VER__)\.gem
   195     }
   196     prog chiliproj:liquid = {
   197         version   = %{V_liquid}
   198         url       = http://rubygems.org/gems/liquid
   199         regex     = liquid-(__VER__)\.gem
   200     }
   201     prog chiliproj:mysql2 = {
   202         version   = %{V_mysql2}
   203         url       = http://rubygems.org/gems/mysql2
   204         regex     = mysql2-(__VER__)\.gem
   205     }
   206     prog chiliproj:netldap = {
   207         version   = %{V_netldap}
   208         url       = http://rubygems.org/gems/net-ldap
   209         regex     = net-ldap-(__VER__)\.gem
   210     }
   211     prog chiliproj:rdoc = {
   212         version   = %{V_rdoc}
   213         url       = http://rubygems.org/gems/rdoc
   214         regex     = rdoc-(__VER__)\.gem
   215     }
   216     prog chiliproj:rubyopenid = {
   217         version   = %{V_rubyopenid}
   218         url       = http://rubygems.org/gems/ruby-openid
   219         regex     = ruby-openid-(__VER__)\.gem
   220     }
   221     prog chiliproj:rubytree = {
   222         version   = %{V_rubytree}
   223         url       = http://rubygems.org/gems/rubytree
   224         regex     = rubytree-(__VER__)\.gem
   225     }
   226     prog chiliproj:sqlite3 = {
   227         version   = %{V_sqlite3}
   228         url       = http://rubygems.org/gems/sqlite3
   229         regex     = sqlite3-(__VER__)\.gem
   230     }
   231     prog chiliproj:thin = {
   232         version   = %{V_thin}
   233         url       = http://rubygems.org/gems/thin
   234         regex     = thin-(__VER__)\.gem
   235     }
   236     prog chiliproj:tzinfo = {
   237         version   = %{V_tzinfo}
   238         url       = http://rubygems.org/gems/tzinfo
   239         regex     = tzinfo-(__VER__)\.gem
   240     }
   241     prog chiliproj:bundler = {
   242         version   = %{V_bundler}
   243         url       = http://rubygems.org/gems/bundler
   244         regex     = bundler-(__VER__)\.gem
   245     }
   247 %prep
   248     %setup -q -n chiliproject-%{version}
   249     %{l_shtool} subst \
   250         -e 's;# \(ENV\[.RAILS_ENV.\] ||= .production.\);\1;' \
   251         config/environment.rb
   252     %{l_shtool} subst \
   253         -e 's;.*<%= l(:text_powered_by.*;;' \
   254         app/views/layouts/base.rhtml
   256 %build
   258 %install
   259     RUBY_VERSION=`%{l_prefix}/bin/gem which rubygems | sed -e 's;.*/\([^/]*\)/rubygems\.rb$;\1;'`
   260     export GEM_HOME=$RPM_BUILD_ROOT%{l_prefix}/lib/chiliproj/gems/$RUBY_VERSION
   261     %{l_shtool} mkdir -f -p -m 755 $GEM_HOME
   262     %{l_shtool} mkdir -f -p $RPM_BUILD_ROOT%{l_prefix}/lib/chiliproj/public/plugin_assets
   263     %{l_shtool} mkdir -f -p $RPM_BUILD_ROOT%{l_prefix}/var/chiliproj
   264     %{l_tar} cf - . | %{l_tar} xf - -C $RPM_BUILD_ROOT%{l_prefix}/lib/chiliproj
   265     %{l_prefix}/bin/gem install --local %{SOURCE3}
   266     %{l_prefix}/bin/gem install --local %{SOURCE4}
   267     %{l_prefix}/bin/gem install --local %{SOURCE5}
   268     %{l_prefix}/bin/gem install --local %{SOURCE6}
   269     %{l_prefix}/bin/gem install --local %{SOURCE7}
   270     %{l_prefix}/bin/gem install --local %{SOURCE8}
   271     %{l_prefix}/bin/gem install --local %{SOURCE9}
   272     %{l_prefix}/bin/gem install --local %{SOURCE10}
   273     %{l_prefix}/bin/gem install --local %{SOURCE11}
   274     %{l_prefix}/bin/gem install --local %{SOURCE12}
   275     %{l_prefix}/bin/gem install --local %{SOURCE13}
   276     %{l_prefix}/bin/gem install --local %{SOURCE14}
   277     %{l_prefix}/bin/gem install --local %{SOURCE15}
   278     %{l_prefix}/bin/gem install --local %{SOURCE16}
   279     %{l_prefix}/bin/gem install --local %{SOURCE17}
   280     %{l_prefix}/bin/gem install --local %{SOURCE18}
   281     %{l_prefix}/bin/gem install --local %{SOURCE19}
   282     %{l_prefix}/bin/gem install --local %{SOURCE20}
   283     %{l_prefix}/bin/gem install --local %{SOURCE21}
   284     %{l_prefix}/bin/gem install --local %{SOURCE22}
   285     %{l_prefix}/bin/gem install --local %{SOURCE23}
   286     %{l_prefix}/bin/gem install --local %{SOURCE24}
   287     %{l_prefix}/bin/gem install --local %{SOURCE25}
   288     %{l_prefix}/bin/gem install --local %{SOURCE27}
   290     #   install configuration
   291     ( cd $RPM_BUILD_ROOT%{l_prefix}/lib/chiliproj
   292       cp %{SOURCE Gemfile.lock} .
   293       echo 'gem "thin"' >>Gemfile
   294       cp config/configuration.yml.example config/configuration.yml
   295       cp config/additional_environment.rb.example config/additional_environment.rb
   296       echo "ENV['GEM_PATH'] = '%{l_prefix}/lib/ruby/gems/$RUBY_VERSION:%{l_prefix}/lib/chiliproj/gems/$RUBY_VERSION'" >>config/additional_environment.rb
   297       %{l_shtool} mkdir -f -p -m 755 .bundle  # prime bundler with configuration
   298       echo 'BUNDLE_WITHOUT: test:de:development:postgres:mysql:rmagick' >.bundle/config
   299       cat >config/database.yml <<EOF
   300 production:
   301   adapter: sqlite3
   302   database: db/prod.sqlite
   303 EOF
   304     ) || exit $?
   306     #   install run command script
   307     %{l_shtool} mkdir -f -p -m 755 \
   308         $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
   309     %{l_shtool} install -c -m 755 %{l_value -s -a} \
   310         -e "s;@l_chilipath@;%{l_prefix}/lib/chiliproj;" \
   311         -e "s;@l_gempath@;%{l_prefix}/lib/ruby/gems/$RUBY_VERSION;" \
   312         %{SOURCE rc.chiliproj} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
   314     #   clean up white spaces
   315     rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/chiliproj/gems/$RUBY_VERSION/gems/rdoc-*/test
   317     #   problem with typical name 'files', existing in this case
   318     %{l_rpmtool} files -v -oaltfiles -r$RPM_BUILD_ROOT \
   319         %{l_files_std} \
   320         '%config %{l_prefix}/lib/chiliproj/config/*' \
   321         '%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/files' \
   322         '%attr(664,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/files/*' \
   323         '%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/log' \
   324         '%attr(664,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/log/*' \
   325         '%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/tmp' \
   326         '%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/tmp/*' \
   327         '%attr(664,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/tmp/test/*' \
   328         '%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/public/plugin_assets' \
   329         '%attr(664,%{l_nusr},%{l_ngrp}) %{l_prefix}/lib/chiliproj/public/plugin_assets/*' \
   330         '%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/var/chiliproj'
   332 %files -f altfiles
   333     #   problem with typical name 'files' which preexists
   335 %clean
   337 %post
   338     if [ $1 -eq 1 ]; then
   339         RUBY_VERSION=`%{l_prefix}/bin/gem which rubygems | sed -e 's;.*/\([^/]*\)/rubygems\.rb$;\1;'`
   340         ( cd $RPM_INSTALL_PREFIX/lib/chiliproj
   341           #   install session
   342           echo 'Creating ChiliProject session key...'
   343           $RPM_INSTALL_PREFIX/lib/ruby/gems/$RUBY_VERSION/bin/bundle \
   344               exec rake -s generate_session_store
   345           #   create initial database
   346           echo 'Creating ChiliProject data schemas...'
   347           $RPM_INSTALL_PREFIX/lib/ruby/gems/$RUBY_VERSION/bin/bundle \
   348               exec rake db:migrate \
   349               RAILS_ENV=production VERBOSE=false
   350           #echo 'Creating ChiliProject initial database...'
   351           #$RPM_INSTALL_PREFIX/lib/ruby/gems/$RUBY_VERSION/bin/bundle \
   352           #    exec rake db:setup >/dev/null 2>&1 \
   353           #    exec rake -s db:create \
   354           #    RAILS_ENV=production
   355           #   insert default configuration into database
   356           echo 'Populating ChiliProject initial database...'
   357           echo 'en' | \
   358           $RPM_INSTALL_PREFIX/lib/ruby/gems/$RUBY_VERSION/bin/bundle \
   359               exec rake redmine:load_default_data >/dev/null \
   360               RAILS_ENV=production
   361           #   correct permissions of generated files
   362           chown %{l_nusr}:%{l_mgrp} \
   363               $RPM_INSTALL_PREFIX/lib/chiliproj/log/production.log \
   364               $RPM_INSTALL_PREFIX/lib/chiliproj/config/initializers/session_store.rb \
   365               $RPM_INSTALL_PREFIX/lib/chiliproj/db \
   366               $RPM_INSTALL_PREFIX/lib/chiliproj/db/* \
   367               $RPM_INSTALL_PREFIX/lib/chiliproj/db/*/*
   368           chmod 0664 \
   369               $RPM_INSTALL_PREFIX/lib/chiliproj/log/production.log \
   370               $RPM_INSTALL_PREFIX/lib/chiliproj/config/initializers/session_store.rb \
   371               $RPM_INSTALL_PREFIX/lib/chiliproj/db/* \
   372               $RPM_INSTALL_PREFIX/lib/chiliproj/db/*/*
   373           chmod 0775 \
   374               $RPM_INSTALL_PREFIX/lib/chiliproj/db \
   375               $RPM_INSTALL_PREFIX/lib/chiliproj/db/migrate
   376         ) || exit $?
   377         echo 'ChiliProject postinstallation finished.'
   378     fi
   379     #   after upgrade, restart service
   380     [ $1 -eq 2 ] || exit 0
   381     RUBY_VERSION=`%{l_prefix}/bin/gem which rubygems | sed -e 's;.*/\([^/]*\)/rubygems\.rb$;\1;'`
   382     ( cd $RPM_INSTALL_PREFIX/lib/chiliproj
   383       ##   migrate existing database
   384       #echo 'Migrating ChiliProject existing database...'
   385       #VERBOSE=false RAILS_ENV=production \
   386       #    $RPM_INSTALL_PREFIX/lib/ruby/gems/$RUBY_VERSION/bin/bundle \
   387       #    exec rake db:migrate
   388     ) || exit $?
   389     eval `%{l_rc} chiliproj status 2>/dev/null`
   390     [ ".$chiliproj_active" = .yes ] && %{l_rc} chiliproj restart
   391     exit 0
   393 %preun
   394     #   before erase, stop service and remove log files
   395     [ $1 -eq 0 ] || exit 0
   396     %{l_rc} chiliproj stop 2>/dev/null
   397     rm -rf $RPM_INSTALL_PREFIX/lib/chiliproj/db 2>/dev/null || true
   398     rm -rf $RPM_INSTALL_PREFIX/lib/chiliproj/public 2>/dev/null || true
   399     rm -rf $RPM_INSTALL_PREFIX/lib/chiliproj/config/initializers 2>/dev/null || true
   400     rm -rf $RPM_INSTALL_PREFIX/lib/chiliproj/log 2>/dev/null || true
   401     rm -f $RPM_INSTALL_PREFIX/var/chiliproj/*.log 2>/dev/null || true
   402     rm -f $RPM_INSTALL_PREFIX/var/chiliproj/*.pid 2>/dev/null || true
   403     exit 0

mercurial