From 95c121f4d0f5a44b8a5733b373701c0eedd6efba Mon Sep 17 00:00:00 2001 From: VysseCodes <205995085+VysseCodes@users.noreply.github.com> Date: Tue, 1 Dec 2026 17:39:53 -0600 Subject: [PATCH] HMG-API isn't installed alongside NEMESIS: a new install on a NEMESIS unit stops install.sh (where every route ends) stops before anything changes when NEMESIS is installed: its binary (/system/xbin/nemesis), its app (NEMESIS.apk) or its LivePatch script at app_process (lib.sh nemesis_installed). The factory nemesis service slot's file isn't NEMESIS. The USB stick's toast says why. Only a new install stops. A unit with HMG-API already on it (its wrapper in the zygote chain, its stock copy or its install record: hmgapi_on_unit) is updated and repaired as before: the orders test showed that stopping it would block the #397 rescue (installing again before the restart after an older uninstall under NEMESIS 1.17), and the unit wouldn't start. HMGAPI_WITH_NEMESIS=1 installs anyway, for maintainers and the off-car tests (no stick file sets it, no message names it), as HMGAPI_FORCE is. Tested off-car only: install/common/test.sh (the two checks), install-test.sh (refused with NEMESIS's binary and with its app alone, nothing changed), orders-test.sh (every order, the rescue included), usb/test.sh (the toast), mod-test.sh, sync-test.sh, scriptcheck-test.sh. --- CHANGELOG.md | 9 +++++++++ install/common/install-test.sh | 14 ++++++++++++++ install/common/install.sh | 8 ++++++++ install/common/lib.sh | 22 ++++++++++++++++++++++ install/common/test.sh | 22 ++++++++++++++++++++++ install/usb/test.sh | 7 +++++++ install/usb/troubleShooter | 4 ++++ 7 files changed, 86 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f898a92..268042d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## Unreleased + +- **HMG-API isn't installed alongside NEMESIS.** On a unit with NEMESIS (its binary, its app + or its LivePatch script at `app_process`), a new install stops before anything changes, on + every route, and the USB stick's toast says why. A unit that already has HMG-API on it (from + an older release, or left by an older uninstall under NEMESIS 1.17) is still updated and + repaired, so the #397 rescue keeps working. The head unit's factory `nemesis` service slot + isn't NEMESIS. + ## 1.1.0 (2026-11-28) 1.1.0-rc.10's code: only the version, this heading and the release notes changed. It is the diff --git a/install/common/install-test.sh b/install/common/install-test.sh index dd8aa7da..e0c93b69 100644 --- a/install/common/install-test.sh +++ b/install/common/install-test.sh @@ -65,6 +65,20 @@ cp install/nemesis/bin/open.sh install/nemesis/bin/start.sh $P/nemesis/bin/; cp (cd $P && md5sum hmgapid lpatch app_process libhmgapi_hook.so hmgapi-hook.jar HmgApi.apk install.sh uninstall.sh lib.sh stock.txt app-pending.sh app-open.sh hook-check.sh boot.sh MAPS.md5 > MANIFEST) # refusals first: nothing may change +# NEMESIS is installed here (the fake nemesis above): a new install stops (2.0: never alongside NEMESIS) +run $P/install.sh $P +check "NEMESIS installed, HMG-API not: new install refused" 1 $rc +has "... saying why" "NEMESIS is installed on this unit, and HMG-API isn't installed alongside NEMESIS, so nothing was changed." "$out" +check "... and names no way around it" "" "$(echo "$out" | grep -i -e force -e WITH_NEMESIS || true)" +check "... nothing changed" "$BEFORE" "$(tree)" +mv $R/system/xbin/nemesis $T/nemesis.off; mkdir -p $R/system/app; : > $R/system/app/NEMESIS.apk +run $P/install.sh $P +has "NEMESIS's app alone: still NEMESIS, refused" "HMG-API isn't installed alongside NEMESIS" "$out" +rm $R/system/app/NEMESIS.apk; rmdir $R/system/app 2>/dev/null || true; mv $T/nemesis.off $R/system/xbin/nemesis +BEFORE=$(tree) +# from here on, the maintainers' variable: the tests below check HMG-API's work under NEMESIS +# (the "keep NEMESIS, remove HMG-API" path and units that have both from older releases need it) +HMGAPI_WITH_NEMESIS=1; export HMGAPI_WITH_NEMESIS cp $R/system/bin/app_process $T/real; echo x >> $R/system/bin/app_process run $P/install.sh $P has "unknown app_process refused" "isn't a known stock build, so nothing was changed" "$out" diff --git a/install/common/install.sh b/install/common/install.sh index bc889914..1fcd7294 100644 --- a/install/common/install.sh +++ b/install/common/install.sh @@ -76,6 +76,14 @@ backup() { capcheck log "HMG-API $VERSION install $(date)" +# NEMESIS installed: a new install stops before anything changes (lib.sh, nemesis_installed). Every +# route (USB, adb, the app, NEMESIS's own package) ends here. HMG-API already on the unit: updated +# or repaired as before (hmgapi_on_unit) +if [ "$HMGAPI_WITH_NEMESIS" != 1 ] && nemesis_installed; then + hmgapi_on_unit || fail "$NEMESIS_STOP" + log "NEMESIS is installed too: updating the HMG-API that's already here (a new install wouldn't go ahead)" +fi + # the payload is whole while read m f; do [ -n "$f" ] || continue diff --git a/install/common/lib.sh b/install/common/lib.sh index 295394e6..06135f5e 100644 --- a/install/common/lib.sh +++ b/install/common/lib.sh @@ -9,6 +9,28 @@ HOOK_END="# HMGAPI_HOOK end" log() { echo "$1"; echo "$1" >> "$LOG" 2>/dev/null; } sum() { set -- $(md5 "$1" 2>/dev/null); echo "$1"; } +# HMG-API isn't installed alongside NEMESIS (2.0): the two take different approaches to the same +# core files (app_process, install-recovery.sh), and keeping both has been behind the worst failures +# (#397). Any of NEMESIS's own files on /system says it's installed: its binary, its app, or its +# LivePatch script at app_process. Not the factory `nemesis` service slot (init.daudio.rc), which is +# stock. Only a new install stops: a unit with HMG-API already on it (hmgapi_on_unit) is updated or +# repaired as before. HMGAPI_WITH_NEMESIS=1: install anyway, for maintainers and the off-car tests only (no stick +# file sets it, no message names it), as HMGAPI_FORCE is. +NEMESIS_STOP="NEMESIS is installed on this unit, and HMG-API isn't installed alongside NEMESIS, so nothing was changed. Moving a unit from NEMESIS to HMG-API isn't in this build yet." +nemesis_installed() { + [ -e "$ROOT/system/xbin/nemesis" ] || [ -e "$ROOT/system/app/NEMESIS.apk" ] || nemesis_livepatch +} +# HMG-API already on the unit: its wrapper anywhere in the zygote chain, its stock copy, or its +# install record. Such a unit (both installed by an older release, or left by an older uninstall +# under NEMESIS 1.17) still gets updates and repairs, or the #397 rescue (install again before the +# next restart) couldn't run and the unit wouldn't start. +hmgapi_on_unit() { + local f + [ -e "$ROOT/system/bin/app_process.hmgapi-stock" ] || [ -f "$ROOT/data/hmgapi/installed.txt" ] && return 0 + for f in $(zygote_files); do is_wrapper "$ROOT$f" && return 0; done + return 1 +} + # NEMESIS 1.17's LivePatch puts its own shell script at /system/bin/app_process (its watchdog # writes it again on every boot, LivePatch package or not) and runs app_process.real, which # holds whatever binary it found there first: stock, or HMG-API's wrapper. Under that script diff --git a/install/common/test.sh b/install/common/test.sh index 21bc1355..89aaa4e6 100644 --- a/install/common/test.sh +++ b/install/common/test.sh @@ -108,6 +108,28 @@ echo 999999 > "$D/state/hook-check.pid" HC > /dev/null check "hook-check: a stale lock (after a restart) doesn't stop it" "1" "$(grep -c 'HMGAPI_HOOK begin' "$T/system/etc/install-recovery.sh")" +# nemesis_installed / hmgapi_on_unit (lib.sh): the 2.0 install gate's two questions +NI() { env ROOT="$T/ni" $SH -c ". $PWD/lib.sh; $1 && echo yes || echo no"; } +rm -rf "$T/ni"; mkdir -p "$T/ni/system/bin" "$T/ni/system/xbin" "$T/ni/system/app" "$T/ni/data/hmgapi" +printf '\177ELFstock' > "$T/ni/system/bin/app_process" +check "gate: a stock unit: no NEMESIS, no HMG-API" "no no" "$(NI nemesis_installed) $(NI hmgapi_on_unit)" +: > "$T/ni/system/xbin/nemesis" +check "gate: NEMESIS's binary: installed" "yes" "$(NI nemesis_installed)" +rm "$T/ni/system/xbin/nemesis"; : > "$T/ni/system/app/NEMESIS.apk" +check "gate: NEMESIS's app: installed" "yes" "$(NI nemesis_installed)" +rm "$T/ni/system/app/NEMESIS.apk" +mv "$T/ni/system/bin/app_process" "$T/ni/system/bin/app_process.real" +printf '#!/system/bin/sh\n# NEMESIS LivePatch\nexec /system/bin/app_process.real "$@"\n' > "$T/ni/system/bin/app_process" +check "gate: NEMESIS's LivePatch script at app_process: installed" "yes" "$(NI nemesis_installed)" +check "... HMG-API not on it (stock .real)" "no" "$(NI hmgapi_on_unit)" +printf '\177ELFwrapper app_process.hmgapi-stock' > "$T/ni/system/bin/app_process.real" +check "gate: HMG-API's wrapper in .real, its stock copy gone (#397, before the restart): HMG-API on the unit" "yes" "$(NI hmgapi_on_unit)" +printf '\177ELFstock' > "$T/ni/system/bin/app_process.real"; : > "$T/ni/data/hmgapi/installed.txt" +check "gate: HMG-API's install record: on the unit" "yes" "$(NI hmgapi_on_unit)" +mkdir -p "$T/ni/data/local/tmp/nemesis"; : > "$T/ni/data/local/tmp/nemesis/nemesis" +rm -f "$T/ni/system/bin/app_process" "$T/ni/data/hmgapi/installed.txt"; mv "$T/ni/system/bin/app_process.real" "$T/ni/system/bin/app_process" +check "gate: only the factory slot's file (/data/local/tmp/nemesis): not NEMESIS" "no" "$(NI nemesis_installed)" + # boot.sh: an apply that was cut off (or a trial) is rolled back, then one restart. A # recover that fails part-way keeps its journal, so restarting on it would loop. mkdir -p "$T/system/bin" diff --git a/install/usb/test.sh b/install/usb/test.sh index a78605a7..511abfc0 100755 --- a/install/usb/test.sh +++ b/install/usb/test.sh @@ -117,6 +117,13 @@ has "no HMGAPI folder: says so" "no HMGAPI folder on the USB stick. Nothing was check "... and fails" 1 $rc mv $S/X $S/HMGAPI +# NEMESIS installed (its binary), HMG-API not: refused, nothing changed, the toast says why +mkdir -p $R/system/xbin; : > $R/system/xbin/nemesis; NB4=$(tree) +run $TS +has "NEMESIS installed: the stick's install is refused, saying why" "NEMESIS is installed on this unit, and HMG-API isn't installed alongside it. Nothing was changed." "$out" +check "... nothing changed, HMG-API not in" "yes no" "$([ "$(tree)" = "$NB4" ] && echo yes || echo no) $(installed)" +rm $R/system/xbin/nemesis + run $TS has "stick install: done" "HMG-API installed, restarting" "$out" check "stick install: exit 0" 0 $rc diff --git a/install/usb/troubleShooter b/install/usb/troubleShooter index a65670ed..a9bc96c9 100755 --- a/install/usb/troubleShooter +++ b/install/usb/troubleShooter @@ -16,6 +16,8 @@ STAGE=$ROOT/data/local/tmp/hmgapi-usb # an app_process build HMG-API hasn't checked (install.sh, uninstall.sh: ASK_BUILD in lib.sh) UNKNOWN_TOAST="HMG-API hasn't checked your car's software build yet, so nothing was changed. Please open an issue at github.com/Open-HMG/HMG-API with HMGAPI/install.log from this stick." +# NEMESIS is installed (install.sh: NEMESIS_STOP in lib.sh) +NEMESIS_TOAST="HMG-API: NEMESIS is installed on this unit, and HMG-API isn't installed alongside it. Nothing was changed." toast() { echo "$1" [ -n "$ROOT" ] && return @@ -89,6 +91,8 @@ if [ $rc = 0 ]; then toast "HMG-API installed, restarting." elif grep -q "isn't a known stock build" "$U/HMGAPI/install.log" 2>/dev/null; then toast "$UNKNOWN_TOAST" +elif grep -q "HMG-API isn't installed alongside NEMESIS" "$U/HMGAPI/install.log" 2>/dev/null; then + toast "$NEMESIS_TOAST" else toast "HMG-API install failed: see HMGAPI/install.log on the stick." fi