From 814270125d489af06bd9ab44c5d4f214ab630cdb Mon Sep 17 00:00:00 2001 From: designgears Date: Sun, 6 Dec 2026 00:15:34 -0700 Subject: [PATCH 1/2] AppRun: launchers started together no longer fail on the version links (#205) ln -sfn unlinks the old link and then creates the new one: a second launcher in between got EEXIST, which set -e turned into an exit. The setup now runs under a flock on the data dir, links are re-pointed only when their target changed and then replaced in one rename, and the payload/Darling copies use per-process temporary names. Fixes #205 Co-Authored-By: Claude Opus 5.5 --- build/release/AppRun | 49 ++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/build/release/AppRun b/build/release/AppRun index bb489c6b..1ab1f715 100755 --- a/build/release/AppRun +++ b/build/release/AppRun @@ -35,22 +35,32 @@ CACHE=$(legacy "${X86SIM_CACHE:-}" "$CACHE") [ -f "$DATA/x86sim.env" ] && grep -q X86CODE_ "$DATA/x86sim.env" && sed -i 's/X86CODE_/X86SIM_/g' "$DATA/x86sim.env" APP=$DATA/app/$VER mkdir -p "$DATA/app" "$DATA/runtimes" "$DATA/var" "$CACHE" +# launchers started together (one x86sim test per phone, #205) set up one at a time: the payload copy and the links +# below are not safe to run twice at once; the lock is let go before the command runs +if command -v flock > /dev/null 2>&1; then exec 9> "$DATA/.launch.lock"; flock 9; fi +# point link $2 at $1: left alone when it already does, else replaced in one rename (ln -sfn unlinks, then creates: +# a launcher in between failed with "Already exists") +relink() { + [ -L "$2" ] && [ "$(readlink "$2")" = "$1" ] && return 0 + ln -sfn "$1" "$2.$$" && mv -Tf "$2.$$" "$2" +} if [ ! -f "$APP/.complete" ] || [ -n "${X86SIM_REFRESH_PAYLOAD:-}" ]; then - rm -rf "$APP.tmp" - mkdir -p "$APP.tmp" - cp -a "$S/payload/." "$APP.tmp/" - cp -a "$S/bin" "$S/licenses" "$S/VERSION" "$S/DARLING_ID" "$S/install-helper.sh" "$APP.tmp/" + T=$APP.tmp.$$ + rm -rf "$T" + mkdir -p "$T" + cp -a "$S/payload/." "$T/" + cp -a "$S/bin" "$S/licenses" "$S/VERSION" "$S/DARLING_ID" "$S/install-helper.sh" "$T/" # x86sim inspect's frontend (share/inspect.rs finds it at /webinspector) - [ ! -d "$S/webinspector" ] || cp -a "$S/webinspector" "$APP.tmp/" - touch "$APP.tmp/.complete" + [ ! -d "$S/webinspector" ] || cp -a "$S/webinspector" "$T/" + touch "$T/.complete" rm -rf "$APP" - mv "$APP.tmp" "$APP" + mv "$T" "$APP" # keep this version and the one before (by modification time) ls -1dt "$DATA"/app/*/ 2>/dev/null | tail -n +3 | while read -r d; do rm -rf "$d"; done fi for d in cli host linux tools tests; do [ -e "$APP/$d" ] || continue - if [ -L "$DATA/$d" ] || [ ! -e "$DATA/$d" ]; then ln -sfn "app/$VER/$d" "$DATA/$d"; fi + if [ -L "$DATA/$d" ] || [ ! -e "$DATA/$d" ]; then relink "app/$VER/$d" "$DATA/$d"; fi done # Darling: "system" = installed by the setup wizard into /opt/x86sim (bin/darling setuid root, one password prompt); # "userns" = no root at all, through an unprivileged user namespace (darling-userns.sh); "nonroot" = no root and no @@ -77,20 +87,22 @@ fi case $mode in system|userns|nonroot) ;; *) echo "x86sim: X86SIM_DARLING_MODE=$mode: use system, userns or nonroot" >&2; exit 1 ;; esac if [ "$mode" = userns ] || [ "$mode" = nonroot ]; then if [ ! -f "$APP/darling/.x86sim-copied" ]; then - rm -rf "$APP/darling.tmp" - cp -a "$S/darling" "$APP/darling.tmp" + T=$APP/darling.tmp.$$ + rm -rf "$T" + cp -a "$S/darling" "$T" # bin/darling is setuid in the payload (for the system install); here it must not be: as root in a container # whose AppImage was unpacked by another uid it ran as that uid, and Darling refused a launcher with privileges # but not root ("started with privileges, but not as root", #13) - chmod -R u-s,g-s "$APP/darling.tmp" - touch "$APP/darling.tmp/.x86sim-copied" - mv "$APP/darling.tmp" "$APP/darling" + chmod -R u-s,g-s "$T" + touch "$T/.x86sim-copied" + mv "$T" "$APP/darling" fi U=$APP/darling-$mode mkdir -p "$U/bin" - cp "$S/darling-$mode.sh" "$U/bin/darling" - ln -sfn ../../darling/bin/darlingserver "$U/bin/darlingserver" - ln -sfn ../darling/libexec "$U/libexec" + # a running phone's darling reads this script: a new copy goes in by rename, never by rewriting it in place + cp "$S/darling-$mode.sh" "$U/bin/darling.$$" && mv -f "$U/bin/darling.$$" "$U/bin/darling" + relink ../../darling/bin/darlingserver "$U/bin/darlingserver" + relink ../darling/libexec "$U/libexec" echo "$DID" > "$U/.x86sim-complete" : > "$U/.x86sim-$mode" target=app/$VER/darling-$mode @@ -99,14 +111,15 @@ else fi # relative (as every link here): Darling sees these paths under /Volumes/SystemRoot, where an absolute target would # resolve against the container's own root -if [ -L "$DATA/darling-prefix" ] || [ ! -e "$DATA/darling-prefix" ]; then ln -sfn "$target" "$DATA/darling-prefix"; fi +if [ -L "$DATA/darling-prefix" ] || [ ! -e "$DATA/darling-prefix" ]; then relink "$target" "$DATA/darling-prefix"; fi # the app menu entry (tools/launcher/core/src/desktop.rs) runs $DATA/x86sim.AppImage: follow this AppImage wherever it # is now (moved, renamed, a newer version started from elsewhere), when the entry is x86Sim's if [ -n "${APPIMAGE:-}" ] && [ -f "$APPIMAGE" ] && [ -L "$DATA/x86sim.AppImage" ] && grep -qx 'X-X86Sim-Managed=true' "${XDG_DATA_HOME:-$HOME/.local/share}/applications/x86sim.desktop" 2>/dev/null && [ "$(readlink "$DATA/x86sim.AppImage")" != "$APPIMAGE" ]; then - ln -sfn "$APPIMAGE" "$DATA/x86sim.AppImage.new" && mv -Tf "$DATA/x86sim.AppImage.new" "$DATA/x86sim.AppImage" + relink "$APPIMAGE" "$DATA/x86sim.AppImage" fi +exec 9>&- export X86SIM_DARLING_MODE=$mode # NixOS keeps the Vulkan drivers in /run/opengl-driver/share/vulkan/icd.d, which the loader finds only through # XDG_DATA_DIRS (#35): without it mtlvk drew on the CPU From ba18d9ff8b8ba504bce598670206e220904685a8 Mon Sep 17 00:00:00 2001 From: "ios-linux-sync[bot]" Date: Sun, 6 Dec 2026 07:56:34 +0000 Subject: [PATCH 2/2] chore(sync): record upstream metadata for x86sim/x86sim@b2f8208fe06d --- .github/upstream-sync-state.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/upstream-sync-state.json b/.github/upstream-sync-state.json index dc50a12a..8f55a259 100644 --- a/.github/upstream-sync-state.json +++ b/.github/upstream-sync-state.json @@ -1,10 +1,10 @@ { "upstream_repo": "x86sim/x86sim", "upstream_branch": "main", - "upstream_sha": "f2a18dd1a6ac3cbfdc12516f0d1b1332e30c2b13", + "upstream_sha": "b2f8208fe06d6d3c5c94c0f3711b19564990dcff", "maintained_branch": "main", - "maintained_base_sha": "592dfa86fc1c9be5e85f6fb26e732dce3f5fd454", - "commits_merged": 6, + "maintained_base_sha": "75472c8fca5cb3e078f9d587e7750288ecb6914e", + "commits_merged": 2, "latest_upstream_release": "v0.11.0", "recent_upstream_releases": [ { @@ -43,6 +43,6 @@ "url": "https://github.com/x86sim/x86sim/releases/tag/v0.9.0" } ], - "synced_at_utc": "2026-12-05T18:54:31.291624+00:00", + "synced_at_utc": "2026-12-06T07:56:33.169858+00:00", "status": "pending_review" }