1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 inherit fcaps golang-build systemd user
10 DESCRIPTION="A tool for managing secrets"
11 HOMEPAGE="https://vaultproject.io/"
12 GO_PN="github.com/hashicorp/${PN}"
18 DEPEND="dev-go/go-oauth2"
21 SRC_URI="https://${GO_PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz
22 https://github.com/mitchellh/gox/archive/v0.3.0.tar.gz -> gox-0.3.0.tar.gz
23 https://github.com/mitchellh/iochan/archive/b584a329b193e206025682ae6c10cdbe03b0cd77.tar.gz -> iochan-b584a329b193e206025682ae6c10cdbe03b0cd77.tar.gz"
25 S="${WORKDIR}/src/${GO_PN}"
28 -m 755 'cap_ipc_lock=+ei' usr/bin/${PN}
33 enewuser ${PN} -1 -1 -1 ${PN}
40 mkdir -p src/${GO_PN%/*} || die
41 mv ${P} src/${GO_PN} || die
43 # Create a writable GOROOT in order to avoid sandbox violations.
44 export GOROOT="${WORKDIR}/goroot"
45 cp -sR "${EPREFIX}"/usr/lib/go "${GOROOT}" || die
46 rm -rf "${GOROOT}/src/${GO_PN}" || die
48 export GOPATH=${WORKDIR}:${WORKDIR}/src/github.com/hashicorp/vault/Godeps/_workspace:$(get_golibdir_gopath)
50 while read -r -d '' x; do
51 rm -rf "${GOROOT}/src/${x}" "${GOROOT}/pkg/${KERNEL}_${ARCH}/${x}"{,.a} || die
52 done < <(find "${WORKDIR}/src/github.com/hashicorp/vault/Godeps/_workspace/src" -maxdepth 3 -mindepth 3 -type d -print0)
54 mkdir -p "${GOROOT}/src/github.com/mitchellh" || die
55 rm -rf "${GOROOT}/src/github.com/mitchellh/gox" || die
56 mv gox-0.3.0 "${GOROOT}/src/github.com/mitchellh/gox" || die
57 rm -rf "${GOROOT}/src/github.com/mitchellh/iochan" || die
58 mv iochan-* "${GOROOT}/src/github.com/mitchellh/iochan" || die
62 # Avoid the need to have a git checkout
64 -e 's:-ldflags.*:\\:' \
65 -i scripts/build.sh || die
69 go install -v -x github.com/mitchellh/gox || die
70 PATH=${GOROOT}/bin:${PATH} emake dev
76 newinitd "${FILESDIR}/${PN}.initd" "${PN}"
77 newconfd "${FILESDIR}/${PN}.confd" "${PN}"
78 systemd_dounit "${FILESDIR}/${PN}.service"
82 doins "${FILESDIR}/"*.json.example
84 keepdir /var/log/${PN}
85 fowners ${PN}:${PN} /var/log/${PN}
88 find "${WORKDIR}"/{pkg,src} -name '.git*' -exec rm -rf {} \; 2>/dev/null
89 find "${WORKDIR}"/src/${GO_PN} -mindepth 1 -maxdepth 1 -type f -delete
90 while read -r -d '' x; do
92 [[ -d ${WORKDIR}/pkg/${KERNEL}_${ARCH}/${x} ||
93 -f ${WORKDIR}/pkg/${KERNEL}_${ARCH}/${x}.a ]] && continue
94 rm -rf "${WORKDIR}"/src/${x}
95 done < <(find "${WORKDIR}"/src/${GO_PN} -mindepth 1 -maxdepth 1 -type d -print0)
96 insopts -m0644 -p # preserve timestamps for bug 551486
97 insinto /usr/lib/go/pkg/${KERNEL}_${ARCH}/${GO_PN%/*}
98 doins -r "${WORKDIR}"/pkg/${KERNEL}_${ARCH}/${GO_PN}
99 insinto /usr/lib/go/src/${GO_PN%/*}
100 doins -r "${WORKDIR}"/src/${GO_PN}