Portage Prefix Python Venv Usr Local Multi Distro

From Gentoo Wiki
Jump to:navigation Jump to:search

Create a Gentoo prefix in /usr/local on a non-Gentoo Linux Distro using a Python Virtual Environment

CODE Create a Portage Prefix in /usr/local on a non-Gentoo Linux Distro
FROM docker.io/ubuntu:rolling
RUN \
ln -sf /usr/share/zoneinfo/UTC /etc/localtime && \
echo America/Los_Angeles > /etc/timezone && \
env DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --no-install-recommends build-essential python-is-python3 python3-venv busybox git ssh wget rsync libssl-dev libz-dev pkg-config && rm -rf /var/lib/apt/lists/* && \
export EPREFIX=/usr/local && \
python -m venv "${EPREFIX}" && \
mkdir -p "${EPREFIX}/usr" && \
ln -s ../../../bin "${EPREFIX}/usr/bin" && \
. "${EPREFIX}/bin/activate" && \
pip install portage && \
for p in env.d portage/make.conf portage/repos.conf; do mkdir -p "${EPREFIX}/etc/${p}"; done && \
echo ROOTPATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin > "${EPREFIX}/etc/env.d/05rootpath" && \
mkdir -p "${EPREFIX}/var/db/repos" && git clone --depth 1 https://github.com/gentoo-mirror/gentoo.git "${EPREFIX}/var/db/repos/gentoo" && \
profile=$(find /usr/local/var/db/repos/gentoo/profiles/default/linux/amd64 -mindepth 1 -maxdepth 1 -type d | tail -n1) && \
ln -snf ../..${profile#${EPREFIX}} "${EPREFIX}/etc/portage/make.profile" && \
groupadd --system -g 250 portage && \
useradd --system -u 250 -g portage --home-dir "${EPREFIX}/var/lib/portage/home" portage && \
echo 'FEATURES="-buildpkg -ipc-sandbox -network-sandbox -pid-sandbox -sandbox -usersandbox"' >> "${EPREFIX}/etc/portage/make.conf/01-defaults.conf" && \
echo 'MAKEOPTS="-j'$(nproc)' -l'$(nproc)'"' >> "${EPREFIX}/etc/portage/make.conf/01-defaults.conf" && \
echo 'EMERGE_DEFAULT_OPTS="-j'$(nproc)' -l'$(nproc)'"' >> "${EPREFIX}/etc/portage/make.conf/01-defaults.conf" && \
emerge -V