zammad.spec 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. Name: zammad
  2. Version: 0.1
  3. Release: 1%{?dist}
  4. Summary: Zammad Application
  5. # Some of the gems compile, and thus this can't be noarch
  6. BuildArch: x86_64
  7. Group: Application/Internet
  8. License: AGPL
  9. URL: https://github.com/martinie/zammmad
  10. # XXX You'll have to create the logrotate script for your application
  11. Source0: %{name}.logrotate
  12. BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
  13. # XXX Building this rpm requires that bundle is available on the path of the user
  14. # that is running rpmbuild. But I'm not sure how to require that there is a
  15. # bundle in the path.
  16. #BuildRequires: /usr/bin/bundle
  17. # XXX Also require gem on the PATH
  18. # BuildRequires: /usr/bin/gem
  19. # XXX Note that you might not require all the below. It will depend on what your gems require to build.
  20. # From docs: http://nokogiri.org/tutorials/installing_nokogiri.html
  21. # and: https://github.com/thoughtbot/capybara-webkit/wiki/Installing-QT
  22. # which hinted that I should look for something like qt webkit devel ...
  23. BuildRequires: libxml2 gcc ruby-devel libxml2-devel libxslt libxslt-devel
  24. # for...I forgot to record what gem requires this to build...
  25. BuildRequires: qt-devel qtwebkit-devel
  26. # for curb
  27. BuildRequires: libcurl-devel
  28. # for sqlite3
  29. BuildRequires: sqlite-devel
  30. # ^^ There may be more requirements above for building on a new dev/rpmbuild env
  31. # XXX Remove if not using apache/passenger/mysql
  32. # Assuming will run via passenger + apache
  33. Requires: mod_passenger, httpd
  34. # And use mysql as the db
  35. Requires: mysql-server
  36. # In order to rotate the logs
  37. Requires: logrotate
  38. # What repository to pull the actual code from
  39. # (assuming git here, you'll need to change for svn or hg)
  40. %define git_repo git@github.com:martini/%{name}.git
  41. #
  42. # DIRS
  43. # - Trying to follow Linux file system hierarchy
  44. #
  45. %define appdir %{rails_home}/%{name}
  46. %define docdir %{_docdir}/railsapps/%{name}
  47. %define libdir %{_libdir}/railsapps/%{name}
  48. %define logdir /var/log/railsapps/%{name}
  49. %define configdir /etc/railsapps/%{name}
  50. %define cachedir /var/cache/railsapps/%{name}
  51. %define datadir /var/lib/railsapps/%{name}
  52. %define logrotatedir /etc/logrotate.d/
  53. %description
  54. Some description of the application
  55. %prep
  56. rm -rf ./%{name}
  57. git clone %{git_repo}
  58. pushd %{name}
  59. git checkout v%{version}
  60. popd
  61. %build
  62. pushd %{name}
  63. # Install all required gems into ./vendor/bundle using the handy bundle commmand
  64. bundle install --deployment
  65. # Compile assets, this only has to be done once AFAIK, so in the RPM is fine
  66. rm -rf ./public/assets/*
  67. bundle exec rake assets:precompile
  68. # For some reason bundler doesn't install itself, this is probably right,
  69. # but I guess it expects bundler to be on the server being deployed to
  70. # already. But the rails-helloworld app crashes on passenger looking for
  71. # bundler, so it would seem to me to be required. So, I used gem to install
  72. # bundler after bundle deployment. :) And the app then works under passenger.
  73. PWD=`pwd`
  74. cat > gemrc <<EOGEMRC
  75. gemhome: $PWD/vendor/bundle/ruby/1.8
  76. gempath:
  77. - $PWD/vendor/bundle/ruby/1.8
  78. EOGEMRC
  79. #gem --source %{gem_source} --config-file ./gemrc install bundler
  80. gem --config-file ./gemrc install bundler
  81. # Don't need the gemrc any more...
  82. rm ./gemrc
  83. # Some of the files in here have /usr/local/bin/ruby set as the bang
  84. # but that won't work, and makes the rpmbuild process add /usr/local/bin/ruby
  85. # to the dependencies. So I'm changing that here. Either way it prob won't
  86. # work. But at least this rids us of the dependencie that we can never meet.
  87. for f in `grep -ril "\/usr\/local\/bin\/ruby" ./vendor`; do
  88. sed -i "s|/usr/local/bin/ruby|/usr/bin/ruby|g" $f
  89. head -1 $f
  90. done
  91. popd
  92. %install
  93. # Create all the defined directories
  94. rm -rf $RPM_BUILD_ROOT
  95. mkdir -p $RPM_BUILD_ROOT/%{appdir}
  96. mkdir -p $RPM_BUILD_ROOT/%{docdir}
  97. mkdir -p $RPM_BUILD_ROOT/%{libdir}
  98. mkdir -p $RPM_BUILD_ROOT/%{logdir}
  99. mkdir -p $RPM_BUILD_ROOT/%{configdir}
  100. mkdir -p $RPM_BUILD_ROOT/%{cachedir}
  101. mkdir -p $RPM_BUILD_ROOT/%{datadir}
  102. mkdir -p $RPM_BUILD_ROOT/%{logrotatedir}
  103. # Start moving files into the proper place in the build root
  104. pushd %{name}
  105. #
  106. # ./public/assets
  107. #
  108. # Again rake assets:precompile creates public/assets which
  109. # shouldn't be in /usr/share/railsapps/%{name} prob cache
  110. #rm -rf ./public/assets/*
  111. mv ./public/assets $RPM_BUILD_ROOT/%{cachedir}
  112. ln -s %{cachedir}/assets ./public/assets
  113. #
  114. # Doc
  115. #
  116. mv ./doc $RPM_BUILD_ROOT/%{docdir}
  117. #
  118. # Config
  119. #
  120. # - only doing database.yml now, might be wrong...
  121. # - XXX What other config files are there if any?
  122. mv ./config/database.yml $RPM_BUILD_ROOT/%{configdir}
  123. pushd config
  124. ln -s %{configdir}/database.yml ./database.yml
  125. popd
  126. #
  127. # lib
  128. #
  129. mv ./vendor $RPM_BUILD_ROOT/%{libdir}
  130. ln -s %{libdir}/vendor ./vendor
  131. #
  132. # tmp/cache
  133. #
  134. mv ./tmp $RPM_BUILD_ROOT/%{cachedir}
  135. ln -s %{cachedir}/tmp ./tmp
  136. #
  137. # log
  138. #
  139. # Only do logdir not logdir/log
  140. rm -rf ./log
  141. #rm ./log/development.log
  142. #rm ./log/test.log
  143. #mv ./log $RPM_BUILD_ROOT/%{logdir}
  144. ln -s %{logdir} ./log
  145. #
  146. # Everything left goes in appdir
  147. #
  148. mv ./* $RPM_BUILD_ROOT/%{appdir}
  149. #
  150. # logrotate
  151. #
  152. cp %{SOURCE0} $RPM_BUILD_ROOT/%{logrotatedir}/%{name}
  153. popd
  154. %clean
  155. rm -rf $RPM_BUILD_ROOT
  156. %files
  157. %defattr(-,root,root,-)
  158. %{appdir}
  159. %{libdir}
  160. %{docdir}
  161. %config %{configdir}/database.yml
  162. # passenger runs as nobody apparently and then http as apache, and I'm not sure which
  163. # needs which...so for now do nobody:apache...wonder if it should be set to run as apache?
  164. %attr(770,nobody,apache) %{logdir}
  165. %attr(770,nobody,apache) %{cachedir}
  166. # %dir allows an empty directory, which this will be at an initial install
  167. %attr(770,nobody,apache) %dir %{datadir}
  168. %{logrotatedir}/%{name}
  169. %doc