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:
22
AGENTS.md
22
AGENTS.md
@@ -34,7 +34,7 @@ zip root
|
||||
|
||||
### Install flow (update-binary)
|
||||
|
||||
1. Locate zip root: `dirname $0` → up 3 levels (`../../..`)
|
||||
1. Locate zip root: `dirname $0` → up 4 levels (`../../../../`)
|
||||
2. Mount `/system` and `/vendor`
|
||||
3. **Append** `system/build.prop` → `/system/build.prop` (backup first to `.bak`)
|
||||
4. Copy `goodix_ts.idc` → `/system/usr/idc/`
|
||||
@@ -43,11 +43,23 @@ zip root
|
||||
|
||||
### Critical constraint: build.prop is APPENDED, never replaced
|
||||
|
||||
`update-binary` line ~72: `cat "$BUILDPROP_SRC" >> /system/build.prop`
|
||||
`update-binary` now uses **key-based dedup**: each line is appended only if its
|
||||
key (`key=` before `=`) does not already exist in the target.
|
||||
|
||||
The `>>` is intentional. Using `>` or `package_extract_dir` would clobber the
|
||||
device's existing properties. Re-flashing duplicates entries — warn the user or
|
||||
add idempotency if this becomes a problem.
|
||||
```sh
|
||||
# 去重追加:逐 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"
|
||||
```
|
||||
|
||||
Re-flashing is now safe — entries are never duplicated.
|
||||
|
||||
## Key Files
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -76,9 +76,10 @@ During flash, TWRP will show:
|
||||
|
||||
## Notes
|
||||
|
||||
- The `build.prop` entries are **appended, not replaced**. Re-flashing
|
||||
the zip multiple times will duplicate the entries — restore from
|
||||
`/system/build.prop.bak` if needed, or inspect the file first.
|
||||
- The `build.prop` entries are **appended with dedup** — each property key
|
||||
(`key=value`) is only added if the key does not already exist in
|
||||
`/system/build.prop`. Re-flashing the zip multiple times is safe and
|
||||
will **not** duplicate entries.
|
||||
- The `sensor_config.xml` covers four camera sensor combinations:
|
||||
rear (`hi846`, `gc8034_rear`) and front (`hi846_front`, `gc8034`),
|
||||
each with OTP EEPROM tuning parameters.
|
||||
|
||||
Reference in New Issue
Block a user