Skip to content

Commit 0f8e559

Browse files
ADFA-5334 fix(proot-builder): fchmodat2 translation + libiconv heal so the static bundle builds
- proot: translate fchmodat2 (452) like fchmodat (mirrors faccessat2), in the sysnums-*.h tables + enter.c. On glibc>=2.39/kernel>=6.6 hosts libc restores dir modes via 452; the bundled proot passed it through untranslated, so recursive copies (tar -x/cp -a) failed under proot and every rootfs tier landed on HOLD. Inert on kernel<6.6. Design: docs/ADR-5334-proot-fchmodat2-perms-restore.md. - proot-builder: force the libiconv/libpopt rebuild in the rsync step -- the tar block deletes libiconv.so and the cached "healing" rebuild was skipped on partial builds, so libpopt failed to link -liconv. No architecture changes (ARCHS untouched).
1 parent 0a8b4ee commit 0f8e559

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

‎tools/proot-builder/build_static.sh‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,19 @@ int __android_log_write(int prio, const char* tag, const char* text) { return 0;
137137
STUB
138138
fi
139139
140+
# --- ADFA-5334 (ADR-5334): translate fchmodat2 (452) like fchmodat, mirroring faccessat2. ---
141+
# glibc>=2.39 restores directory modes via fchmodat2; proot passes it through untranslated, so
142+
# recursive perms-preserving copies (tar -x / cp -a) fail under proot on kernel>=6.6 build hosts.
143+
local sysdir="$TERMUX_PKG_SRCDIR/src/syscall"
144+
grep -q 'SYSNUM(fchmodat2)' "$sysdir/sysnums.list" || \
145+
sed -i '/^SYSNUM(fchmodat)$/a SYSNUM(fchmodat2)' "$sysdir/sysnums.list"
146+
grep -q 'case PR_fchmodat2:' "$sysdir/enter.c" || \
147+
sed -i 's/^\([[:space:]]*\)case PR_fchmodat:$/\1case PR_fchmodat:\n\1case PR_fchmodat2:/' "$sysdir/enter.c"
148+
for h in "$sysdir"/sysnums-*.h; do
149+
grep -q 'PR_fchmodat2' "$h" && continue
150+
grep -q 'PR_faccessat2' "$h" && sed -i 's/^\([[:space:]]*\)\[ 439 \] = PR_faccessat2,/&\n\1[ 452 ] = PR_fchmodat2,/' "$h"
151+
done
152+
140153
LDFLAGS+=" -static -ffunction-sections -fdata-sections -Wl,--gc-sections"
141154
CFLAGS+=" -static"
142155
}
@@ -441,7 +454,10 @@ for mapping in "${ARCHS[@]}"; do
441454
else
442455
echo ">> Healing sysroot and Building Rsync..."
443456
FORCE_FLAG=$([ "$REBUILD_RSYNC" -eq 1 ] && echo "-f" || echo "")
444-
./scripts/run-docker.sh ./build-package.sh $FORCE_FLAG -a "$TERMUX_ARCH" libiconv libpopt
457+
# ADFA-5334: the TAR block deletes libiconv.so to force static tar; libiconv is then cached, so
458+
# this "healing" rebuild is skipped WITHOUT -f and libpopt fails to link -liconv. Force it so
459+
# libiconv.so is actually restored before libpopt/rsync link (completes the sysroot-healing intent).
460+
./scripts/run-docker.sh ./build-package.sh -f -a "$TERMUX_ARCH" libiconv libpopt
445461
./scripts/run-docker.sh ./build-package.sh $FORCE_FLAG -a "$TERMUX_ARCH" rsync
446462

447463
EXTRACT_DIR="$BUILD_DIR/extract_${TERMUX_ARCH}_rsync"

0 commit comments

Comments
 (0)