feat(xtask): 为常用 busybox 子命令建立符号链接

This commit is contained in:
YdrMaster 2022-05-11 19:26:23 +08:00
parent 6ba9602e8f
commit 72c2191039
2 changed files with 11 additions and 2 deletions

View File

@ -14,7 +14,7 @@
### 使用步骤
- 现在 `cargo rootfs {arch}` 将清空已有 `rootfs/{arch}`,然后产生供 zCore 以 linux 模式启动的最小文件系统——只有 `/bin/busybox``lib/lib/ld-musl-{arch}.so.1` 两个文件;
- 现在 `cargo rootfs {arch}` 将清空已有 `rootfs/{arch}`,然后产生供 zCore 以 linux 模式启动的最小文件系统——只有 `/bin/busybox``lib/lib/ld-musl-{arch}.so.1` 两个文件,以及一些指向 busybox 的符号链接
- `cargo libc-test {arch}` 命令将向 `rootfs/{arch}` 放入 libc 测试的测例文件,在必要时下载交叉编译工具链;
- 增加 `cargo other-test {arch}` 命令,向 `rootfs/{arch}` 放入其他测试的测例文件;
- `cargo image {arch}` 命令将 `rootfs/{arch}` 打包成 `zCore/{arch}.img` 文件,过程中不关心 `rootfs/{arch}` 的内容。因此如需要向文件系统加入文件,在 `image` 之前放入 `rootfs/{arch}` 即可;

View File

@ -88,6 +88,16 @@ impl Arch {
ArchCommands::X86_64 => PathBuf::from("prebuilt/linux/libc-libos.so"),
};
fs::copy(so, dir.join(libc_so)).unwrap();
// 为常用功能建立符号链接
const SH: &[&str] = &[
"cat", "cp", "echo", "false", "grep", "gzip", "kill", "ln", "ls", "mkdir", "mv",
"pidof", "ping", "ping6", "printenv", "ps", "pwd", "rm", "rmdir", "sh", "sleep",
"stat", "tar", "touch", "true", "uname", "usleep", "watch",
];
let bin = dir.join("bin");
for sh in SH {
unix::fs::symlink("busybox", bin.join(sh)).unwrap();
}
}
/// 将 libc-test 放入 rootfs。
@ -133,7 +143,6 @@ impl Arch {
// 递归 rootfs
self.rootfs(false);
let rootfs = self.command.rootfs();
unix::fs::symlink("busybox", rootfs.join("bin/ls")).unwrap();
match self.command {
ArchCommands::Riscv64 => {
let target = self.command.target();