fix: 隔离每轮更新安装包路径#5219
Open
eyaeya wants to merge 1 commit into
Open
Conversation
bb3270e to
9b6068e
Compare
This was referenced Jul 8, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Dependency chain
无硬依赖,可独立合并。若与 #5217/#5218 同批处理,建议先合并 #5217 和 #5218,再合并本 PR,便于先稳定锁语义再处理后台安装交接竞态。若 #5197 后续继续修改
openclash_update.sh,需要保留本 PR 的 per-run package/helper staging 语义。问题现象
OpenClash 更新父脚本在预检后启动后台安装脚本,但父脚本结束后会释放外层更新锁。后台安装脚本原先读取固定的
/tmp/openclash.ipk或/tmp/openclash.apk,且 helper 脚本也固定为/tmp/openclash_update.sh。此时第二次更新可以进入父脚本,删除或重写第一轮仍在使用的交接文件。根因
下载和安装跨越两个进程:父脚本负责下载和启动 procd 后台服务,后台脚本负责实际
opkg install/apk add。两者通过固定/tmp/openclash.ipk|apk和固定/tmp/openclash_update.sh交接状态,但这些路径不随启动轮次隔离。证据
/tmp/openclash.ipk|apk。/tmp/openclash_update.sh,第一轮延迟清理可能删除第二轮刚生成的 helper。tests/openclash_update_package_path_test.sh禁止固定包路径和固定 helper 路径回归,并要求后台安装脚本接收本轮 staged package 路径。修复方案
/tmp/openclash_update_$$.ipk|apk,每轮进程独立。/tmp/openclash_update_$$.sh,ubus command 和延迟清理都使用该路径。opkg install/apk add读取该路径。为什么没有扩大范围
本 PR 不改变下载 URL、代理、重试、安装锁、包管理器调用参数或自动更新返回语义。系统包管理器锁删除由 #5217 处理;OpenClash 自有
flock锁文件稳定性由 #5218 处理。与已有开启态 PR 的关系
验证
bash -n luci-app-openclash/root/usr/share/openclash/*.sh:通过bash -n luci-app-openclash/root/etc/init.d/openclash:通过bash -n tests/*.sh:通过for t in tests/*.sh; do bash "$t"; done:全部通过git diff --check:通过rg -n '^(<<<<<<<|=======|>>>>>>>)':无匹配未做 live router 写入验证。
剩余风险
如果后台安装已经进入包管理器内部,仍依赖系统包管理器自身的锁和错误处理;本 PR 只保证 OpenClash 不再通过固定
/tmp/openclash.ipk|apk或固定/tmp/openclash_update.sh跨轮覆盖安装输入。