Skip to content

Commit bf7ed06

Browse files
authored
Merge pull request #104 from avdgrinten/cbuildrt-workspace
base: Update to new cbuildrt
2 parents 698cb68 + 85b63b2 commit bf7ed06

2 files changed

Lines changed: 27 additions & 10 deletions

File tree

xbstrap/base.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2366,17 +2366,18 @@ def run_cbuildrt(
23662366
environ=None,
23672367
host_environ=None,
23682368
):
2369-
workspace = _util.find_cbuildrt_workspace()
2370-
_util.try_mkdir(workspace, recursive=True)
2369+
workspace = _util.ensure_cbuildrt_workspace()
23712370

23722371
cbuild_json = {
23732372
"user": {"uid": 0, "gid": 0},
23742373
"process": {
23752374
"args": list(args),
23762375
"environ": environ or {},
23772376
},
2378-
"subUid": {"auto": True, "self": site_container_yml["uid"]},
2379-
"subGid": {"auto": True, "self": site_container_yml["gid"]},
2377+
"mapCurrentUserTo": {
2378+
"uid": site_container_yml["uid"],
2379+
"gid": site_container_yml["gid"],
2380+
},
23802381
"bindMounts": bind_mounts or [],
23812382
"volumes": volumes or [],
23822383
}
@@ -2399,7 +2400,7 @@ def run_cbuildrt(
23992400
)
24002401

24012402
result = subprocess.call(
2402-
["cbuildrt", "--workspace", workspace, f.name],
2403+
["cbuildrt", "run", "--workspace", workspace, f.name],
24032404
env=host_environ,
24042405
)
24052406
if result != 0:
@@ -2842,8 +2843,10 @@ def run_program(
28422843
],
28432844
}
28442845
if is_xbstrap_rootfs:
2845-
cbuild_json["subUid"] = {"auto": True, "self": container_yml["uid"]}
2846-
cbuild_json["subGid"] = {"auto": True, "self": container_yml["gid"]}
2846+
cbuild_json["mapCurrentUserTo"] = {
2847+
"uid": container_yml["uid"],
2848+
"gid": container_yml["gid"],
2849+
}
28472850
if sysroot is not None:
28482851
if verbosity:
28492852
_util.log_info(f"Bind mounting {sysroot} as sysroot")
@@ -2868,10 +2871,9 @@ def run_program(
28682871
environ, "PATH", prepend=[os.path.join(_util.find_home(), "bin")]
28692872
)
28702873

2871-
workspace = _util.find_cbuildrt_workspace()
2872-
_util.try_mkdir(workspace, recursive=True)
2874+
workspace = _util.ensure_cbuildrt_workspace()
28732875
proc = subprocess.Popen(
2874-
["cbuildrt", "--workspace", workspace, f.name],
2876+
["cbuildrt", "run", "--workspace", workspace, f.name],
28752877
env=environ,
28762878
)
28772879
proc.wait()

xbstrap/util.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import os
77
import os.path as path
88
import re
9+
import subprocess
910
import sys
1011
import urllib.parse
1112
import urllib.request
@@ -61,6 +62,20 @@ def find_cbuildrt_workspace():
6162
return os.path.join(find_cache_dir(), "cbuildrt")
6263

6364

65+
def ensure_cbuildrt_workspace():
66+
workspace = find_cbuildrt_workspace()
67+
try_mkdir(os.path.dirname(workspace), recursive=True)
68+
meta_path = os.path.join(workspace, "workspace.json")
69+
if not os.path.exists(meta_path):
70+
environ = os.environ.copy()
71+
build_environ_paths(environ, "PATH", prepend=[os.path.join(find_home(), "bin")])
72+
subprocess.check_call(
73+
["cbuildrt", "init", "--workspace", workspace],
74+
env=environ,
75+
)
76+
return workspace
77+
78+
6479
def try_mkdir(path, recursive=False):
6580
try:
6681
if not recursive:

0 commit comments

Comments
 (0)