gogs.spec 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. ##
  2. ## gogs.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2015 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.6.1
  25. %define V_gogs_snap 20150406
  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}
  37. Release: 20150406
  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: app.ini
  42. # build information
  43. BuildPreReq: OpenPKG, openpkg >= 20140101, go
  44. PreReq: OpenPKG, openpkg >= 20140101
  45. PreReq: git
  46. %description
  47. Gogs is a hosting service for the Git version control system.
  48. %track
  49. prog gogs = {
  50. version = %{V_gogs_snap}
  51. url = https://github.com/gogits/gogs/releases
  52. regex = v(__VER__)\.tar\.gz
  53. }
  54. %prep
  55. %setup -q -n gogs
  56. %build
  57. # build program
  58. ( export GOPATH=`pwd`
  59. cd $GOPATH/src/github.com/gogits/gogs
  60. go build -tags "sqlite" -x -o gogs
  61. ) || exit $?
  62. # remove spaces from filenames
  63. ( cd src/github.com/gogits/gogs/conf/license
  64. mv "Mozilla Public License Version 2.0" MPL-2.0
  65. mv "CC0 1.0 Universal" CC0-1.0
  66. mv "MIT License" MIT
  67. mv "BSD license" BSD
  68. mv "GPL v2" GPL-2.0
  69. mv "Eclipse Public License v1.0" EPL-1.0
  70. mv "Affero GPL" AGPL-3.0
  71. mv "LGPL v2.1" LGPL-2.1
  72. mv "Apache v2 License" Apache-2.0
  73. mv "LGPL v3" LGPL-3.0
  74. mv "BSD (3-Clause) License" BSD-3C
  75. mv "ISC license" ISC
  76. mv "Artistic License 2.0" Artistic-2.0
  77. mv "GPL v3" GPL-3.0
  78. ) || exit $?
  79. ( cd src/github.com/gogits/gogs/conf/gitignore
  80. mv "C Sharp" "C-Sharp"
  81. mv "Google Go" "Google-Go"
  82. ) || exit $?
  83. %install
  84. # create directory hierarchy
  85. %{l_shtool} mkdir -f -p -m 755 \
  86. $RPM_BUILD_ROOT%{l_prefix}/bin \
  87. $RPM_BUILD_ROOT%{l_prefix}/sbin \
  88. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  89. $RPM_BUILD_ROOT%{l_prefix}/etc/gogs \
  90. $RPM_BUILD_ROOT%{l_prefix}/share/gogs/custom/conf \
  91. $RPM_BUILD_ROOT%{l_prefix}/var/gogs/run \
  92. $RPM_BUILD_ROOT%{l_prefix}/var/gogs/log \
  93. $RPM_BUILD_ROOT%{l_prefix}/var/gogs/tmp \
  94. $RPM_BUILD_ROOT%{l_prefix}/var/gogs/db \
  95. $RPM_BUILD_ROOT%{l_prefix}/var/gogs/data \
  96. $RPM_BUILD_ROOT%{l_prefix}/var/gogs/repo
  97. # install program
  98. %{l_shtool} install -c -s -m 755 \
  99. src/github.com/gogits/gogs/gogs \
  100. $RPM_BUILD_ROOT%{l_prefix}/sbin/
  101. # install run-time files
  102. ( cd src/github.com/gogits/gogs
  103. cp -r conf public templates \
  104. $RPM_BUILD_ROOT%{l_prefix}/share/gogs/
  105. ) || exit $?
  106. # install default configuration
  107. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  108. %{SOURCE app.ini} \
  109. $RPM_BUILD_ROOT%{l_prefix}/etc/gogs/
  110. # provide links to final location
  111. ln -s ../../../../etc/gogs/app.ini \
  112. $RPM_BUILD_ROOT%{l_prefix}/share/gogs/custom/conf/app.ini
  113. ln -s ../../var/gogs/data \
  114. $RPM_BUILD_ROOT%{l_prefix}/share/gogs/data
  115. ln -s ../../sbin/gogs \
  116. $RPM_BUILD_ROOT%{l_prefix}/share/gogs/gogs
  117. # install run-command script
  118. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  119. %{SOURCE rc.gogs} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  120. # determine installation files
  121. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  122. %{l_files_std} \
  123. '%config %attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/etc/gogs/*' \
  124. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/gogs/*' \
  125. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/gogs/*/*'
  126. %files -f files
  127. %clean
  128. %post
  129. # after upgrade, restart service
  130. if [ $1 -eq 1 ]; then
  131. # display information about next steps
  132. ( echo "After starting Gogs with"
  133. echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg rc gogs start"
  134. echo "you should configure it by visiting:"
  135. echo " http://localhost:3000/"
  136. ) | %{l_rpmtool} msg -b -t notice
  137. elif [ $1 -eq 2 ]; then
  138. eval `%{l_rc} gogs status 2>/dev/null`
  139. [ ".$gogs_active" = .yes ] && %{l_rc} gogs restart
  140. fi
  141. exit 0
  142. %preun
  143. # before erase, stop service and remove log files
  144. [ $1 -eq 0 ] || exit 0
  145. %{l_rc} gogs stop 2>/dev/null
  146. rm -rf $RPM_INSTALL_PREFIX/var/gogs/log/* >/dev/null 2>&1 || true
  147. rm -rf $RPM_INSTALL_PREFIX/var/gogs/run/* >/dev/null 2>&1 || true
  148. rm -rf $RPM_INSTALL_PREFIX/var/gogs/tmp/* >/dev/null 2>&1 || true
  149. rm -rf $RPM_INSTALL_PREFIX/var/gogs/db/* >/dev/null 2>&1 || true
  150. rm -rf $RPM_INSTALL_PREFIX/var/gogs/repo/* >/dev/null 2>&1 || true
  151. rm -rf $RPM_INSTALL_PREFIX/var/gogs/data/* >/dev/null 2>&1 || true
  152. exit 0