consul-template-0.16.0.ebuild 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. # Copyright 1999-2016 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=6
  4. inherit golang-base systemd user
  5. KEYWORDS="~amd64"
  6. DESCRIPTION="Generic template rendering and notifications with Consul"
  7. EGO_PN="github.com/hashicorp/${PN}/..."
  8. HOMEPAGE="http://${EGO_PN%/*}"
  9. LICENSE="MPL-2.0"
  10. SLOT="0"
  11. IUSE=""
  12. RESTRICT="test"
  13. DEPEND=">=dev-lang/go-1.6:="
  14. RDEPEND=""
  15. SRC_URI="https://${EGO_PN%/*}/archive/v${PV}.tar.gz -> ${P}.tar.gz
  16. https://github.com/mitchellh/gox/archive/c9740af9c6574448fd48eb30a71f964014c7a837.tar.gz -> gox-c9740af9c6574448fd48eb30a71f964014c7a837.tar.gz
  17. https://github.com/mitchellh/iochan/archive/87b45ffd0e9581375c491fef3d32130bb15c5bd7.tar.gz -> iochan-87b45ffd0e9581375c491fef3d32130bb15c5bd7.tar.gz
  18. "
  19. pkg_setup() {
  20. enewgroup ${PN}
  21. enewuser ${PN} -1 -1 -1 ${PN}
  22. }
  23. get_archive_go_package() {
  24. local archive=${1} uri x
  25. for x in ${SRC_URI}; do
  26. if [[ ${x} == http* ]]; then
  27. uri=${x}
  28. elif [[ ${x} == ${archive} ]]; then
  29. break
  30. fi
  31. done
  32. uri=${uri#https://}
  33. echo ${uri%/archive/*}
  34. }
  35. unpack_go_packages() {
  36. local go_package x
  37. # Unpack packages to appropriate locations for GOPATH
  38. for x in ${A}; do
  39. unpack ${x}
  40. if [[ ${x} == *.tar.gz ]]; then
  41. go_package=$(get_archive_go_package ${x})
  42. mkdir -p src/${go_package%/*}
  43. mv ${go_package##*/}-* src/${go_package} || die
  44. fi
  45. done
  46. }
  47. src_unpack() {
  48. mkdir "${S}" && cd "${S}" || die
  49. unpack_go_packages
  50. }
  51. src_prepare() {
  52. eapply_user
  53. # Avoid the need to have a git checkout
  54. sed -e 's:^GIT.*::' -i src/${EGO_PN%/*}/scripts/build.sh || die
  55. }
  56. src_compile() {
  57. export GOPATH=${S}
  58. go install -v -work -x ${EGO_BUILD_FLAGS} "github.com/mitchellh/gox/..." || die
  59. cd "${S}"/src/${EGO_PN%/*} || die
  60. PATH=${PATH}:${S}/bin \
  61. XC_ARCH=$(go env GOARCH) \
  62. XC_OS=$(go env GOOS) \
  63. emake bin
  64. }
  65. src_test() {
  66. cd "${S}"/src/${EGO_PN%/*} || die
  67. emake test || die
  68. }
  69. src_install() {
  70. dobin "${S}/bin/${PN}"
  71. dodoc "${S}"/src/${EGO_PN%/*}/{CHANGELOG.md,README.md}
  72. keepdir /var/log/${PN}
  73. fowners ${PN}:${PN} /var/log/${PN}
  74. newinitd "${FILESDIR}/${PN}.initd" "${PN}"
  75. insinto /etc/logrotate.d
  76. newins "${FILESDIR}/${PN}.logrotated" "${PN}"
  77. newconfd "${FILESDIR}/${PN}.confd" "${PN}"
  78. systemd_dounit "${FILESDIR}/${PN}.service"
  79. keepdir /etc/${PN}.d
  80. insinto /etc/${PN}.d
  81. doins "${FILESDIR}/"*.json.example
  82. }