gotty.spec 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. ##
  2. ## gotty.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 version
  24. %define V_gotty_base 1.0.1
  25. %define V_gotty_snap 20171115
  26. # package information
  27. Name: gotty
  28. Summary: Web Terminal Sharing
  29. URL: https://github.com/yudai/gotty
  30. Vendor: Iwasaki Yudai
  31. Packager: OpenPKG Foundation e.V.
  32. Distribution: OpenPKG Community
  33. Class: EVAL
  34. Group: Web
  35. License: MIT
  36. Version: %{V_gotty_base}
  37. Release: 20171115
  38. # list of sources
  39. Source0: http://download.openpkg.org/components/versioned/gotty/gotty-%{V_gotty_snap}.tar.xz
  40. Source1: rc.gotty
  41. # build information
  42. BuildPreReq: OpenPKG, openpkg >= 20160101, go
  43. PreReq: OpenPKG, openpkg >= 20160101
  44. %description
  45. GoTTY is a simple command line tool that turns any CLI tool into a
  46. web application.
  47. %track
  48. prog gotty:release = {
  49. version = %{V_gotty_base}
  50. url = https://github.com/yudai/gotty/releases
  51. regex = v(__VER__)\.tar\.gz
  52. }
  53. prog gotty:snapshot = {
  54. version = %{V_gotty_snap}
  55. url = http://download.openpkg.org/components/versioned/gotty/
  56. regex = gotty-(__VER__)\.tar\.xz
  57. }
  58. %prep
  59. %setup -q -n gotty
  60. %build
  61. # build program
  62. export GOPATH=`pwd`
  63. cd src/github.com/yudai/gotty
  64. go build -x .
  65. %install
  66. # create directory hierarchy
  67. %{l_shtool} mkdir -f -p -m 755 \
  68. $RPM_BUILD_ROOT%{l_prefix}/bin \
  69. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  70. $RPM_BUILD_ROOT%{l_prefix}/var/gotty/log \
  71. $RPM_BUILD_ROOT%{l_prefix}/var/gotty/run
  72. # install program
  73. %{l_shtool} install -c -s -m 755 \
  74. src/github.com/yudai/gotty/gotty \
  75. $RPM_BUILD_ROOT%{l_prefix}/bin/gotty
  76. # install run-command script
  77. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  78. %{SOURCE rc.gotty} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  79. # determine installation files
  80. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  81. %{l_files_std} \
  82. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/gotty/*'
  83. %files -f files
  84. %clean
  85. %post
  86. if [ $1 -eq 1 ]; then
  87. :
  88. elif [ $1 -eq 2 ]; then
  89. # after upgrade, restart service
  90. eval `%{l_rc} gotty status 2>/dev/null`
  91. [ ".$gotty_active" = .yes ] && %{l_rc} gotty restart
  92. fi
  93. exit 0
  94. %preun
  95. # before erase, stop service and remove log files
  96. if [ $1 -eq 0 ]; then
  97. %{l_rc} gotty stop 2>/dev/null
  98. rm -f $RPM_INSTALL_PREFIX/var/gotty/log/* >/dev/null 2>&1 || true
  99. rm -f $RPM_INSTALL_PREFIX/var/gotty/run/* >/dev/null 2>&1 || true
  100. fi
  101. exit 0