Merge sp/adbd-tcp-off into sprint [skip ci]

Brings the adbd branch commits made after the earlier merge d1011ce: 3baa28a (source tarballs in the gate inputs), 5dd20f0 (gate comment) and 70ce85a (0015 index line). Merge base is d1011ce, so the merge has no conflicts.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B1W6qGNpGNtFT7nhShpH56
This commit is contained in:
BFE Engineering
2026-11-12 05:24:31 -06:00
co-authored by Claude Haiku 5.5
4 changed files with 57 additions and 23 deletions
+5 -4
View File
@@ -109,7 +109,8 @@ applying the patches, then stages `buildroot/files/` and applies
a copy of the base tree and runs the android-tools rule of the Makefile under
make. It checks the adbd TCP listener removal (flare-edge#3129), the rule's
fail-closed behaviour (bfe-core1106-sdk#45) and the adbd rebuild gate as the
Makefile evaluates it (bfe-core1106-sdk#44, #46). `BASE_DIR` is the luckfox base
Makefile evaluates it, including a changed source tarball (bfe-core1106-sdk#44,
#46, #49). `BASE_DIR` is the luckfox base
commit 824b817f8, `sysdrv/tools/board/android-tools` only:
git -C <luckfox-sdk> archive 824b817f8 sysdrv/tools/board/android-tools | tar -C BASE_DIR -xf -
@@ -119,7 +120,7 @@ commit 824b817f8, `sysdrv/tools/board/android-tools` only:
The toolchain is a stub: the compiler stub only creates its output file, so
nothing is compiled. Run the test with `none` as the patch file to see the base
fail. `adbd-no-tcp-cases.sh` runs the real patch (must pass), the unpatched base
and three mutants of the patch (each must fail for the reason it names).
and four mutants of the patch (each must fail for the reason it names).
## Completeness check
@@ -326,8 +327,8 @@ calls from the device half of `adb_main()` and runs last in
It also changes the Makefile gate. adbd was rebuilt only when `out/usr/bin/adbd`
was missing, so a patch-set change never reached an SDK tree that already held
the binary (bfe-core1106-sdk#44). `adbd-current.sh` now compares a stamp in
`out/.adbd-inputs` with a hash of the Makefile, the gate script and the patch
set, and the build writes that stamp.
`out/.adbd-inputs` with a hash of the Makefile, the gate script, the patch set
and the two adbd source tarballs, and the build writes that stamp.
The rule now stops at the first failed step (a debian series entry, an
`android-tools.patch.sh` step run with `-e`, the build, or the copy into
@@ -15,8 +15,8 @@ It also closes a build gap (bfe-core1106-sdk#44). The Makefile rebuilt adbd
only when out/usr/bin/adbd was missing, so a patch-set change never reached an
image built on an SDK tree that already held the binary. The Makefile now
gates adbd on adbd-current.sh: the build writes a stamp holding a hash of the
Makefile, the gate script and the patch set, and a missing or stale stamp
rebuilds adbd.
Makefile, the gate script, the patch set and the two adbd source tarballs, and
a missing or stale stamp rebuilds adbd (bfe-core1106-sdk#49).
The rule stops at the first failed step: a debian series entry, an
android-tools.patch.sh step (run with -e), the build, or the copy into
@@ -25,12 +25,12 @@ the patch set gets one (bfe-core1106-sdk#45).
Regression tests: luckfox-sdk-patches/tests/test-adbd-no-tcp.sh runs the rule
under make with stub toolchains. It checks the listeners, the fail-closed
cases, the stamp and the gate that the Makefile evaluates (bfe-core1106-sdk#46).
tests/adbd-no-tcp-cases.sh runs the real patch, the unpatched base and mutants
that must fail.
cases, the stamp, a source tarball change and the gate that the Makefile
evaluates (bfe-core1106-sdk#46, #49). tests/adbd-no-tcp-cases.sh runs the real
patch, the unpatched base and mutants that must fail.
diff --git a/sysdrv/tools/board/android-tools/Makefile b/sysdrv/tools/board/android-tools/Makefile
index bb72255..889e983 100644
index bb72255..7ec24f7 100644
--- a/sysdrv/tools/board/android-tools/Makefile
+++ b/sysdrv/tools/board/android-tools/Makefile
@@ -23,6 +23,15 @@ PKG_TARBALL_DEBIAN := android-tools_4.2.2+git20130218-3ubuntu41.debian.tar.gz
@@ -38,13 +38,13 @@ index bb72255..889e983 100644
PKG_INSTALL_BIN_DIR := $(CURRENT_DIR)/$(PKG_BIN)/usr/bin
+# flare-edge#3129: adbd is rebuilt whenever its inputs change. The stamp holds
+# the hash of this Makefile, adbd-current.sh and the android-tools patch set.
+# An adbd without a matching stamp (left in out/ by a build from other patches)
+# is built again from the regenerated source. Every step below stops the rule
+# when it fails, and the stamp is written last, so no binary that was not built
+# from the patch set gets one (bfe-core1106-sdk#45).
+# the hash of this Makefile, adbd-current.sh, the android-tools patch set and
+# the two adbd source tarballs. An adbd without a matching stamp (left in out/
+# by a build from other inputs) is built again from the regenerated source.
+# The series, patch, build and copy steps stop the rule on failure; the stamp is
+# written last, so no binary that was not built from these inputs gets one (bfe-core1106-sdk#45).
+ADBD_STAMP := $(CURRENT_DIR)/$(PKG_BIN)/.adbd-inputs
+ADBD_INPUTS := $(shell cat $(CURRENT_DIR)/Makefile $(CURRENT_DIR)/adbd-current.sh $(CURRENT_DIR)/$(PKG_PATCHES_ANDROID_TOOLS)/* | sha256sum | cut -d' ' -f1)
+ADBD_INPUTS := $(shell cat $(CURRENT_DIR)/Makefile $(CURRENT_DIR)/adbd-current.sh $(CURRENT_DIR)/$(PKG_PATCHES_ANDROID_TOOLS)/* $(CURRENT_DIR)/$(PKG_TARBALL_ANDROID_TOOLS) $(CURRENT_DIR)/$(PKG_TARBALL_DEBIAN) | sha256sum | cut -d' ' -f1)
+
PKG_DEP_OPENSSL := $(CURRENT_DIR)/../toolkits/openssl
PKG_DEP_ZLIB := $(CURRENT_DIR)/../toolkits/zlib
+13 -1
View File
@@ -2,7 +2,7 @@
# adbd-no-tcp-cases.sh BASE_DIR PATCH_FILE
#
# Runs test-adbd-no-tcp.sh on the real patch (must PASS), on the unpatched base
# (must FAIL), and on three mutants of the patch. Each mutant must FAIL, and its
# (must FAIL), and on four mutants of the patch. Each mutant must FAIL, and its
# FAIL line must name the reason given here:
# gate-makefile-only ADBD_INPUTS hashes only the Makefile; the patch set and
# the gate script are dropped (bfe-core1106-sdk#46)
@@ -10,6 +10,8 @@
# so a failed 0017 hunk still stamps adbd (bfe-core1106-sdk#45)
# copy-unchecked only the copy into out/usr/bin is unchecked, so a failed
# copy still writes the stamp (bfe-core1106-sdk#45)
# gate-no-tarballs ADBD_INPUTS drops the two source tarballs, so a changed
# tarball keeps a stale adbd (bfe-core1106-sdk#49)
# Usage and layout: see test-adbd-no-tcp.sh.
# Exit 0 when every case behaves as expected, 1 otherwise, 2 on usage.
set -u
@@ -74,6 +76,10 @@ cat > "$WORK/copy-unchecked.sed" <<'SEDEOF'
}
SEDEOF
cat > "$WORK/gate-no-tarballs.sed" <<'SEDEOF'
s#^+ADBD_INPUTS := .*$#+ADBD_INPUTS := $(shell cat $(CURRENT_DIR)/Makefile $(CURRENT_DIR)/adbd-current.sh $(CURRENT_DIR)/$(PKG_PATCHES_ANDROID_TOOLS)/* | sha256sum | cut -d' ' -f1)#
SEDEOF
expect 0 "real patch" "$PATCH"
expect 1 "unpatched base" none
if mutant gate-makefile-only; then
@@ -92,6 +98,12 @@ else
bad "mutant copy-unchecked does not change the patch"
fi
if mutant gate-no-tarballs; then
expect 1 "mutant gate-no-tarballs" "$WORK/gate-no-tarballs.patch" "ADBD_INPUTS is"
else
bad "mutant gate-no-tarballs does not change the patch"
fi
if [ "$fail" = 0 ]; then
echo "RESULT PASS"
exit 0
+27 -6
View File
@@ -5,7 +5,8 @@
# 127.0.0.1:5037), bfe-core1106-sdk#44 (a change to the adbd patch set never
# reached the image), bfe-core1106-sdk#45 (a failed patch or copy step still
# stamped adbd current) and bfe-core1106-sdk#46 (the gate was tested by a copy
# of its formula instead of by the Makefile).
# of its formula instead of by the Makefile) and bfe-core1106-sdk#49 (a changed
# source tarball did not rebuild adbd).
#
# BASE_DIR holds sysdrv/tools/board/android-tools at the luckfox base commit
# 824b817f8, as in the vendor checkout:
@@ -154,16 +155,16 @@ else
fi
# 4. The gate, as the Makefile evaluates it: ADBD_INPUTS must be the sha256 of
# the Makefile, adbd-current.sh and the patch set, the three inputs that the
# stamp must match.
# the Makefile, adbd-current.sh, the patch set and the two adbd source
# tarballs, the five inputs that the stamp must match.
# shellcheck disable=SC2016 # the make text must reach make unexpanded
printf '%s\n' '$(info ADBD_INPUTS=$(ADBD_INPUTS))' > "$WORK/probe.mk" || exit 2
probe=$(cd "$GOOD" && make -s -f Makefile -f "$WORK/probe.mk" SYSDRV_PARAM=/dev/null no-such-target 2>/dev/null | sed -n 's/^ADBD_INPUTS=//p')
want=$(cd "$AT" && cat Makefile adbd-current.sh android-tools-patches/* 2>/dev/null | sha256sum | cut -d' ' -f1)
want=$(cd "$AT" && cat Makefile adbd-current.sh android-tools-patches/* android-tools_4.2.2+git20130218.orig.tar.xz android-tools_4.2.2+git20130218-3ubuntu41.debian.tar.gz 2>/dev/null | sha256sum | cut -d' ' -f1)
if [ -n "$probe" ] && [ "$probe" = "$want" ]; then
pass "ADBD_INPUTS is the sha256 of Makefile, adbd-current.sh and the patch set"
pass "ADBD_INPUTS is the sha256 of Makefile, adbd-current.sh, the patch set and the source tarballs"
else
bad "ADBD_INPUTS is '$probe', want '$want' (sha256 of Makefile, adbd-current.sh and the patch set)"
bad "ADBD_INPUTS is '$probe', want '$want' (sha256 of Makefile, adbd-current.sh, the patch set and the source tarballs)"
fi
# 5. The rule itself: a matching stamp with adbd present skips the build, and a
@@ -194,6 +195,26 @@ else
bad "rule did not rebuild adbd without a stamp (rc $RC, compiler runs $CC_RUNS)"
fi
# 5b. The source tarballs are inputs too: a changed tarball must rebuild adbd
# when the Makefile, the gate script and the patch set are unchanged.
D=$(case_at tarball) || exit 2
run_make "$D" "$WORK/tarball-built.log"
first_built=0
if [ "$RC" = 0 ] && [ "$CC_RUNS" -gt 0 ]; then first_built=1; fi
t=$D/android-tools_4.2.2+git20130218-3ubuntu41.debian.tar.gz
tb=$WORK/tarball-edit
rm -rf "$tb" && mkdir -p "$tb" || exit 2
if [ "$first_built" = 1 ] && tar -xzf "$t" -C "$tb" && : > "$tb/debian/.tarball-changed" && tar -czf "$t.new" -C "$tb" debian && mv "$t.new" "$t"; then
run_make "$D" "$WORK/tarball.log"
if [ "$RC" = 0 ] && [ "$CC_RUNS" -gt 0 ]; then
pass "rule rebuilds adbd when a source tarball changes"
else
bad "rule did not rebuild adbd after a source tarball change (rc $RC, compiler runs $CC_RUNS)"
fi
else
bad "could not build the tarball case (first build or tarball edit failed)"
fi
# 6. Fail closed. An injected failure must stop the rule with a non-zero status
# and leave no stamp. The failures before the compile step must also stop the
# rule before the compiler runs.