gogs.spec 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. ##
  2. ## gogs.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2017 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 information
  24. %define V_gogs_base 0.11.31
  25. %define V_gogs_snap 20171118
  26. # package information
  27. Name: gogs
  28. Summary: Git Hosting Service
  29. URL: http://gogs.io/
  30. Vendor: GoGits
  31. Packager: OpenPKG Foundation e.V.
  32. Distribution: OpenPKG Community
  33. Class: EVAL
  34. Group: Database
  35. License: MIT
  36. Version: %{V_gogs_base}.%{V_gogs_snap}
  37. Release: 20171118
  38. # list of sources
  39. Source0: http://download.openpkg.org/components/versioned/gogs/gogs-%{V_gogs_snap}.tar.xz
  40. Source1: rc.gogs
  41. Source2: gogs-serv.c
  42. Source3: gogs-update.sh
  43. Source4: app.ini
  44. Patch0: gogs.patch
  45. # build information
  46. BuildPreReq: OpenPKG, openpkg >= 20160101, go
  47. PreReq: OpenPKG, openpkg >= 20160101
  48. PreReq: git
  49. %description
  50. Gogs is a hosting service for the Git version control system.
  51. %track
  52. prog gogs = {
  53. version = %{V_gogs_base}
  54. url = https://github.com/gogits/gogs/releases
  55. regex = v(__VER__)\.tar\.gz
  56. }
  57. %prep
  58. %setup -q -n gogs
  59. %patch -p0
  60. %build
  61. # patch sources
  62. %{l_shtool} subst %{l_value -s -a} \
  63. src/github.com/gogits/gogs/models/ssh_key.go
  64. # build program
  65. ( export GOPATH=`pwd`
  66. cd $GOPATH/src/github.com/gogits/gogs
  67. go build -tags "sqlite" -x -o gogs
  68. ) || exit $?
  69. # build the setuid wrapper
  70. cp %{SOURCE gogs-serv.c} .
  71. %{l_shtool} subst %{l_value -s -a} gogs-serv.c
  72. %{l_cc} %{l_cflags} %{l_ldflags} -o gogs-serv gogs-serv.c
  73. # remove spaces from filenames
  74. ( cd src/github.com/gogits/gogs/conf/license
  75. mv "Affero General Public License v1.0" AGPL-1.0
  76. mv "Apache License 1.0" Apache-1.0
  77. mv "Apache License 1.1" Apache-1.1
  78. mv "Apache License 2.0" Apache-2.0
  79. mv "Artistic License 1.0" Artistic-1.0
  80. mv "Artistic License 2.0" Artistic-2.0
  81. mv "BSD 2-clause License" BSD-2C
  82. mv "BSD 3-clause License" BSD-3C
  83. mv "BSD 4-clause License" BSD-4C
  84. mv "BSD license" BSD
  85. mv "Creative Commons CC0 1.0 Universal" CC0-1.0
  86. mv "Eclipse Public License 1.0" EPL-1.0
  87. mv "GNU Affero General Public License v3.0" AGPL-3.0
  88. mv "GNU Free Documentation License v1.1" FDL-1.1
  89. mv "GNU Free Documentation License v1.2" FDL-1.2
  90. mv "GNU Free Documentation License v1.3" FDL-1.3
  91. mv "GNU General Public License v1.0" GPL-1.0
  92. mv "GNU General Public License v2.0" GPL-2.0
  93. mv "GNU General Public License v3.0" GPL-3.0
  94. mv "GNU Lesser General Public License v2.1" LGPL-2.1
  95. mv "GNU Lesser General Public License v3.0" LGPL-3.0
  96. mv "GNU Library General Public License v2.0" LGPL-2.0
  97. mv "ISC license" ISC
  98. mv "MIT License" MIT
  99. mv "Mozilla Public License 1.0" MPL-1.0
  100. mv "Mozilla Public License 1.1" MPL-1.1
  101. mv "Mozilla Public License 2.0" MPL-2.0
  102. rm -f "Abstyles License"
  103. rm -f "Academic Free License v1.1"
  104. rm -f "Academic Free License v1.2"
  105. rm -f "Academic Free License v2.0"
  106. rm -f "Academic Free License v2.1"
  107. rm -f "Academic Free License v3.0"
  108. rm -f "Creative Commons Zero v1.0 Universal"
  109. rm -f "Educational Community License v1.0"
  110. rm -f "Educational Community License v2.0"
  111. ) || exit $?
  112. ( cd src/github.com/gogits/gogs/conf/gitignore
  113. rm -f Clojure.gitignore
  114. rm -f Fortran.gitignore
  115. mv "C Sharp" "C-Sharp.gitignore"
  116. ) || exit $?
  117. %install
  118. # create directory hierarchy
  119. %{l_shtool} mkdir -f -p -m 755 \
  120. $RPM_BUILD_ROOT%{l_prefix}/bin \
  121. $RPM_BUILD_ROOT%{l_prefix}/sbin \
  122. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  123. $RPM_BUILD_ROOT%{l_prefix}/etc/gogs \
  124. $RPM_BUILD_ROOT%{l_prefix}/share/gogs \
  125. $RPM_BUILD_ROOT%{l_prefix}/var/gogs/run \
  126. $RPM_BUILD_ROOT%{l_prefix}/var/gogs/log \
  127. $RPM_BUILD_ROOT%{l_prefix}/var/gogs/home \
  128. $RPM_BUILD_ROOT%{l_prefix}/var/gogs/db \
  129. $RPM_BUILD_ROOT%{l_prefix}/var/gogs/data \
  130. $RPM_BUILD_ROOT%{l_prefix}/var/gogs/repo
  131. # install program
  132. %{l_shtool} install -c -s -m 755 \
  133. src/github.com/gogits/gogs/gogs \
  134. $RPM_BUILD_ROOT%{l_prefix}/sbin/
  135. # install setuid wrapper script
  136. %{l_shtool} install -c -s -m 755 \
  137. gogs-serv $RPM_BUILD_ROOT%{l_prefix}/sbin/
  138. # install run-time files
  139. ( cd src/github.com/gogits/gogs
  140. cp -r conf public templates \
  141. $RPM_BUILD_ROOT%{l_prefix}/share/gogs/
  142. ) || exit $?
  143. # install default configuration
  144. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  145. %{SOURCE app.ini} \
  146. $RPM_BUILD_ROOT%{l_prefix}/etc/gogs/
  147. # provide links to final location
  148. rm -f $RPM_BUILD_ROOT%{l_prefix}/share/gogs/conf/app.ini
  149. ln -s ../../../etc/gogs/app.ini \
  150. $RPM_BUILD_ROOT%{l_prefix}/share/gogs/conf/app.ini
  151. ln -s ../../var/gogs/data \
  152. $RPM_BUILD_ROOT%{l_prefix}/share/gogs/data
  153. ln -s ../../sbin/gogs \
  154. $RPM_BUILD_ROOT%{l_prefix}/share/gogs/gogs
  155. # install "gogs update" wrapper
  156. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  157. %{SOURCE gogs-update.sh} $RPM_BUILD_ROOT%{l_prefix}/sbin/gogs-update
  158. # install run-command script
  159. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  160. %{SOURCE rc.gogs} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  161. # determine installation files
  162. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  163. %{l_files_std} \
  164. '%dir %attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/etc/gogs' \
  165. '%config %attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/etc/gogs/*' \
  166. '%attr(4755,%{l_rusr},%{l_rgrp}) %{l_prefix}/sbin/gogs-serv' \
  167. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/gogs/*' \
  168. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/gogs/*/*'
  169. %files -f files
  170. %clean
  171. %post
  172. # after upgrade, restart service
  173. if [ $1 -eq 1 ]; then
  174. # display information about next steps
  175. ( echo "After starting Gogs with"
  176. echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg rc gogs start"
  177. echo "you should configure it by visiting:"
  178. echo " http://localhost:3000/"
  179. ) | %{l_rpmtool} msg -b -t notice
  180. elif [ $1 -eq 2 ]; then
  181. eval `%{l_rc} gogs status 2>/dev/null`
  182. [ ".$gogs_active" = .yes ] && %{l_rc} gogs restart
  183. fi
  184. exit 0
  185. %preun
  186. # before erase, stop service and remove log files
  187. [ $1 -eq 0 ] || exit 0
  188. %{l_rc} gogs stop 2>/dev/null
  189. rm -rf $RPM_INSTALL_PREFIX/var/gogs/log/* >/dev/null 2>&1 || true
  190. rm -rf $RPM_INSTALL_PREFIX/var/gogs/run/* >/dev/null 2>&1 || true
  191. rm -rf $RPM_INSTALL_PREFIX/var/gogs/home/* >/dev/null 2>&1 || true
  192. rm -rf $RPM_INSTALL_PREFIX/var/gogs/db/* >/dev/null 2>&1 || true
  193. rm -rf $RPM_INSTALL_PREFIX/var/gogs/repo/* >/dev/null 2>&1 || true
  194. rm -rf $RPM_INSTALL_PREFIX/var/gogs/data/* >/dev/null 2>&1 || true
  195. exit 0