1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 inherit fcaps golang-base systemd user
9 EGO_PN="github.com/hashicorp/${PN}/..."
10 DESCRIPTION="A tool for managing secrets"
11 HOMEPAGE="https://vaultproject.io/"
12 SRC_URI="https://${EGO_PN%/*}/archive/v${PV}.tar.gz -> ${P}.tar.gz
13 https://github.com/mitchellh/gox/archive/c9740af9c6574448fd48eb30a71f964014c7a837.tar.gz -> gox-c9740af9c6574448fd48eb30a71f964014c7a837.tar.gz
14 https://github.com/mitchellh/iochan/archive/87b45ffd0e9581375c491fef3d32130bb15c5bd7.tar.gz -> iochan-87b45ffd0e9581375c491fef3d32130bb15c5bd7.tar.gz
23 DEPEND=">=dev-lang/go-1.6:="
29 -m 755 'cap_ipc_lock=+ep' usr/bin/${PN}
32 get_archive_go_package() {
33 local archive=${1} uri x
34 for x in ${SRC_URI}; do
35 if [[ ${x} == http* ]]; then
37 elif [[ ${x} == ${archive} ]]; then
42 echo ${uri%/archive/*}
45 unpack_go_packages() {
47 # Unpack packages to appropriate locations for GOPATH
50 if [[ ${x} == *.tar.gz ]]; then
51 go_package=$(get_archive_go_package ${x})
52 mkdir -p src/${go_package%/*}
53 mv ${go_package##*/}-* src/${go_package} || die
59 mkdir "${S}" && cd "${S}" || die
65 # Avoid the need to have a git checkout
66 sed -e 's:^GIT.*::' -i src/${EGO_PN%/*}/scripts/build.sh || die
71 enewuser ${PN} -1 -1 -1 ${PN}
76 go install -v -work -x ${EGO_BUILD_FLAGS} "github.com/mitchellh/gox/..." || die
77 go install -v -work -x ${EGO_BUILD_FLAGS} "${EGO_PN}"
78 # the previous command returns 2 on success...
79 [[ -d ${S}/pkg/$(go env GOOS)_$(go env GOARCH)/${EGO_PN%/*} ]] || die
80 cd "${S}"/src/${EGO_PN%/*} || die
81 PATH=${PATH}:${S}/bin \
82 XC_ARCH=$(go env GOARCH) \
83 XC_OS=$(go env GOOS) \
84 XC_OSARCH=$(go env GOOS)/$(go env GOARCH) \
91 dodoc "${S}"/src/${EGO_PN%/*}/{CHANGELOG.md,CONTRIBUTING.md,README.md}
92 newinitd "${FILESDIR}/${PN}.initd" "${PN}"
93 newconfd "${FILESDIR}/${PN}.confd" "${PN}"
94 systemd_dounit "${FILESDIR}/${PN}.service"
98 doins "${FILESDIR}/"*.json.example
100 keepdir /var/log/${PN}
101 fowners ${PN}:${PN} /var/log/${PN}
103 dobin "${S}/bin/${PN}"
105 rm -rf "${S}"/{src,pkg/$(go env GOOS)_$(go env GOARCH)}/${EGO_PN%/*}/vendor
106 find "${S}"/src/${EGO_PN%/*} -mindepth 1 -maxdepth 1 -type f -delete || die
108 while read -r -d '' x; do
110 [[ -d ${S}/pkg/$(go env GOOS)_$(go env GOARCH)/${x} ||
111 -f ${S}/pkg/$(go env GOOS)_$(go env GOARCH)/${x}.a ]] && continue
112 rm -rf "${S}"/src/${x}
113 done < <(find "${S}"/src/${EGO_PN%/*} -mindepth 1 -maxdepth 1 -type d -print0)
114 insopts -m0644 -p # preserve timestamps for bug 551486
115 insinto $(dirname "$(get_golibdir)/pkg/$(go env GOOS)_$(go env GOARCH)/${EGO_PN%/*}")
116 doins -r "${S}"/pkg/$(go env GOOS)_$(go env GOARCH)/${EGO_PN%/*}
117 insinto $(dirname "$(get_golibdir)/src/${EGO_PN%/*}")
118 doins -r "${S}"/src/${EGO_PN%/*}