Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions tests/make-bundle
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,27 @@ grep -c "install link line this tool does not know" <<<"$out" >/dev/null || fail
cp "$t/MANIFEST.saved" "$mf"
pass "manifest.json's install_link: only for an image built for the link, with its protocol"

# The install plan writes only slot B's five boot images and userdata
# (AGENTS.md §1): a descriptor whose BOOT_IMAGES or UFS_RW names any other
# partition, here with its own allowlist entry beside it, stops the bundle
# with the name, and the earlier bundle stays
conf=$r/device/testdev/device.conf
descriptor() { printf 'CODENAME=testdev\nNAME="Test device"\nBOOT_IMAGES="%s"\nUFS_RW="%s"\n' "$1" "$2" > "$conf"; }
printf modem > "$k/images/modem.img"
printf vbmeta > "$k/images/vbmeta.img"
before=$(cd "$b" && sha256sum SHA256SUMS)
for c in "boot dtbo modem|boot_b dtbo_b modem_b userdata|BOOT_IMAGES.* not modem" \
"boot dtbo vbmeta|boot_b dtbo_b vbmeta_b userdata|BOOT_IMAGES.* not vbmeta" \
"boot dtbo|boot_b dtbo_b modem_b userdata|UFS_RW.* not modem_b"; do
IFS='|' read -r images rw says <<<"$c"
descriptor "$images" "$rw"
if out=$(bundle); then fail "BOOT_IMAGES=\"$images\" UFS_RW=\"$rw\" stops the bundle: it wrote $(grep -o '"partition": "[a-z_]*"' "$b/manifest.json" | cut -d'"' -f4 | xargs)"; fi
grep -cE "^bundle-manifest: .*$says\$" <<<"$out" >/dev/null || fail "the refusal names the partition ($says): $out"
[[ $(cd "$b" && sha256sum SHA256SUMS) == "$before" ]] && intact || fail "a refused descriptor leaves the bundle as it was"
done
descriptor "boot dtbo" "boot_b dtbo_b userdata"
pass "a descriptor naming modem, vbmeta or modem_b stops the bundle, and the earlier bundle stays"

# Format 1, for every device today (no INSTALL_SLOT): manifest.json's install
# plan and README.txt's two slot paragraphs as they were before format 2
python3 -I - "$b/manifest.json" <<'PY' || fail "a slot-B bundle's install plan is format 1's, unchanged"
Expand Down
19 changes: 10 additions & 9 deletions tools/bundle-manifest
Original file line number Diff line number Diff line change
Expand Up @@ -312,18 +312,19 @@ def main():
"never": NEVER,
}
fmt = FORMAT
# The only images and guard names a release may carry, in either format
# (bin/omamobile's UFS_RW_ALLOWED): never vbmeta, abl or modem, which
# would be written as slot B's image (format 1) or as the running slot's
# live image (format 2)
for p in boot_images:
if p not in IMAGES_ACTIVE:
die("BOOT_IMAGES may hold only %s, not %s" % (" ".join(IMAGES_ACTIVE), p))
for p in allow:
if p not in [i + "_b" for i in IMAGES_ACTIVE] + ["userdata"]:
die("UFS_RW may hold only slot B boot images and userdata, not %s" % p)
if slot == "active":
# The guard opens the running slot's images (the packed list's slot-B
# names, mapped by the init) and userdata, and no other partition
# Its own list, the only images and guard names a format 2 release
# may carry (bin/omamobile's UFS_RW_ALLOWED): never vbmeta, abl or
# modem, which would be written as the running slot's live image
for p in boot_images:
if p not in IMAGES_ACTIVE:
die("BOOT_IMAGES may hold only %s, not %s" % (" ".join(IMAGES_ACTIVE), p))
for p in allow:
if p not in [i + "_b" for i in IMAGES_ACTIVE] + ["userdata"]:
die("UFS_RW may hold only slot B boot images and userdata, not %s" % p)
guard_images = [p[:-2] for p in allow if p.endswith("_b")]
also = [p for p in allow if not p.endswith("_b")]
if also != ["userdata"]:
Expand Down