Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

composepost: Normalize rpmdb.sqlite-shm #4074

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions rust/src/composepost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use crate::{bwrap, importer};
use anyhow::{anyhow, bail, format_err, Context, Result};
use camino::{Utf8Path, Utf8PathBuf};
use cap_std::fs::Dir;
use cap_std::fs::OpenOptions;
use cap_std::fs_utf8::Dir as Utf8Dir;
use cap_std::io_lifetimes::AsFilelike;
use cap_std_ext::cap_std;
Expand Down Expand Up @@ -271,8 +272,20 @@ fn postprocess_cleanup_rpmdb_impl(rootfs_dfd: &Dir) -> Result<()> {
let ent = ent?;
let name = ent.file_name()?;
let name = name.as_str();
if matches!(name, ".dbenv.lock" | ".rpm.lock") || name.starts_with("__db.") {
d.remove_file(name)?;
match name {
// BDB cruft
".dbenv.lock" | ".rpm.lock" => d.remove_file(name)?,
name if name.starts_with("__db.") => d.remove_file(name)?,
// SQLite case. Today, it seems to work to remove the WAL, but removing the SHM
// file causes a runtime error as RPM tries to mutate a read-only database.
"rpmdb.sqlite-shm" => {
// This one needs zeroing today sadly
let size = ent.metadata()?.size();
let f = ent.open_with(OpenOptions::new().truncate(true))?;
f.set_len(size)?;
}
"rpmdb.sqlite-wal" => d.remove_file(name)?,
_ => {}
}
}
Ok(())
Expand Down