limesurvey.spec 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. ##
  2. ## limesurvey.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2008 OpenPKG Foundation e.V. <http://openpkg.net/>
  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. ##
  23. # package version
  24. %define V_dist 171plus_build5326_20080715
  25. %define V_opkg 1.71
  26. # package information
  27. Name: limesurvey
  28. Summary: Survey System
  29. URL: http://www.limesurvey.org/
  30. Vendor: LimeSurvey Project Team
  31. Packager: OpenPKG Foundation e.V.
  32. Distribution: OpenPKG Community
  33. Class: EVAL
  34. Group: Web
  35. License: GPL
  36. Version: %{V_opkg}
  37. Release: 20080722
  38. # package options
  39. %option with_pgsql yes
  40. %option with_mysql no
  41. # checking for option conflicts
  42. %if "%{with_mysql}" == "no" && "%{with_pgsql}" == "no"
  43. %{error:one of the build-time options 'with_mysql' or 'with_pgsql' have to be enabled}
  44. %endif
  45. %if "%{with_mysql}" == "yes" && "%{with_pgsql}" == "yes"
  46. %{error:only one of the build-time options 'with_mysql' or 'with_pgsql' can be enabled at a time}
  47. %endif
  48. # list of sources
  49. Source0: http://switch.dl.sourceforge.net/limesurvey/limesurvey%{V_dist}.tar.gz
  50. Source1: limesurvey-apache.conf
  51. Source2: limesurvey-setup.sh
  52. Source3: rc.limesurvey
  53. # build information
  54. Prefix: %{l_prefix}
  55. BuildRoot: %{l_buildroot}
  56. BuildPreReq: OpenPKG, openpkg >= 20060823
  57. PreReq: OpenPKG, openpkg >= 20060823
  58. PreReq: apache
  59. PreReq: apache-php
  60. %if "%{with_mysql}" == "yes"
  61. PreReq: apache-php::with_mysql = yes
  62. %endif
  63. %if "%{with_pgsql}" == "yes"
  64. PreReq: apache-php::with_pgsql = yes
  65. %endif
  66. PreReq: apache-php::with_pcre = yes
  67. PreReq: apache-php::with_session = yes
  68. PreReq: apache-php::with_mbstring = yes
  69. PreReq: apache-php::with_iconv = yes
  70. PreReq: apache-php::with_gd = yes
  71. AutoReq: no
  72. AutoReqProv: no
  73. %description
  74. LimeSurvey is a Web application to create online surveys. It
  75. features open/closed surveys, branching, participant administration,
  76. quotas, WYSIWYG HTML editor, email invitations & reminders,
  77. assessments, basic statistics and more.
  78. %track
  79. prog limesurvey = {
  80. version = %{version}
  81. url = http://prdownloads.sourceforge.net/limesurvey/
  82. regex = limesurvey(.+?)\.tar\.gz
  83. }
  84. %prep
  85. %setup -q -n limesurvey
  86. chmod -R u+w .
  87. %build
  88. %install
  89. # create installation hierarchy
  90. rm -rf $RPM_BUILD_ROOT
  91. %{l_shtool} mkdir -f -p -m 755 \
  92. $RPM_BUILD_ROOT%{l_prefix}/sbin \
  93. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  94. $RPM_BUILD_ROOT%{l_prefix}/etc/limesurvey \
  95. $RPM_BUILD_ROOT%{l_prefix}/libexec/limesurvey \
  96. $RPM_BUILD_ROOT%{l_prefix}/var/limesurvey/run \
  97. $RPM_BUILD_ROOT%{l_prefix}/var/limesurvey/log \
  98. $RPM_BUILD_ROOT%{l_prefix}/var/limesurvey/db
  99. # install base system
  100. cp -rp * $RPM_BUILD_ROOT%{l_prefix}/libexec/limesurvey/
  101. # adjust default configuration
  102. %if "%{with_mysql}" == "yes"
  103. l_dbtype="mysql"
  104. %endif
  105. %if "%{with_pgsql}" == "yes"
  106. l_dbtype="postgres"
  107. %endif
  108. %{l_shtool} subst \
  109. -e "s;\\(databasetype[^']*'\\)[^']*\\('\\);\\1${l_dbtype}\\2;" \
  110. -e "s;\\(databasename[^']*'\\)[^']*\\('\\);\\1limesurvey\\2;" \
  111. -e "s;\\(databaseuser[^']*'\\)[^']*\\('\\);\\1limesurvey\\2;" \
  112. -e "s;\\(databasepass[^']*'\\)[^']*\\('\\);\\1limesurvey\\2;" \
  113. $RPM_BUILD_ROOT%{l_prefix}/libexec/limesurvey/config.php
  114. # install run-command script
  115. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  116. %{SOURCE rc.limesurvey} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  117. # install database setup script
  118. %if "%{with_mysql}" == "yes"
  119. l_dbtype="mysql"
  120. %endif
  121. %if "%{with_pgsql}" == "yes"
  122. l_dbtype="pgsql"
  123. %endif
  124. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  125. -e "s;@l_dbtype@;$l_dbtype;g" \
  126. -e "s;@l_bash@;%{l_bash};g" \
  127. %{SOURCE limesurvey-setup.sh} $RPM_BUILD_ROOT%{l_prefix}/sbin/limesurvey-setup
  128. # install custom Apache configuration
  129. l_hostname=`%{l_shtool} echo -e %h`
  130. l_domainname=`%{l_shtool} echo -e %d | cut -c2-`
  131. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  132. -e "s;@l_hostname@;$l_hostname;g" \
  133. -e "s;@l_domainname@;$l_domainname;g" \
  134. %{SOURCE limesurvey-apache.conf} \
  135. $RPM_BUILD_ROOT%{l_prefix}/etc/limesurvey/
  136. # determine installation files
  137. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  138. %{l_files_std} \
  139. '%config %{l_prefix}/etc/limesurvey' \
  140. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/libexec/limesurvey' \
  141. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/limesurvey'
  142. %files -f files
  143. %clean
  144. rm -rf $RPM_BUILD_ROOT
  145. %post
  146. if [ $1 -eq 1 ]; then
  147. # display final hints on initial installation
  148. ( echo "1. To complete this installation of LimeSurvey please start"
  149. echo " the RDBMS and initialize the LimeSurvey database like this:"
  150. %if "%{with_mysql}" == "yes"
  151. echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg rc mysql start"
  152. %endif
  153. %if "%{with_pgsql}" == "yes"
  154. echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg rc postgresql start"
  155. %endif
  156. echo " \$ $RPM_INSTALL_PREFIX/sbin/limesurvey-setup install"
  157. echo ""
  158. echo "2. Now start LimeSurvey by running the command"
  159. echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg rc limesurvey start"
  160. echo " and connect with a browser to the URL:"
  161. echo " http://127.0.0.1:8084/limesurvey/admin/install/"
  162. echo ""
  163. echo "3. cleanup after installation to enable run-time:"
  164. echo " \$ rm -f $RPM_INSTALL_PREFIX/libexec/limesurvey/admin/install"
  165. echo ""
  166. echo "4. By default, LimeSurvey runs its own Apache server on IPv4 address"
  167. echo " 127.0.0.1, TCP port 8084. Please change this by editing the"
  168. echo " \"Listen 127.0.0.1:8084\" directive in"
  169. echo " $RPM_INSTALL_PREFIX/etc/limesurvey/limesurvey-apache.conf"
  170. echo ""
  171. echo "5. Access LimeSurvey via:"
  172. echo " http://127.0.0.1:8080/limesurvey/"
  173. ) | %{l_rpmtool} msg -b -t notice
  174. fi
  175. if [ $1 -eq 2 ]; then
  176. # after upgrade, restart service
  177. eval `%{l_rc} limesurvey status 2>/dev/null`
  178. [ ".$limesurvey_active" = .yes ] && %{l_rc} limesurvey restart
  179. fi
  180. exit 0
  181. %preun
  182. if [ $1 -eq 0 ]; then
  183. # before erase, stop service and remove log files
  184. %{l_rc} limesurvey stop 2>/dev/null
  185. rm -f $RPM_INSTALL_PREFIX/var/limesurvey/log/* >/dev/null 2>&1 || true
  186. rm -f $RPM_INSTALL_PREFIX/var/limesurvey/run/* >/dev/null 2>&1 || true
  187. rm -f $RPM_INSTALL_PREFIX/var/limesurvey/db/* >/dev/null 2>&1 || true
  188. fi
  189. exit 0