|
| 1 | +# Copyright 1999-2025 Gentoo Authors |
| 2 | +# Distributed under the terms of the GNU General Public License v2 |
| 3 | + |
| 4 | +EAPI=8 |
| 5 | + |
| 6 | +inherit go-module linux-info toolchain-funcs |
| 7 | + |
| 8 | +DESCRIPTION="A tool that facilitates building OCI images" |
| 9 | +HOMEPAGE="https://github.com/containers/buildah" |
| 10 | + |
| 11 | +# main pkg |
| 12 | +LICENSE="Apache-2.0" |
| 13 | +# deps |
| 14 | +LICENSE+=" BSD BSD-2 CC-BY-SA-4.0 ISC MIT MPL-2.0" |
| 15 | + |
| 16 | +SLOT="0" |
| 17 | +IUSE="apparmor btrfs +seccomp systemd test" |
| 18 | +RESTRICT="test" |
| 19 | +DOCS=( |
| 20 | + "CHANGELOG.md" |
| 21 | + "troubleshooting.md" |
| 22 | + "docs/tutorials" |
| 23 | +) |
| 24 | + |
| 25 | +if [[ ${PV} == 9999* ]]; then |
| 26 | + inherit git-r3 |
| 27 | + EGIT_REPO_URI="https://github.com/containers/buildah.git" |
| 28 | +else |
| 29 | + SRC_URI="https://github.com/containers/buildah/archive/v${PV}.tar.gz -> ${P}.tar.gz" |
| 30 | + KEYWORDS="~amd64 ~arm64" |
| 31 | +fi |
| 32 | + |
| 33 | +RDEPEND=" |
| 34 | + systemd? ( sys-apps/systemd ) |
| 35 | + btrfs? ( sys-fs/btrfs-progs ) |
| 36 | + seccomp? ( sys-libs/libseccomp:= ) |
| 37 | + apparmor? ( sys-libs/libapparmor:= ) |
| 38 | + >=app-containers/containers-common-0.58.0-r1 |
| 39 | + app-crypt/gpgme:= |
| 40 | + dev-libs/libgpg-error:= |
| 41 | + dev-libs/libassuan:= |
| 42 | + sys-apps/shadow:= |
| 43 | +" |
| 44 | +DEPEND="${RDEPEND}" |
| 45 | +BDEPEND="dev-go/go-md2man" |
| 46 | + |
| 47 | +pkg_pretend() { |
| 48 | + local CONFIG_CHECK="" |
| 49 | + use btrfs && CONFIG_CHECK+=" ~BTRFS_FS" |
| 50 | + check_extra_config |
| 51 | + |
| 52 | + linux_config_exists || ewarn "Cannot determine configuration of your kernel." |
| 53 | +} |
| 54 | + |
| 55 | +src_prepare() { |
| 56 | + default |
| 57 | + |
| 58 | + # ensure all necessary files are there |
| 59 | + local file |
| 60 | + for file in docs/Makefile hack/libsubid_tag.sh hack/apparmor_tag.sh \ |
| 61 | + hack/systemd_tag.sh btrfs_installed_tag.sh btrfs_tag.sh; do |
| 62 | + [[ -f "${file}" ]] || die |
| 63 | + done |
| 64 | + |
| 65 | + sed -i -e "s|/usr/local|/usr|g" Makefile docs/Makefile || die |
| 66 | + echo -e '#!/usr/bin/env bash\necho libsubid' > hack/libsubid_tag.sh || die |
| 67 | + |
| 68 | + cat <<-EOF > hack/apparmor_tag.sh || die |
| 69 | + #!/usr/bin/env bash |
| 70 | + $(usex apparmor 'echo apparmor' echo) |
| 71 | + EOF |
| 72 | + |
| 73 | + use seccomp || eapply "${FILESDIR}/${PN}-1.37.5-disable-seccomp.patch" |
| 74 | + |
| 75 | + cat <<-EOF > hack/systemd_tag.sh || die |
| 76 | + #!/usr/bin/env bash |
| 77 | + $(usex systemd 'echo systemd' echo) |
| 78 | + EOF |
| 79 | + |
| 80 | + echo -e "#!/usr/bin/env bash\n echo" > btrfs_installed_tag.sh || die |
| 81 | + cat <<-EOF > btrfs_tag.sh || die |
| 82 | + #!/usr/bin/env bash |
| 83 | + $(usex btrfs echo 'echo exclude_graphdriver_btrfs') |
| 84 | + EOF |
| 85 | + |
| 86 | + use test || eapply "${FILESDIR}/${PN}-1.40.1-disable-tests.patch" |
| 87 | +} |
| 88 | + |
| 89 | +src_compile() { |
| 90 | + # For non-live versions, prevent git operations which causes sandbox violations |
| 91 | + # https://github.com/gentoo/gentoo/pull/33531#issuecomment-1786107493 |
| 92 | + [[ ${PV} != 9999* ]] && export COMMIT_NO="" GIT_COMMIT="" |
| 93 | + |
| 94 | + tc-export AS LD STRIP |
| 95 | + export GOMD2MAN="$(command -v go-md2man)" |
| 96 | + export SELINUXOPT= |
| 97 | + default |
| 98 | +} |
| 99 | + |
| 100 | +src_test() { |
| 101 | + emake test-unit |
| 102 | +} |
| 103 | + |
| 104 | +src_install() { |
| 105 | + emake DESTDIR="${ED}" SELINUXOPT= install install.completions |
| 106 | + einstalldocs |
| 107 | +} |
0 commit comments