Modern Apps git

← Modern-Apps.git

scripts: fix install version bump on macOS, make dhu runnable

Commit
6eb1e1c9d883bff43e38ccdbd2303cbfd1f84d73
Author
Vayun Mathur <[email protected]>
When
2026-11-01 05:53 UTC (1 month ago)
Parents
a38c79c
install
- device_version_code used `\S` in `sed -E`, which BSD sed (macOS)
  does not support, so the on-device versionCode always read empty and
  -PversionCodeOverride was never applied. Installs over a newer
  on-device build failed with INSTALL_FAILED_VERSION_DOWNGRADE.
- The lookup also matched by prefix: `pm list packages` filters by
  substring, so com.vayunmathur.music picked up
  com.vayunmathur.musicbrainz's versionCode. The sed pattern now
  matches the exact (escaped) package name.

dhu
- Mark executable (was 100644, so ./dhu failed with Permission denied).
- When --device-id is not given, use the Pixel 8 if attached, else the
  first non-emulator device, instead of hard-failing on a Pixel 9.
- The DHU exits on stdin EOF and nohup points stdin at an unreadable
  file, so the detached launch died within seconds. Launch it behind
  `tail -f /dev/null |` so stdin stays open.
- --help used `head -n -1` (GNU-only); use `sed '$d'`.

Verified on macOS: ./install bumps to the on-device versionCode for
both auto and music; ./dhu --help works; ./dhu picks the Pixel 9,
forwards 5277, captures logcat and keeps the DHU running.

Diff

dhu
diff --git a/dhu b/dhuold mode 100644new mode 100755index 9fdfb8d74e..a4d9434280--- a/dhu+++ b/dhu@@ -6,6 +6,7 @@ #   ./dhu                                # full loop, log to analysis/dhu-<timestamp>.log #   ./dhu --no-log                       # skip the logcat capture (DHU only) #   ./dhu --device-id 44050DLJH001PC     # target a different device+#                                        # (default: the Pixel 8, else the first non-emulator device) # # Notes: #   DHU is interactive: piping its stdout closes stdin and it exits, so it@@ -14,13 +15,13 @@ set -euo pipefail  SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"-DEVICE_ID="44050DLJH001PC"+DEVICE_ID="" NO_LOG=0  while [[ $# -gt 0 ]]; do   case "$1" in     -h|--help|help)-      sed -n '2,/^set -euo/p' "$SCRIPT_DIR/dhu" | sed 's/^# \{0,1\}//' | head -n -1; exit 0;;+      sed -n '2,/^set -euo/p' "$SCRIPT_DIR/dhu" | sed 's/^# \{0,1\}//' | sed '$d'; exit 0;;     --no-log|--nolog|-NoLog) NO_LOG=1; shift;;     --device-id|-DeviceId) DEVICE_ID="${2:?--device-id needs a value}"; shift 2;;     --device-id=*) DEVICE_ID="${1#--device-id=}"; shift;;@@ -40,6 +41,15 @@ if [[ -z "$DHU_EXE" ]]; then fi  # The phone listens; the DHU reaches it through the forward.+if [[ -z "$DEVICE_ID" ]]; then+  attached="$(adb devices | awk 'NR>1 && $2=="device" && $1 !~ /^emulator/ {print $1}')"+  if grep -qx "44050DLJH001PC" <<<"$attached"; then+    DEVICE_ID="44050DLJH001PC"+  else+    DEVICE_ID="$(head -n1 <<<"$attached")"+  fi+  [[ -n "$DEVICE_ID" ]] || { echo "Error: no physical device attached." >&2; exit 1; }+fi adb -s "$DEVICE_ID" forward tcp:5277 tcp:5277 echo "forward tcp:5277 -> $DEVICE_ID" @@ -59,6 +69,7 @@ if [[ "${OS:-}" == "Windows_NT" ]]; then   # git-bash: `start` detaches the GUI like Start-Process did.   start "" "$DHU_EXE" else-  nohup "$DHU_EXE" >/dev/null 2>&1 &+  # DHU exits on stdin EOF, and nohup points stdin at an unreadable file; keep a pipe open.+  (cd "$(dirname "$DHU_EXE")" && nohup sh -c 'tail -f /dev/null | "$0"' "$DHU_EXE" >/dev/null 2>&1 &) fi echo "DHU launched (detached)"
install
diff --git a/install b/installindex cc1e643acb..5aa8764705 100755--- a/install+++ b/install@@ -515,7 +515,7 @@ built_apk() { # on-device versionCode for a package, empty when not installed. device_version_code() {   "$ADB_BIN" -s "$TARGET_SERIAL" shell pm list packages --show-versioncode "$1" 2>/dev/null \-    | sed -nE 's/^package:\S+[[:space:]]+versionCode:([0-9]+).*/\1/p' | head -1+    | sed -nE "s/^package:${1//./\\.}[[:space:]]+versionCode:([0-9]+).*/\\1/p" | head -1 }  # exit 0 when the package is installed as a system app.