add psudofs mounting to transation hooks because im stupid and it wasn't a feature before
This commit is contained in:
+21
-1
@@ -550,7 +550,14 @@ fn run_hook_command(
|
||||
None
|
||||
};
|
||||
|
||||
let mut command = if fakeroot::is_root() && rootfs.join("bin/sh").exists() {
|
||||
let use_chroot = fakeroot::is_root() && rootfs.join("bin/sh").exists();
|
||||
let _mounts = if should_mount_chroot_filesystems(rootfs, use_chroot) {
|
||||
Some(super::scripts::mount_chroot_filesystems(rootfs, None)?)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let mut command = if use_chroot {
|
||||
let mut cmd = Command::new("chroot");
|
||||
cmd.arg(rootfs).arg("/bin/sh").arg("-lc").arg(&hook.command);
|
||||
cmd
|
||||
@@ -589,6 +596,10 @@ fn run_hook_command(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn should_mount_chroot_filesystems(rootfs: &Path, use_chroot: bool) -> bool {
|
||||
use_chroot && super::scripts::should_use_chroot(rootfs)
|
||||
}
|
||||
|
||||
fn run_command_with_optional_stdin(
|
||||
command: &mut Command,
|
||||
stdin_payload: Option<&str>,
|
||||
@@ -662,6 +673,15 @@ mod tests {
|
||||
assert!(!wildcard_match("usr/bin/*", "usr/lib/libc.so"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn transaction_hooks_mount_filesystems_only_for_target_chroots() {
|
||||
let rootfs = tempfile::tempdir().unwrap();
|
||||
|
||||
assert!(should_mount_chroot_filesystems(rootfs.path(), true));
|
||||
assert!(!should_mount_chroot_filesystems(rootfs.path(), false));
|
||||
assert!(!should_mount_chroot_filesystems(Path::new("/"), true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_hook_accepts_starpack_style_sections() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user