fix: correct zip root path and add idempotent build.prop append

- Fix ZIPROOT path from 3 to 4 levels up (../../../../)

- Add path validation before install

- Replace simple cat append with key-based dedup for build.prop (skips existing keys to prevent duplication on re-flash)

- Update AGENTS.md and README.md to reflect the changes
This commit is contained in:
purpl
2026-07-03 11:29:20 +08:00
parent 155a991897
commit c87557d537
3 changed files with 38 additions and 11 deletions

View File

@@ -33,7 +33,13 @@ abort() {
# The script lives at: META-INF/com/google/android/update-binary
# Zip root is 3 levels up from the script's directory.
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
ZIPROOT=$(cd "$SCRIPT_DIR/../../.." && pwd)
# 脚本位于 META-INF/com/google/android/update-binary向上4级到 zip 根
ZIPROOT=$(cd "$SCRIPT_DIR/../../../../" && pwd)
# 验证路径正确
if [ ! -f "$ZIPROOT/system/build.prop" ]; then
abort "Cannot locate zip root (system/build.prop not found)."
fi
ui_print "========================================"
ui_print " CB-C6s-STU-GSI-Fixes"
@@ -68,8 +74,16 @@ fi
cp /system/build.prop /system/build.prop.bak 2>/dev/null
chmod 644 /system/build.prop.bak 2>/dev/null
# APPEND — 使用 >> 追加而非覆盖
cat "$BUILDPROP_SRC" >> /system/build.prop
# 去重追加:逐 key 检查,仅追加不存在的条目
while IFS= read -r line || [ -n "$line" ]; do
case "$line" in
''|'#'*) continue;;
esac
key="${line%%=*}"
if ! grep -q "^${key}=" /system/build.prop 2>/dev/null; then
echo "$line" >> /system/build.prop
fi
done < "$BUILDPROP_SRC"
chmod 644 /system/build.prop
ui_print "build.prop: entries appended. Backup at build.prop.bak"