From a4fe8d9e15959154ef2ca62ee0a14c4a2e535ff3 Mon Sep 17 00:00:00 2001 From: Cory Forsstrom Date: Wed, 6 Mar 2024 14:09:34 -0800 Subject: [PATCH] Fix error when moss remove all packages (glibc) --- moss/src/client/mod.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/moss/src/client/mod.rs b/moss/src/client/mod.rs index 166ecec5..b18ac79d 100644 --- a/moss/src/client/mod.rs +++ b/moss/src/client/mod.rs @@ -242,7 +242,7 @@ impl Client { pub fn new_state(&self, selections: &[Selection], summary: impl ToString) -> Result, Error> { let old_state = self.installation.active_state; - let fstree = self.blit_root(selections.iter().map(|s| &s.package), old_state.map(state::Id::next))?; + let fstree = self.blit_root(selections.iter().map(|s| &s.package))?; match &self.scope { Scope::Stateful => { @@ -519,7 +519,6 @@ impl Client { fn blit_root<'a>( &self, packages: impl IntoIterator, - state_id: Option, ) -> Result, Error> { let progress = ProgressBar::new(1).with_style( ProgressStyle::with_template("\n|{bar:20.red/blue}| {pos}/{len} {msg}") @@ -688,7 +687,14 @@ BUG_REPORT_URL="https://github.com/serpent-os""#, tx = state_id.unwrap_or_default() ); - fs::write(root.join("usr").join("lib").join("os-release"), os_release)?; + // It's possible this doesn't exist if + // we remove all packages (= + let dir = root.join("usr").join("lib"); + if !dir.exists() { + fs::create_dir(&dir)?; + } + + fs::write(dir.join("os-release"), os_release)?; Ok(()) }