From 63184fc558330567f227773797e1ee9e64f666bb Mon Sep 17 00:00:00 2001 From: Cappy Ishihara Date: Sat, 30 Mar 2024 20:47:39 +0700 Subject: [PATCH] Add basic support for downloading extra packages in the disc image --- src/builder.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/builder.rs b/src/builder.rs index e6096f7..57cb1ef 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -311,6 +311,10 @@ pub struct DnfRootBuilder { pub arch_exclude: BTreeMap>, #[serde(default)] pub repodir: Option, + + /// Extra packages to download in the disc image idk + #[serde(default)] + pub extra_packages: Vec, } impl RootBuilder for DnfRootBuilder { @@ -375,6 +379,24 @@ impl RootBuilder for DnfRootBuilder { manifest.users.iter().try_for_each(|user| user.add_to_chroot(&chroot))?; } + // get the workspace folder + + let out = manifest.out_file.as_ref().map_or("katsu-work/repo", |s| s); + let out = Path::new(out); + + if !self.extra_packages.is_empty() { + // workaround for being unable to access fields in run_cmd! + let extra_packages = self.extra_packages.clone(); + info!("Downloading extra packages to workspace"); + // todo: copy the repo to the resulting image + // run command in host namespace + cmd_lib::run_cmd!( + mkdir -p $out; + $dnf download -y --destdir=$out $[extra_packages] 2>&1; + createrepo_c $out; + )?; + } + // now, let's run some funny post-install scripts info!("Running post-install scripts");