summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHermes Agent <hermes@localhost>2026-08-11 21:08:42 +0000
committerHermes Agent <hermes@localhost>2026-08-11 21:08:42 +0000
commit4b3418a8a771edd87f85d3770fc7fd4e6fc05c09 (patch)
tree60a31725ac364db68c69dbd71471b54d8eeb01d2 /src
parentde352f683f104c68106d488863f338afdb836e94 (diff)
Archive independent rootfs with required privileges
Diffstat (limited to 'src')
-rw-r--r--src/main.rs40
1 files changed, 22 insertions, 18 deletions
diff --git a/src/main.rs b/src/main.rs
index 44cb296..9e081a8 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -18,31 +18,35 @@ fn main() {
let rootfs = workdir.join("chroot");
let artifact = artifact_path(&project);
- if workdir.exists() {
- fs::remove_dir_all(&workdir).expect("remove previous Hasher workdir");
+ let archive_existing = env::args().any(|argument| argument == "--archive-existing");
+ if !archive_existing {
+ if workdir.exists() {
+ fs::remove_dir_all(&workdir).expect("remove previous Hasher workdir");
+ }
+ fs::create_dir_all(&workdir).expect("create Hasher workdir");
+ run(
+ Command::new("hsh")
+ .args(["--mountpoints=/proc", "--initroot-only", "--workdir"])
+ .arg(&workdir),
+ "initialize isolated Hasher root",
+ );
+
+ let mut install = Command::new("hsh-install");
+ install.args(["--mountpoints=/proc", "--workdir"]);
+ install.arg(&workdir);
+ install.args(profile.install_arguments());
+ run(&mut install, "install target rootfs packages");
}
- fs::create_dir_all(&workdir).expect("create Hasher workdir");
+ assert!(rootfs.is_dir(), "isolated rootfs is missing: {}", rootfs.display());
fs::create_dir_all(artifact.parent().expect("artifact parent")).expect("create output directory");
- run(
- Command::new("hsh")
- .args(["--mountpoints=/proc", "--initroot-only", "--workdir"])
- .arg(&workdir),
- "initialize isolated Hasher root",
- );
-
- let mut install = Command::new("hsh-install");
- install.args(["--mountpoints=/proc", "--workdir"]);
- install.arg(&workdir);
- install.args(profile.install_arguments());
- run(&mut install, "install target rootfs packages");
-
if artifact.exists() {
fs::remove_file(&artifact).expect("remove previous artifact");
}
run(
- Command::new("tar")
- .args(["--numeric-owner", "--xattrs", "--acls", "--exclude=./.host", "-C"])
+ Command::new("sudo")
+ .arg("tar")
+ .args(["--numeric-owner", "--exclude=./.host", "-C"])
.arg(&rootfs)
.args(["-cpf"])
.arg(&artifact)