vault-0.6.2.ebuild 2.3 KB

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