Skip to content
Open
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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 14 additions & 0 deletions install/common/install-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 8 additions & 0 deletions install/common/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions install/common/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions install/common/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 7 additions & 0 deletions install/usb/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions install/usb/troubleShooter
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading