syncthing.spec 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. ##
  2. ## syncthing.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2016 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_syncthing_base 0.14.10
  25. %define V_syncthing_snap 20161106
  26. # package information
  27. Name: syncthing
  28. Summary: Folder Synchronization Service
  29. URL: https://syncthing.net/
  30. Vendor: The Syncthing Authors
  31. Packager: OpenPKG Foundation e.V.
  32. Distribution: OpenPKG Community
  33. Class: EVAL
  34. Group: Filesystem
  35. License: MPL
  36. Version: %{V_syncthing_base}
  37. Release: 20161106
  38. # list of sources
  39. Source0: http://download.openpkg.org/components/versioned/syncthing/syncthing-%{V_syncthing_snap}.tar.xz
  40. Source1: rc.syncthing
  41. Patch0: syncthing.patch
  42. # build information
  43. BuildPreReq: OpenPKG, openpkg >= 20160101, go
  44. PreReq: OpenPKG, openpkg >= 20160101
  45. %description
  46. Syncthing pursues the following goals: Define a protocol for
  47. synchronization of a folder between a number of collaborating
  48. devices. This protocol should be well defined, unambiguous, easily
  49. understood, free to use, efficient, secure and language neutral.
  50. This is called the Block Exchange Protocol. Provide the reference
  51. implementation to demonstrate the usability of said protocol. This
  52. is the syncthing(1) utility.
  53. %track
  54. prog syncthing = {
  55. version = %{V_syncthing_base}
  56. url = https://github.com/syncthing/syncthing/releases
  57. regex = v(\d+\.\d+\.\d+)\.tar\.gz
  58. }
  59. %prep
  60. %setup -q -n syncthing
  61. %patch -p0
  62. %build
  63. # build program
  64. ( export GOPATH=`pwd`
  65. cd $GOPATH/src/github.com/syncthing/syncthing
  66. %{l_bash} build.sh
  67. rm -f bin/testutil
  68. ) || exit $?
  69. %install
  70. # create directory hierarchy
  71. %{l_shtool} mkdir -f -p -m 755 \
  72. $RPM_BUILD_ROOT%{l_prefix}/bin \
  73. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  74. $RPM_BUILD_ROOT%{l_prefix}/etc/syncthing \
  75. $RPM_BUILD_ROOT%{l_prefix}/var/syncthing/run \
  76. $RPM_BUILD_ROOT%{l_prefix}/var/syncthing/log \
  77. $RPM_BUILD_ROOT%{l_prefix}/var/syncthing/data
  78. # install program
  79. %{l_shtool} install -c -s -m 755 \
  80. src/github.com/syncthing/syncthing/bin/syncthing \
  81. $RPM_BUILD_ROOT%{l_prefix}/bin/
  82. # install run-command script
  83. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  84. %{SOURCE rc.syncthing} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  85. # determine installation files
  86. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  87. %{l_files_std} \
  88. '%config %{l_prefix}/etc/syncthing/*' \
  89. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/syncthing/*'
  90. %files -f files
  91. %clean
  92. %post
  93. if [ $1 -eq 2 ]; then
  94. # after upgrade, restart service
  95. eval `%{l_rc} syncthing status 2>/dev/null`
  96. [ ".$syncthing_active" = .yes ] && %{l_rc} syncthing restart
  97. fi
  98. exit 0
  99. %preun
  100. if [ $1 -eq 0 ]; then
  101. # before erase, stop service and remove log files
  102. %{l_rc} syncthing stop 2>/dev/null
  103. rm -rf $RPM_INSTALL_PREFIX/var/syncthing/log/* >/dev/null 2>&1 || true
  104. rm -rf $RPM_INSTALL_PREFIX/var/syncthing/run/* >/dev/null 2>&1 || true
  105. rm -rf $RPM_INSTALL_PREFIX/var/syncthing/data/* >/dev/null 2>&1 || true
  106. fi
  107. exit 0