commit d6d194d358312d6c31ada66fbb53cd183f87d6f3
parent 317d88bdcf0c790489dfbfd3882fd29d4ebcb7b0
Author: ccx <ccx@te2000.cz>
Date: Thu, 31 Oct 2024 13:41:47 +0000
Fix paths for sandbox.py and env files
Diffstat:
4 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/command/pthbs-build b/command/pthbs-build
@@ -1,4 +1,5 @@
#!/bin/sh
+if test -n "$pthbs_xtrace"; then set -x; fi
bsh=$(sha256sum $1) || exit $?
bsh=${bsh%% *}
if test -z "$pthbs_workdir"; then
@@ -17,6 +18,10 @@ if test -z "$pthbs_cache"; then
printf '%s\n' >&2 "$0: fatal: pthbs_cache env var undefined or empty"
exit 100
fi
+if test -z "$pthbs_source"; then
+ printf '%s\n' >&2 "$0: fatal: pthbs_source env var undefined or empty"
+ exit 100
+fi
mkdir -p "$pthbs_workdir/builddir.$$" || exit $?
workdir=$(realpath "$pthbs_workdir/builddir.$$")
@@ -207,23 +212,25 @@ function at_filehash(hash_type, file_hash, dst, dstdir){
sandbox_cmd=sandbox_cmd " -m " q("allow/read+/bin/***")
sandbox_cmd=sandbox_cmd " -munshare/net:1 -munshare/ipc:1"
} else if(sandbox_mode == "userns") {
- sandbox_cmd=" "q(ENVIRON["pthbs"]"/sandbox/ns_sandbox.py")" --mode=userns"
+ sandbox_cmd=" "q(ENVIRON["pthbs_source"]"/sandbox/ns_sandbox.py")" --mode=userns"
+ sandbox_cmd=sandbox_cmd" --versions="q(ENVIRON["pthbs_versions"])
sandbox_cmd=sandbox_cmd" --extra-mount=tmpfs:"q(ENVIRON["pthbs_workdir"])
sandbox_cmd=sandbox_cmd" --extra-mount=ro_bind:"q(ENVIRON["pthbs_pkgdir"]":"ENVIRON["pthbs_pkgdir"])
sandbox_cmd=sandbox_cmd" --extra-mount=rw_bind:"q(ENVIRON["workdir"]":"ENVIRON["workdir"])
sandbox_cmd=sandbox_cmd" --extra-mount=rw_bind:"q(ENVIRON["workdir"]"/.tmp:/tmp")
sandbox_cmd=sandbox_cmd" -- "q(ENVIRON["pthbs_workdir"]"/root")
- printf "%s\n", "mkdir -p "q(ENVIRON["workdir"]"/.tmp")
+ printf "%s\n", "mkdir -p "q(ENVIRON["workdir"]"/.tmp")" "q(ENVIRON["pthbs_workdir"]"/root")
} else if(sandbox_mode == "root") {
- sandbox_cmd=" "q(ENVIRON["pthbs_workdir"]"/venv/bin/python")" "q(ENVIRON["pthbs"]"/sandbox/ns_sandbox.py")" --mode=root"
- sandbox_cmd=sandbox_cmd" --untar="q(ENVIRON["pthbs"]"/sandbox/root.tar")
+ sandbox_cmd=" "q(ENVIRON["pthbs_cache"]"/venv/bin/python")" "q(ENVIRON["pthbs_source"]"/sandbox/ns_sandbox.py")" --mode=root"
+ sandbox_cmd=sandbox_cmd" --versions="q(ENVIRON["pthbs_versions"])
+ sandbox_cmd=sandbox_cmd" --untar="q(ENVIRON["pthbs_source"]"/sandbox/root.tar")
sandbox_cmd=sandbox_cmd" --chdir="q(ENVIRON["workdir"])
sandbox_cmd=sandbox_cmd" --extra-mount=tmpfs:"q(ENVIRON["pthbs_workdir"])
sandbox_cmd=sandbox_cmd" --extra-mount=ro_bind:"q(ENVIRON["pthbs_pkgdir"]":"ENVIRON["pthbs_pkgdir"])
sandbox_cmd=sandbox_cmd" --extra-mount=rw_bind:"q(ENVIRON["workdir"]":"ENVIRON["workdir"])
sandbox_cmd=sandbox_cmd" --extra-mount=rw_bind:"q(ENVIRON["workdir"]"/.tmp:/tmp")
sandbox_cmd=sandbox_cmd" -- "q(ENVIRON["pthbs_workdir"]"/root")
- printf "%s\n", "mkdir -p "q(ENVIRON["workdir"]"/.tmp")
+ printf "%s\n", "mkdir -p "q(ENVIRON["workdir"]"/.tmp")" "q(ENVIRON["pthbs_workdir"]"/root")
} else {
fatal("unrecognized sanbox_mode " sandbox_mode)
}
diff --git a/command/pthbs-makegen b/command/pthbs-makegen
@@ -1,5 +1,5 @@
#!/bin/sh
-#set -x
+if test -n "$pthbs_xtrace"; then set -x; fi
bsh=$(sha256sum $1) || exit $?
bsh=${bsh%% *}
if test -z "$pthbs_workdir"; then
@@ -92,7 +92,7 @@ function make_envfile( n, envfile, envhash) {
if(!env_count) {
fatal("environment is empty")
}
- envfile = makedir "/package.sha256."ENVIRON["bsh"]".env"
+ envfile = ENVIRON["makedir"] "/package.sha256."ENVIRON["bsh"]".env"
for(n=1; n<=env_count; n++) {
print env[n] >envfile
}
diff --git a/pthbs.mk b/pthbs.mk
@@ -12,6 +12,7 @@ export pthbs_pkgdir:=$(abspath $(packages))
export pthbs_workdir:=$(abspath $(work))
export pthbs_indexdir:=$(abspath $(index))
export pthbs_cache:=$(abspath $(cache))
+export pthbs_source:=$(abspath $(pthbs))
no_default:
@echo "pthbs has no default target to build"
diff --git a/sandbox/ns_sandbox.py b/sandbox/ns_sandbox.py
@@ -452,8 +452,16 @@ class Settings:
else:
v = {}
+ versions = args.versions
+ if versions is None and 'versions' in v:
+ versions = pathlib.PosixPath(v['versions'])
+ if versions is None and 'pthbs_versions' in env:
+ versions = pathlib.PosixPath(env['pthbs_versions'])
+ if versions is None:
+ raise ValueError("Versions directory not specified as argument, yaml nor environment")
+
return cls(
- versions=(args.versions or pathlib.PosixPath(v['versions'])),
+ versions=versions,
root=args.root_dir,
chdir=args.chdir,
vars=v,