Default to sqlite rpmdb backend on f34

There won't be any support for writing to the bdb backend in f34, so
e.g. pkglayering won't work (and obviously even composes wouldn't work
once the buildroot moves to f34).

Instead of requiring the whole world to add an `rpmdb` key in their
manifests, let's just add a compile flag for it, and tweak the spec file
to use this flag on f34.
This commit is contained in:
Jonathan Lebon 2020-12-21 17:27:52 -05:00 committed by OpenShift Merge Robot
parent 41ff46a1a6
commit db775f43ec
6 changed files with 29 additions and 3 deletions

View File

@ -49,3 +49,8 @@ debug = true
# We need this to avoid leaking symbols, see # We need this to avoid leaking symbols, see
# https://internals.rust-lang.org/t/rust-staticlibs-and-optimizing-for-size/5746 # https://internals.rust-lang.org/t/rust-staticlibs-and-optimizing-for-size/5746
lto = true lto = true
[features]
sqlite-rpmdb-default = []
default = []

View File

@ -91,6 +91,10 @@ privdata_DATA = src/app/rpm-ostree-0-integration.conf
# Propagate automake verbose mode # Propagate automake verbose mode
cargo_build = $(cargo) build $(if $(subst 0,,$(V)),--verbose,) cargo_build = $(cargo) build $(if $(subst 0,,$(V)),--verbose,)
if BUILDOPT_ENABLE_SQLITE_RPMDB_DEFAULT
cargo_build += --features sqlite-rpmdb-default
endif
tooling_src = bindgen/Cargo.toml bindgen/src/main.rs tooling_src = bindgen/Cargo.toml bindgen/src/main.rs
tooling-build: tooling-build:
cd $(top_srcdir)/tooling && $(cargo_build) --release --all-targets cd $(top_srcdir)/tooling && $(cargo_build) --release --all-targets

View File

@ -176,6 +176,12 @@ AC_ARG_WITH(bubblewrap,
[with_bubblewrap=/usr/bin/bwrap]) [with_bubblewrap=/usr/bin/bwrap])
AC_DEFINE_UNQUOTED(WITH_BUBBLEWRAP_PATH, ["$with_bubblewrap"], [Define to bubblewrap path]) AC_DEFINE_UNQUOTED(WITH_BUBBLEWRAP_PATH, ["$with_bubblewrap"], [Define to bubblewrap path])
AC_ARG_ENABLE(sqlite_rpmdb_default,
AS_HELP_STRING([--enable-sqlite-rpmdb-default],
[Default to sqlite rpmdb backend (default: no)]),,
[enable_sqlite_rpmdb_default=no])
AM_CONDITIONAL(BUILDOPT_ENABLE_SQLITE_RPMDB_DEFAULT, test x$enable_sqlite_rpmdb_default = xyes)
RPM_OSTREE_FEATURES="$RPM_OSTREE_FEATURES compose" RPM_OSTREE_FEATURES="$RPM_OSTREE_FEATURES compose"
dnl PKG_CHECK_VAR added to pkg-config 0.28 (though it's already in the new pkgconf; this dnl PKG_CHECK_VAR added to pkg-config 0.28 (though it's already in the new pkgconf; this
@ -290,4 +296,5 @@ echo "
gtk-doc: $enable_gtk_doc gtk-doc: $enable_gtk_doc
rust: $rust_debug_release rust: $rust_debug_release
cbindgen: ${cbindgen:-internal} cbindgen: ${cbindgen:-internal}
sqlite rpmdb default: ${enable_sqlite_rpmdb_default}
" "

View File

@ -99,7 +99,8 @@ It supports the following parameters:
* `rpmdb`: String, optional: The RPM database backend. Can be one of * `rpmdb`: String, optional: The RPM database backend. Can be one of
`bdb`, `ndb`, or `sqlite`. If unspecified, defaults to `bdb` for `bdb`, `ndb`, or `sqlite`. If unspecified, defaults to `bdb` for
compatibility. compatibility. The default can be set to `sqlite` at compile-time
via `--enable-sqlite-rpmdb-default`.
* `cliwrap`: boolean, optional. Defaults to `false`. If enabled, * `cliwrap`: boolean, optional. Defaults to `false`. If enabled,
rpm-ostree will replace binaries such as `/usr/bin/rpm` with rpm-ostree will replace binaries such as `/usr/bin/rpm` with

View File

@ -31,6 +31,10 @@ BuildRequires: rust
%bcond_without zchunk %bcond_without zchunk
%endif %endif
%if 0%{?fedora} >= 34
%define sqlite_rpmdb_default "--enable-sqlite-rpmdb-default"
%endif
# For the autofiles bits below # For the autofiles bits below
BuildRequires: /usr/bin/python3 BuildRequires: /usr/bin/python3
# We always run autogen.sh # We always run autogen.sh
@ -135,7 +139,7 @@ env NOCONFIGURE=1 ./autogen.sh
# the %%configure macro today assumes (reasonably) that one is building # the %%configure macro today assumes (reasonably) that one is building
# C/C++ and sets C{,XX}FLAGS # C/C++ and sets C{,XX}FLAGS
export RUSTFLAGS="%{build_rustflags}" export RUSTFLAGS="%{build_rustflags}"
%configure --disable-silent-rules --enable-gtk-doc %configure --disable-silent-rules --enable-gtk-doc %{?sqlite_rpmdb_default}
%make_build %make_build
%install %install

View File

@ -24,6 +24,11 @@ use crate::utils;
const INCLUDE_MAXDEPTH: u32 = 50; const INCLUDE_MAXDEPTH: u32 = 50;
#[cfg(not(feature = "sqlite-rpmdb-default"))]
const DEFAULT_RPMDB_BACKEND: RpmdbBackend = RpmdbBackend::BDB;
#[cfg(feature = "sqlite-rpmdb-default")]
const DEFAULT_RPMDB_BACKEND: RpmdbBackend = RpmdbBackend::Sqlite;
/// This struct holds file descriptors for any external files/data referenced by /// This struct holds file descriptors for any external files/data referenced by
/// a TreeComposeConfig. /// a TreeComposeConfig.
struct TreefileExternals { struct TreefileExternals {
@ -1558,7 +1563,7 @@ mod ffi {
#[no_mangle] #[no_mangle]
pub extern "C" fn ror_treefile_get_rpmdb(tf: *mut Treefile) -> *mut libc::c_char { pub extern "C" fn ror_treefile_get_rpmdb(tf: *mut Treefile) -> *mut libc::c_char {
let tf = ref_from_raw_ptr(tf); let tf = ref_from_raw_ptr(tf);
let s: &str = match tf.parsed.rpmdb.as_ref().unwrap_or(&RpmdbBackend::BDB) { let s: &str = match tf.parsed.rpmdb.as_ref().unwrap_or(&DEFAULT_RPMDB_BACKEND) {
RpmdbBackend::BDB => "bdb", RpmdbBackend::BDB => "bdb",
RpmdbBackend::Sqlite => "sqlite", RpmdbBackend::Sqlite => "sqlite",
RpmdbBackend::NDB => "ndb", RpmdbBackend::NDB => "ndb",