release v2.0.31:维护脚本 shebang 改 #!/bin/sh(--root 沙箱下正好指向 $PREFIX/bin/sh)
This commit is contained in:
@@ -48,7 +48,7 @@ object TermuxInstaller {
|
||||
* 把戳的值带上版本号,**对不上就只重跑修正式步骤**(不重新解压,
|
||||
* 解压要几十秒)。以后再加这类"装完之后要修一下"的逻辑,把这里 +1。
|
||||
*/
|
||||
private const val STAMP_VALUE = "ok:22"
|
||||
private const val STAMP_VALUE = "ok:23"
|
||||
|
||||
/**
|
||||
* 安装日志。
|
||||
@@ -494,9 +494,33 @@ object TermuxInstaller {
|
||||
}
|
||||
if (binary) continue
|
||||
|
||||
val text = String(bytes, Charsets.UTF_8)
|
||||
if (!text.contains(oldData)) continue
|
||||
var text = String(bytes, Charsets.UTF_8)
|
||||
|
||||
// ★★ dpkg 的维护脚本(var/lib/dpkg/info/xxx.postinst)要特殊处理。
|
||||
//
|
||||
// 我们给 dpkg 传了 --root=\(为了让它那套编译死的
|
||||
// 绝对路径落回我们自己目录),于是**脚本的 shebang 也会在
|
||||
// 沙箱里解析**:
|
||||
// #!/data/user/0/<包名>/files/usr/bin/sh
|
||||
// → \/data/user/0/<包名>/files/usr/bin/sh ← 不存在
|
||||
// 表现是:
|
||||
// dpkg: unable to execute .../openssh.postinst:
|
||||
// No such file or directory
|
||||
//
|
||||
// 改成 #!/bin/sh 就对了 —— 在沙箱里它正好是 \/bin/sh,
|
||||
// 而那个文件确实存在。
|
||||
val relPath = file.relativeTo(prefix).path.replace('\\', '/')
|
||||
if (relPath.startsWith("var/lib/dpkg/info/") ||
|
||||
relPath.startsWith("var/lib/dpkg/updates/")
|
||||
) {
|
||||
text = text.replaceFirst(
|
||||
Regex("^#![^\\n]*"), "#!/bin/sh",
|
||||
)
|
||||
file.writeText(text, Charsets.UTF_8)
|
||||
continue
|
||||
}
|
||||
|
||||
if (!text.contains(oldData)) continue
|
||||
file.writeText(text.replace(oldData, newData), Charsets.UTF_8)
|
||||
val rel = file.relativeTo(prefix).path.replace('\\', '/')
|
||||
if (rel.startsWith("bin/") || rel.startsWith("libexec/")) {
|
||||
|
||||
Reference in New Issue
Block a user