Conversation
审阅者指南将 CSC 功能的 post-fs 脚本重构为使用基于哈希的增量处理,以及 Magisk/KSU 的 overlay 风格部署来替代直接的 bind mount,同时加强对 floating_feature 的路径处理,并确保 CSC 工具可执行;对 service.sh 进行了一处轻微注释调整。 更新后的功能文件处理与 overlay 部署时序图sequenceDiagram
participant PostFsScript
participant CSCTool
participant Filesystem
participant MagiskKSU
Note over PostFsScript: process_feature_file(label, filename, config_name)
PostFsScript->>Filesystem: find_file for origin_path
alt origin_path not found and label ff
PostFsScript->>Filesystem: check /system/etc/floating_feature.xml
alt exists
PostFsScript->>PostFsScript: set origin_path=/system/etc/floating_feature.xml
else not exists
PostFsScript->>Filesystem: check /etc/floating_feature.xml
alt exists
PostFsScript->>PostFsScript: set origin_path=/etc/floating_feature.xml
else not exists
PostFsScript-->>PostFsScript: log skip and return
end
end
else origin_path found
PostFsScript-->>PostFsScript: use found origin_path
end
PostFsScript->>Filesystem: read user_config from CONFIG_PATH
PostFsScript->>PostFsScript: calc_hash(origin_path, user_config, TOOL)
PostFsScript->>Filesystem: read old_hash from HASH_DIR/label.md5
PostFsScript->>PostFsScript: compare current_hash with old_hash
PostFsScript->>Filesystem: check MODDIR+normalized_origin_path exists
alt hash unchanged and deployed file exists
PostFsScript-->>PostFsScript: log no change, skip processing
else changed or first run
Note over PostFsScript: label ff plaintext path
alt label == ff
PostFsScript->>Filesystem: cp origin_path to decoded_file
alt user_config exists
PostFsScript->>CSCTool: --patch decoded_file user_config patched_file
CSCTool-->>PostFsScript: patched_file
else no user_config
PostFsScript->>Filesystem: cp decoded_file to patched_file
end
PostFsScript->>Filesystem: deploy_for_mount patched_file -> target_path
PostFsScript->>Filesystem: write current_hash to HASH_DIR/label.md5
else non ff encrypted path
PostFsScript->>CSCTool: --decode origin_path decoded_file
CSCTool-->>PostFsScript: decoded_file
alt decoded_file missing
PostFsScript-->>PostFsScript: log decode failure and return
else decoded_file ok
alt user_config exists
PostFsScript->>CSCTool: --patch decoded_file user_config patched_file
CSCTool-->>PostFsScript: patched_file
else no user_config
PostFsScript->>Filesystem: cp decoded_file to patched_file
end
PostFsScript->>CSCTool: --encode patched_file final_file
CSCTool-->>PostFsScript: final_file or failure
alt final_file exists
PostFsScript->>Filesystem: deploy_for_mount final_file -> /system+origin_path
else encode failed
PostFsScript->>Filesystem: deploy_for_mount patched_file -> /system+origin_path
end
PostFsScript->>Filesystem: write current_hash to HASH_DIR/label.md5
end
end
end
Note over MagiskKSU,Filesystem: Later, Magisk/KSU uses module files under MODDIR for OverlayFS/Magic Mount
文件级改动
提示与命令与 Sourcery 交互
自定义你的体验访问你的控制面板 以:
获取帮助Original review guide in EnglishReviewer's GuideRefactors the CSC feature post-fs script to use hash-based incremental processing and Magisk/KSU overlay-style deployment instead of direct bind mounts, adds more robust path handling for floating_feature, and ensures the CSC tool is executable; minor comment tweak in service.sh. Sequence diagram for updated feature file processing and overlay deploymentsequenceDiagram
participant PostFsScript
participant CSCTool
participant Filesystem
participant MagiskKSU
Note over PostFsScript: process_feature_file(label, filename, config_name)
PostFsScript->>Filesystem: find_file for origin_path
alt origin_path not found and label ff
PostFsScript->>Filesystem: check /system/etc/floating_feature.xml
alt exists
PostFsScript->>PostFsScript: set origin_path=/system/etc/floating_feature.xml
else not exists
PostFsScript->>Filesystem: check /etc/floating_feature.xml
alt exists
PostFsScript->>PostFsScript: set origin_path=/etc/floating_feature.xml
else not exists
PostFsScript-->>PostFsScript: log skip and return
end
end
else origin_path found
PostFsScript-->>PostFsScript: use found origin_path
end
PostFsScript->>Filesystem: read user_config from CONFIG_PATH
PostFsScript->>PostFsScript: calc_hash(origin_path, user_config, TOOL)
PostFsScript->>Filesystem: read old_hash from HASH_DIR/label.md5
PostFsScript->>PostFsScript: compare current_hash with old_hash
PostFsScript->>Filesystem: check MODDIR+normalized_origin_path exists
alt hash unchanged and deployed file exists
PostFsScript-->>PostFsScript: log no change, skip processing
else changed or first run
Note over PostFsScript: label ff plaintext path
alt label == ff
PostFsScript->>Filesystem: cp origin_path to decoded_file
alt user_config exists
PostFsScript->>CSCTool: --patch decoded_file user_config patched_file
CSCTool-->>PostFsScript: patched_file
else no user_config
PostFsScript->>Filesystem: cp decoded_file to patched_file
end
PostFsScript->>Filesystem: deploy_for_mount patched_file -> target_path
PostFsScript->>Filesystem: write current_hash to HASH_DIR/label.md5
else non ff encrypted path
PostFsScript->>CSCTool: --decode origin_path decoded_file
CSCTool-->>PostFsScript: decoded_file
alt decoded_file missing
PostFsScript-->>PostFsScript: log decode failure and return
else decoded_file ok
alt user_config exists
PostFsScript->>CSCTool: --patch decoded_file user_config patched_file
CSCTool-->>PostFsScript: patched_file
else no user_config
PostFsScript->>Filesystem: cp decoded_file to patched_file
end
PostFsScript->>CSCTool: --encode patched_file final_file
CSCTool-->>PostFsScript: final_file or failure
alt final_file exists
PostFsScript->>Filesystem: deploy_for_mount final_file -> /system+origin_path
else encode failed
PostFsScript->>Filesystem: deploy_for_mount patched_file -> /system+origin_path
end
PostFsScript->>Filesystem: write current_hash to HASH_DIR/label.md5
end
end
end
Note over MagiskKSU,Filesystem: Later, Magisk/KSU uses module files under MODDIR for OverlayFS/Magic Mount
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - 我发现了 3 个问题,并给出了一些整体反馈:
- 在非 ff 分支中,你调用了
deploy_for_mount "$final_file" "/system$origin_path"(回退路径同理),但origin_path可能已经是/system下或其他根路径下的绝对路径;建议直接传入原始的origin_path,并让deploy_for_mount自行处理规范化,以避免生成诸如/system/optics/...这样的无效路径。 /etc/*→/system/etc/*的路径规范化逻辑同时出现在增量 Hash 校验和deploy_for_mount内部;你可以把这段路径规范化逻辑集中到一个统一的辅助函数中,避免“检查文件是否存在”和“实际部署文件的位置”之间出现细微不一致。
供 AI 代理使用的提示(Prompt for AI Agents)
Please address the comments from this code review:
## Overall Comments
- In the non-ff branch you call `deploy_for_mount "$final_file" "/system$origin_path"` (and similarly for the fallback), but `origin_path` may already be an absolute path under `/system` or another root; consider passing the raw `origin_path` and letting `deploy_for_mount` handle any normalization to avoid generating invalid paths like `/system/optics/...`.
- The `/etc/*` → `/system/etc/*` normalization logic appears in both the incremental hash check and inside `deploy_for_mount`; you could centralize this path normalization in a single helper to avoid subtle inconsistencies between where you check for existing files and where you actually deploy them.
## Individual Comments
### Comment 1
<location path="module_files/post-fs-data.sh" line_range="190-194" />
<code_context>
- safe_mount "$final_file" "$origin_path"
- restorecon "$origin_path"
+ debug "部署加密文件以供挂载"
+ deploy_for_mount "$final_file" "/system$origin_path"
+ echo "$current_hash" > "$hash_file" # 记录 Hash
else
- log "注意: 加密失败,尝试挂载明文文件"
- safe_mount "$patched_file" "$origin_path"
- restorecon "$origin_path"
+ log "注意: 加密失败,尝试部署明文文件"
+ deploy_for_mount "$patched_file" "/system$origin_path"
+ # 即使失败使用明文,依然保存Hash,避免每次重启重复失败操作
+ echo "$current_hash" > "$hash_file"
</code_context>
<issue_to_address>
**issue (bug_risk):** 在这里使用 "/system$origin_path" 很可能会生成错误的覆盖目标路径。
在这个分支中,`origin_path` 已经是真实的源路径(例如 `/optics/configs/...`),之前也被直接作为挂载目标使用。把调用改成 `deploy_for_mount "$final_file" "/system$origin_path"` 会把路径重写为 `/system/optics/...`,这是另一个位置,可能会导致覆盖层无法作用于真正的配置文件。同时也把 `/etc -> /system/etc` 的细节泄露到了调用方。请传递真实的目标路径(例如 `origin_path` 或其规范化结果),并把所有 `/system` 相关的规范化逻辑都保留在 `deploy_for_mount` 内部。
</issue_to_address>
### Comment 2
<location path="module_files/post-fs-data.sh" line_range="123-128" />
<code_context>
+ [ -f "$hash_file" ] && old_hash=$(cat "$hash_file")
+
+ # 检查标准化后的部署路径是否存在文件
+ local check_path="$origin_path"
+ case "$check_path" in
+ /etc/*) check_path="/system$check_path" ;;
+ esac
+
+ if [ "$current_hash" = "$old_hash" ] && [ -f "$MODDIR$check_path" ]; then
+ log "增量更新校验通过: $label 无变动,跳过处理。"
+ return
</code_context>
<issue_to_address>
**issue (bug_risk):** 基于 Hash 的“短路”逻辑使用的目标路径与后续部署使用的目标路径不同,会导致不必要的重复处理。
在非 `ff` 流程中,你最终部署到 `/system$origin_path`,但 Hash 短路逻辑检查的是 `$MODDIR$origin_path`(只有 `/etc/*` 会加上 `/system` 前缀)。对于非 `/etc` 路径,这会保证 `-f` 检查必然失败,从而在 Hash 相同的情况下仍然强制重复处理。请考虑:(a)让 `check_path` 与最终 `deploy_for_mount` 的目标路径保持一致,或者(b)把“目标路径计算”抽取成一个共享的辅助函数,供 Hash 检查和部署逻辑共同使用。
</issue_to_address>
### Comment 3
<location path="module_files/post-fs-data.sh" line_range="77" />
<code_context>
+ cp -f "$src_file" "$module_target_path"
+
+ # 同步 SELinux 上下文
+ if [ -f "$origin_path" ]; then
+ local ctx=$(ls -Z "$origin_path" | awk '{print $1}')
+ [ -n "$ctx" ] && chcon "$ctx" "$module_target_path"
fi
+
</code_context>
<issue_to_address>
**suggestion:** 当所选的 origin 路径不存在时,SELinux 上下文复制可能会静默失败。
在 `deploy_for_mount` 中,调用者可能会传入一个“合成”的 `origin_path`(例如 `"/system$origin_path"`),这个路径可能尚不存在,因此该检查会直接跳过上下文复制,让覆盖层文件保持默认的 SELinux 上下文。如果你确实需要镜像原始文件的 SELinux 上下文,建议使用一个一定存在的路径作为 `ls -Z` 的来源(例如真实的原始文件路径或某个规范化路径);或者当 `$origin_path` 不存在时,退回到对 `"$module_target_path"` 调用 `restorecon`,而不是什么也不做。
```suggestion
# 同步 SELinux 上下文
# 优先从真实存在的 origin_path 复制 SELinux 上下文;
# 若 origin_path 不存在或无法获取上下文,则回退为对目标执行 restorecon。
if [ -n "$origin_path" ] && [ -e "$origin_path" ]; then
local ctx
ctx=$(ls -Z "$origin_path" 2>/dev/null | awk '{print $1}')
if [ -n "$ctx" ]; then
chcon "$ctx" "$module_target_path" 2>/dev/null || {
# chcon 失败时回退 restorecon(若可用)
if command -v restorecon >/dev/null 2>&1; then
restorecon "$module_target_path" 2>/dev/null
fi
}
else
# 未能解析出上下文,直接回退 restorecon(若可用)
if command -v restorecon >/dev/null 2>&1; then
restorecon "$module_target_path" 2>/dev/null
fi
fi
else
# origin_path 不存在或为空时,不再静默跳过,改为回退 restorecon(若可用)
if command -v restorecon >/dev/null 2>&1; then
restorecon "$module_target_path" 2>/dev/null
fi
fi
```
</issue_to_address>帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的评审质量。
Original comment in English
Hey - I've found 3 issues, and left some high level feedback:
- In the non-ff branch you call
deploy_for_mount "$final_file" "/system$origin_path"(and similarly for the fallback), butorigin_pathmay already be an absolute path under/systemor another root; consider passing the raworigin_pathand lettingdeploy_for_mounthandle any normalization to avoid generating invalid paths like/system/optics/.... - The
/etc/*→/system/etc/*normalization logic appears in both the incremental hash check and insidedeploy_for_mount; you could centralize this path normalization in a single helper to avoid subtle inconsistencies between where you check for existing files and where you actually deploy them.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In the non-ff branch you call `deploy_for_mount "$final_file" "/system$origin_path"` (and similarly for the fallback), but `origin_path` may already be an absolute path under `/system` or another root; consider passing the raw `origin_path` and letting `deploy_for_mount` handle any normalization to avoid generating invalid paths like `/system/optics/...`.
- The `/etc/*` → `/system/etc/*` normalization logic appears in both the incremental hash check and inside `deploy_for_mount`; you could centralize this path normalization in a single helper to avoid subtle inconsistencies between where you check for existing files and where you actually deploy them.
## Individual Comments
### Comment 1
<location path="module_files/post-fs-data.sh" line_range="190-194" />
<code_context>
- safe_mount "$final_file" "$origin_path"
- restorecon "$origin_path"
+ debug "部署加密文件以供挂载"
+ deploy_for_mount "$final_file" "/system$origin_path"
+ echo "$current_hash" > "$hash_file" # 记录 Hash
else
- log "注意: 加密失败,尝试挂载明文文件"
- safe_mount "$patched_file" "$origin_path"
- restorecon "$origin_path"
+ log "注意: 加密失败,尝试部署明文文件"
+ deploy_for_mount "$patched_file" "/system$origin_path"
+ # 即使失败使用明文,依然保存Hash,避免每次重启重复失败操作
+ echo "$current_hash" > "$hash_file"
</code_context>
<issue_to_address>
**issue (bug_risk):** Using "/system$origin_path" here likely produces an incorrect overlay target path.
In this branch, `origin_path` is already the real source path (e.g. `/optics/configs/...`) and was previously used directly as the mount target. Changing the call to `deploy_for_mount "$final_file" "/system$origin_path"` rewrites that to `/system/optics/...`, which is a different location and may prevent the overlay from affecting the actual config file. It also spreads `/etc -> /system/etc` concerns into the caller. Please pass the real target path (e.g. `origin_path` or a canonicalized variant) and keep any `/system` normalization inside `deploy_for_mount`.
</issue_to_address>
### Comment 2
<location path="module_files/post-fs-data.sh" line_range="123-128" />
<code_context>
+ [ -f "$hash_file" ] && old_hash=$(cat "$hash_file")
+
+ # 检查标准化后的部署路径是否存在文件
+ local check_path="$origin_path"
+ case "$check_path" in
+ /etc/*) check_path="/system$check_path" ;;
+ esac
+
+ if [ "$current_hash" = "$old_hash" ] && [ -f "$MODDIR$check_path" ]; then
+ log "增量更新校验通过: $label 无变动,跳过处理。"
+ return
</code_context>
<issue_to_address>
**issue (bug_risk):** Hash-based short‑circuit uses a different target path than the later deployment, causing unnecessary reprocessing.
In non-`ff` flows you deploy to `/system$origin_path`, but the hash short‑circuit probes `$MODDIR$origin_path` (only `/etc/*` gets the `/system` prefix). For non-`/etc` paths this guarantees the `-f` check fails and forces reprocessing even when hashes match. Please either (a) make `check_path` match the final `deploy_for_mount` target, or (b) factor target-path computation into a shared helper used by both the hash check and deployment.
</issue_to_address>
### Comment 3
<location path="module_files/post-fs-data.sh" line_range="77" />
<code_context>
+ cp -f "$src_file" "$module_target_path"
+
+ # 同步 SELinux 上下文
+ if [ -f "$origin_path" ]; then
+ local ctx=$(ls -Z "$origin_path" | awk '{print $1}')
+ [ -n "$ctx" ] && chcon "$ctx" "$module_target_path"
fi
+
</code_context>
<issue_to_address>
**suggestion:** SELinux context copy may fail silently when the chosen origin path does not exist.
In `deploy_for_mount`, callers may pass a synthetic `origin_path` (e.g. `"/system$origin_path"`) that doesn’t exist yet, so this check just skips context copy and leaves the overlay with a default context. If you need to mirror the original file’s SELinux context, consider using a path that’s guaranteed to exist as the `ls -Z` source (e.g. the real origin file or a canonical path), or falling back to `restorecon "$module_target_path"` when `$origin_path` is missing instead of doing nothing.
```suggestion
# 同步 SELinux 上下文
# 优先从真实存在的 origin_path 复制 SELinux 上下文;
# 若 origin_path 不存在或无法获取上下文,则回退为对目标执行 restorecon。
if [ -n "$origin_path" ] && [ -e "$origin_path" ]; then
local ctx
ctx=$(ls -Z "$origin_path" 2>/dev/null | awk '{print $1}')
if [ -n "$ctx" ]; then
chcon "$ctx" "$module_target_path" 2>/dev/null || {
# chcon 失败时回退 restorecon(若可用)
if command -v restorecon >/dev/null 2>&1; then
restorecon "$module_target_path" 2>/dev/null
fi
}
else
# 未能解析出上下文,直接回退 restorecon(若可用)
if command -v restorecon >/dev/null 2>&1; then
restorecon "$module_target_path" 2>/dev/null
fi
fi
else
# origin_path 不存在或为空时,不再静默跳过,改为回退 restorecon(若可用)
if command -v restorecon >/dev/null 2>&1; then
restorecon "$module_target_path" 2>/dev/null
fi
fi
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| deploy_for_mount "$final_file" "/system$origin_path" | ||
| echo "$current_hash" > "$hash_file" # 记录 Hash | ||
| else | ||
| log "注意: 加密失败,尝试挂载明文文件" | ||
| safe_mount "$patched_file" "$origin_path" | ||
| restorecon "$origin_path" | ||
| log "注意: 加密失败,尝试部署明文文件" | ||
| deploy_for_mount "$patched_file" "/system$origin_path" |
There was a problem hiding this comment.
issue (bug_risk): 在这里使用 "/system$origin_path" 很可能会生成错误的覆盖目标路径。
在这个分支中,origin_path 已经是真实的源路径(例如 /optics/configs/...),之前也被直接作为挂载目标使用。把调用改成 deploy_for_mount "$final_file" "/system$origin_path" 会把路径重写为 /system/optics/...,这是另一个位置,可能会导致覆盖层无法作用于真正的配置文件。同时也把 /etc -> /system/etc 的细节泄露到了调用方。请传递真实的目标路径(例如 origin_path 或其规范化结果),并把所有 /system 相关的规范化逻辑都保留在 deploy_for_mount 内部。
Original comment in English
issue (bug_risk): Using "/system$origin_path" here likely produces an incorrect overlay target path.
In this branch, origin_path is already the real source path (e.g. /optics/configs/...) and was previously used directly as the mount target. Changing the call to deploy_for_mount "$final_file" "/system$origin_path" rewrites that to /system/optics/..., which is a different location and may prevent the overlay from affecting the actual config file. It also spreads /etc -> /system/etc concerns into the caller. Please pass the real target path (e.g. origin_path or a canonicalized variant) and keep any /system normalization inside deploy_for_mount.
| local check_path="$origin_path" | ||
| case "$check_path" in | ||
| /etc/*) check_path="/system$check_path" ;; | ||
| esac | ||
|
|
||
| if [ "$current_hash" = "$old_hash" ] && [ -f "$MODDIR$check_path" ]; then |
There was a problem hiding this comment.
issue (bug_risk): 基于 Hash 的“短路”逻辑使用的目标路径与后续部署使用的目标路径不同,会导致不必要的重复处理。
在非 ff 流程中,你最终部署到 /system$origin_path,但 Hash 短路逻辑检查的是 $MODDIR$origin_path(只有 /etc/* 会加上 /system 前缀)。对于非 /etc 路径,这会保证 -f 检查必然失败,从而在 Hash 相同的情况下仍然强制重复处理。请考虑:(a)让 check_path 与最终 deploy_for_mount 的目标路径保持一致,或者(b)把“目标路径计算”抽取成一个共享的辅助函数,供 Hash 检查和部署逻辑共同使用。
Original comment in English
issue (bug_risk): Hash-based short‑circuit uses a different target path than the later deployment, causing unnecessary reprocessing.
In non-ff flows you deploy to /system$origin_path, but the hash short‑circuit probes $MODDIR$origin_path (only /etc/* gets the /system prefix). For non-/etc paths this guarantees the -f check fails and forces reprocessing even when hashes match. Please either (a) make check_path match the final deploy_for_mount target, or (b) factor target-path computation into a shared helper used by both the hash check and deployment.
| # 复制文件到模块对应目录,KSU/Magisk 会在稍后自动 OverlayFS 挂载它 | ||
| cp -f "$src_file" "$module_target_path" | ||
|
|
||
| # 同步 SELinux 上下文 |
There was a problem hiding this comment.
suggestion: 当所选的 origin 路径不存在时,SELinux 上下文复制可能会静默失败。
在 deploy_for_mount 中,调用者可能会传入一个“合成”的 origin_path(例如 "/system$origin_path"),这个路径可能尚不存在,因此该检查会直接跳过上下文复制,让覆盖层文件保持默认的 SELinux 上下文。如果你确实需要镜像原始文件的 SELinux 上下文,建议使用一个一定存在的路径作为 ls -Z 的来源(例如真实的原始文件路径或某个规范化路径);或者当 $origin_path 不存在时,退回到对 "$module_target_path" 调用 restorecon,而不是什么也不做。
| # 同步 SELinux 上下文 | |
| # 同步 SELinux 上下文 | |
| # 优先从真实存在的 origin_path 复制 SELinux 上下文; | |
| # 若 origin_path 不存在或无法获取上下文,则回退为对目标执行 restorecon。 | |
| if [ -n "$origin_path" ] && [ -e "$origin_path" ]; then | |
| local ctx | |
| ctx=$(ls -Z "$origin_path" 2>/dev/null | awk '{print $1}') | |
| if [ -n "$ctx" ]; then | |
| chcon "$ctx" "$module_target_path" 2>/dev/null || { | |
| # chcon 失败时回退 restorecon(若可用) | |
| if command -v restorecon >/dev/null 2>&1; then | |
| restorecon "$module_target_path" 2>/dev/null | |
| fi | |
| } | |
| else | |
| # 未能解析出上下文,直接回退 restorecon(若可用) | |
| if command -v restorecon >/dev/null 2>&1; then | |
| restorecon "$module_target_path" 2>/dev/null | |
| fi | |
| fi | |
| else | |
| # origin_path 不存在或为空时,不再静默跳过,改为回退 restorecon(若可用) | |
| if command -v restorecon >/dev/null 2>&1; then | |
| restorecon "$module_target_path" 2>/dev/null | |
| fi | |
| fi |
Original comment in English
suggestion: SELinux context copy may fail silently when the chosen origin path does not exist.
In deploy_for_mount, callers may pass a synthetic origin_path (e.g. "/system$origin_path") that doesn’t exist yet, so this check just skips context copy and leaves the overlay with a default context. If you need to mirror the original file’s SELinux context, consider using a path that’s guaranteed to exist as the ls -Z source (e.g. the real origin file or a canonical path), or falling back to restorecon "$module_target_path" when $origin_path is missing instead of doing nothing.
| # 同步 SELinux 上下文 | |
| # 同步 SELinux 上下文 | |
| # 优先从真实存在的 origin_path 复制 SELinux 上下文; | |
| # 若 origin_path 不存在或无法获取上下文,则回退为对目标执行 restorecon。 | |
| if [ -n "$origin_path" ] && [ -e "$origin_path" ]; then | |
| local ctx | |
| ctx=$(ls -Z "$origin_path" 2>/dev/null | awk '{print $1}') | |
| if [ -n "$ctx" ]; then | |
| chcon "$ctx" "$module_target_path" 2>/dev/null || { | |
| # chcon 失败时回退 restorecon(若可用) | |
| if command -v restorecon >/dev/null 2>&1; then | |
| restorecon "$module_target_path" 2>/dev/null | |
| fi | |
| } | |
| else | |
| # 未能解析出上下文,直接回退 restorecon(若可用) | |
| if command -v restorecon >/dev/null 2>&1; then | |
| restorecon "$module_target_path" 2>/dev/null | |
| fi | |
| fi | |
| else | |
| # origin_path 不存在或为空时,不再静默跳过,改为回退 restorecon(若可用) | |
| if command -v restorecon >/dev/null 2>&1; then | |
| restorecon "$module_target_path" 2>/dev/null | |
| fi | |
| fi |
Summary by Sourcery
为 OneUI CSC 功能文件引入基于哈希的增量处理和覆盖(overlay)式部署,以减少重复工作,并与 Magisk/KSU 挂载集成。
增强内容:
floating_feature的处理,提供更清晰的system/etc回退逻辑和统一的部署流程。Original summary in English
Summary by Sourcery
Introduce hash-based incremental processing and overlay deployment for OneUI CSC feature files to reduce redundant work and integrate with Magisk/KSU mounting.
Enhancements: