Skip to content

Commit

Permalink
fix(xtask): ld-musl-{arch}.so.1 不能用符号链接
Browse files Browse the repository at this point in the history
  • Loading branch information
YdrMaster committed Jun 14, 2022
1 parent cfbc8d2 commit 904644e
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions xtask/src/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ impl LinuxRootfs {
/// 从安装目录拷贝所有 so 和 so 链接到 rootfs
fn put_libs(&self, musl: impl AsRef<Path>, dir: impl AsRef<Path>) {
let lib = self.path().join("lib");
let musl_libc_protected = format!("ld-musl-{}.so.1", self.0.name());
let musl_libc_ignored = "libc.so";
let strip = musl
.as_ref()
.join("bin")
Expand All @@ -125,12 +127,16 @@ impl LinuxRootfs {
.filter_map(|res| res.map(|e| e.path()).ok())
.filter(|path| check_so(path))
.for_each(|source| {
let target = lib.join(source.file_name().unwrap());
dir::rm(&target).unwrap();
let name = source.file_name().unwrap();
let target = lib.join(name);
if source.is_symlink() {
// `fs::copy` 会拷贝文件内容
unix::fs::symlink(source.read_link().unwrap(), target).unwrap();
} else {
if name != musl_libc_protected.as_str() {
dir::rm(&target).unwrap();
// `fs::copy` 会拷贝文件内容
unix::fs::symlink(source.read_link().unwrap(), target).unwrap();
}
} else if name != musl_libc_ignored {
dir::rm(&target).unwrap();
fs::copy(source, &target).unwrap();
Ext::new(&strip).arg("-s").arg(target).status();
}
Expand Down

0 comments on commit 904644e

Please sign in to comment.