49
49
BUILD_DIR = 'build'
50
50
BUNDLED_DIR = 'bundled'
51
51
SYSROOT_DIR = 'sysroot'
52
+ EXTRA_FILES = 'extra-files'
53
+ SYSROOT_CARGO_HOME = os .path .join (SYSROOT_DIR , 'cargo-home' )
52
54
BASE_FILES_DIR = 'base-files'
53
55
OVMF_FILES = ['OVMF-pure-efi.fd' ]
54
56
@@ -240,6 +242,26 @@ def build_userland_sysroot(args):
240
242
if not os .path .exists (SYSROOT_DIR ):
241
243
os .mkdir (SYSROOT_DIR )
242
244
245
+ # FIXME(xbstrap): xbstrap does not copy over the extra-files/rust/config.toml
246
+ # file into the cargo home directory.
247
+ if not os .path .exists (SYSROOT_CARGO_HOME ):
248
+ os .mkdir (SYSROOT_CARGO_HOME )
249
+
250
+ cargo_sys_cfg = os .path .join (SYSROOT_CARGO_HOME , 'config.toml' )
251
+ if not os .path .exists (cargo_sys_cfg ):
252
+ cargo_cfg_fd = open (os .path .join (
253
+ EXTRA_FILES , 'rust' , 'config.toml' ), 'r' )
254
+ cargo_cfg = cargo_cfg_fd .read ()
255
+ cargo_cfg_fd .close ()
256
+
257
+ cargo_cfg = cargo_cfg .replace ("@SOURCE_ROOT@" , os .getcwd ())
258
+ cargo_cfg = cargo_cfg .replace (
259
+ "@BUILD_ROOT@" , os .path .join (os .getcwd (), SYSROOT_DIR ))
260
+
261
+ cargo_cfg_fd = open (cargo_sys_cfg , "w+" )
262
+ cargo_cfg_fd .write (cargo_cfg )
263
+ cargo_cfg_fd .close ()
264
+
243
265
blink = os .path .join (SYSROOT_DIR , 'bootstrap.link' )
244
266
245
267
if not os .path .islink (blink ):
@@ -479,7 +501,7 @@ def get_sysctl(name: str) -> str:
479
501
if status != 0 :
480
502
print ("`sysctl` failed: " , end = "" )
481
503
print (stderr .decode ())
482
-
504
+
483
505
return stdout .strip ().decode ()
484
506
485
507
@@ -493,11 +515,11 @@ def is_kvm_supported() -> bool:
493
515
if platform == "darwin" :
494
516
# Check for VMX support
495
517
cpu_features = get_sysctl ("machdep.cpu.features" )
496
- vmx_support = "VMX" in cpu_features .split (' ' )
518
+ vmx_support = "VMX" in cpu_features .split (' ' )
497
519
498
520
# Check for HVF support
499
521
hv_support = get_sysctl ("kern.hv_support" ) == "1"
500
-
522
+
501
523
return hv_support and vmx_support
502
524
503
525
if platform == "linux" :
0 commit comments