Skip to content

Commit

Permalink
Fix error when moss remove all packages (glibc)
Browse files Browse the repository at this point in the history
  • Loading branch information
tarkah authored and ermo committed Mar 7, 2024
1 parent b2d1966 commit a4fe8d9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions moss/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ impl Client {
pub fn new_state(&self, selections: &[Selection], summary: impl ToString) -> Result<Option<State>, 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 => {
Expand Down Expand Up @@ -519,7 +519,6 @@ impl Client {
fn blit_root<'a>(
&self,
packages: impl IntoIterator<Item = &'a package::Id>,
state_id: Option<state::Id>,
) -> Result<vfs::tree::Tree<PendingFile>, Error> {
let progress = ProgressBar::new(1).with_style(
ProgressStyle::with_template("\n|{bar:20.red/blue}| {pos}/{len} {msg}")
Expand Down Expand Up @@ -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(())
}
Expand Down

0 comments on commit a4fe8d9

Please sign in to comment.