diff --git a/src/builder.rs b/src/builder.rs index 50d4f8c..17049c3 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -63,7 +63,7 @@ impl RootBuilder for DnfRootBuilder { fn build(&self, chroot: &Path, manifest: &Manifest) -> Result<()> { info!("Running Pre-install scripts"); - run_all_scripts(manifest.scripts.pre.clone(), chroot, false)?; + run_all_scripts(&manifest.scripts.pre, chroot, false)?; if let Some(disk) = &manifest.disk { let f = disk.fstab(chroot)?; @@ -102,32 +102,27 @@ impl RootBuilder for DnfRootBuilder { } options.append(&mut exclude.iter().map(|p| format!("--exclude={p}")).collect()); - // todo: maybe not unwrap? util::run_with_chroot(chroot, || -> Result<()> { cmd_lib::run_cmd!( - dnf install -y --releasever=${releasever} --installroot=${chroot} $[packages] $[options]; - dnf clean all --installroot=${chroot}; + dnf install -y --releasever=$releasever --installroot=$chroot $[packages] $[options]; + dnf clean all --installroot=$chroot; )?; Ok(()) })?; info!("Setting up users"); - let users = &manifest.users; - - if users.is_empty() { + if manifest.users.is_empty() { warn!("No users specified, no users will be created!"); } else { - for user in users { - user.add_to_chroot(chroot)?; - } + manifest.users.iter().try_for_each(|user| user.add_to_chroot(chroot))?; } // now, let's run some funny post-install scripts info!("Running post-install scripts"); - run_all_scripts(manifest.scripts.post.clone(), &chroot, true)?; + run_all_scripts(&manifest.scripts.post, &chroot, true)?; Ok(()) } @@ -180,10 +175,10 @@ pub fn run_script(script: Script, chroot: &Path, in_chroot: bool) -> Result<()> Ok(()) } -pub fn run_all_scripts(scripts: Vec