vendor-overlay, reset-password: the third system; the uninstallers stay system-agnostic

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DqKKtBQZCfxYnHuBCuDqqn
This commit is contained in:
Abdurrahman Kaan DikeçandClaude Opus 5.5 committed 2026-10-05 02:12:33 +03:00
1 parent 83e3855ca8
commit fd4d83ea0e
4 files changed
+32 -8

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
#!/bin/sh
# Choose which system on the Linux disk area boots next. Any directory with an /etc and an init counts, so
# ubuntu, openwrt, immortalwrt, arch, debian, kali ... all work the same way.
# ubuntu, openwrt, openwrt-luci, immortalwrt, arch, debian, kali ... all work the same way.
# mu300-os show installed systems and the current choice
# mu300-os <name> boot that system from now on (reboot to apply)
# OpenWrt: od/timeout come from the static busybox in /opt/mu300/busybox-bin
+23
View File
@@ -103,6 +103,29 @@ class Rules(unittest.TestCase):
for f in ('uninstall.sh', 'uninstall.ps1', 'tools/reset-password.sh', 'tools/android-import-hotspot.sh'):
self.assertIn('mu300sd', (TOP / f).read_text(), f)
def test_every_system_list_has_openwrt_luci(self):
# every place that names the systems knows the third one, by its name or by the OpenWrt kind pattern
files = ('boot/init', 'rootfs/overlay/opt/mu300/bin/mu300-update', 'rootfs/overlay/opt/mu300/bin/mu300-os',
'tools/android-install.sh', 'tools/reset-password.sh', 'tools/vendor-overlay.py', 'install.sh',
'install.ps1', 'tools/make-release.sh')
for f in files:
with self.subTest(file=f):
# each skip is lifted alone by the task that gives its file the third system
if f == 'install.sh':
self.skipTest('install.sh: until Task 6')
if f == 'install.ps1':
self.skipTest('install.ps1: until Task 7')
if f == 'tools/make-release.sh':
self.skipTest('tools/make-release.sh: until Task 11')
text = (TOP / f).read_text()
self.assertTrue('openwrt-luci' in text or 'openwrt-*' in text or 'openwrt|openwrt-' in text, f)
def test_uninstallers_have_no_per_system_list(self):
# they remove the whole Linux filesystem; a per-system case arm added later would forget the third name
for f in ('uninstall.sh', 'uninstall.ps1'):
text = (TOP / f).read_text()
self.assertNotRegex(text, r'(^|\s)(ubuntu|openwrt)\)', f)
def test_init_finds_partitions_after_the_modules(self):
# the eMMC driver is one of the vendor modules: misc and boot_b cannot be found before they are loaded
init = (TOP / 'boot' / 'init').read_text()
+7 -6
View File
@@ -3,12 +3,13 @@
# (adb + su); it mounts the Linux filesystem from Android and rewrites the password hash in /etc/shadow. With an
# installation on the SD card (ext4 labelled mu300sd) that one is changed: it is the one that boots.
#
# tools/reset-password.sh [ubuntu|openwrt|both] (default: both)
# tools/reset-password.sh [ubuntu|openwrt|openwrt-luci|all] (default: all; both is an alias of all)
#
# Forgot the password and Linux boots by default? Unplug the device about ten seconds after it powers on and plug
# it back in: the bootloader sees an unfinished boot and falls back to Android, then run this.
set -eu
WHICH=${1:-both}
WHICH=${1:-all}
[ "$WHICH" = both ] && WHICH=all
TOP=$(cd "$(dirname "$0")/.." && pwd)
T=/data/local/tmp
@@ -19,7 +20,7 @@ su_do() { adb shell "su -c '$1'" </dev/null | tr -d '\r'; }
t() { printf '%s' "$1"; }
gib() { awk -v b="$1" 'BEGIN { printf "%.1f GiB", b / 1073741824 }'; }
case $WHICH in ubuntu|openwrt|both) ;; *) die "usage: $0 [ubuntu|openwrt|both]" ;; esac
case $WHICH in ubuntu|openwrt|openwrt-luci|all) ;; *) die "usage: $0 [ubuntu|openwrt|openwrt-luci|all]" ;; esac
command -v adb >/dev/null || die "adb not found"
command -v python3 >/dev/null || die "python3 not found"
. "$TOP/tools/linux-mode.sh"
@@ -63,7 +64,7 @@ echo "$out" | grep -q '^MOUNTED' || die "could not mount the Linux filesystem ($
trap 'su_do "sync; sh '"$T"'/android-mount-mu300root.sh -u '"$T"'/mu300root" >/dev/null 2>&1 || true' EXIT
systems=$WHICH
[ "$WHICH" = both ] && systems="ubuntu openwrt"
[ "$WHICH" = all ] && systems="ubuntu openwrt openwrt-luci"
found=
for os in $systems; do
[ "$(su_do "[ -f $T/mu300root/$os/etc/shadow ] && echo y")" = y ] && found="$found $os"
@@ -71,14 +72,14 @@ done
[ -n "$found" ] || die "no installed system found on the Linux filesystem"
echo " systems:$found"
printf 'New password for "ubuntu" (Ubuntu) and "root" (OpenWrt): '
printf 'New password for "ubuntu" (Ubuntu) and "root" (OpenWrt, openwrt-luci): '
[ -t 0 ] && stty -echo; read -r pw1; printf '\nRepeat: '; read -r pw2; [ -t 0 ] && stty echo; echo
[ "$pw1" = "$pw2" ] && [ ${#pw1} -ge 6 ] || die "passwords differ or are shorter than 6 characters"
HASH=$(printf '%s\n' "$pw1" | python3 "$TOP/tools/sha512crypt.py")
case $HASH in \$6\$*) ;; *) die "could not build the password hash" ;; esac
for os in $found; do
case $os in ubuntu) user=ubuntu ;; openwrt) user=root ;; esac
case $os in ubuntu) user=ubuntu ;; openwrt|openwrt-*) user=root ;; esac
# the hash contains $ and /, which the device shell would expand inside su -c: edit the file on this computer
tmp=$(mktemp)
adb shell "su -c 'cat $T/mu300root/$os/etc/shadow > /data/local/tmp/mu300-pull.bin'" </dev/null >/dev/null
+1 -1
View File
@@ -132,7 +132,7 @@ def add_members(tar, src: Path, dest: str, seen: set, rename=None):
def main():
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
ap.add_argument('--os', required=True, choices=['ubuntu', 'openwrt'])
ap.add_argument('--os', required=True, choices=['ubuntu', 'openwrt', 'openwrt-luci'])
ap.add_argument('--firmware', type=Path)
ap.add_argument('--android-subset', type=Path, required=True)
ap.add_argument('--gpu-subset', type=Path)