@@ -41,10 +41,14 @@ if [ ! -d "$WORK/opencode-pty-${PTY_VERSION}/.git" ]; then
4141 git clone --depth 1 --branch " v${PTY_VERSION} " https://github.com/anomalyco/opencode-pty.git " $WORK /opencode-pty-${PTY_VERSION} "
4242fi
4343for p in opencode-pty-socket-tmpdir.patch opencode-pty-buildrs-android.patch; do
44- git -C " $WORK /opencode-pty-${PTY_VERSION} " apply --check " $REPO_ROOT /patches/$p "
45- git -C " $WORK /opencode-pty-${PTY_VERSION} " apply " $REPO_ROOT /patches/$p " 2> /dev/null || true
44+ if git -C " $WORK /opencode-pty-${PTY_VERSION} " apply --reverse --check " $REPO_ROOT /patches/$p " 2> /dev/null; then
45+ echo " $p already applied, skipping"
46+ else
47+ git -C " $WORK /opencode-pty-${PTY_VERSION} " apply --check " $REPO_ROOT /patches/$p "
48+ git -C " $WORK /opencode-pty-${PTY_VERSION} " apply " $REPO_ROOT /patches/$p "
49+ fi
4650done
47- # idempotent: already-applied is fine , broken-patch is fatal (checked above)
51+ # idempotent: already-applied is skipped , broken-patch is fatal (checked above)
4852(
4953 cd " $WORK /opencode-pty-${PTY_VERSION} "
5054 rustup target add " $TARGET "
@@ -61,8 +65,12 @@ if [ ! -d "$WORK/bun-pty-${BUN_PTY_VERSION}/.git" ]; then
6165fi
6266# portable-pty 0.8 pulls termios/serial (no Android target); 0.9 uses serial2.
6367# The rust-pty code compiles unchanged (verified on-device).
64- git -C " $WORK /bun-pty-${BUN_PTY_VERSION} " apply --check " $REPO_ROOT /patches/bun-pty-portable09.patch"
65- git -C " $WORK /bun-pty-${BUN_PTY_VERSION} " apply " $REPO_ROOT /patches/bun-pty-portable09.patch" 2> /dev/null || true
68+ if git -C " $WORK /bun-pty-${BUN_PTY_VERSION} " apply --reverse --check " $REPO_ROOT /patches/bun-pty-portable09.patch" 2> /dev/null; then
69+ echo " bun-pty-portable09.patch already applied, skipping"
70+ else
71+ git -C " $WORK /bun-pty-${BUN_PTY_VERSION} " apply --check " $REPO_ROOT /patches/bun-pty-portable09.patch"
72+ git -C " $WORK /bun-pty-${BUN_PTY_VERSION} " apply " $REPO_ROOT /patches/bun-pty-portable09.patch"
73+ fi
6674(
6775 cd " $WORK /bun-pty-${BUN_PTY_VERSION} /rust-pty"
6876 rustup target add " $TARGET "
0 commit comments