48 lines
1.4 KiB
Python
Executable File
48 lines
1.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
|
|
def main():
|
|
environ = os.environ
|
|
|
|
repobind = []
|
|
repodir = environ['REPO_DIR']
|
|
repos = str.split(environ['REPO_NAMES'])
|
|
for repo in repos:
|
|
repobind.append(f"--bind={repodir}/{repo}:/var/db/repos/{repo}")
|
|
|
|
kernelbind = []
|
|
kernelpathfile=environ['KERNEL_PATH']
|
|
try:
|
|
with open(kernelpathfile, 'rb') as f:
|
|
kernelpath = f.read().decode("utf-8")
|
|
except OSError:
|
|
kernelpath = "NONE"
|
|
if kernelpath != "NONE":
|
|
if not os.path.exists(kernelpath):
|
|
os.makedirs(kernelpath)
|
|
##kernelbind.append(f"--bind={kernelpath}:/usr/src/{os.path.basename(os.path.dirname(kernelpath))}")
|
|
kernelbind.append(f"--bind={kernelpath}:/usr/src/linux")
|
|
|
|
command = [
|
|
"systemd-nspawn",
|
|
"--quiet",
|
|
f"--directory={environ['CHROOT']}",
|
|
f"--machine={environ['container']}",
|
|
f"--capability=CAP_NET_ADMIN",
|
|
f"--bind={environ['PORTAGE_DIR']}:/var/db/repos/gentoo",
|
|
f"--bind={environ['VA_PKGDIR']}:/var/cache/binpkgs",
|
|
f"--bind={environ['DISTDIR']}:/var/cache/distfiles",
|
|
] + repobind + kernelbind + sys.argv[1:]
|
|
|
|
if os.environ.get("VA_ARCH") == "linux32":
|
|
command = ["linux32"] + command
|
|
|
|
sys.exit(subprocess.call(command))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|