sys-block/open-iscsi: Merge unnecessary udev dep removal
[gentoo.git] / app-admin / vault / vault-0.1.2.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6
7 inherit fcaps golang-build systemd user
8
9 KEYWORDS="~amd64"
10 DESCRIPTION="A tool for managing secrets"
11 HOMEPAGE="https://vaultproject.io/"
12 GO_PN="github.com/hashicorp/${PN}"
13 LICENSE="MPL-2.0"
14 SLOT="0"
15 IUSE=""
16 RESTRICT="test"
17
18 DEPEND="dev-go/go-oauth2"
19 RDEPEND=""
20
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"
24 STRIP_MASK="*.a"
25 S="${WORKDIR}/src/${GO_PN}"
26
27 FILECAPS=(
28         -m 755 'cap_ipc_lock=+ei' usr/bin/${PN}
29 )
30
31 pkg_setup() {
32         enewgroup ${PN}
33         enewuser ${PN} -1 -1 -1 ${PN}
34 }
35
36 src_unpack() {
37         local x
38
39         default
40         mkdir -p src/${GO_PN%/*} || die
41         mv ${P} src/${GO_PN} || die
42
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
47
48         export GOPATH=${WORKDIR}:${WORKDIR}/src/github.com/hashicorp/vault/Godeps/_workspace:$(get_golibdir_gopath)
49
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)
53
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
59 }
60
61 src_prepare() {
62         # Avoid the need to have a git checkout
63         sed -e 's:^GIT.*::' \
64                 -e 's:-ldflags.*:\\:' \
65                 -i scripts/build.sh || die
66 }
67
68 src_compile() {
69         go install -v -x github.com/mitchellh/gox || die
70         PATH=${GOROOT}/bin:${PATH} emake dev
71 }
72
73 src_install() {
74         local x
75
76         newinitd "${FILESDIR}/${PN}.initd" "${PN}"
77         newconfd "${FILESDIR}/${PN}.confd" "${PN}"
78         systemd_dounit "${FILESDIR}/${PN}.service"
79
80         keepdir /etc/${PN}.d
81         insinto /etc/${PN}.d
82         doins "${FILESDIR}/"*.json.example
83
84         keepdir /var/log/${PN}
85         fowners ${PN}:${PN} /var/log/${PN}
86
87         dobin bin/${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
91                 x=${x#${WORKDIR}/src}
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}
101 }