consul-0.7.1.ebuild 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. # Copyright 1999-2016 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. app-arch/zip
  19. >=dev-lang/go-1.6:=
  20. >=dev-go/go-tools-0_pre20160121"
  21. RDEPEND=""
  22. pkg_setup() {
  23. enewgroup consul
  24. enewuser consul -1 -1 /var/lib/${PN} consul
  25. }
  26. get_archive_go_package() {
  27. local archive=${1} uri x
  28. for x in ${SRC_URI}; do
  29. if [[ ${x} == http* ]]; then
  30. uri=${x}
  31. elif [[ ${x} == ${archive} ]]; then
  32. break
  33. fi
  34. done
  35. uri=${uri#https://}
  36. echo ${uri%/archive/*}
  37. }
  38. unpack_go_packages() {
  39. local go_package x
  40. # Unpack packages to appropriate locations for GOPATH
  41. for x in ${A}; do
  42. unpack ${x}
  43. if [[ ${x} == *.tar.gz ]]; then
  44. go_package=$(get_archive_go_package ${x})
  45. mkdir -p src/${go_package%/*}
  46. mv ${go_package##*/}-* src/${go_package} || die
  47. fi
  48. done
  49. }
  50. src_unpack() {
  51. mkdir "${S}" || die
  52. cd "${S}" || die
  53. unpack_go_packages
  54. }
  55. src_prepare() {
  56. eapply_user
  57. # Avoid the need to have a git checkout
  58. sed -e 's:^GIT.*::' \
  59. -e 's:-X main.GitCommit.*:" \\:' \
  60. -i "${S}/src/${EGO_PN}/scripts/build.sh" || die
  61. # go install golang.org/x/tools/cmd/stringer: mkdir /usr/lib/go-gentoo/bin/: permission denied
  62. sed -e 's:go get -u -v $(GOTOOLS)::' \
  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. PATH=${PATH}:${S}/bin XC_ARCH=$(go env GOARCH) XC_OS=$(go env GOOS) \
  69. emake -C "${S}/src/${EGO_PN}"
  70. }
  71. src_install() {
  72. local x
  73. dobin "${S}/bin/${PN}"
  74. keepdir /etc/consul.d
  75. insinto /etc/consul.d
  76. doins "${FILESDIR}/"*.json.example
  77. for x in /var/{lib,log}/${PN}; do
  78. keepdir "${x}"
  79. fowners consul:consul "${x}"
  80. done
  81. newinitd "${FILESDIR}/consul.initd" "${PN}"
  82. newconfd "${FILESDIR}/consul.confd" "${PN}"
  83. insinto /etc/logrotate.d
  84. newins "${FILESDIR}/${PN}.logrotated" "${PN}"
  85. systemd_dounit "${FILESDIR}/consul.service"
  86. }