syncthing-0.14.23.ebuild 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=6
  4. EGO_PN="github.com/${PN}/${PN}"
  5. inherit golang-vcs-snapshot systemd user versionator
  6. DESCRIPTION="Open Source Continuous File Synchronization"
  7. HOMEPAGE="https://syncthing.net"
  8. SRC_URI="https://${EGO_PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
  9. LICENSE="MPL-2.0"
  10. SLOT="0"
  11. KEYWORDS="~amd64 ~x86 ~arm"
  12. IUSE="tools"
  13. DOCS=(README.md AUTHORS CONTRIBUTING.md)
  14. pkg_setup() {
  15. enewgroup ${PN}
  16. enewuser ${PN} -1 -1 /var/lib/${PN} ${PN}
  17. if use tools ; then
  18. # separate user for the relay server
  19. enewgroup strelaysrv
  20. enewuser strelaysrv -1 -1 /var/lib/strelaysrv strelaysrv
  21. # and his home folder
  22. keepdir /var/lib/strelaysrv
  23. fowners strelaysrv:strelaysrv /var/lib/strelaysrv
  24. fi
  25. }
  26. src_prepare() {
  27. default
  28. sed -i \
  29. 's|^ExecStart=.*|ExecStart=/usr/libexec/syncthing/strelaysrv|' \
  30. src/${EGO_PN}/cmd/strelaysrv/etc/linux-systemd/strelaysrv.service \
  31. || die
  32. }
  33. src_compile() {
  34. export GOPATH="${S}:$(get_golibdir_gopath)"
  35. cd src/${EGO_PN} || die
  36. go run build.go -version "v${PV}" -no-upgrade install \
  37. $(usex tools "all" "") || die "build failed"
  38. }
  39. src_test() {
  40. cd src/${EGO_PN} || die
  41. go run build.go test || die "test failed"
  42. }
  43. src_install() {
  44. pushd src/${EGO_PN} >& /dev/null || die
  45. doman man/*.[157]
  46. einstalldocs
  47. dobin bin/syncthing
  48. if use tools ; then
  49. exeinto /usr/libexec/syncthing
  50. local exe
  51. for exe in bin/* ; do
  52. [[ "${exe}" == "bin/syncthing" ]] || doexe "${exe}"
  53. done
  54. fi
  55. popd >& /dev/null || die
  56. # openrc and systemd service files
  57. systemd_dounit src/${EGO_PN}/etc/linux-systemd/system/${PN}{@,-resume}.service
  58. systemd_douserunit src/${EGO_PN}/etc/linux-systemd/user/${PN}.service
  59. newconfd "${FILESDIR}/${PN}.confd" ${PN}
  60. newinitd "${FILESDIR}/${PN}.initd" ${PN}
  61. keepdir /var/{lib,log}/${PN}
  62. fowners ${PN}:${PN} /var/{lib,log}/${PN}
  63. insinto /etc/logrotate.d
  64. newins "${FILESDIR}/${PN}.logrotate" ${PN}
  65. if use tools ; then
  66. # openrc and systemd service files
  67. systemd_dounit src/${EGO_PN}/cmd/strelaysrv/etc/linux-systemd/strelaysrv.service
  68. newconfd "${FILESDIR}/strelaysrv.confd" strelaysrv
  69. newinitd "${FILESDIR}/strelaysrv.initd" strelaysrv
  70. insinto /etc/logrotate.d
  71. newins "${FILESDIR}/strelaysrv.logrotate" strelaysrv
  72. fi
  73. }
  74. pkg_postinst() {
  75. local v
  76. for v in ${REPLACING_VERSIONS}; do
  77. if [[ $(get_version_component_range 2) -gt \
  78. $(get_version_component_range 2 ${v}) ]]; then
  79. ewarn "Version ${PV} is not protocol-compatible with version" \
  80. "0.$(($(get_version_component_range 2) - 1)).x or lower."
  81. ewarn "Make sure all your devices are running at least version" \
  82. "0.$(get_version_component_range 2).0."
  83. fi
  84. done
  85. # check if user syncthing-relaysrv exists
  86. # if yes, warn that it has been moved to strelaysrv
  87. if [[ -n "$(egetent passwd syncthing-relaysrv 2>/dev/null)" ]]; then
  88. ewarn
  89. ewarn "The user and group for the relay server have been changed"
  90. ewarn "from syncthing-relaysrv to strelaysrv"
  91. ewarn "The old user and group are not deleted automatically. Delete them by running:"
  92. ewarn " userdel -r syncthing-relaysrv"
  93. ewarn " groupdel syncthing-relaysrv"
  94. fi
  95. }