Files
cleanyourtv/tools/restore.sh
T
Gathin23 66284088af Merge PR #248: tools record the state a debloat list changes, so restore replays it
Fixes on merge:
- recovery.py --save: when a record already exists, names the list gained since the
  first run are added with their state before this list disabled them; entries
  already in the record are never overwritten. Restore no longer leaves those
  packages disabled for good.
- recovery.py --commands: when the recorded Home is com.gathin.tvhome, Home goes to
  the stock launcher resolved on the TV instead. The stock launcher is always
  enabled again unless the record says it was already disabled before cleanup.
- disable.sh, restore.sh: build the list directory with pwd -W where available, so
  Git Bash hands the Windows Python a C:/ path it can open, and the record name
  matches the one the PowerShell scripts compute.
- restore.sh: the comment now says what stops a refused plan (recovery.py prints
  nothing until the whole plan is built), not pipefail.
- tests: an edited list re-run and restored, the custom launcher owning Home, a stock
  launcher disabled before cleanup, and the stock launcher enabled exactly once.
- README: the restore section describes both behaviours.
2026-10-20 11:21:46 +05:30

24 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Put the TV back the way it was before tools/disable.sh, using the state recorded at that time:
# packages that were already disabled stay disabled, Home goes back to the component that owned it,
# and the animation scales go back to their recorded values. Pass the same list you ran disable with.
#
# Usage: TV_HOST=192.168.1.50 tools/restore.sh examples/xiaomi-mi-tv-4a/debloat.txt [stock.launcher.package]
set -euo pipefail
LIST="${1:?usage: restore.sh <debloat list> [stock launcher package]}"
# Resolve the list against the caller's directory before moving into the repo. Git Bash's pwd says
# /c/Users/..., which the Windows Python cannot open with MSYS_NO_PATHCONV=1 set; pwd -W gives
# C:/Users/..., the same path (and so the same record) as the PowerShell scripts.
LIST_DIR="$(cd "$(dirname "$LIST")" && { pwd -W 2>/dev/null || pwd; })"
LIST="$LIST_DIR/$(basename "$LIST")"
cd "$(dirname "$0")/.."
STOCK="${2:-com.google.android.tvlauncher}"
PY=tools/venv/bin/python
[ -x "$PY" ] || PY=tools/venv/Scripts/python.exe
export MSYS_NO_PATHCONV=1
# recovery.py reads and validates the list itself, prints the batch for tv.py and says on stderr what
# it will leave alone. Without a record it warns and falls back to enabling the whole list. A refused
# plan never reaches the TV because recovery.py prints nothing until the whole plan is built, so
# tv.py reads an empty batch; pipefail only makes this script exit non-zero afterwards.
"$PY" -I tools/recovery.py --commands "$LIST" "$STOCK" | "$PY" -I tools/tv.py --batch