Skip to content

Commit

Permalink
Error out if sqlite is default, but configured for something else
Browse files Browse the repository at this point in the history
In Fedora 34+ librpm can no longer write bdb, so we fail
to build RHCOS.  But the error for this is obscure.  Make
this an obvious, up front error.

This relies on the implicit "sqlite default == fedora34+ == rpm without bdb write".

xref openshift/os#552
xref https://bugzilla.redhat.com/show_bug.cgi?id=1938928
  • Loading branch information
cgwalters committed Jul 10, 2021
1 parent 33a0612 commit 7b65c97
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ pub mod ffi {
fn get_selinux(&self) -> bool;
fn get_releasever(&self) -> &str;
fn get_rpmdb(&self) -> String;
fn validate_rpmdb(&self) -> Result<()>;
fn get_files_remove_regex(&self, package: &str) -> Vec<String>;
fn print_deprecation_warnings(&self);
fn sanitycheck_externals(&self) -> Result<()>;
Expand Down
11 changes: 11 additions & 0 deletions rust/src/treefile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,17 @@ impl Treefile {
s.to_string()
}

/// Error out if the default is sqlite, but something else is configured.
/// xref https://bugzilla.redhat.com/show_bug.cgi?id=1938928
pub(crate) fn validate_rpmdb(&self) -> CxxResult<()> {
if let Some(rpmdb) = self.parsed.rpmdb.as_ref() {
if DEFAULT_RPMDB_BACKEND == RpmdbBackend::Sqlite && *rpmdb != DEFAULT_RPMDB_BACKEND {
return Err(anyhow!("Cannot write rpmdb backend: {:?}", rpmdb).into());
}
}
Ok(())
}

pub(crate) fn get_files_remove_regex(&self, package: &str) -> Vec<String> {
let mut files_to_remove: Vec<String> = Vec::new();
if let Some(ref packages) = self.parsed.remove_from_packages {
Expand Down
4 changes: 4 additions & 0 deletions src/libpriv/rpmostree-core.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,9 @@ rpmostree_context_new_compose (int userroot_dfd,
/* Compose contexts always have a treefile */
ret->treefile_rs = &treefile_rs;

// Check this early
ret->treefile_rs->validate_rpmdb();

rpmostree_context_set_cache_root (ret, userroot_dfd);

// The ref needs special handling as it gets variable-substituted.
Expand Down Expand Up @@ -737,6 +740,7 @@ rpmostree_context_setup (RpmOstreeContext *self,
*/
if (!self->is_system && self->treefile_rs)
{
// See also validate_rpmdb() that we called early
auto rpmdb_backend = self->treefile_rs->get_rpmdb();
dnf_context_set_rpm_macro (self->dnfctx, "_db_backend", rpmdb_backend.c_str());
}
Expand Down

0 comments on commit 7b65c97

Please sign in to comment.