2018-10-27 20:04:00 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
environ = os.environ
|
|
|
|
|
2021-02-05 20:45:54 +01:00
|
|
|
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}")
|
|
|
|
|
2021-05-22 19:53:34 +02:00
|
|
|
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")
|
|
|
|
|
2018-10-27 20:04:00 +02:00
|
|
|
command = [
|
|
|
|
"systemd-nspawn",
|
|
|
|
"--quiet",
|
|
|
|
f"--directory={environ['CHROOT']}",
|
|
|
|
f"--machine={environ['container']}",
|
2021-02-05 16:09:03 +01:00
|
|
|
f"--capability=CAP_NET_ADMIN",
|
2021-02-05 15:13:54 +01:00
|
|
|
f"--bind={environ['PORTAGE_DIR']}:/var/db/repos/gentoo",
|
|
|
|
f"--bind={environ['VA_PKGDIR']}:/var/cache/binpkgs",
|
|
|
|
f"--bind={environ['DISTDIR']}:/var/cache/distfiles",
|
2021-05-22 19:53:34 +02:00
|
|
|
] + repobind + kernelbind + sys.argv[1:]
|
2018-10-27 20:04:00 +02:00
|
|
|
|
|
|
|
if os.environ.get("VA_ARCH") == "linux32":
|
|
|
|
command = ["linux32"] + command
|
|
|
|
|
2018-12-02 09:04:26 +01:00
|
|
|
sys.exit(subprocess.call(command))
|
2018-10-27 20:04:00 +02:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|