blob: 342e75f2312fcffe42b049cc1d506ccd6724daee [file] [log] [blame]
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=7
CONTAINERD_COMMIT=0e8719f54c6dc6571fc1170da75a85e86c17636b
EGO_PN="github.com/containerd/${PN}"
# lakitu: inherits eutils and systemd to install the containerd.service.
inherit golang-vcs-snapshot toolchain-funcs eutils systemd
DESCRIPTION="A daemon to control runC"
HOMEPAGE="https://containerd.io/"
SRC_URI="https://github.com/containerd/containerd/archive/v${PV}.tar.gz -> ${P}.tar.gz"
# This includes the licenses of dependencies as the binary is statically linked.
#
# If LICENSE contains BSD, ISC, or MIT, then chromite will scan the source for
# copyright attribution. If the package vendors its dependencies or includes a
# THIRD_PARTY_LICENSES/ directory, then chromite will properly attribute all
# dependencies in about_os_credits.html.
#
# This list was determined by inspecting the output of:
# go-licenses csv github.com/containerd/containerd/cmd/containerd
# go-licenses csv github.com/containerd/containerd/cmd/ctr
# go-licenses csv github.com/containerd/containerd/cmd/containerd-shim
# go-licenses csv github.com/containerd/containerd/cmd/containerd-shim-runc-v1
# go-licenses csv github.com/containerd/containerd/cmd/containerd-shim-runc-v2
# go-licenses csv github.com/containerd/containerd/cmd/containerd-stress
# inside a clone of the package repo.
# https://github.com/google/go-licenses
LICENSE="Apache-2.0 BSD-2 BSD ISC MIT MPL-2.0"
SLOT="0"
KEYWORDS="*"
IUSE="apparmor btrfs device-mapper +cri hardened +seccomp selinux test"
DEPEND="
btrfs? ( sys-fs/btrfs-progs )
seccomp? ( sys-libs/libseccomp )
"
# lakitu: RDEPEND on sys-apps/systemd because of the dependency on
# containerd.service.
RDEPEND="
${DEPEND}
>=app-emulation/runc-1.0.0
sys-apps/systemd
"
BDEPEND="
dev-go/go-md2man
virtual/pkgconfig
test? ( ${RDEPEND} )
"
# tests require root or docker
# upstream does not recommend stripping binary
RESTRICT+=" strip test"
S="${WORKDIR}/${P}/src/${EGO_PN}"
PATCHES=(
# lakitu: set containerd path to /usr/bin/containerd
"${FILESDIR}"/1.4.0-customize-containerd-service.patch
)
src_prepare() {
default
sed -i -e "s/git describe --match.*$/echo ${PV})/"\
-e "s/git rev-parse HEAD.*$/echo ${CONTAINERD_COMMIT})/"\
-e "s/-s -w//" \
Makefile || die
}
src_compile() {
local options=(
$(usev apparmor)
$(usex btrfs "" "no_btrfs")
$(usex cri "" "no_cri")
$(usex device-mapper "" "no_devmapper")
$(usev seccomp)
$(usev selinux)
)
myemakeargs=(
BUILDTAGS="${options[*]}"
DESTDIR="${ED}"
LDFLAGS="$(usex hardened '-extldflags -fno-PIC' '')"
)
export GOPATH="${WORKDIR}/${P}" # ${PWD}/vendor
export GOFLAGS="-v -x -mod=vendor"
# lakitu: export a function named 'go' that invokes the go cross-compiler.
# The containerd Makefile will invoke this function instead of doing a PATH
# lookup for the go binary.
GO="$(tc-getGO)"
export GO
go() {
echo "${GO} $@" 1>&2
"${GO}" "$@"
}
export -f go
# lakitu: don't build man pages as cross-compiling man pages doesn't
# work on ARM.
# TODO(mikewu@): renable man pages building once b/178526852 is fixed.
#emake "${myemakeargs[@]}" all man
emake "${myemakeargs[@]}" all
unset -f go
}
src_install() {
dobin bin/*
# lakitu: don't install man pages as cross-compiling man pages doesn't
# work on ARM.
# TODO(mikewu@): uncomment the following line once b/178526852 is fixed.
#doman man/*
# lakitu: we use systemd service to start containerd.
# newinitd "${FILESDIR}"/${PN}.initd "${PN}"
keepdir /var/lib/containerd
# we already installed manpages, remove markdown source
# before installing docs directory
rm -r docs/man || die
local DOCS=( README.md docs/. )
einstalldocs
# lakitu: runs containerd as an individual service. This prevents
# docker from supervising containerd.
systemd_dounit containerd.service
systemd_enable_service multi-user.target containerd.service
}