consul-0.7.5.ebuild 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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/consul"
  7. DESCRIPTION="A tool for service discovery, monitoring and configuration"
  8. HOMEPAGE="http://www.consul.io"
  9. SRC_URI="https://github.com/hashicorp/consul/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.7.5:=
  19. >=dev-go/go-tools-0_pre20160121"
  20. RDEPEND=""
  21. pkg_setup() {
  22. enewgroup consul
  23. enewuser consul -1 -1 /var/lib/${PN} consul
  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. -i "${S}/src/${EGO_PN}/GNUmakefile" || die
  63. }
  64. src_compile() {
  65. export GOPATH="${S}"
  66. go install -v -work -x ${EGO_BUILD_FLAGS} "github.com/mitchellh/gox/..." || die
  67. # The dev target sets causes build.sh to set appropriate XC_OS
  68. # and XC_ARCH, and skips generation of an unused zip file,
  69. # avoiding a dependency on app-arch/zip.
  70. PATH=${PATH}:${S}/bin \
  71. emake -C "${S}/src/${EGO_PN}" dev
  72. }
  73. src_install() {
  74. local x
  75. dobin "${S}/bin/${PN}"
  76. keepdir /etc/consul.d
  77. insinto /etc/consul.d
  78. doins "${FILESDIR}/"*.json.example
  79. for x in /var/{lib,log}/${PN}; do
  80. keepdir "${x}"
  81. fowners consul:consul "${x}"
  82. done
  83. newinitd "${FILESDIR}/consul.initd" "${PN}"
  84. newconfd "${FILESDIR}/consul.confd" "${PN}"
  85. insinto /etc/logrotate.d
  86. newins "${FILESDIR}/${PN}.logrotated" "${PN}"
  87. systemd_dounit "${FILESDIR}/consul.service"
  88. }