serf-0.8.0.ebuild 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=6
  4. inherit systemd user
  5. KEYWORDS="~amd64"
  6. EGO_PN="github.com/hashicorp/serf"
  7. DESCRIPTION="Service orchestration and management tool"
  8. HOMEPAGE="https://www.serfdom.io/"
  9. SRC_URI="https://github.com/hashicorp/serf/archive/v${PV}.tar.gz -> ${P}.tar.gz
  10. https://github.com/mitchellh/gox/archive/c9740af9c6574448fd48eb30a71f964014c7a837.tar.gz -> gox-c9740af9c6574448fd48eb30a71f964014c7a837.tar.gz
  11. https://github.com/mitchellh/iochan/archive/87b45ffd0e9581375c491fef3d32130bb15c5bd7.tar.gz -> iochan-87b45ffd0e9581375c491fef3d32130bb15c5bd7.tar.gz
  12. "
  13. SLOT="0"
  14. LICENSE="MPL-2.0"
  15. IUSE=""
  16. RESTRICT="test"
  17. DEPEND="
  18. >=dev-lang/go-1.6:=
  19. >=dev-go/go-tools-0_pre20160121"
  20. RDEPEND=""
  21. pkg_setup() {
  22. enewgroup serf
  23. enewuser serf -1 -1 /var/lib/${PN} serf
  24. }
  25. get_archive_go_package() {
  26. local archive=${1} uri x
  27. for x in ${SRC_URI}; do
  28. if [[ ${x} == http* ]]; then
  29. uri=${x}
  30. elif [[ ${x} == ${archive} ]]; then
  31. break
  32. fi
  33. done
  34. uri=${uri#https://}
  35. echo ${uri%/archive/*}
  36. }
  37. unpack_go_packages() {
  38. local go_package x
  39. # Unpack packages to appropriate locations for GOPATH
  40. for x in ${A}; do
  41. unpack ${x}
  42. if [[ ${x} == *.tar.gz ]]; then
  43. go_package=$(get_archive_go_package ${x})
  44. mkdir -p src/${go_package%/*}
  45. mv ${go_package##*/}-* src/${go_package} || die
  46. fi
  47. done
  48. }
  49. src_unpack() {
  50. mkdir "${S}" || die
  51. cd "${S}" || die
  52. unpack_go_packages
  53. }
  54. src_prepare() {
  55. eapply_user
  56. # Avoid the need to have a git checkout
  57. sed -e 's:^GIT.*::' \
  58. -e 's:-X main.GitCommit.*:" \\:' \
  59. -i "${S}/src/${EGO_PN}/scripts/build.sh" || die
  60. # go install golang.org/x/tools/cmd/stringer: mkdir /usr/lib/go-gentoo/bin/: permission denied
  61. sed -e 's:go get -u -v $(GOTOOLS)::' \
  62. -e 's:^GIT.*::' \
  63. -i "${S}/src/${EGO_PN}/GNUmakefile" || die
  64. }
  65. src_compile() {
  66. export GOPATH="${S}"
  67. go install -v -work -x ${EGO_BUILD_FLAGS} "github.com/mitchellh/gox/..." || die
  68. # The dev target sets causes build.sh to set appropriate XC_OS
  69. # and XC_ARCH, and skips generation of an unused zip file,
  70. # avoiding a dependency on app-arch/zip.
  71. PATH=${PATH}:${S}/bin \
  72. emake -C "${S}/src/${EGO_PN}" dev
  73. }
  74. src_install() {
  75. local x
  76. dobin "${S}/bin/${PN}"
  77. keepdir /etc/serf.d
  78. insinto /etc/serf.d
  79. for x in /var/{lib,log}/${PN}; do
  80. keepdir "${x}"
  81. fowners serf:serf "${x}"
  82. done
  83. newinitd "${FILESDIR}/serf.initd" "${PN}"
  84. newconfd "${FILESDIR}/serf.confd" "${PN}"
  85. insinto /etc/logrotate.d
  86. newins "${FILESDIR}/${PN}.logrotated" "${PN}"
  87. systemd_dounit "${FILESDIR}/serf.service"
  88. }