From 7210f43f50b31e373815a1f4c9261557993b54c9 Mon Sep 17 00:00:00 2001 From: Aiden McClelland Date: Fri, 14 Nov 2025 19:00:33 -0700 Subject: [PATCH] build and efi fixes --- core/build-cli.sh | 5 ++++- core/build-containerbox.sh | 7 ++++++- core/build-registrybox.sh | 7 ++++++- core/build-startbox.sh | 7 ++++++- core/build-ts.sh | 7 ++++++- core/build-tunnelbox.sh | 7 ++++++- core/startos/src/disk/util.rs | 3 +++ core/startos/src/os_install/mod.rs | 5 ++++- core/startos/src/update/mod.rs | 7 +++++++ debian/startos/postinst | 1 - 10 files changed, 48 insertions(+), 8 deletions(-) diff --git a/core/build-cli.sh b/core/build-cli.sh index 57d5ed2c1..82159f743 100755 --- a/core/build-cli.sh +++ b/core/build-cli.sh @@ -60,4 +60,7 @@ fi echo "FEATURES=\"$FEATURES\"" echo "RUSTFLAGS=\"$RUSTFLAGS\"" -rust-zig-builder cargo zigbuild --manifest-path=./core/Cargo.toml $BUILD_FLAGS --no-default-features --features $FEATURE_ARGS --locked --bin start-cli --target=$TARGET \ No newline at end of file +rust-zig-builder cargo zigbuild --manifest-path=./core/Cargo.toml $BUILD_FLAGS --no-default-features --features $FEATURE_ARGS --locked --bin start-cli --target=$TARGET +if [ "$(ls -nd "core/target/$TARGET/release/start-cli" | awk '{ print $3 }')" != "$UID" ]; then + rust-zig-builder sh -c "cd core && chown -R $UID:$UID target && chown -R $UID:$UID /root/.cargo" +fi \ No newline at end of file diff --git a/core/build-containerbox.sh b/core/build-containerbox.sh index efa0f6fce..dc439e833 100755 --- a/core/build-containerbox.sh +++ b/core/build-containerbox.sh @@ -2,6 +2,8 @@ cd "$(dirname "${BASH_SOURCE[0]}")" +source ./builder-alias.sh + set -ea shopt -s expand_aliases @@ -33,4 +35,7 @@ fi echo "FEATURES=\"$FEATURES\"" echo "RUSTFLAGS=\"$RUSTFLAGS\"" -cross build --manifest-path=./core/Cargo.toml $BUILD_FLAGS --no-default-features --features cli-container,$FEATURES --locked --bin containerbox --target=$RUST_ARCH-unknown-linux-musl \ No newline at end of file +rust-zig-builder cargo zigbuild --manifest-path=./core/Cargo.toml $BUILD_FLAGS --no-default-features --features cli-container,$FEATURES --locked --bin containerbox --target=$RUST_ARCH-unknown-linux-musl +if [ "$(ls -nd "core/target/$RUST_ARCH-unknown-linux-musl/release/containerbox" | awk '{ print $3 }')" != "$UID" ]; then + rust-zig-builder sh -c "chown -R $UID:$UID core/target && chown -R $UID:$UID /root/.cargo" +fi \ No newline at end of file diff --git a/core/build-registrybox.sh b/core/build-registrybox.sh index ec6630d0f..9add8f3e8 100755 --- a/core/build-registrybox.sh +++ b/core/build-registrybox.sh @@ -2,6 +2,8 @@ cd "$(dirname "${BASH_SOURCE[0]}")" +source ./builder-alias.sh + set -ea shopt -s expand_aliases @@ -33,4 +35,7 @@ fi echo "FEATURES=\"$FEATURES\"" echo "RUSTFLAGS=\"$RUSTFLAGS\"" -cross build --manifest-path=./core/Cargo.toml $BUILD_FLAGS --no-default-features --features cli-registry,registry,$FEATURES --locked --bin registrybox --target=$RUST_ARCH-unknown-linux-musl +rust-zig-builder cargo zigbuild --manifest-path=./core/Cargo.toml $BUILD_FLAGS --no-default-features --features cli-registry,registry,$FEATURES --locked --bin registrybox --target=$RUST_ARCH-unknown-linux-musl +if [ "$(ls -nd "core/target/$RUST_ARCH-unknown-linux-musl/release/registrybox" | awk '{ print $3 }')" != "$UID" ]; then + rust-zig-builder sh -c "chown -R $UID:$UID core/target && chown -R $UID:$UID /root/.cargo" +fi \ No newline at end of file diff --git a/core/build-startbox.sh b/core/build-startbox.sh index 655566879..66b5cb35c 100755 --- a/core/build-startbox.sh +++ b/core/build-startbox.sh @@ -2,6 +2,8 @@ cd "$(dirname "${BASH_SOURCE[0]}")" +source ./builder-alias.sh + set -ea shopt -s expand_aliases @@ -33,4 +35,7 @@ fi echo "FEATURES=\"$FEATURES\"" echo "RUSTFLAGS=\"$RUSTFLAGS\"" -cross build --manifest-path=./core/Cargo.toml $BUILD_FLAGS --no-default-features --features cli,startd,$FEATURES --locked --bin startbox --target=$RUST_ARCH-unknown-linux-musl +rust-zig-builder cargo zigbuild --manifest-path=./core/Cargo.toml $BUILD_FLAGS --no-default-features --features cli,startd,$FEATURES --locked --bin startbox --target=$RUST_ARCH-unknown-linux-musl +if [ "$(ls -nd "core/target/$RUST_ARCH-unknown-linux-musl/release/startbox" | awk '{ print $3 }')" != "$UID" ]; then + rust-zig-builder sh -c "chown -R $UID:$UID core/target && chown -R $UID:$UID /root/.cargo" +fi \ No newline at end of file diff --git a/core/build-ts.sh b/core/build-ts.sh index e29a43a66..c62fe165d 100755 --- a/core/build-ts.sh +++ b/core/build-ts.sh @@ -2,6 +2,8 @@ cd "$(dirname "${BASH_SOURCE[0]}")" +source ./builder-alias.sh + set -ea shopt -s expand_aliases @@ -31,4 +33,7 @@ if [[ "${ENVIRONMENT}" =~ (^|-)console($|-) ]]; then fi echo "FEATURES=\"$FEATURES\"" echo "RUSTFLAGS=\"$RUSTFLAGS\"" -cross test --manifest-path=./core/Cargo.toml $BUILD_FLAGS --no-default-features --features test,$FEATURES --locked 'export_bindings_' +rust-zig-builder cargo test --manifest-path=./core/Cargo.toml $BUILD_FLAGS --no-default-features --features test,$FEATURES --locked 'export_bindings_' +if [ "$(ls -nd "core/startos/bindings" | awk '{ print $3 }')" != "$UID" ]; then + rust-zig-builder sh -c "chown -R $UID:$UID core/target chown -R $UID:$UID core/startos/bindings && chown -R $UID:$UID /root/.cargo" +fi \ No newline at end of file diff --git a/core/build-tunnelbox.sh b/core/build-tunnelbox.sh index da662c9b7..f89208ccb 100755 --- a/core/build-tunnelbox.sh +++ b/core/build-tunnelbox.sh @@ -2,6 +2,8 @@ cd "$(dirname "${BASH_SOURCE[0]}")" +source ./builder-alias.sh + set -ea shopt -s expand_aliases @@ -33,4 +35,7 @@ fi echo "FEATURES=\"$FEATURES\"" echo "RUSTFLAGS=\"$RUSTFLAGS\"" -cross build --manifest-path=./core/Cargo.toml $BUILD_FLAGS --no-default-features --features cli-tunnel,tunnel,$FEATURES --locked --bin tunnelbox --target=$RUST_ARCH-unknown-linux-musl +rust-zig-builder cargo zigbuild --manifest-path=./core/Cargo.toml $BUILD_FLAGS --no-default-features --features cli-tunnel,tunnel,$FEATURES --locked --bin tunnelbox --target=$RUST_ARCH-unknown-linux-musl +if [ "$(ls -nd "core/target/$RUST_ARCH-unknown-linux-musl/release/tunnelbox" | awk '{ print $3 }')" != "$UID" ]; then + rust-zig-builder sh -c "chown -R $UID:$UID core/target && chown -R $UID:$UID /root/.cargo" +fi \ No newline at end of file diff --git a/core/startos/src/disk/util.rs b/core/startos/src/disk/util.rs index a6b5bea39..596b31f2b 100644 --- a/core/startos/src/disk/util.rs +++ b/core/startos/src/disk/util.rs @@ -280,6 +280,9 @@ pub async fn list(os: &OsPartitionInfo) -> Result, Error> { .try_fold( BTreeMap::::new(), |mut disks, dir_entry| async move { + if dir_entry.file_type().await?.is_dir() { + return Ok(disks); + } if let Some(disk_path) = dir_entry.path().file_name().and_then(|s| s.to_str()) { let (disk_path, part_path) = if let Some(end) = PARTITION_REGEX.find(disk_path) { ( diff --git a/core/startos/src/os_install/mod.rs b/core/startos/src/os_install/mod.rs index 7b5609b6a..3581eaa50 100644 --- a/core/startos/src/os_install/mod.rs +++ b/core/startos/src/os_install/mod.rs @@ -356,7 +356,10 @@ pub async fn execute( let mut install = Command::new("chroot"); install.arg(overlay.path()).arg("grub-install"); if tokio::fs::metadata("/sys/firmware/efi").await.is_err() { - install.arg("--target=i386-pc"); + match ARCH { + "x86_64" => install.arg("--target=i386-pc"), + _ => &mut install, + }; } else { match ARCH { "x86_64" => install.arg("--target=x86_64-efi"), diff --git a/core/startos/src/update/mod.rs b/core/startos/src/update/mod.rs index 635ab59c1..a14c86fc9 100644 --- a/core/startos/src/update/mod.rs +++ b/core/startos/src/update/mod.rs @@ -1,4 +1,5 @@ use std::collections::BTreeMap; +use std::env::consts::ARCH; use std::path::Path; use std::time::Duration; @@ -498,6 +499,12 @@ async fn do_update( None }; + Command::new("chroot") + .arg(root_guard.path()) + .arg("grub-install") + .invoke(crate::ErrorKind::Grub) + .await?; + Command::new("chroot") .arg(root_guard.path()) .arg("update-grub2") diff --git a/debian/startos/postinst b/debian/startos/postinst index cca71d3e8..afc71cb5f 100755 --- a/debian/startos/postinst +++ b/debian/startos/postinst @@ -122,7 +122,6 @@ ln -sf /usr/lib/startos/scripts/wireguard-vps-proxy-setup /usr/bin/wireguard-vps echo "fs.inotify.max_user_watches=1048576" > /etc/sysctl.d/97-startos.conf -locale-gen en_US.UTF-8 dpkg-reconfigure --frontend noninteractive locales if ! getent group | grep '^startos:'; then