Skip to content

Commit

Permalink
installer: Move packages from Context to Model
Browse files Browse the repository at this point in the history
Why on earth did we ever have model data there?!

Signed-off-by: Ikey Doherty <[email protected]>
  • Loading branch information
ikeycode committed Jun 28, 2024
1 parent 1ec2ed0 commit 02ccb11
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 18 deletions.
2 changes: 1 addition & 1 deletion crates/installer/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ impl Installer {
priority: 0,
}));
s.push(Step::install_packages(InstallPackages {
names: context.packages.iter().cloned().collect::<Vec<_>>(),
names: model.packages.iter().cloned().collect::<Vec<_>>(),
}));

// Lastly, flip cleanups to front in reverse (due to mounts)
Expand Down
3 changes: 3 additions & 0 deletions crates/installer/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ pub struct Model<'a> {

/// Timezone ID
pub timezone: Option<String>,

/// Package selections
pub packages: BTreeSet<String>,
}
12 changes: 0 additions & 12 deletions crates/installer/src/steps/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use std::{collections::BTreeSet, path::PathBuf};
pub struct Context {
pub root: PathBuf,
mounts: BTreeSet<PathBuf>,
pub(crate) packages: BTreeSet<String>,
}

impl Context {
Expand All @@ -19,22 +18,11 @@ impl Context {
Self {
root: root.into(),
mounts: BTreeSet::new(),
packages: BTreeSet::new(),
}
}

/// Push a successful mount into the unmount list
pub fn push_mount(&mut self, mount: impl Into<PathBuf>) {
self.mounts.insert(mount.into());
}

pub fn with_packages<I: IntoIterator<Item = impl AsRef<str>>>(self, pkgs: I) -> Self {
Self {
packages: pkgs
.into_iter()
.map(|p| p.as_ref().to_string())
.collect::<BTreeSet<_>>(),
..self
}
}
}
7 changes: 2 additions & 5 deletions lichen_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ async fn main() -> color_eyre::Result<()> {
partitions: [rootfs.clone()].into(),
locale: Some(selected_locale),
timezone: Some(timezone),
packages: selections.selections_with(["develop", "gnome", "kernel-desktop"])?,
};
println!("\n\n");

Expand All @@ -152,11 +153,7 @@ async fn main() -> color_eyre::Result<()> {
// Push some packages into the installer based on selections

// TODO: Use proper temp directory
let mut context = installer::steps::Context::new("/tmp/lichen").with_packages(selections.selections_with([
"develop",
"gnome",
"kernel-desktop",
])?);
let mut context = installer::steps::Context::new("/tmp/lichen");

let (cleanups, steps) = inst.compile_to_steps(&model, &context)?;
let multi = indicatif::MultiProgress::new();
Expand Down

0 comments on commit 02ccb11

Please sign in to comment.