dev-python/pytest: arm64 stable (bug #723996)
[gentoo.git] / app-emulation / libpod / libpod-1.9.3.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 EGIT_COMMIT="5d44534fff6877b1cb15b760242279ae6293154c"
7
8 inherit bash-completion-r1 flag-o-matic go-module
9
10 DESCRIPTION="Library and podman tool for running OCI-based containers in Pods"
11 HOMEPAGE="https://github.com/containers/libpod/"
12 SRC_URI="https://github.com/containers/libpod/archive/v${PV}.tar.gz -> ${P}.tar.gz"
13 LICENSE="Apache-2.0 BSD BSD-2 CC-BY-SA-4.0 ISC MIT MPL-2.0"
14 SLOT="0"
15
16 KEYWORDS="~amd64"
17 IUSE="apparmor btrfs +fuse +rootless selinux"
18 RESTRICT="test"
19
20 COMMON_DEPEND="
21         app-crypt/gpgme:=
22         >=app-emulation/conmon-2.0.0
23         || ( >=app-emulation/runc-1.0.0_rc6 app-emulation/crun )
24         dev-libs/libassuan:=
25         dev-libs/libgpg-error:=
26         net-misc/cni-plugins
27         sys-fs/lvm2
28         sys-libs/libseccomp:=
29
30         apparmor? ( sys-libs/libapparmor )
31         btrfs? ( sys-fs/btrfs-progs )
32         rootless? ( app-emulation/slirp4netns )
33         selinux? ( sys-libs/libselinux:= )
34 "
35 DEPEND="
36         ${COMMON_DEPEND}
37         dev-go/go-md2man"
38 RDEPEND="${COMMON_DEPEND}
39         fuse? ( sys-fs/fuse-overlayfs )"
40
41 src_prepare() {
42         default
43
44         # Disable installation of python modules here, since those are
45         # installed by separate ebuilds.
46         local makefile_sed_args=(
47                 -e '/^GIT_.*/d'
48                 -e 's/$(GO) build/$(GO) build -v -work -x/'
49                 -e 's/^\(install:.*\) install\.python$/\1/'
50         )
51
52         has_version -b '>=dev-lang/go-1.13.9' || makefile_sed_args+=(-e 's:GO111MODULE=off:GO111MODULE=on:')
53
54         sed "${makefile_sed_args[@]}" -i Makefile || die
55
56         sed -e 's|OUTPUT="${CIRRUS_TAG:.*|OUTPUT='v${PV}'|' \
57                 -i hack/get_release_info.sh || die
58 }
59
60 src_compile() {
61         # Filter unsupported linker flags
62         filter-flags '-Wl,*'
63
64         [[ -f hack/apparmor_tag.sh ]] || die
65         if use apparmor; then
66                 echo -e "#!/bin/sh\necho apparmor" > hack/apparmor_tag.sh || die
67         else
68                 echo -e "#!/bin/sh\ntrue" > hack/apparmor_tag.sh || die
69         fi
70
71         [[ -f hack/btrfs_installed_tag.sh ]] || die
72         if use btrfs; then
73                 echo -e "#!/bin/sh\ntrue" > hack/btrfs_installed_tag.sh || die
74         else
75                 echo -e "#!/bin/sh\necho exclude_graphdriver_btrfs" > \
76                         hack/btrfs_installed_tag.sh || die
77         fi
78
79         [[ -f hack/selinux_tag.sh ]] || die
80         if use selinux; then
81                 echo -e "#!/bin/sh\necho selinux" > hack/selinux_tag.sh || die
82         else
83                 echo -e "#!/bin/sh\ntrue" > hack/selinux_tag.sh || die
84         fi
85
86         export -n GOCACHE GOPATH XDG_CACHE_HOME
87         GOBIN="${S}/bin" \
88                 emake all \
89                         GIT_BRANCH=master \
90                         GIT_BRANCH_CLEAN=master \
91                         COMMIT_NO="${EGIT_COMMIT}" \
92                         GIT_COMMIT="${EGIT_COMMIT}"
93 }
94
95 src_install() {
96         emake DESTDIR="${D}" PREFIX="${EPREFIX}/usr" install
97
98         insinto /etc/containers
99         newins test/registries.conf registries.conf.example
100         newins test/policy.json policy.json.example
101
102         insinto /usr/share/containers
103         doins seccomp.json
104
105         newinitd "${FILESDIR}"/podman.initd podman
106
107         insinto /etc/logrotate.d
108         newins "${FILESDIR}/podman.logrotated" podman
109
110         dobashcomp completions/bash/*
111
112         keepdir /var/lib/containers
113 }
114
115 pkg_preinst() {
116         LIBPOD_ROOTLESS_UPGRADE=false
117         if use rootless; then
118                 has_version 'app-emulation/libpod[rootless]' || LIBPOD_ROOTLESS_UPGRADE=true
119         fi
120 }
121
122 pkg_postinst() {
123         local want_newline=false
124         if [[ ! ( -e ${EROOT%/*}/etc/containers/policy.json && -e ${EROOT%/*}/etc/containers/registries.conf ) ]]; then
125                 elog "You need to create the following config files:"
126                 elog "/etc/containers/registries.conf"
127                 elog "/etc/containers/policy.json"
128                 elog "To copy over default examples, use:"
129                 elog "cp /etc/containers/registries.conf{.example,}"
130                 elog "cp /etc/containers/policy.json{.example,}"
131                 want_newline=true
132         fi
133         if [[ ${LIBPOD_ROOTLESS_UPGRADE} == true ]] ; then
134                 ${want_newline} && elog ""
135                 elog "For rootless operation, you need to configure subuid/subgid"
136                 elog "for user running podman. In case subuid/subgid has only been"
137                 elog "configured for root, run:"
138                 elog "usermod --add-subuids 1065536-1131071 <user>"
139                 elog "usermod --add-subgids 1065536-1131071 <user>"
140                 want_newline=true
141         fi
142 }