-
Notifications
You must be signed in to change notification settings - Fork 0
/
mkosi.build.chroot
executable file
·37 lines (31 loc) · 1.13 KB
/
mkosi.build.chroot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python3
# vim: smarttab:expandtab:ts=4:sw=4:ft=python
from os import environ
from os.path import basename
from subprocess import run
from pathlib import Path
root_dir: Path = Path("/root")
src_dir: Path = Path(environ["SRCDIR"])
build_dir: Path = Path(environ["BUILDDIR"])
output_dir: Path = Path(environ["OUTPUTDIR"])
dest_dir: Path = Path(environ["DESTDIR"])
pip_cache_dir: Path = build_dir / ".pip_cache"
# even though pip is a python module, the preferred interface is via the CLI
pip_wheel: list = [
"pip",
"wheel",
"--cache-dir",
pip_cache_dir,
"-w", output_dir / "wheels",
"-c", src_dir / "requirements" / "upper-constraints.txt",
]
# install the wanted application from upstream
pip_cache_dir.mkdir(parents=True, exist_ok=True)
python_source: Path = src_dir / "src"
repos = [item for item in python_source.iterdir() if item.is_dir() and basename(item)[0] != '.']
cmd = pip_wheel + repos
git_safe_directory = ["git", "config", "--global", "--add", "safe.directory"]
run(git_safe_directory + [src_dir], check=True)
for repo in repos:
run(git_safe_directory + [repo], check=True)
run(cmd, check=True)