1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 inherit eutils fcaps golang-build 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"
20 DEPEND="dev-go/go-oauth2:="
28 -m 755 'cap_ipc_lock=+ei' usr/bin/${PN}
33 enewuser ${PN} -1 -1 -1 ${PN}
41 mkdir -p "$(dirname "${S}/src/${EGO_PN%/*}")" || die
42 mv "${S}_" "${S}/src/${EGO_PN%/*}" || die
44 # Create a writable GOROOT in order to avoid sandbox violations.
45 export GOROOT="${WORKDIR}/goroot"
46 cp -sR "${EPREFIX}"/usr/lib/go "${GOROOT}" || die
47 rm -rf "${GOROOT}"/{src,pkg/$(go env GOOS)_$(go env GOARCH)}/"${EGO_PN%/*}" || die
49 export GOPATH=${S}:${S}/src/github.com/hashicorp/vault/Godeps/_workspace:$(get_golibdir_gopath)
51 while read -r -d '' x; do
52 rm -rf "${GOROOT}/src/${x}" "${GOROOT}/pkg/$(go env GOOS)_$(go env GOARCH)/${x}"{,.a} || die
53 done < <(find "${P}/src/github.com/hashicorp/vault/Godeps/_workspace/src" -maxdepth 3 -mindepth 3 -type d -print0)
57 go build -v -work -x ${EGO_BUILD_FLAGS} "${EGO_PN}" || die
58 go install -v -work -x ${EGO_BUILD_FLAGS} "${EGO_PN}" || die
64 newinitd "${FILESDIR}/${PN}.initd" "${PN}"
65 newconfd "${FILESDIR}/${PN}.confd" "${PN}"
66 systemd_dounit "${FILESDIR}/${PN}.service"
70 doins "${FILESDIR}/"*.json.example
72 keepdir /var/log/${PN}
73 fowners ${PN}:${PN} /var/log/${PN}
75 dobin "${S}/bin/${PN}"
77 find "${S}"/src/${EGO_PN%/*} -mindepth 1 -maxdepth 1 -type f -delete || die
79 while read -r -d '' x; do
81 [[ -d ${S}/pkg/$(go env GOOS)_$(go env GOARCH)/${x} ||
82 -f ${S}/pkg/$(go env GOOS)_$(go env GOARCH)/${x}.a ]] && continue
83 rm -rf "${S}"/src/${x}
84 done < <(find "${S}"/src/${EGO_PN%/*} -mindepth 1 -maxdepth 1 -type d -print0)
85 insopts -m0644 -p # preserve timestamps for bug 551486
86 insinto $(dirname "$(get_golibdir)/pkg/$(go env GOOS)_$(go env GOARCH)/${EGO_PN%/*}")
87 doins -r "${S}"/pkg/$(go env GOOS)_$(go env GOARCH)/${EGO_PN%/*}
88 insinto $(dirname "$(get_golibdir)/src/${EGO_PN%/*}")
89 doins -r "${S}"/src/${EGO_PN%/*}