fix(setup): skip sudo apt when the Windows toolchain is already installed
setup.sh --win ran `sudo apt-get install` (and update-alternatives) unconditionally, forcing the whole run under sudo even when mingw-w64 was already present. Running setup as root makes the daemon cross-compile run as root, leaving root-owned artifacts under external/dragonx that break `make clean` on a later non-sudo build (stale objects relink -> mingw link failure recurs). Gate the apt/update-alternatives block behind a presence check so `./setup.sh --win` runs sudo-free (and the daemon build as the invoking user) when the toolchain is already installed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
9
setup.sh
9
setup.sh
@@ -284,6 +284,14 @@ fi
|
|||||||
header "Windows Cross-Compile"
|
header "Windows Cross-Compile"
|
||||||
|
|
||||||
if $SETUP_WIN; then
|
if $SETUP_WIN; then
|
||||||
|
# Only touch apt / update-alternatives (which need sudo) when the toolchain is missing. If it is
|
||||||
|
# already installed, skip them so `./setup.sh --win` can run WITHOUT sudo — important because the
|
||||||
|
# daemon cross-compile that follows should run as the invoking user. Running the whole setup under
|
||||||
|
# sudo leaves root-owned build artifacts under external/dragonx, which then break `make clean` on
|
||||||
|
# a later non-sudo build (stale objects get relinked -> the mingw link failure recurs).
|
||||||
|
if has_cmd x86_64-w64-mingw32-g++-posix || has_cmd x86_64-w64-mingw32-g++; then
|
||||||
|
ok "Windows cross-compile toolchain already present — skipping apt install"
|
||||||
|
else
|
||||||
win_pkgs="$(get_pkgs win)"
|
win_pkgs="$(get_pkgs win)"
|
||||||
if [[ -n "$win_pkgs" ]]; then
|
if [[ -n "$win_pkgs" ]]; then
|
||||||
install_pkgs "$win_pkgs" "Windows cross-compile"
|
install_pkgs "$win_pkgs" "Windows cross-compile"
|
||||||
@@ -298,6 +306,7 @@ if $SETUP_WIN; then
|
|||||||
/usr/bin/x86_64-w64-mingw32-g++-posix 2>/dev/null || true
|
/usr/bin/x86_64-w64-mingw32-g++-posix 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Fetch libsodium for Windows
|
# Fetch libsodium for Windows
|
||||||
if [[ ! -f "$PROJECT_DIR/libs/libsodium-win/lib/libsodium.a" ]]; then
|
if [[ ! -f "$PROJECT_DIR/libs/libsodium-win/lib/libsodium.a" ]]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user