Use target hostnames and restore lk2nd bootloader reboot
This commit is contained in:
1 parent
1c011b360a
commit
3b96b8f242
22 files changed
+203
-70
No files matched your search
@@ -151,6 +151,7 @@ fi
|
||||
if [ -x "$BASE_DIR/scripts/version.sh" ]; then
|
||||
"$BASE_DIR/scripts/version.sh" "$TARGET_ROOTFS"
|
||||
fi
|
||||
"$BASE_DIR/scripts/set-bananarchy-hostname.sh" "$TARGET_ROOTFS" "$DEVICE"
|
||||
# Pre-create the user's modem/SMS log and blocklist directories so that the
|
||||
# root-run dual-SIM daemon never creates them root-owned on a fresh image.
|
||||
mkdir -p "$TARGET_ROOTFS/home/user/.local/share/sxmo/modem" \
|
||||
|
||||
@@ -160,16 +160,7 @@ chown 0:0 "$ROOTFS/etc/bananarchy"
|
||||
chmod 0700 "$ROOTFS/etc/bananarchy"
|
||||
|
||||
echo "[5/8] Writing base system configuration..."
|
||||
printf '%s\n' "nokia-argon" > "$ROOTFS/etc/hostname"
|
||||
cat > "$ROOTFS/etc/hosts" <<EOF
|
||||
127.0.0.1 nokia-argon localhost.localdomain localhost
|
||||
::1 localhost ipv6-localhost ipv6-loopback
|
||||
fe00::0 ipv6-localnet
|
||||
ff00::0 ipv6-mcastprefix
|
||||
ff02::1 ipv6-allnodes
|
||||
ff02::2 ipv6-allrouters
|
||||
ff02::3 ipv6-allhosts
|
||||
EOF
|
||||
"$REPO/scripts/set-bananarchy-hostname.sh" "$ROOTFS" "$DEVICE"
|
||||
printf '%s\n' "LANG=C.UTF-8" > "$ROOTFS/etc/locale.conf"
|
||||
if [ -f "$ROOTFS/usr/share/zoneinfo/UTC" ]; then
|
||||
cp "$ROOTFS/usr/share/zoneinfo/UTC" "$ROOTFS/etc/localtime"
|
||||
@@ -189,7 +180,8 @@ fi
|
||||
printf '\n' >> "$ROOTFS/etc/machine-id"
|
||||
fi
|
||||
mkdir -p "$ROOTFS/etc/sysctl.d"
|
||||
cat > "$ROOTFS/etc/sysctl.d/90-nokia-argon-lowram.conf" <<EOF
|
||||
rm -f "$ROOTFS/etc/sysctl.d/90-nokia-argon-lowram.conf"
|
||||
cat > "$ROOTFS/etc/sysctl.d/90-bananarchy-lowram.conf" <<EOF
|
||||
vm.swappiness = 180
|
||||
vm.page-cluster = 0
|
||||
vm.vfs_cache_pressure = 150
|
||||
|
||||
@@ -59,7 +59,7 @@ check_images() {
|
||||
--image "$DIAG_IMAGE" --patch "$PATCH" --expect-fastboot 1
|
||||
python3 "$BASE_DIR/scripts/check-lk2nd-beatles.py" \
|
||||
--image "$DISPLAY_IMAGE" --patch "$PATCH" --expect-fastboot 0 \
|
||||
--expect-display 1 --allow-missing-cookie
|
||||
--expect-display 1
|
||||
}
|
||||
|
||||
if [ "$CHECK_ONLY" = 1 ]; then
|
||||
|
||||
@@ -250,8 +250,6 @@ def main():
|
||||
help="require (1) or forbid (0) the forced-fastboot diagnostic build")
|
||||
ap.add_argument("--expect-display", type=int, choices=(0, 1), default=0,
|
||||
help="require (1) or forbid (0) the boot-time SPI display build")
|
||||
ap.add_argument("--allow-missing-cookie", action="store_true",
|
||||
help="allow the known-good display image built before the low-bit reboot cookie")
|
||||
args = ap.parse_args()
|
||||
|
||||
problems = []
|
||||
@@ -304,8 +302,7 @@ def main():
|
||||
b"aligned read exceeds partition"):
|
||||
if marker not in data:
|
||||
problems.append("binary is missing %r" % marker.decode("ascii", "replace"))
|
||||
if not args.allow_missing_cookie and \
|
||||
b"beatles low-bit reboot cookie" not in data:
|
||||
if b"beatles low-bit reboot cookie" not in data:
|
||||
problems.append("binary is missing b'beatles low-bit reboot cookie'")
|
||||
if not data.endswith(b"SEANDROIDENFORCE"):
|
||||
problems.append("missing SEANDROIDENFORCE trailer")
|
||||
|
||||
@@ -17,6 +17,41 @@ for script in "$BASE_DIR"/*.sh "$BASE_DIR"/scripts/*.sh; do
|
||||
fi
|
||||
done
|
||||
|
||||
echo "[check] Target-specific hostname..."
|
||||
HOSTNAME_HELPER="$BASE_DIR/scripts/set-bananarchy-hostname.sh"
|
||||
if [ ! -x "$HOSTNAME_HELPER" ]; then
|
||||
fail "missing or non-executable scripts/set-bananarchy-hostname.sh"
|
||||
fi
|
||||
if ! grep -qF 'set-bananarchy-hostname.sh' "$BASE_DIR/scripts/bootstrap-rootfs-container.sh" || \
|
||||
! grep -qF 'set-bananarchy-hostname.sh' "$BASE_DIR/scripts/apply-bananarchy-overlay.sh" || \
|
||||
grep -qF '"nokia-argon" > "$ROOTFS/etc/hostname"' \
|
||||
"$BASE_DIR/scripts/bootstrap-rootfs-container.sh"; then
|
||||
fail "target rootfs bootstrap no longer uses the target-specific hostname helper"
|
||||
fi
|
||||
if [ -x "$HOSTNAME_HELPER" ]; then
|
||||
HOSTNAME_TMP="$(mktemp -d)"
|
||||
for dev in nokia-argon nokia-beatles nokia-tough nokia-sparkler nokia-leo; do
|
||||
if ! "$HOSTNAME_HELPER" "$HOSTNAME_TMP" "$dev"; then
|
||||
fail "hostname helper failed for $dev"
|
||||
continue
|
||||
fi
|
||||
if [ "$(cat "$HOSTNAME_TMP/etc/hostname" 2>/dev/null)" != "$dev" ] || \
|
||||
! grep -qF "127.0.0.1 $dev localhost.localdomain localhost" \
|
||||
"$HOSTNAME_TMP/etc/hosts" 2>/dev/null || \
|
||||
[ "$(readlink "$HOSTNAME_TMP/etc/runlevels/boot/hostname" 2>/dev/null)" != \
|
||||
"/etc/init.d/hostname" ]; then
|
||||
fail "hostname helper produced the wrong identity for $dev"
|
||||
fi
|
||||
done
|
||||
rm -rf "$HOSTNAME_TMP"
|
||||
fi
|
||||
if ! grep -qF 'BANANARCHY_USER_PASSWORD="${BANANARCHY_USER_PASSWORD:-147147}"' \
|
||||
"$BASE_DIR/scripts/bootstrap-rootfs.sh" || \
|
||||
! grep -qF 'openssl passwd -6 -salt bananarchy "$PASSWORD"' \
|
||||
"$BASE_DIR/scripts/bootstrap-rootfs-container.sh"; then
|
||||
fail "the default 147147 unlock passcode is no longer provisioned"
|
||||
fi
|
||||
|
||||
echo "[check] Python syntax..."
|
||||
python3 - "$BASE_DIR" <<'PYEOF' || exit 1
|
||||
import ast
|
||||
@@ -207,8 +242,8 @@ for variant in normal diagnostic display; do
|
||||
;;
|
||||
display)
|
||||
image="$BASE_DIR/images/boot-lk2nd-nokia-beatles-display.img"
|
||||
opts="--expect-fastboot 0 --expect-display 1 --allow-missing-cookie"
|
||||
label="nokia-beatles known-good display lk2nd image"
|
||||
opts="--expect-fastboot 0 --expect-display 1"
|
||||
label="nokia-beatles display lk2nd image with Fastboot reboot cookie"
|
||||
;;
|
||||
esac
|
||||
if [ ! -f "$image" ]; then
|
||||
@@ -317,10 +352,10 @@ fi
|
||||
|
||||
echo "[check] Known-good flashable image set..."
|
||||
for pair in \
|
||||
"b4d0555f17dd1e224069641603ff3d120fd3ea5c219a34de227caf240a077558 images/bananarchy-nokia-argon.img" \
|
||||
"e2267187c58920b5c5b822d940b81e0df8f59e7788fed00e3d31dfbdb290c7fc images/bananarchy-nokia-beatles.img" \
|
||||
"69a44f60eb123ebddf600be927155dc4a599ec35b7a0cf80060f4ba01f599f08 images/bananarchy-nokia-argon.img" \
|
||||
"f4e9b8b2b36d4ffa9ba4f74de293b14f16b5ed45bbd5ab1d62bc2023242b73b2 images/bananarchy-nokia-beatles.img" \
|
||||
"6715abd414fd02fd21ca8c2cd621a8a21e78f46d079b2d185b38a1f7a4a3e659 images/boot-bananarchy-nokia-beatles.img" \
|
||||
"e1fdd8551b6393184a465638881b63ca58c04e1e8f655f092260a18379e1cbe6 images/boot-lk2nd-nokia-beatles-display.img"; do
|
||||
"b5549698c20f4de7603fc746d32bb5baa96ec377e41e74407823c98506fc185d images/boot-lk2nd-nokia-beatles-display.img"; do
|
||||
set -- $pair
|
||||
want=$1
|
||||
path="$BASE_DIR/$2"
|
||||
@@ -649,8 +684,38 @@ for mod in mux-core mux-gpio spi-mux; do
|
||||
fail "modules-load.d is missing $mod"
|
||||
fi
|
||||
done
|
||||
if ! grep -q 'PON_SOFT_RB_SPARE.*0x02U' "$BASE_DIR/src/leds-msm8905-torch/leds-msm8905-torch.c"; then
|
||||
fail "the torch reboot cookie no longer selects the lk2nd Fastboot menu"
|
||||
echo "[check] Reboot-to-bootloader Fastboot cookie..."
|
||||
TORCH_SRC="$BASE_DIR/src/leds-msm8905-torch/leds-msm8905-torch.c"
|
||||
for token in '#define FASTBOOT_COOKIE_LOW 0x02U' \
|
||||
'#define FASTBOOT_COOKIE_DUAL 0x0aU' \
|
||||
'of_machine_is_compatible("nokia,beatles")' \
|
||||
'regmap_write(pon_regmap, QPNP_PON_SOFT_RB_SPARE, cookie)'; do
|
||||
if ! grep -qF "$token" "$TORCH_SRC"; then
|
||||
fail "the torch reboot cookie lost the target-aware lk2nd Fastboot path ($token)"
|
||||
fi
|
||||
done
|
||||
for f in scripts/check-lk2nd-beatles.py scripts/build-lk2nd-beatles.sh \
|
||||
scripts/test-lk2nd-beatles-port.py; do
|
||||
if grep -qF -- '--allow-missing-cookie' "$BASE_DIR/$f" || \
|
||||
grep -qF 'allow_missing_cookie' "$BASE_DIR/$f"; then
|
||||
fail "$f still permits a display lk2nd image without the reboot cookie"
|
||||
fi
|
||||
done
|
||||
if ! grep -qF 'opts="--expect-fastboot 0 --expect-display 1"' "$BASE_DIR/scripts/check-rebuild.sh"; then
|
||||
fail "check-rebuild.sh no longer requires the display lk2nd reboot cookie"
|
||||
fi
|
||||
for f in src/sxmo-dmenu/dmenu.c \
|
||||
overlay/rootfs/usr/bin/sxmo_appmenu.sh \
|
||||
overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_contextmenu.sh; do
|
||||
if ! grep -qF 'Reboot to bootloader' "$BASE_DIR/$f"; then
|
||||
fail "$f lost the Reboot to bootloader menu item"
|
||||
fi
|
||||
done
|
||||
if ! grep -qF 'set_kernel_reboot_mode "bootloader"' \
|
||||
"$BASE_DIR/overlay/rootfs/usr/bin/sxmo_power.sh" || \
|
||||
! grep -qF 'force_reboot_cmd "bootloader"' \
|
||||
"$BASE_DIR/overlay/rootfs/usr/bin/sxmo_power.sh"; then
|
||||
fail "sxmo_power.sh no longer reboots through the canonical bootloader mode"
|
||||
fi
|
||||
for stale in images/boot-bananarchy-nokia-beatles-debug.img \
|
||||
images/boot-bananarchy-nokia-beatles-ramoops.img; do
|
||||
|
||||
Executable
+47
@@ -0,0 +1,47 @@
|
||||
#!/bin/sh
|
||||
# Install the target-specific hostname, hosts file and hostname service link.
|
||||
set -eu
|
||||
|
||||
ROOTFS="${1:-}"
|
||||
DEVICE="${2:-nokia-argon}"
|
||||
|
||||
if [ -z "$ROOTFS" ] || [ ! -d "$ROOTFS" ]; then
|
||||
echo "Usage: $0 <rootfs-dir> <device>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$DEVICE" in
|
||||
nokia-argon|argon)
|
||||
DEVICE="nokia-argon"
|
||||
;;
|
||||
nokia-beatles|beatles)
|
||||
DEVICE="nokia-beatles"
|
||||
;;
|
||||
nokia-tough|nokia-coconut|tough|coconut)
|
||||
DEVICE="nokia-tough"
|
||||
;;
|
||||
nokia-sparkler|sparkler)
|
||||
DEVICE="nokia-sparkler"
|
||||
;;
|
||||
nokia-leo|leo)
|
||||
DEVICE="nokia-leo"
|
||||
;;
|
||||
*)
|
||||
echo "Error: Unsupported device '$DEVICE'." >&2
|
||||
echo "Supported devices: nokia-argon, nokia-beatles, nokia-tough, nokia-sparkler, nokia-leo" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
mkdir -p "$ROOTFS/etc" "$ROOTFS/etc/runlevels/boot"
|
||||
printf '%s\n' "$DEVICE" > "$ROOTFS/etc/hostname"
|
||||
cat > "$ROOTFS/etc/hosts" <<EOF
|
||||
127.0.0.1 $DEVICE localhost.localdomain localhost
|
||||
::1 $DEVICE localhost ipv6-localhost ipv6-loopback
|
||||
fe00::0 ipv6-localnet
|
||||
ff00::0 ipv6-mcastprefix
|
||||
ff02::1 ipv6-allnodes
|
||||
ff02::2 ipv6-allrouters
|
||||
ff02::3 ipv6-allhosts
|
||||
EOF
|
||||
ln -sfn /etc/init.d/hostname "$ROOTFS/etc/runlevels/boot/hostname"
|
||||
@@ -37,19 +37,17 @@ def main():
|
||||
test_c = os.path.join(BASE, "bootloader", "lk2nd", "test_spi_panel_init.c")
|
||||
|
||||
variants = (
|
||||
("images/boot-lk2nd-nokia-beatles.img", 0, 0, False),
|
||||
("images/boot-lk2nd-nokia-beatles-diagnostic.img", 1, 0, False),
|
||||
("images/boot-lk2nd-nokia-beatles-display.img", 0, 1, True),
|
||||
("images/boot-lk2nd-nokia-beatles.img", 0, 0),
|
||||
("images/boot-lk2nd-nokia-beatles-diagnostic.img", 1, 0),
|
||||
("images/boot-lk2nd-nokia-beatles-display.img", 0, 1),
|
||||
)
|
||||
for image, fastboot, display, allow_missing_cookie in variants:
|
||||
for image, fastboot, display in variants:
|
||||
ok &= check(os.path.isfile(os.path.join(BASE, image)), "%s exists" % image)
|
||||
if not os.path.isfile(os.path.join(BASE, image)):
|
||||
continue
|
||||
cmd = [sys.executable, validator, "--image", image,
|
||||
"--expect-fastboot", str(fastboot),
|
||||
"--expect-display", str(display)]
|
||||
if allow_missing_cookie:
|
||||
cmd.append("--allow-missing-cookie")
|
||||
r = subprocess.run(cmd, cwd=BASE, capture_output=True, text=True)
|
||||
for line in r.stdout.strip().split("\n"):
|
||||
if line:
|
||||
|
||||
Reference in new issue
Block a user