diff --git a/.gitmodules b/.gitmodules index b219f0bb..0fa78ea4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ [submodule "libglnx"] path = libglnx url = https://gitlab.gnome.org/GNOME/libglnx.git -[submodule "libdnf"] - path = libdnf - url = https://github.com/rpm-software-management/libdnf diff --git a/Cargo.lock b/Cargo.lock index 75cca4a6..db3e7f8f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -175,25 +175,6 @@ dependencies = [ "vec_map", ] -[[package]] -name = "cmake" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb6210b637171dfba4cda12e579ac6dc73f5165ad56133e5d72ef3131f320855" -dependencies = [ - "cc", -] - -[[package]] -name = "codespan-reporting" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6ce42b8998a383572e0a802d859b1f00c79b7b7474e62fff88ee5c2845d9c13" -dependencies = [ - "termcolor", - "unicode-width", -] - [[package]] name = "console" version = "0.14.0" @@ -322,21 +303,6 @@ dependencies = [ "link-cplusplus", ] -[[package]] -name = "cxx-build" -version = "1.0.49" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f5bde7453f995f4edcbe37c653dbc434018a4fda5941b3437005a36f69b156a" -dependencies = [ - "cc", - "codespan-reporting", - "lazy_static", - "proc-macro2", - "quote", - "scratch", - "syn", -] - [[package]] name = "cxxbridge-flags" version = "1.0.49" @@ -811,18 +777,6 @@ version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "789da6d93f1b866ffe175afc5322a4d76c038605a1c3319bb57b06967ca98a36" -[[package]] -name = "libdnf-sys" -version = "0.1.0" -dependencies = [ - "anyhow", - "cmake", - "cxx", - "cxx-build", - "glib", - "system-deps 3.1.1", -] - [[package]] name = "libsystemd-sys" version = "0.8.0" @@ -1542,7 +1496,6 @@ dependencies = [ "indoc", "lazy_static", "libc", - "libdnf-sys", "maplit", "memfd", "nix", @@ -1604,12 +1557,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "scratch" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e114536316b51a5aa7a0e59fc49661fd263c5507dd08bd28de052e57626ce69" - [[package]] name = "serde" version = "1.0.126" diff --git a/Cargo.toml b/Cargo.toml index 18c3806e..9d423a2f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,7 +45,7 @@ indoc = "1.0.3" indicatif = "0.15.0" lazy_static = "1.4.0" libc = "0.2.95" -libdnf-sys = { path = "rust/libdnf-sys", version = "0.1.0" } +#libdnf-sys = { path = "rust/libdnf-sys", version = "0.1.0" } maplit = "1.0" memfd = "0.4.0" nix = "0.20.0" diff --git a/Makefile-rpm-ostree.am b/Makefile-rpm-ostree.am index e8a1266b..70dff70c 100644 --- a/Makefile-rpm-ostree.am +++ b/Makefile-rpm-ostree.am @@ -72,7 +72,6 @@ rpmostree_common_cflags = -I$(srcdir)/src/app -I$(srcdir)/src/daemon \ -I$(srcdir)/src/lib -I$(srcdir)/src/libpriv -I$(libglnx_srcpath) \ -DG_LOG_DOMAIN=\"rpm-ostreed\" \ -DLIBDIR=\"$(libdir)\" -DPKGLIBDIR=\"$(pkglibdir)\" \ - -I $(top_srcdir)/libdnf \ -D_RPMOSTREE_EXTERN= \ $(PKGDEP_LIBRPMOSTREE_CFLAGS) $(PKGDEP_RPMOSTREE_CFLAGS) rpmostree_bin_common_cflags = $(rpmostree_common_cflags) diff --git a/libdnf b/libdnf deleted file mode 160000 index 6c2ac678..00000000 --- a/libdnf +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6c2ac6786a423c00750a44805ade0268dd6d19e5 diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 611baec6..7f63e2ca 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -41,10 +41,10 @@ pub mod ffi { type GVariant = crate::FFIGVariant; type GVariantDict = crate::FFIGVariantDict; - #[namespace = "dnfcxx"] - type DnfPackage = libdnf_sys::DnfPackage; - #[namespace = "dnfcxx"] - type DnfRepo = libdnf_sys::DnfRepo; +// #[namespace = "dnfcxx"] +// type DnfPackage = libdnf_sys::DnfPackage; +// #[namespace = "dnfcxx"] +// type DnfRepo = libdnf_sys::DnfRepo; } /// Currently cxx-rs doesn't support mappings; like probably most projects, @@ -506,7 +506,7 @@ pub mod ffi { // Currently only used in unit tests #[allow(dead_code)] fn nevra_to_cache_branch(nevra: &CxxString) -> Result>; - fn get_repodata_chksum_repr(pkg: &mut DnfPackage) -> Result; + //fn get_repodata_chksum_repr(pkg: &mut DnfPackage) -> Result; } } diff --git a/rust/src/lockfile.rs b/rust/src/lockfile.rs index 3e021981..704659e1 100644 --- a/rust/src/lockfile.rs +++ b/rust/src/lockfile.rs @@ -10,8 +10,8 @@ /* Copied and adapted from: treefile.rs */ -pub use self::ffi::*; -use crate::utils; +//pub use self::ffi::*; +//use crate::utils; use anyhow::{anyhow, bail, Result}; use chrono::prelude::*; use openat_ext::OpenatDirExt; @@ -24,26 +24,26 @@ use std::path::Path; use std::pin::Pin; use crate::cxxrsutil::CxxResult; -use libdnf_sys::*; +//use libdnf_sys::*; /// Given a lockfile filename, parse it -fn lockfile_parse>(filename: P) -> Result { - let filename = filename.as_ref(); - let fmt = utils::InputFormat::detect_from_filename(filename)?; - let mut f = io::BufReader::new(utils::open_file(filename)?); - let lf = utils::parse_stream(&fmt, &mut f).map_err(|e| { - io::Error::new( - io::ErrorKind::InvalidInput, - format!("Parsing {}: {}", filename.to_string_lossy(), e.to_string()), - ) - })?; - Ok(lf) -} +//fn lockfile_parse>(filename: P) -> Result { +// let filename = filename.as_ref(); +// let fmt = utils::InputFormat::detect_from_filename(filename)?; +// let mut f = io::BufReader::new(utils::open_file(filename)?); +// let lf = utils::parse_stream(&fmt, &mut f).map_err(|e| { +// io::Error::new( +// io::ErrorKind::InvalidInput, +// format!("Parsing {}: {}", filename.to_string_lossy(), e.to_string()), +// ) +// })?; +// Ok(lf) +//} /// Given lockfile filenames, parse them. Later lockfiles may override packages from earlier ones. fn lockfile_parse_multiple>(filenames: &[P]) -> Result { let mut final_lockfile: Option = None; - for filename in filenames { +/* for filename in filenames { let lf = lockfile_parse(filename)?; if lf.packages.is_none() && lf.source_packages.is_none() { bail!( @@ -56,7 +56,7 @@ fn lockfile_parse_multiple>(filenames: &[P]) -> Result t, - Err(e) => { - eprintln!("Invalid rpm-md repo {} timestamp: {}: {}", id, generated, e); - 0 - } - }; - let generated = match Utc.timestamp_opt(generated, 0) { - chrono::offset::LocalResult::Single(t) => t, - _ => { - eprintln!("Invalid rpm-md repo {} timestamp: {}", id, generated); - Utc.timestamp(0, 0) - } - }; - lockfile_repos.insert(id, LockfileRepoMetadata { generated }); - } +// for i in 0..rpmmd_repos.as_mut().length() { +// let repo_ref = rpmmd_repos.as_mut().get(i); +// let repo_ref = unsafe { &mut *(&mut repo_ref.0 as *mut _ as *mut libdnf_sys::DnfRepo) }; +// let id = dnf_repo_get_id(repo_ref).unwrap(); +// let generated = dnf_repo_get_timestamp_generated(repo_ref).unwrap(); +// let generated: i64 = match generated.try_into() { +// Ok(t) => t, +// Err(e) => { +// eprintln!("Invalid rpm-md repo {} timestamp: {}: {}", id, generated, e); +// 0 +// } +// }; +// let generated = match Utc.timestamp_opt(generated, 0) { +// chrono::offset::LocalResult::Single(t) => t, +// _ => { +// eprintln!("Invalid rpm-md repo {} timestamp: {}", id, generated); +// Utc.timestamp(0, 0) +// } +// }; +// lockfile_repos.insert(id, LockfileRepoMetadata { generated }); +// } let filename = Path::new(filename); let lockfile_dir = openat::Dir::open(filename.parent().unwrap_or_else(|| Path::new("/")))?; diff --git a/src/app/libmain.cxx b/src/app/libmain.cxx index 0eb0ee74..fe029376 100644 --- a/src/app/libmain.cxx +++ b/src/app/libmain.cxx @@ -465,7 +465,7 @@ early_main (void) * controls a global var. And it's not just the `DnfContext` that uses it, but e.g. * `DnfSack` and Repo too. So just do this upfront. XXX: Clean up that API so it's always * attached to a context object. */ - dnf_context_set_config_file_path(""); +// dnf_context_set_config_file_path(""); } static int diff --git a/src/app/rpmostree-builtin-shlib-backend.cxx b/src/app/rpmostree-builtin-shlib-backend.cxx index 6abf12b3..6fb4bfa6 100644 --- a/src/app/rpmostree-builtin-shlib-backend.cxx +++ b/src/app/rpmostree-builtin-shlib-backend.cxx @@ -99,16 +99,16 @@ rpmostree_builtin_shlib_backend (int argc, if (g_str_equal (arg, "get-basearch")) { - g_autoptr(DnfContext) ctx = dnf_context_new (); - ret = g_variant_new_string (dnf_context_get_base_arch (ctx)); +// g_autoptr(DnfContext) ctx = dnf_context_new (); +// ret = g_variant_new_string (dnf_context_get_base_arch (ctx)); } else if (g_str_equal (arg, "varsubst-basearch")) { const char *src = argv[2]; - g_autoptr(DnfContext) ctx = dnf_context_new (); - auto varsubsts = rpmostree_dnfcontext_get_varsubsts (ctx); - auto rets = rpmostreecxx::varsubstitute (src, *varsubsts); - ret = g_variant_new_string (rets.c_str()); +// g_autoptr(DnfContext) ctx = dnf_context_new (); +// auto varsubsts = rpmostree_dnfcontext_get_varsubsts (ctx); +// auto rets = rpmostreecxx::varsubstitute (src, *varsubsts); +// ret = g_variant_new_string (rets.c_str()); } else if (g_str_equal (arg, "packagelist-from-commit")) { diff --git a/src/app/rpmostree-builtin-status.cxx b/src/app/rpmostree-builtin-status.cxx index d31497a3..a5cb258a 100644 --- a/src/app/rpmostree-builtin-status.cxx +++ b/src/app/rpmostree-builtin-status.cxx @@ -26,8 +26,8 @@ #include #include #include -#include +#include "libdnf_stub.h" #include "rpmostree-builtins.h" #include "rpmostree-ex-builtins.h" #include "rpmostree-libbuiltin.h" diff --git a/src/app/rpmostree-clientlib.cxx b/src/app/rpmostree-clientlib.cxx index 975fe518..7e39e8d2 100644 --- a/src/app/rpmostree-clientlib.cxx +++ b/src/app/rpmostree-clientlib.cxx @@ -1012,14 +1012,14 @@ rpmostree_sort_pkgs_strv (const char *const* pkgs, g_autoptr(GPtrArray) repo_pkgs = g_ptr_array_new_with_free_func (g_free); g_auto(GVariantBuilder) builder; // TODO: better API/cache for this - g_autoptr(DnfContext) ctx = dnf_context_new (); - auto basearch = dnf_context_get_base_arch (ctx); +// g_autoptr(DnfContext) ctx = dnf_context_new (); +// auto basearch = dnf_context_get_base_arch (ctx); g_variant_builder_init (&builder, G_VARIANT_TYPE ("ah")); for (const char *const* pkgiter = pkgs; pkgiter && *pkgiter; pkgiter++) { auto pkg = *pkgiter; - auto fds = rpmostreecxx::client_handle_fd_argument(pkg, basearch); + auto fds = rpmostreecxx::client_handle_fd_argument(pkg, "x86_64"); if (fds.size() > 0) { for (const auto & fd: fds) diff --git a/src/app/rpmostree-compose-builtin-tree.cxx b/src/app/rpmostree-compose-builtin-tree.cxx index 4d88ee95..5548741b 100644 --- a/src/app/rpmostree-compose-builtin-tree.cxx +++ b/src/app/rpmostree-compose-builtin-tree.cxx @@ -25,8 +25,8 @@ #include #include #include -#include -#include +//#include +//#include #include #include #include @@ -37,6 +37,7 @@ #include #include +#include "libdnf_stub.h" #include "rpmostree-compose-builtins.h" #include "rpmostree-util.h" #include "rpmostree-composeutil.h" @@ -274,8 +275,8 @@ install_packages (RpmOstreeTreeComposeContext *self, { int rootfs_dfd = self->rootfs_dfd; DnfContext *dnfctx = rpmostree_context_get_dnf (self->corectx); - if (opt_proxy) - dnf_context_set_http_proxy (dnfctx, opt_proxy); +// if (opt_proxy) +// dnf_context_set_http_proxy (dnfctx, opt_proxy); /* Hack this here... see https://github.com/rpm-software-management/libhif/issues/53 * but in the future we won't be using librpm at all for unpack/scripts, so it won't @@ -284,20 +285,20 @@ install_packages (RpmOstreeTreeComposeContext *self, { const char *debuglevel = getenv ("RPMOSTREE_RPM_VERBOSITY"); if (!debuglevel) debuglevel = "info"; - dnf_context_set_rpm_verbosity (dnfctx, debuglevel); +// dnf_context_set_rpm_verbosity (dnfctx, debuglevel); rpmlogSetFile(NULL); } { int tf_dfd = (*self->treefile_rs)->get_workdir(); g_autofree char *abs_tf_path = glnx_fdrel_abspath (tf_dfd, "."); - dnf_context_set_repo_dir (dnfctx, abs_tf_path); +// dnf_context_set_repo_dir (dnfctx, abs_tf_path); } /* By default, retain packages in addition to metadata with --cachedir, unless * we're doing unified core, in which case the pkgcache repo is the cache. */ - if (opt_cachedir && !opt_unified_core) - dnf_context_set_keep_cache (dnfctx, TRUE); +// if (opt_cachedir && !opt_unified_core) +// dnf_context_set_keep_cache (dnfctx, TRUE); /* For compose, always try to refresh metadata; we're used in build servers * where fetching should be cheap. We also have --cache-only which is * used by coreos-assembler. Today we don't expose the default, but we @@ -385,10 +386,10 @@ install_packages (RpmOstreeTreeComposeContext *self, /* FIXME - just do a depsolve here before we compute download requirements */ g_autofree char *ret_new_inputhash = NULL; - if (!rpmostree_composeutil_checksum (dnf_context_get_goal (dnfctx), self->repo, - **self->treefile_rs, self->treefile, - &ret_new_inputhash, error)) - return FALSE; +// if (!rpmostree_composeutil_checksum (dnf_context_get_goal (dnfctx), self->repo, +// **self->treefile_rs, self->treefile, +// &ret_new_inputhash, error)) +// return FALSE; g_print ("Input state hash: %s\n", ret_new_inputhash); @@ -402,11 +403,11 @@ install_packages (RpmOstreeTreeComposeContext *self, if (previous_inputhash) { - if (strcmp (previous_inputhash, ret_new_inputhash) == 0) - { - *out_unmodified = TRUE; - return TRUE; /* NB: early return */ - } +// if (strcmp (previous_inputhash, ret_new_inputhash) == 0) +// { +// *out_unmodified = TRUE; +// return TRUE; /* NB: early return */ +// } } else g_print ("Previous commit found, but without rpmostree.inputhash metadata key\n"); @@ -481,23 +482,23 @@ install_packages (RpmOstreeTreeComposeContext *self, * https://github.com/projectatomic/rpm-ostree/issues/729 */ g_auto(GLnxConsoleRef) console = { 0, }; - g_autoptr(DnfState) hifstate = dnf_state_new (); +// g_autoptr(DnfState) hifstate = dnf_state_new (); - guint progress_sigid = g_signal_connect (hifstate, "percentage-changed", - reinterpret_cast(on_hifstate_percentage_changed), - (void*)"Installing packages:"); +// guint progress_sigid = g_signal_connect (hifstate, "percentage-changed", +// reinterpret_cast(on_hifstate_percentage_changed), +// (void*)"Installing packages:"); glnx_console_lock (&console); if (!rpmostree_composeutil_legacy_prep_dev (rootfs_dfd, error)) return FALSE; - if (!dnf_transaction_commit (dnf_context_get_transaction (dnfctx), - dnf_context_get_goal (dnfctx), - hifstate, error)) - return FALSE; +// if (!dnf_transaction_commit (dnf_context_get_transaction (dnfctx), +// dnf_context_get_goal (dnfctx), +// hifstate, error)) +// return FALSE; - g_signal_handler_disconnect (hifstate, progress_sigid); +// g_signal_handler_disconnect (hifstate, progress_sigid); } if (out_unmodified) @@ -690,8 +691,8 @@ rpm_ostree_compose_context_new (const char *treefile_pathstr, /* FIXME refactor things to break the dependency of DnfContext -> arch -> treefile */ std::string arch; { - g_autoptr(DnfContext) ctx = dnf_context_new (); - arch = dnf_context_get_base_arch (ctx); +// g_autoptr(DnfContext) ctx = dnf_context_new (); +// arch = dnf_context_get_base_arch (ctx); } self->treefile_path = g_file_new_for_path (treefile_pathstr); self->treefile_rs = rpmostreecxx::treefile_new(gs_file_get_path_cached (self->treefile_path), arch, self->workdir_dfd); @@ -788,12 +789,12 @@ inject_advisories (RpmOstreeTreeComposeContext *self, GError **error) { g_autoptr(GPtrArray) pkgs = rpmostree_context_get_packages (self->corectx); - DnfContext *dnfctx = rpmostree_context_get_dnf (self->corectx); - DnfSack *yum_sack = dnf_context_get_sack (dnfctx); - g_autoptr(GVariant) advisories = rpmostree_advisories_variant (yum_sack, pkgs); +// DnfContext *dnfctx = rpmostree_context_get_dnf (self->corectx); +// DnfSack *yum_sack = dnf_context_get_sack (dnfctx); +// g_autoptr(GVariant) advisories = rpmostree_advisories_variant (yum_sack, pkgs); - if (advisories && g_variant_n_children (advisories) > 0) - g_hash_table_insert (self->metadata, g_strdup ("rpmostree.advisories"), g_steal_pointer (&advisories)); +// if (advisories && g_variant_n_children (advisories) > 0) +// g_hash_table_insert (self->metadata, g_strdup ("rpmostree.advisories"), g_steal_pointer (&advisories)); return TRUE; } @@ -1535,7 +1536,7 @@ rpmostree_compose_builtin_extensions (int argc, { int tf_dfd = treefile->get_workdir(); g_autofree char *abs_tf_path = glnx_fdrel_abspath (tf_dfd, "."); - dnf_context_set_repo_dir (rpmostree_context_get_dnf (ctx), abs_tf_path); +// dnf_context_set_repo_dir (rpmostree_context_get_dnf (ctx), abs_tf_path); } #define TMP_EXTENSIONS_ROOTFS "rpmostree-extensions.tmp" @@ -1603,51 +1604,51 @@ rpmostree_compose_builtin_extensions (int argc, g_autoptr(GPtrArray) extensions_pkgs = rpmostree_context_get_packages (ctx); for (guint i = 0; i < extensions_pkgs->len; i++) { - DnfPackage *pkg = (DnfPackage*)extensions_pkgs->pdata[i]; - const char *src = dnf_package_get_filename (pkg); - const char *basename = glnx_basename (src); - GLnxFileCopyFlags flags = static_cast(GLNX_FILE_COPY_NOXATTRS | GLNX_FILE_COPY_NOCHOWN); - if (!glnx_file_copy_at (AT_FDCWD, dnf_package_get_filename (pkg), NULL, output_dfd, - basename, flags, cancellable, error)) - return FALSE; +// DnfPackage *pkg = (DnfPackage*)extensions_pkgs->pdata[i]; +// const char *src = dnf_package_get_filename (pkg); +// const char *basename = glnx_basename (src); +// GLnxFileCopyFlags flags = static_cast(GLNX_FILE_COPY_NOXATTRS | GLNX_FILE_COPY_NOCHOWN); +// if (!glnx_file_copy_at (AT_FDCWD, dnf_package_get_filename (pkg), NULL, output_dfd, +// basename, flags, cancellable, error)) +// return FALSE; } /* This is hacky: for "development" extensions, we don't want any depsolving * against the base OS. Rather than awkwardly teach the core about this, we * just reuse its sack and keep all the functionality here. */ - DnfContext *dnfctx = rpmostree_context_get_dnf (ctx); - DnfSack *sack = dnf_context_get_sack (dnfctx); +// DnfContext *dnfctx = rpmostree_context_get_dnf (ctx); +// DnfSack *sack = dnf_context_get_sack (dnfctx); /* disable the system repo; we always want to download, even if already in the base */ - dnf_sack_repo_enabled (sack, HY_SYSTEM_REPO_NAME, 0); +// dnf_sack_repo_enabled (sack, HY_SYSTEM_REPO_NAME, 0); auto pkgs = extensions->get_development_packages(); g_autoptr(GPtrArray) devel_pkgs_to_download = g_ptr_array_new_with_free_func (g_object_unref); for (auto & pkg : pkgs) { - g_autoptr(GPtrArray) matches = rpmostree_get_matching_packages (sack, pkg.c_str()); - if (matches->len == 0) - return glnx_throw (error, "Package %s not found", pkg.c_str()); - DnfPackage *found_pkg = (DnfPackage*)matches->pdata[0]; - g_ptr_array_add (devel_pkgs_to_download, g_object_ref (found_pkg)); +// g_autoptr(GPtrArray) matches = rpmostree_get_matching_packages (sack, pkg.c_str()); +// if (matches->len == 0) +// return glnx_throw (error, "Package %s not found", pkg.c_str()); +// DnfPackage *found_pkg = (DnfPackage*)matches->pdata[0]; +// g_ptr_array_add (devel_pkgs_to_download, g_object_ref (found_pkg)); } - rpmostree_set_repos_on_packages (dnfctx, devel_pkgs_to_download); +// rpmostree_set_repos_on_packages (dnfctx, devel_pkgs_to_download); if (!rpmostree_download_packages (devel_pkgs_to_download, cancellable, error)) return FALSE; for (guint i = 0; i < devel_pkgs_to_download->len; i++) { - DnfPackage *pkg = (DnfPackage*)devel_pkgs_to_download->pdata[i]; - const char *src = dnf_package_get_filename (pkg); - const char *basename = glnx_basename (src); - GLnxFileCopyFlags flags = static_cast(GLNX_FILE_COPY_NOXATTRS | GLNX_FILE_COPY_NOCHOWN); - if (!glnx_file_copy_at (AT_FDCWD, dnf_package_get_filename (pkg), NULL, output_dfd, - basename, flags, cancellable, error)) - return FALSE; +// DnfPackage *pkg = (DnfPackage*)devel_pkgs_to_download->pdata[i]; +// const char *src = dnf_package_get_filename (pkg); +// const char *basename = glnx_basename (src); +// GLnxFileCopyFlags flags = static_cast(GLNX_FILE_COPY_NOXATTRS | GLNX_FILE_COPY_NOCHOWN); +// if (!glnx_file_copy_at (AT_FDCWD, dnf_package_get_filename (pkg), NULL, output_dfd, +// basename, flags, cancellable, error)) +// return FALSE; } // XXX: account for development extensions diff --git a/src/app/rpmostree-composeutil.cxx b/src/app/rpmostree-composeutil.cxx index 05946c28..097f3e8a 100644 --- a/src/app/rpmostree-composeutil.cxx +++ b/src/app/rpmostree-composeutil.cxx @@ -25,8 +25,8 @@ #include #include #include -#include -#include +//#include +//#include #include #include #include @@ -35,6 +35,7 @@ #include #include +#include "libdnf_stub.h" #include "rpmostree-composeutil.h" #include "rpmostree-util.h" #include "rpmostree-core.h" diff --git a/src/daemon/rpmostree-sysroot-core.cxx b/src/daemon/rpmostree-sysroot-core.cxx index cb514dd2..02457b3f 100644 --- a/src/daemon/rpmostree-sysroot-core.cxx +++ b/src/daemon/rpmostree-sysroot-core.cxx @@ -113,26 +113,26 @@ add_package_refs_to_set (RpmOstreeRefSack *rsack, GCancellable *cancellable, GError **error) { - g_autoptr(GPtrArray) pkglist = NULL; - hy_autoquery HyQuery query = hy_query_create (rsack->sack); - hy_query_filter (query, HY_PKG_REPONAME, HY_EQ, HY_SYSTEM_REPO_NAME); - pkglist = hy_query_run (query); +// g_autoptr(GPtrArray) pkglist = NULL; +// hy_autoquery HyQuery query = hy_query_create (rsack->sack); +// hy_query_filter (query, HY_PKG_REPONAME, HY_EQ, HY_SYSTEM_REPO_NAME); +// pkglist = hy_query_run (query); /* TODO: convert this to an iterator to avoid lots of malloc */ - if (pkglist->len == 0) +// if (pkglist->len == 0) return glnx_throw (error, "Failed to find any packages in root"); - else - { - for (guint i = 0; i < pkglist->len; i++) - { - auto pkg = static_cast(pkglist->pdata[i]); - g_autofree char *pkgref = rpmostree_get_cache_branch_pkg (pkg); - g_hash_table_add (referenced_pkgs, util::move_nullify (pkgref)); - } - } +// else +// { +// for (guint i = 0; i < pkglist->len; i++) +// { +// auto pkg = static_cast(pkglist->pdata[i]); +// g_autofree char *pkgref = rpmostree_get_cache_branch_pkg (pkg); +// g_hash_table_add (referenced_pkgs, util::move_nullify (pkgref)); +// } +// } - return TRUE; +// return TRUE; } /* Loop over all deployments, gathering all referenced NEVRAs for diff --git a/src/daemon/rpmostree-sysroot-upgrader.cxx b/src/daemon/rpmostree-sysroot-upgrader.cxx index 0803b92b..7d6eaa07 100644 --- a/src/daemon/rpmostree-sysroot-upgrader.cxx +++ b/src/daemon/rpmostree-sysroot-upgrader.cxx @@ -689,14 +689,14 @@ finalize_removal_overrides (RpmOstreeSysrootUpgrader *self, g_autoptr(GPtrArray) inactive_removals = g_ptr_array_new (); GLNX_HASH_TABLE_FOREACH (removals, const char*, pkgname) { - g_autoptr(DnfPackage) pkg = NULL; - if (!rpmostree_sack_get_by_pkgname (self->rsack->sack, pkgname, &pkg, error)) - return FALSE; - - if (pkg) - g_ptr_array_add (ret_final_removals, g_strdup (pkgname)); - else - g_ptr_array_add (inactive_removals, (gpointer)pkgname); +// g_autoptr(DnfPackage) pkg = NULL; +// if (!rpmostree_sack_get_by_pkgname (self->rsack->sack, pkgname, &pkg, error)) +// return FALSE; +// +// if (pkg) +// g_ptr_array_add (ret_final_removals, g_strdup (pkgname)); +// else +// g_ptr_array_add (inactive_removals, (gpointer)pkgname); } if (inactive_removals->len > 0) @@ -731,18 +731,18 @@ finalize_replacement_overrides (RpmOstreeSysrootUpgrader *self, if (!rpmostree_decompose_nevra (nevra, &pkgname, NULL, NULL, NULL, NULL, error)) return FALSE; - g_autoptr(DnfPackage) pkg = NULL; - if (!rpmostree_sack_get_by_pkgname (self->rsack->sack, pkgname, &pkg, error)) - return FALSE; - - /* make inactive if it's missing or if that exact nevra is already present */ - if (pkg && !rpmostree_sack_has_subject (self->rsack->sack, nevra)) - { - g_ptr_array_add (ret_final_local_replacements, - g_strconcat (sha256, ":", nevra, NULL)); - } - else - g_ptr_array_add (inactive_replacements, (gpointer)nevra); +// g_autoptr(DnfPackage) pkg = NULL; +// if (!rpmostree_sack_get_by_pkgname (self->rsack->sack, pkgname, &pkg, error)) +// return FALSE; +// +// /* make inactive if it's missing or if that exact nevra is already present */ +// if (pkg && !rpmostree_sack_has_subject (self->rsack->sack, nevra)) +// { +// g_ptr_array_add (ret_final_local_replacements, +// g_strconcat (sha256, ":", nevra, NULL)); +// } +// else +// g_ptr_array_add (inactive_replacements, (gpointer)nevra); } if (inactive_replacements->len > 0) @@ -820,7 +820,7 @@ finalize_overlays (RpmOstreeSysrootUpgrader *self, if (rpmostree_sack_has_subject (self->rsack->sack, nevra)) return glnx_throw (error, "Package '%s' is already in the base", nevra); - dnf_sack_add_cmdline_package (self->rsack->sack, path); +// dnf_sack_add_cmdline_package (self->rsack->sack, path); } } @@ -846,24 +846,24 @@ finalize_overlays (RpmOstreeSysrootUpgrader *self, * that might be confusing to users. */ for (guint i = 0; i < matches->len; i++) { - auto pkg = static_cast(matches->pdata[i]); - const char *name = dnf_package_get_name (pkg); - const char *repo = dnf_package_get_reponame (pkg); - - if (g_strcmp0 (repo, HY_CMDLINE_REPO_NAME) == 0) - continue; /* local RPM added up above */ - - if (g_hash_table_contains (removals, name)) - return glnx_throw (error, - "Cannot request '%s' provided by removed package '%s'", - pattern, dnf_package_get_nevra (pkg)); +// auto pkg = static_cast(matches->pdata[i]); +// const char *name = dnf_package_get_name (pkg); +// const char *repo = dnf_package_get_reponame (pkg); +// +// if (g_strcmp0 (repo, HY_CMDLINE_REPO_NAME) == 0) +// continue; /* local RPM added up above */ +// +// if (g_hash_table_contains (removals, name)) +// return glnx_throw (error, +// "Cannot request '%s' provided by removed package '%s'", +// pattern, dnf_package_get_nevra (pkg)); } /* Otherwise, it's an inactive request: remember them so we can print a nice notice. * Just use the first package as the "providing" pkg. */ - const char *providing_nevra = dnf_package_get_nevra (static_cast(matches->pdata[0])); - g_hash_table_insert (inactive_requests, (gpointer)pattern, - g_strdup (providing_nevra)); +// const char *providing_nevra = dnf_package_get_nevra (static_cast(matches->pdata[0])); +// g_hash_table_insert (inactive_requests, (gpointer)pattern, +// g_strdup (providing_nevra)); } if (g_hash_table_size (inactive_requests) > 0) @@ -954,8 +954,8 @@ prep_local_assembly (RpmOstreeSysrootUpgrader *self, self->layering_type = RPMOSTREE_SYSROOT_UPGRADER_LAYERING_RPMMD_REPOS; /* keep a ref on it in case the level higher up needs it */ - self->rpmmd_sack = - (DnfSack*)g_object_ref (dnf_context_get_sack (rpmostree_context_get_dnf (self->ctx))); +// self->rpmmd_sack = +// (DnfSack*)g_object_ref (dnf_context_get_sack (rpmostree_context_get_dnf (self->ctx))); } else { diff --git a/src/daemon/rpmostreed-deployment-utils.cxx b/src/daemon/rpmostreed-deployment-utils.cxx index 8d86794e..fed16464 100644 --- a/src/daemon/rpmostreed-deployment-utils.cxx +++ b/src/daemon/rpmostreed-deployment-utils.cxx @@ -536,15 +536,16 @@ modified_dnfpkg_variant_new (RpmOstreePkgTypes type, RpmOstreePackage *pkg_old, DnfPackage *pkg_new) { - const char *name_old = rpm_ostree_package_get_name (pkg_old); - const char *name_new = dnf_package_get_name (pkg_new); - g_assert_cmpstr (name_old, ==, name_new); - return g_variant_ref_sink ( - g_variant_new ("(us(ss)(ss))", type, name_old, - rpm_ostree_package_get_evr (pkg_old), - rpm_ostree_package_get_arch (pkg_old), - dnf_package_get_evr (pkg_new), - dnf_package_get_arch (pkg_new))); +// const char *name_old = rpm_ostree_package_get_name (pkg_old); +// const char *name_new = dnf_package_get_name (pkg_new); +// g_assert_cmpstr (name_old, ==, name_new); +// return g_variant_ref_sink ( +// g_variant_new ("(us(ss)(ss))", type, name_old, +// rpm_ostree_package_get_evr (pkg_old), +// rpm_ostree_package_get_arch (pkg_old), +// dnf_package_get_evr (pkg_new), +// dnf_package_get_arch (pkg_new))); +return NULL; } static gboolean @@ -668,24 +669,25 @@ find_package (DnfSack *sack, gboolean newer, RpmOstreePackage *pkg) { - hy_autoquery HyQuery query = hy_query_create (sack); - hy_query_filter (query, HY_PKG_NAME, HY_EQ, rpm_ostree_package_get_name (pkg)); - if (newer) - { - hy_query_filter (query, HY_PKG_EVR, HY_GT, rpm_ostree_package_get_evr (pkg)); - hy_query_filter (query, HY_PKG_ARCH, HY_NEQ, "src"); - hy_query_filter_latest (query, TRUE); - } - else - { - /* we want an exact match */ - hy_query_filter (query, HY_PKG_NEVRA, HY_EQ, rpm_ostree_package_get_nevra (pkg)); - } - g_autoptr(GPtrArray) pkgs = hy_query_run (query); - if (pkgs->len == 0) - return NULL; /* canonicalize to NULL */ - g_ptr_array_sort (pkgs, (GCompareFunc)rpmostree_pkg_array_compare); - return (DnfPackage*)g_object_ref (pkgs->pdata[pkgs->len-1]); +// hy_autoquery HyQuery query = hy_query_create (sack); +// hy_query_filter (query, HY_PKG_NAME, HY_EQ, rpm_ostree_package_get_name (pkg)); +// if (newer) +// { +// hy_query_filter (query, HY_PKG_EVR, HY_GT, rpm_ostree_package_get_evr (pkg)); +// hy_query_filter (query, HY_PKG_ARCH, HY_NEQ, "src"); +// hy_query_filter_latest (query, TRUE); +// } +// else +// { +// /* we want an exact match */ +// hy_query_filter (query, HY_PKG_NEVRA, HY_EQ, rpm_ostree_package_get_nevra (pkg)); +// } +// g_autoptr(GPtrArray) pkgs = hy_query_run (query); +// if (pkgs->len == 0) +// return NULL; /* canonicalize to NULL */ +// g_ptr_array_sort (pkgs, (GCompareFunc)rpmostree_pkg_array_compare); +// return (DnfPackage*)g_object_ref (pkgs->pdata[pkgs->len-1]); + return NULL; } /* For all layered pkgs, check if there are newer versions in the rpmmd. Add diff to @@ -732,12 +734,12 @@ rpmmd_diff_guess (OstreeRepo *repo, for (guint i = 0; i < all_layered_pkgs->len; i++) { auto pkg = static_cast(all_layered_pkgs->pdata[i]); - g_autoptr(DnfPackage) newer_pkg = find_package (sack, TRUE, pkg); - if (!newer_pkg) - continue; - - g_ptr_array_add (newer_packages, g_object_ref (newer_pkg)); - rpm_diff_add_layered_diff (rpm_diff, pkg, newer_pkg); +// g_autoptr(DnfPackage) newer_pkg = find_package (sack, TRUE, pkg); +// if (!newer_pkg) +// continue; +// +// g_ptr_array_add (newer_packages, g_object_ref (newer_pkg)); +// rpm_diff_add_layered_diff (rpm_diff, pkg, newer_pkg); } /* canonicalize to NULL if there's nothing new */ @@ -760,15 +762,15 @@ rpm_ostree_pkgs_to_dnf (DnfSack *sack, for (guint i = 0; i < n; i++) { auto pkg = static_cast(rpm_ostree_pkgs->pdata[i]); - hy_autoquery HyQuery query = hy_query_create (sack); - hy_query_filter (query, HY_PKG_NAME, HY_EQ, rpm_ostree_package_get_name (pkg)); - hy_query_filter (query, HY_PKG_EVR, HY_EQ, rpm_ostree_package_get_evr (pkg)); - hy_query_filter (query, HY_PKG_ARCH, HY_EQ, rpm_ostree_package_get_arch (pkg)); - g_autoptr(GPtrArray) pkgs = hy_query_run (query); - - /* 0 --> ostree stream is out of sync with rpmmd repos probably? */ - if (pkgs->len > 0) - g_ptr_array_add (dnf_pkgs, g_object_ref (pkgs->pdata[0])); +// hy_autoquery HyQuery query = hy_query_create (sack); +// hy_query_filter (query, HY_PKG_NAME, HY_EQ, rpm_ostree_package_get_name (pkg)); +// hy_query_filter (query, HY_PKG_EVR, HY_EQ, rpm_ostree_package_get_evr (pkg)); +// hy_query_filter (query, HY_PKG_ARCH, HY_EQ, rpm_ostree_package_get_arch (pkg)); +// g_autoptr(GPtrArray) pkgs = hy_query_run (query); +// +// /* 0 --> ostree stream is out of sync with rpmmd repos probably? */ +// if (pkgs->len > 0) +// g_ptr_array_add (dnf_pkgs, g_object_ref (pkgs->pdata[0])); } return util::move_nullify (dnf_pkgs); diff --git a/src/daemon/rpmostreed-deployment-utils.h b/src/daemon/rpmostreed-deployment-utils.h index 18d7609d..5c976fa6 100644 --- a/src/daemon/rpmostreed-deployment-utils.h +++ b/src/daemon/rpmostreed-deployment-utils.h @@ -19,8 +19,9 @@ #pragma once #include -#include +//#include +#include "libdnf_stub.h" #include "rpmostreed-types.h" G_BEGIN_DECLS diff --git a/src/daemon/rpmostreed-transaction-types.cxx b/src/daemon/rpmostreed-transaction-types.cxx index 12dde523..4008376d 100644 --- a/src/daemon/rpmostreed-transaction-types.cxx +++ b/src/daemon/rpmostreed-transaction-types.cxx @@ -740,13 +740,13 @@ get_sack_for_booted (OstreeSysroot *sysroot, rpmostree_context_configure_from_deployment (ctx, sysroot, booted_deployment); /* streamline: we don't need rpmdb or filelists, but we *do* need updateinfo */ - if (!rpmostree_context_download_metadata (ctx, - (DnfContextSetupSackFlags)(DNF_CONTEXT_SETUP_SACK_FLAG_SKIP_RPMDB | - DNF_CONTEXT_SETUP_SACK_FLAG_SKIP_FILELISTS | - DNF_CONTEXT_SETUP_SACK_FLAG_LOAD_UPDATEINFO), cancellable, error)) - return FALSE; - - *out_sack = (DnfSack*)g_object_ref (dnf_context_get_sack (dnfctx)); +// if (!rpmostree_context_download_metadata (ctx, +// (DnfContextSetupSackFlags)(DNF_CONTEXT_SETUP_SACK_FLAG_SKIP_RPMDB | +// DNF_CONTEXT_SETUP_SACK_FLAG_SKIP_FILELISTS | +// DNF_CONTEXT_SETUP_SACK_FLAG_LOAD_UPDATEINFO), cancellable, error)) +// return FALSE; +// +// *out_sack = (DnfSack*)g_object_ref (dnf_context_get_sack (dnfctx)); return TRUE; } @@ -1155,8 +1155,8 @@ deploy_transaction_execute (RpmostreedTransaction *transaction, g_autoptr(GString) pkgnames = g_string_new (""); for (guint i = 0; i < pkgs->len; i++) { - auto p = static_cast(pkgs->pdata[i]); - g_string_append_printf (pkgnames, " %s", dnf_package_get_nevra (p)); +// auto p = static_cast(pkgs->pdata[i]); +// g_string_append_printf (pkgnames, " %s", dnf_package_get_nevra (p)); } return glnx_throw (error, "\"%s\" is already provided by:%s. Use " "--allow-inactive to explicitly " @@ -1363,8 +1363,8 @@ deploy_transaction_execute (RpmostreedTransaction *transaction, return glnx_throw (error, "Multiple packages match \"%s\"", pkg); /* canonicalize to just the pkg name */ - const char *pkgname = dnf_package_get_name (static_cast(pkgs->pdata[0])); - g_ptr_array_add (pkgnames, (void*)pkgname); +// const char *pkgname = dnf_package_get_name (static_cast(pkgs->pdata[0])); +// g_ptr_array_add (pkgnames, (void*)pkgname); } g_ptr_array_add (pkgnames, NULL); @@ -1398,17 +1398,17 @@ deploy_transaction_execute (RpmostreedTransaction *transaction, return glnx_throw (error, "Refusing to download rpm-md for offline OS '%s'", self->osname); - g_autoptr(DnfSack) sack = NULL; - if (g_hash_table_size (rpmostree_origin_get_packages (origin)) > 0) - { - if (!get_sack_for_booted (sysroot, repo, booted_deployment, &sack, - cancellable, error)) - return FALSE; - } - - if (!generate_update_variant (repo, booted_deployment, NULL, sack, - cancellable, error)) - return FALSE; +// g_autoptr(DnfSack) sack = NULL; +// if (g_hash_table_size (rpmostree_origin_get_packages (origin)) > 0) +// { +// if (!get_sack_for_booted (sysroot, repo, booted_deployment, &sack, +// cancellable, error)) +// return FALSE; +// } +// +// if (!generate_update_variant (repo, booted_deployment, NULL, sack, +// cancellable, error)) +// return FALSE; /* Note early return */ return TRUE; @@ -2305,9 +2305,9 @@ refresh_md_transaction_execute (RpmostreedTransaction *transaction, rpmostree_context_configure_from_deployment (ctx, sysroot, cfg_merge_deployment); /* don't even bother loading the rpmdb */ - if (!rpmostree_context_download_metadata (ctx, DNF_CONTEXT_SETUP_SACK_FLAG_SKIP_RPMDB, - cancellable, error)) - return FALSE; +// if (!rpmostree_context_download_metadata (ctx, DNF_CONTEXT_SETUP_SACK_FLAG_SKIP_RPMDB, +// cancellable, error)) +// return FALSE; return TRUE; } @@ -2386,21 +2386,21 @@ modify_yum_repo_transaction_finalize (GObject *object) G_OBJECT_CLASS (modify_yum_repo_transaction_parent_class)->finalize (object); } -static DnfRepo * -get_dnf_repo_by_id (RpmOstreeContext *ctx, const char *repo_id) -{ - DnfContext *dnfctx = rpmostree_context_get_dnf (ctx); - - GPtrArray *repos = dnf_context_get_repos (dnfctx); - for (guint i = 0; i < repos->len; i++) - { - auto repo = static_cast(repos->pdata[i]); - if (g_strcmp0 (dnf_repo_get_id (repo), repo_id) == 0) - return repo; - } - - return NULL; -} +//static DnfRepo * +//get_dnf_repo_by_id (RpmOstreeContext *ctx, const char *repo_id) +//{ +// DnfContext *dnfctx = rpmostree_context_get_dnf (ctx); +// +// GPtrArray *repos = dnf_context_get_repos (dnfctx); +// for (guint i = 0; i < repos->len; i++) +// { +// auto repo = static_cast(repos->pdata[i]); +// if (g_strcmp0 (dnf_repo_get_id (repo), repo_id) == 0) +// return repo; +// } +// +// return NULL; +//} static gboolean modify_yum_repo_transaction_execute (RpmostreedTransaction *transaction, @@ -2427,8 +2427,8 @@ modify_yum_repo_transaction_execute (RpmostreedTransaction *transaction, /* point libdnf to our repos dir */ rpmostree_context_configure_from_deployment (ctx, sysroot, cfg_merge_deployment); - DnfRepo *repo = get_dnf_repo_by_id (ctx, self->repo_id); - if (repo == NULL) +// DnfRepo *repo = get_dnf_repo_by_id (ctx, self->repo_id); +// if (repo == NULL) return glnx_throw (error, "Yum repo '%s' not found", self->repo_id); GVariantIter iter; @@ -2450,11 +2450,11 @@ modify_yum_repo_transaction_execute (RpmostreedTransaction *transaction, g_strcmp0 (value, "1") != 0) return glnx_throw (error, "Only '0' and '1' are allowed for the '%s' key", parameter); - if (!dnf_repo_set_data (repo, parameter, value, error)) +// if (!dnf_repo_set_data (repo, parameter, value, error)) return FALSE; } - if (!dnf_repo_commit (repo, error)) +// if (!dnf_repo_commit (repo, error)) return FALSE; return TRUE; diff --git a/src/libpriv/libdnf_stub.h b/src/libpriv/libdnf_stub.h new file mode 100644 index 00000000..dab6bab2 --- /dev/null +++ b/src/libpriv/libdnf_stub.h @@ -0,0 +1,49 @@ +#pragma once +struct DnfState{}; + +struct DnfRepo{}; + +struct DnfPackage{}; + +struct DnfSack{}; + +struct DnfContext{}; +typedef DnfContext* DnfContext_autoptr; + +typedef enum { + DNF_ADVISORY_KIND_UNKNOWN = 0, /* ordered by rough importance */ + DNF_ADVISORY_KIND_SECURITY = 1, + DNF_ADVISORY_KIND_BUGFIX = 2, + DNF_ADVISORY_KIND_ENHANCEMENT = 3, + DNF_ADVISORY_KIND_NEWPACKAGE = 4 +} DnfAdvisoryKind; + +typedef enum { + DNF_REPO_ENABLED_NONE = 0, + DNF_REPO_ENABLED_PACKAGES = 1, + DNF_REPO_ENABLED_METADATA = 2, + /*< private >*/ + DNF_REPO_ENABLED_LAST +} DnfRepoEnabled; + +typedef enum { + DNF_STATE_ACTION_UNKNOWN = 0, /* Since: 0.1.0 */ + DNF_STATE_ACTION_DOWNLOAD_PACKAGES = 8, /* Since: 0.1.0 */ + DNF_STATE_ACTION_DOWNLOAD_METADATA = 20, /* Since: 0.1.0 */ + DNF_STATE_ACTION_LOADING_CACHE = 27, /* Since: 0.1.0 */ + DNF_STATE_ACTION_TEST_COMMIT = 15, /* Since: 0.1.0 */ + DNF_STATE_ACTION_REQUEST = 17, /* Since: 0.1.0 */ + DNF_STATE_ACTION_REMOVE = 6, /* Since: 0.1.0 */ + DNF_STATE_ACTION_INSTALL = 9, /* Since: 0.1.0 */ + DNF_STATE_ACTION_UPDATE = 10, /* Since: 0.1.2 */ + DNF_STATE_ACTION_CLEANUP = 11, /* Since: 0.1.2 */ + DNF_STATE_ACTION_OBSOLETE = 12, /* Since: 0.1.2 */ + DNF_STATE_ACTION_REINSTALL = 13, /* Since: 0.1.6 */ + DNF_STATE_ACTION_DOWNGRADE = 14, /* Since: 0.1.6 */ + DNF_STATE_ACTION_QUERY = 4, /* Since: 0.1.2 */ + /*< private >*/ + DNF_STATE_ACTION_LAST +} DnfStateAction; + +typedef int HyGoal; +typedef int DnfContextSetupSackFlags; \ No newline at end of file diff --git a/src/libpriv/rpmostree-core.cxx b/src/libpriv/rpmostree-core.cxx index bea40ca5..4c655e92 100644 --- a/src/libpriv/rpmostree-core.cxx +++ b/src/libpriv/rpmostree-core.cxx @@ -29,11 +29,12 @@ #include #include #include -#include -#include +//#include +//#include #include #include +#include "libdnf_stub.h" #include "rpmostree-core-private.h" #include "rpmostree-postprocess.h" #include "rpmostree-rpm-util.h" @@ -115,7 +116,7 @@ compare_pkgs (gconstpointer ap, { auto a = (DnfPackage**)ap; auto b = (DnfPackage**)bp; - return dnf_package_cmp (*a, *b); + return 0;//dnf_package_cmp (*a, *b); } /*********************************************************** @@ -351,32 +352,32 @@ rpmostree_context_new_client (OstreeRepo *repo) */ rpmsqSetInterruptSafety (FALSE); - self->dnfctx = dnf_context_new (); - DECLARE_RPMSIGHANDLER_RESET; - dnf_context_set_http_proxy (self->dnfctx, g_getenv ("http_proxy")); - - dnf_context_set_repo_dir (self->dnfctx, "/etc/yum.repos.d"); - dnf_context_set_cache_dir (self->dnfctx, RPMOSTREE_CORE_CACHEDIR RPMOSTREE_DIR_CACHE_REPOMD); - dnf_context_set_solv_dir (self->dnfctx, RPMOSTREE_CORE_CACHEDIR RPMOSTREE_DIR_CACHE_SOLV); - dnf_context_set_lock_dir (self->dnfctx, "/run/rpm-ostree/" RPMOSTREE_DIR_LOCK); - dnf_context_set_user_agent (self->dnfctx, PACKAGE_NAME "/" PACKAGE_VERSION); - /* don't need SWDB: https://github.com/rpm-software-management/libdnf/issues/645 */ - dnf_context_set_write_history (self->dnfctx, FALSE); - - dnf_context_set_check_disk_space (self->dnfctx, FALSE); - dnf_context_set_check_transaction (self->dnfctx, FALSE); - - /* we don't need any plugins */ - dnf_context_set_plugins_dir (self->dnfctx, NULL); - - /* Force disable internal libdnf Count Me logic */ - dnf_conf_add_setopt("*.countme", DNF_CONF_COMMANDLINE, "false", NULL); +// self->dnfctx = dnf_context_new (); +// DECLARE_RPMSIGHANDLER_RESET; +// dnf_context_set_http_proxy (self->dnfctx, g_getenv ("http_proxy")); +// +// dnf_context_set_repo_dir (self->dnfctx, "/etc/yum.repos.d"); +// dnf_context_set_cache_dir (self->dnfctx, RPMOSTREE_CORE_CACHEDIR RPMOSTREE_DIR_CACHE_REPOMD); +// dnf_context_set_solv_dir (self->dnfctx, RPMOSTREE_CORE_CACHEDIR RPMOSTREE_DIR_CACHE_SOLV); +// dnf_context_set_lock_dir (self->dnfctx, "/run/rpm-ostree/" RPMOSTREE_DIR_LOCK); +// dnf_context_set_user_agent (self->dnfctx, PACKAGE_NAME "/" PACKAGE_VERSION); +// /* don't need SWDB: https://github.com/rpm-software-management/libdnf/issues/645 */ +// dnf_context_set_write_history (self->dnfctx, FALSE); +// +// dnf_context_set_check_disk_space (self->dnfctx, FALSE); +// dnf_context_set_check_transaction (self->dnfctx, FALSE); +// +// /* we don't need any plugins */ +// dnf_context_set_plugins_dir (self->dnfctx, NULL); +// +// /* Force disable internal libdnf Count Me logic */ +// dnf_conf_add_setopt("*.countme", DNF_CONF_COMMANDLINE, "false", NULL); /* Hack until libdnf+librepo know how to better negotaiate zchunk. * see also the bits in configure.ac that define HAVE_ZCHUNK **/ #ifndef HAVE_ZCHUNK - dnf_context_set_zchunk (self->dnfctx, FALSE); +// dnf_context_set_zchunk (self->dnfctx, FALSE); #endif return self; @@ -398,19 +399,19 @@ rpmostree_context_new_compose (int userroot_dfd, ret->treefile_rs = &treefile_rs; { g_autofree char *reposdir = glnx_fdrel_abspath (userroot_dfd, "rpmmd.repos.d"); - dnf_context_set_repo_dir (ret->dnfctx, reposdir); +// dnf_context_set_repo_dir (ret->dnfctx, reposdir); } { const char *cache_rpmmd = glnx_strjoina ("cache/", RPMOSTREE_DIR_CACHE_REPOMD); g_autofree char *cachedir = glnx_fdrel_abspath (userroot_dfd, cache_rpmmd); - dnf_context_set_cache_dir (ret->dnfctx, cachedir); +// dnf_context_set_cache_dir (ret->dnfctx, cachedir); } { const char *cache_solv = glnx_strjoina ("cache/", RPMOSTREE_DIR_CACHE_SOLV); g_autofree char *cachedir = glnx_fdrel_abspath (userroot_dfd, cache_solv); - dnf_context_set_solv_dir (ret->dnfctx, cachedir); +// dnf_context_set_solv_dir (ret->dnfctx, cachedir); } { const char *lock = glnx_strjoina ("cache/", RPMOSTREE_DIR_LOCK); g_autofree char *lockdir = glnx_fdrel_abspath (userroot_dfd, lock); - dnf_context_set_lock_dir (ret->dnfctx, lockdir); +// dnf_context_set_lock_dir (ret->dnfctx, lockdir); } // The ref needs special handling as it gets variable-substituted. @@ -471,7 +472,7 @@ rpmostree_context_configure_from_deployment (RpmOstreeContext *self, g_build_filename (cfg_deployment_root, "etc/yum.repos.d", NULL); /* point libhif to the yum.repos.d and os-release of the merge deployment */ - dnf_context_set_repo_dir (self->dnfctx, reposdir); +// dnf_context_set_repo_dir (self->dnfctx, reposdir); /* point the core to the passwd & group of the merge deployment */ g_assert (!self->passwd_dir); @@ -568,12 +569,12 @@ rpmostree_context_get_rpmmd_repo_commit_metadata (RpmOstreeContext *self) { g_auto(GVariantBuilder) repo_builder; g_variant_builder_init (&repo_builder, (GVariantType*)"a{sv}"); - auto repo = static_cast(repos->pdata[i]); - const char *id = dnf_repo_get_id (repo); - g_variant_builder_add (&repo_builder, "{sv}", "id", g_variant_new_string (id)); - guint64 ts = dnf_repo_get_timestamp_generated (repo); - g_variant_builder_add (&repo_builder, "{sv}", "timestamp", g_variant_new_uint64 (ts)); - g_variant_builder_add (&repo_list_builder, "@a{sv}", g_variant_builder_end (&repo_builder)); +// auto repo = static_cast(repos->pdata[i]); +// const char *id = dnf_repo_get_id (repo); +// g_variant_builder_add (&repo_builder, "{sv}", "id", g_variant_new_string (id)); +// guint64 ts = dnf_repo_get_timestamp_generated (repo); +// g_variant_builder_add (&repo_builder, "{sv}", "timestamp", g_variant_new_uint64 (ts)); +// g_variant_builder_add (&repo_list_builder, "@a{sv}", g_variant_builder_end (&repo_builder)); } return g_variant_ref_sink (g_variant_builder_end (&repo_list_builder)); } @@ -582,7 +583,7 @@ std::unique_ptr> rpmostree_dnfcontext_get_varsubsts (DnfContext *context) { auto r = std::make_unique>(); - r->push_back(rpmostreecxx::StringMapping{"basearch", dnf_context_get_base_arch (context) }); +// r->push_back(rpmostreecxx::StringMapping{"basearch", dnf_context_get_base_arch (context) }); return r; } @@ -596,14 +597,14 @@ enable_one_repo (GPtrArray *sources, { for (guint i = 0; i < sources->len; i++) { - auto src = static_cast(sources->pdata[i]); - const char *id = dnf_repo_get_id (src); - - if (strcmp (reponame, id) != 0) - continue; - - dnf_repo_set_enabled (src, DNF_REPO_ENABLED_PACKAGES); - return TRUE; +// auto src = static_cast(sources->pdata[i]); +// const char *id = dnf_repo_get_id (src); +// +// if (strcmp (reponame, id) != 0) +// continue; +// +// dnf_repo_set_enabled (src, DNF_REPO_ENABLED_PACKAGES); +// return TRUE; } return glnx_throw (error, "Unknown rpm-md repository: %s", reponame); @@ -612,12 +613,12 @@ enable_one_repo (GPtrArray *sources, static void disable_all_repos (RpmOstreeContext *context) { - GPtrArray *sources = dnf_context_get_repos (context->dnfctx); - for (guint i = 0; i < sources->len; i++) - { - auto src = static_cast(sources->pdata[i]); - dnf_repo_set_enabled (src, DNF_REPO_ENABLED_NONE); - } +// GPtrArray *sources = dnf_context_get_repos (context->dnfctx); +// for (guint i = 0; i < sources->len; i++) +// { +// auto src = static_cast(sources->pdata[i]); +// dnf_repo_set_enabled (src, DNF_REPO_ENABLED_NONE); +// } } /* Enable all repos in @repos */ @@ -626,12 +627,12 @@ enable_repos (RpmOstreeContext *context, const char *const *repos, GError **error) { - GPtrArray *sources = dnf_context_get_repos (context->dnfctx); - for (const char *const *iter = repos; iter && *iter; iter++) - { - if (!enable_one_repo (sources, *iter, error)) - return FALSE; - } +// GPtrArray *sources = dnf_context_get_repos (context->dnfctx); +// for (const char *const *iter = repos; iter && *iter; iter++) +// { +// if (!enable_one_repo (sources, *iter, error)) +// return FALSE; +// } return TRUE; } @@ -689,13 +690,13 @@ rpmostree_context_setup (RpmOstreeContext *self, */ if (releasever.length() == 0) releasever = "rpmostree-unset-releasever"; - dnf_context_set_release_ver (self->dnfctx, releasever.c_str()); +// dnf_context_set_release_ver (self->dnfctx, releasever.c_str()); } - else if (releasever.length() > 0) - dnf_context_set_release_ver (self->dnfctx, releasever.c_str()); +// else if (releasever.length() > 0) +// dnf_context_set_release_ver (self->dnfctx, releasever.c_str()); - dnf_context_set_install_root (self->dnfctx, install_root); - dnf_context_set_source_root (self->dnfctx, source_root); +// dnf_context_set_install_root (self->dnfctx, install_root); +// dnf_context_set_source_root (self->dnfctx, source_root); /* Set the RPM _install_langs macro, which gets processed by librpm; this is * currently only referenced in the traditional or non-"unified core" code. @@ -703,13 +704,13 @@ rpmostree_context_setup (RpmOstreeContext *self, if (!self->is_system && self->treefile_rs) { auto instlangs = self->treefile_rs->format_install_langs_macro(); - if (instlangs.length() > 0) - dnf_context_set_rpm_macro (self->dnfctx, "_install_langs", instlangs.c_str()); +// if (instlangs.length() > 0) +// dnf_context_set_rpm_macro (self->dnfctx, "_install_langs", instlangs.c_str()); } /* This is what we use as default. Note we should be able to drop this in the * future now that we inject a macro to set that value in our OSTrees. */ - dnf_context_set_rpm_macro (self->dnfctx, "_dbpath", "/" RPMOSTREE_RPMDB_LOCATION); +// dnf_context_set_rpm_macro (self->dnfctx, "_dbpath", "/" RPMOSTREE_RPMDB_LOCATION); /* Set the database backend only in the compose path. It then becomes the default * for any client side layering. @@ -717,11 +718,11 @@ rpmostree_context_setup (RpmOstreeContext *self, if (!self->is_system && self->treefile_rs) { auto rpmdb_backend = self->treefile_rs->get_rpmdb(); - dnf_context_set_rpm_macro (self->dnfctx, "_db_backend", rpmdb_backend.c_str()); +// dnf_context_set_rpm_macro (self->dnfctx, "_db_backend", rpmdb_backend.c_str()); } - if (!dnf_context_setup (self->dnfctx, cancellable, error)) - return FALSE; +// if (!dnf_context_setup (self->dnfctx, cancellable, error)) +// return FALSE; /* disable all repos in pkgcache-only mode, otherwise obey "repos" key */ if (self->pkgcache_only) @@ -781,14 +782,14 @@ rpmostree_context_setup (RpmOstreeContext *self, * the default, but we make sure. This is a bit of a messy topic, but for * rpm-ostree we're being more strict about requiring repos. */ - for (guint i = 0; i < repos->len; i++) - dnf_repo_set_required (static_cast(repos->pdata[i]), TRUE); +// for (guint i = 0; i < repos->len; i++) +// dnf_repo_set_required (static_cast(repos->pdata[i]), TRUE); - if (self->treefile_rs && !self->treefile_rs->get_documentation()) - { - dnf_transaction_set_flags (dnf_context_get_transaction (self->dnfctx), - DNF_TRANSACTION_FLAG_NODOCS); - } +// if (self->treefile_rs && !self->treefile_rs->get_documentation()) +// { +// dnf_transaction_set_flags (dnf_context_get_transaction (self->dnfctx), +// DNF_TRANSACTION_FLAG_NODOCS); +// } /* We could likely delete this, but I'm keeping a log message just in case */ if (g_variant_dict_contains (self->spec->dict, "ignore-scripts")) @@ -889,7 +890,7 @@ get_nevra_relpath (const char *nevra) static char * get_package_relpath (DnfPackage *pkg) { - return get_nevra_relpath (dnf_package_get_nevra (pkg)); + return 0;//get_nevra_relpath (dnf_package_get_nevra (pkg)); } /* We maintain a temporary copy on disk of the RPM header value; librpm will @@ -961,16 +962,16 @@ checkout_pkg_metadata_by_dnfpkg (RpmOstreeContext *self, GCancellable *cancellable, GError **error) { - const char *nevra = dnf_package_get_nevra (pkg); - g_autofree char *cachebranch = rpmostree_get_cache_branch_pkg (pkg); - OstreeRepo *pkgcache_repo = get_pkgcache_repo (self); - g_autoptr(GVariant) header = NULL; - - if (!get_header_variant (pkgcache_repo, cachebranch, &header, - cancellable, error)) +// const char *nevra = dnf_package_get_nevra (pkg); +// g_autofree char *cachebranch = rpmostree_get_cache_branch_pkg (pkg); +// OstreeRepo *pkgcache_repo = get_pkgcache_repo (self); +// g_autoptr(GVariant) header = NULL; +// +// if (!get_header_variant (pkgcache_repo, cachebranch, &header, +// cancellable, error)) return FALSE; - return checkout_pkg_metadata (self, nevra, header, cancellable, error); +// return checkout_pkg_metadata (self, nevra, header, cancellable, error); } gboolean @@ -1033,8 +1034,8 @@ rpmostree_context_download_metadata (RpmOstreeContext *self, /* https://github.com/rpm-software-management/libdnf/pull/416 * https://github.com/projectatomic/rpm-ostree/issues/1127 */ - if (flags & DNF_CONTEXT_SETUP_SACK_FLAG_SKIP_FILELISTS) - dnf_context_set_enable_filelists (self->dnfctx, FALSE); +// if (flags & DNF_CONTEXT_SETUP_SACK_FLAG_SKIP_FILELISTS) +// dnf_context_set_enable_filelists (self->dnfctx, FALSE); g_autoptr(GPtrArray) rpmmd_repos = rpmostree_get_enabled_rpmmd_repos (self->dnfctx, DNF_REPO_ENABLED_PACKAGES); @@ -1045,9 +1046,9 @@ rpmostree_context_download_metadata (RpmOstreeContext *self, g_assert_cmpint (rpmmd_repos->len, ==, 0); /* this is essentially a no-op */ - g_autoptr(DnfState) hifstate = dnf_state_new (); - if (!dnf_context_setup_sack_with_flags (self->dnfctx, hifstate, flags, error)) - return FALSE; +// g_autoptr(DnfState) hifstate = dnf_state_new (); +// if (!dnf_context_setup_sack_with_flags (self->dnfctx, hifstate, flags, error)) +// return FALSE; /* Note early return; no repos to fetch. */ return TRUE; @@ -1059,8 +1060,8 @@ rpmostree_context_download_metadata (RpmOstreeContext *self, g_string_append (enabled_repos, "Enabled rpm-md repositories:"); for (guint i = 0; i < rpmmd_repos->len; i++) { - auto repo = static_cast(rpmmd_repos->pdata[i]); - g_string_append_printf (enabled_repos, " %s", dnf_repo_get_id (repo)); +// auto repo = static_cast(rpmmd_repos->pdata[i]); +// g_string_append_printf (enabled_repos, " %s", dnf_repo_get_id (repo)); } } else @@ -1074,95 +1075,95 @@ rpmostree_context_download_metadata (RpmOstreeContext *self, */ for (guint i = 0; i < rpmmd_repos->len; i++) { - auto repo = static_cast(rpmmd_repos->pdata[i]); - g_autoptr(DnfState) hifstate = dnf_state_new (); - - /* Until libdnf speaks GCancellable: https://github.com/projectatomic/rpm-ostree/issues/897 */ - if (g_cancellable_set_error_if_cancelled (cancellable, error)) - return FALSE; - - /* For the cache_age bits, see https://github.com/projectatomic/rpm-ostree/pull/1562 - * AKA a7bbf5bc142d9dac5b1bfb86d0466944d38baa24 - * We have our own cache age as we want to default to G_MAXUINT so we - * respect the repo's metadata_expire if set. But the compose tree path - * also sets this to 0 to force expiry. - */ - guint cache_age = G_MAXUINT-1; - switch (self->dnf_cache_policy) - { - case RPMOSTREE_CONTEXT_DNF_CACHE_FOREVER: - cache_age = G_MAXUINT; - break; - case RPMOSTREE_CONTEXT_DNF_CACHE_DEFAULT: - /* Handled above */ - break; - case RPMOSTREE_CONTEXT_DNF_CACHE_NEVER: - cache_age = 0; - break; - } - gboolean did_update = FALSE; - if (!dnf_repo_check(repo, - cache_age, - hifstate, - NULL)) - { - dnf_state_reset (hifstate); - auto msg = g_strdup_printf ("Updating metadata for '%s'", dnf_repo_get_id (repo)); - auto progress = rpmostreecxx::progress_percent_begin(msg); - guint progress_sigid = g_signal_connect (hifstate, "percentage-changed", - G_CALLBACK (on_hifstate_percentage_changed), - (void*)progress.get()); - if (!dnf_repo_update (repo, DNF_REPO_UPDATE_FLAG_FORCE, hifstate, error)) - return glnx_prefix_error (error, "Updating rpm-md repo '%s'", dnf_repo_get_id (repo)); - - did_update = TRUE; - - g_signal_handler_disconnect (hifstate, progress_sigid); - progress->end(""); - } - - guint64 ts = dnf_repo_get_timestamp_generated (repo); - g_autofree char *repo_ts_str = rpmostree_timestamp_str_from_unix_utc (ts); - rpmostree_output_message ("rpm-md repo '%s'%s; generated: %s", - dnf_repo_get_id (repo), !did_update ? " (cached)" : "", - repo_ts_str); +// auto repo = static_cast(rpmmd_repos->pdata[i]); +// g_autoptr(DnfState) hifstate = dnf_state_new (); +// +// /* Until libdnf speaks GCancellable: https://github.com/projectatomic/rpm-ostree/issues/897 */ +// if (g_cancellable_set_error_if_cancelled (cancellable, error)) +// return FALSE; +// +// /* For the cache_age bits, see https://github.com/projectatomic/rpm-ostree/pull/1562 +// * AKA a7bbf5bc142d9dac5b1bfb86d0466944d38baa24 +// * We have our own cache age as we want to default to G_MAXUINT so we +// * respect the repo's metadata_expire if set. But the compose tree path +// * also sets this to 0 to force expiry. +// */ +// guint cache_age = G_MAXUINT-1; +// switch (self->dnf_cache_policy) +// { +// case RPMOSTREE_CONTEXT_DNF_CACHE_FOREVER: +// cache_age = G_MAXUINT; +// break; +// case RPMOSTREE_CONTEXT_DNF_CACHE_DEFAULT: +// /* Handled above */ +// break; +// case RPMOSTREE_CONTEXT_DNF_CACHE_NEVER: +// cache_age = 0; +// break; +// } +// gboolean did_update = FALSE; +// if (!dnf_repo_check(repo, +// cache_age, +// hifstate, +// NULL)) +// { +// dnf_state_reset (hifstate); +// auto msg = g_strdup_printf ("Updating metadata for '%s'", dnf_repo_get_id (repo)); +// auto progress = rpmostreecxx::progress_percent_begin(msg); +// guint progress_sigid = g_signal_connect (hifstate, "percentage-changed", +// G_CALLBACK (on_hifstate_percentage_changed), +// (void*)progress.get()); +// if (!dnf_repo_update (repo, DNF_REPO_UPDATE_FLAG_FORCE, hifstate, error)) +// return glnx_prefix_error (error, "Updating rpm-md repo '%s'", dnf_repo_get_id (repo)); +// +// did_update = TRUE; +// +// g_signal_handler_disconnect (hifstate, progress_sigid); +// progress->end(""); +// } +// +// guint64 ts = dnf_repo_get_timestamp_generated (repo); +// g_autofree char *repo_ts_str = rpmostree_timestamp_str_from_unix_utc (ts); +// rpmostree_output_message ("rpm-md repo '%s'%s; generated: %s", +// dnf_repo_get_id (repo), !did_update ? " (cached)" : "", +// repo_ts_str); } if (g_cancellable_set_error_if_cancelled (cancellable, error)) return FALSE; /* The _setup_sack function among other things imports the metadata into libsolv */ - { g_autoptr(DnfState) hifstate = dnf_state_new (); - auto progress = rpmostreecxx::progress_percent_begin("Importing rpm-md"); - guint progress_sigid = g_signal_connect (hifstate, "percentage-changed", - G_CALLBACK (on_hifstate_percentage_changed), - (void*)progress.get()); - - /* We already explictly checked the repos above; don't try to check them - * again. - */ - dnf_context_set_cache_age (self->dnfctx, G_MAXUINT); - - /* This will check the metadata again, but it *should* hit the cache; down - * the line we should really improve the libdnf API around all of this. - */ - DECLARE_RPMSIGHANDLER_RESET; - if (!dnf_context_setup_sack_with_flags (self->dnfctx, hifstate, flags, error)) - return FALSE; - g_signal_handler_disconnect (hifstate, progress_sigid); - } +// { g_autoptr(DnfState) hifstate = dnf_state_new (); +// auto progress = rpmostreecxx::progress_percent_begin("Importing rpm-md"); +// guint progress_sigid = g_signal_connect (hifstate, "percentage-changed", +// G_CALLBACK (on_hifstate_percentage_changed), +// (void*)progress.get()); +// +// /* We already explictly checked the repos above; don't try to check them +// * again. +// */ +// dnf_context_set_cache_age (self->dnfctx, G_MAXUINT); +// +// /* This will check the metadata again, but it *should* hit the cache; down +// * the line we should really improve the libdnf API around all of this. +// */ +// DECLARE_RPMSIGHANDLER_RESET; +// if (!dnf_context_setup_sack_with_flags (self->dnfctx, hifstate, flags, error)) +// return FALSE; +// g_signal_handler_disconnect (hifstate, progress_sigid); +// } /* For now, we don't natively support modules. But we still want to be able to install * modular packages if the repos are enabled, but libdnf automatically filters them out. * So for now, let's tell libdnf that we do want to be able to see them. See: * https://github.com/projectatomic/rpm-ostree/issues/1435 */ - dnf_sack_set_module_excludes (dnf_context_get_sack (self->dnfctx), NULL); - /* And also mark all repos as hotfix repos so that we can indiscriminately cherry-pick - * from modular repos and non-modular repos alike. */ - g_autoptr(GPtrArray) repos = - rpmostree_get_enabled_rpmmd_repos (self->dnfctx, DNF_REPO_ENABLED_PACKAGES); - for (guint i = 0; i < repos->len; i++) - dnf_repo_set_module_hotfixes (static_cast(repos->pdata[i]), TRUE); +// dnf_sack_set_module_excludes (dnf_context_get_sack (self->dnfctx), NULL); +// /* And also mark all repos as hotfix repos so that we can indiscriminately cherry-pick +// * from modular repos and non-modular repos alike. */ +// g_autoptr(GPtrArray) repos = +// rpmostree_get_enabled_rpmmd_repos (self->dnfctx, DNF_REPO_ENABLED_PACKAGES); +// for (guint i = 0; i < repos->len; i++) +// dnf_repo_set_module_hotfixes (static_cast(repos->pdata[i]), TRUE); return TRUE; } @@ -1184,7 +1185,7 @@ journal_rpmmd_info (RpmOstreeContext *self) for (guint i = 0; i < repos->len; i++) { - auto repo = static_cast(repos->pdata[i]); +// auto repo = static_cast(repos->pdata[i]); if (first) first = FALSE; @@ -1194,25 +1195,25 @@ journal_rpmmd_info (RpmOstreeContext *self) g_string_append (enabled_repos_solvables, ", "); g_string_append (enabled_repos_timestamps, ", "); } - g_autofree char *quoted = g_shell_quote (dnf_repo_get_id (repo)); - g_string_append (enabled_repos, quoted); - total_solvables += dnf_repo_get_n_solvables (repo); - g_string_append_printf (enabled_repos_solvables, "%u", - dnf_repo_get_n_solvables (repo)); - g_string_append_printf (enabled_repos_timestamps, "%" G_GUINT64_FORMAT, - dnf_repo_get_timestamp_generated (repo)); +// g_autofree char *quoted = g_shell_quote (dnf_repo_get_id (repo)); +// g_string_append (enabled_repos, quoted); +// total_solvables += dnf_repo_get_n_solvables (repo); +// g_string_append_printf (enabled_repos_solvables, "%u", +// dnf_repo_get_n_solvables (repo)); +// g_string_append_printf (enabled_repos_timestamps, "%" G_GUINT64_FORMAT, +// dnf_repo_get_timestamp_generated (repo)); } - sd_journal_send ("MESSAGE_ID=" SD_ID128_FORMAT_STR, - SD_ID128_FORMAT_VAL(RPMOSTREE_MESSAGE_PKG_REPOS), - "MESSAGE=Preparing pkg txn; enabled repos: [%s] solvables: %u", - enabled_repos->str, total_solvables, - "SACK_N_SOLVABLES=%i", - dnf_sack_count (dnf_context_get_sack (self->dnfctx)), - "ENABLED_REPOS=[%s]", enabled_repos->str, - "ENABLED_REPOS_SOLVABLES=[%s]", enabled_repos_solvables->str, - "ENABLED_REPOS_TIMESTAMPS=[%s]", enabled_repos_timestamps->str, - NULL); +// sd_journal_send ("MESSAGE_ID=" SD_ID128_FORMAT_STR, +// SD_ID128_FORMAT_VAL(RPMOSTREE_MESSAGE_PKG_REPOS), +// "MESSAGE=Preparing pkg txn; enabled repos: [%s] solvables: %u", +// enabled_repos->str, total_solvables, +// "SACK_N_SOLVABLES=%i", +// dnf_sack_count (dnf_context_get_sack (self->dnfctx)), +// "ENABLED_REPOS=[%s]", enabled_repos->str, +// "ENABLED_REPOS_SOLVABLES=[%s]", enabled_repos_solvables->str, +// "ENABLED_REPOS_TIMESTAMPS=[%s]", enabled_repos_timestamps->str, +// NULL); } } @@ -1292,7 +1293,7 @@ pkg_is_cached (DnfPackage *pkg) * that - which is what happens with the ostree commits * above. */ - return g_file_test (dnf_package_get_filename (pkg), G_FILE_TEST_EXISTS); + return FALSE; //g_file_test (dnf_package_get_filename (pkg), G_FILE_TEST_EXISTS); } /* Given @pkg, return its state in the pkgcache repo. It could be not present, @@ -1349,35 +1350,35 @@ find_pkg_in_ostree (RpmOstreeContext *self, * newer versions of LocalPackages from the repos. But we do want to check * whether a relabel will be necessary. */ - const char *reponame = dnf_package_get_reponame (pkg); - if (g_strcmp0 (reponame, HY_CMDLINE_REPO_NAME) != 0) - { - auto expected_chksum_repr = rpmostreecxx::get_repodata_chksum_repr(*pkg); - - gboolean same_pkg_chksum = FALSE; - if (!commit_has_matching_repodata_chksum_repr (commit, - expected_chksum_repr.c_str(), - &same_pkg_chksum, error)) - return FALSE; - - if (!same_pkg_chksum) - return TRUE; /* Note early return */ - - /* We need to handle things like the nodocs flag changing; in that case we - * have to redownload. - */ - const bool global_nodocs = (self->treefile_rs && !self->treefile_rs->get_documentation()); - - gboolean pkgcache_commit_is_nodocs; - if (!g_variant_dict_lookup (metadata_dict, "rpmostree.nodocs", "b", &pkgcache_commit_is_nodocs)) - pkgcache_commit_is_nodocs = FALSE; - - /* We treat a mismatch of documentation state as simply not being - * imported at all. - */ - if (global_nodocs != (bool)pkgcache_commit_is_nodocs) - return TRUE; - } +// const char *reponame = dnf_package_get_reponame (pkg); +// if (g_strcmp0 (reponame, HY_CMDLINE_REPO_NAME) != 0) +// { +// auto expected_chksum_repr = rpmostreecxx::get_repodata_chksum_repr(*pkg); +// +// gboolean same_pkg_chksum = FALSE; +// if (!commit_has_matching_repodata_chksum_repr (commit, +// expected_chksum_repr.c_str(), +// &same_pkg_chksum, error)) +// return FALSE; +// +// if (!same_pkg_chksum) +// return TRUE; /* Note early return */ +// +// /* We need to handle things like the nodocs flag changing; in that case we +// * have to redownload. +// */ +// const bool global_nodocs = (self->treefile_rs && !self->treefile_rs->get_documentation()); +// +// gboolean pkgcache_commit_is_nodocs; +// if (!g_variant_dict_lookup (metadata_dict, "rpmostree.nodocs", "b", &pkgcache_commit_is_nodocs)) +// pkgcache_commit_is_nodocs = FALSE; +// +// /* We treat a mismatch of documentation state as simply not being +// * imported at all. +// */ +// if (global_nodocs != (bool)pkgcache_commit_is_nodocs) +// return TRUE; +// } /* We found an import, let's load the sepolicy state */ *out_in_ostree = TRUE; @@ -1395,30 +1396,30 @@ void rpmostree_set_repos_on_packages (DnfContext *dnfctx, GPtrArray *packages) { - GPtrArray *sources = dnf_context_get_repos (dnfctx); - /* ownership of key and val stays in sources */ - g_autoptr(GHashTable) name_to_repo = g_hash_table_new (g_str_hash, g_str_equal); - for (guint i = 0; i < sources->len; i++) - { - DnfRepo *source = (DnfRepo*)sources->pdata[i]; - g_hash_table_insert (name_to_repo, (gpointer)dnf_repo_get_id (source), source); - } - - for (guint i = 0; i < packages->len; i++) - { - DnfPackage *pkg = (DnfPackage*)packages->pdata[i]; - const char *reponame = dnf_package_get_reponame (pkg); - gboolean is_locally_cached = - (g_strcmp0 (reponame, HY_CMDLINE_REPO_NAME) == 0); - - if (is_locally_cached) - continue; - - DnfRepo *repo = (DnfRepo*)g_hash_table_lookup (name_to_repo, reponame); - g_assert (repo); - - dnf_package_set_repo (pkg, repo); - } +// GPtrArray *sources = dnf_context_get_repos (dnfctx); +// /* ownership of key and val stays in sources */ +// g_autoptr(GHashTable) name_to_repo = g_hash_table_new (g_str_hash, g_str_equal); +// for (guint i = 0; i < sources->len; i++) +// { +// DnfRepo *source = (DnfRepo*)sources->pdata[i]; +// g_hash_table_insert (name_to_repo, (gpointer)dnf_repo_get_id (source), source); +// } +// +// for (guint i = 0; i < packages->len; i++) +// { +// DnfPackage *pkg = (DnfPackage*)packages->pdata[i]; +// const char *reponame = dnf_package_get_reponame (pkg); +// gboolean is_locally_cached = +// (g_strcmp0 (reponame, HY_CMDLINE_REPO_NAME) == 0); +// +// if (is_locally_cached) +// continue; +// +// DnfRepo *repo = (DnfRepo*)g_hash_table_lookup (name_to_repo, reponame); +// g_assert (repo); +// +// dnf_package_set_repo (pkg, repo); +// } } /* determine of all the marked packages, which ones we'll need to download, @@ -1450,9 +1451,9 @@ sort_packages (RpmOstreeContext *self, if (g_cancellable_set_error_if_cancelled (cancellable, error)) return FALSE; - const char *reponame = dnf_package_get_reponame (pkg); - gboolean is_locally_cached = - (g_strcmp0 (reponame, HY_CMDLINE_REPO_NAME) == 0); +// const char *reponame = dnf_package_get_reponame (pkg); +// gboolean is_locally_cached = +// (g_strcmp0 (reponame, HY_CMDLINE_REPO_NAME) == 0); /* NB: We're assuming here that the presence of an ostree repo means that * the user intends to import the pkg vs e.g. installing it like during a @@ -1464,26 +1465,26 @@ sort_packages (RpmOstreeContext *self, * RpmOstreeContext to express *why* they are calling prepare(). * */ - { - gboolean in_ostree = FALSE; - gboolean selinux_match = FALSE; - gboolean cached = pkg_is_cached (pkg); - - if (!find_pkg_in_ostree (self, pkg, self->sepolicy, - &in_ostree, &selinux_match, error)) - return FALSE; - - if (is_locally_cached) - g_assert (in_ostree); - - if (!in_ostree && !cached) - g_ptr_array_add (self->pkgs_to_download, g_object_ref (pkg)); - if (!in_ostree) - g_ptr_array_add (self->pkgs_to_import, g_object_ref (pkg)); - /* This logic is equivalent to that in rpmostree_context_force_relabel() */ - if (in_ostree && !selinux_match) - g_ptr_array_add (self->pkgs_to_relabel, g_object_ref (pkg)); - } +// { +// gboolean in_ostree = FALSE; +// gboolean selinux_match = FALSE; +// gboolean cached = pkg_is_cached (pkg); +// +// if (!find_pkg_in_ostree (self, pkg, self->sepolicy, +// &in_ostree, &selinux_match, error)) +// return FALSE; +// +// if (is_locally_cached) +// g_assert (in_ostree); +// +// if (!in_ostree && !cached) +// g_ptr_array_add (self->pkgs_to_download, g_object_ref (pkg)); +// if (!in_ostree) +// g_ptr_array_add (self->pkgs_to_import, g_object_ref (pkg)); +// /* This logic is equivalent to that in rpmostree_context_force_relabel() */ +// if (in_ostree && !selinux_match) +// g_ptr_array_add (self->pkgs_to_relabel, g_object_ref (pkg)); +// } } return TRUE; @@ -1516,13 +1517,13 @@ throw_package_list (GError **error, const char *prefix, GPtrArray *pkgs) static GVariant* gv_nevra_from_pkg (DnfPackage *pkg) { - return g_variant_ref_sink (g_variant_new ("(sstsss)", - dnf_package_get_nevra (pkg), - dnf_package_get_name (pkg), - dnf_package_get_epoch (pkg), - dnf_package_get_version (pkg), - dnf_package_get_release (pkg), - dnf_package_get_arch (pkg))); + return NULL; //g_variant_ref_sink (g_variant_new ("(sstsss)", +// dnf_package_get_nevra (pkg), +// dnf_package_get_name (pkg), +// dnf_package_get_epoch (pkg), +// dnf_package_get_version (pkg), +// dnf_package_get_release (pkg), +// dnf_package_get_arch (pkg))); } /* g_variant_hash can't handle container types */ @@ -1548,133 +1549,133 @@ check_goal_solution (RpmOstreeContext *self, GPtrArray *replaced_nevras, GError **error) { - HyGoal goal = dnf_context_get_goal (self->dnfctx); - - /* check that we're not removing anything we didn't expect */ - { g_autoptr(GPtrArray) forbidden = g_ptr_array_new_with_free_func (g_free); - - /* also collect info about those we're removing */ - g_assert (!self->pkgs_to_remove); - self->pkgs_to_remove = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, - (GDestroyNotify)g_variant_unref); - g_autoptr(GPtrArray) packages = dnf_goal_get_packages (goal, - DNF_PACKAGE_INFO_REMOVE, - DNF_PACKAGE_INFO_OBSOLETE, -1); - for (guint i = 0; i < packages->len; i++) - { - auto pkg = static_cast(packages->pdata[i]); - const char *name = dnf_package_get_name (pkg); - const char *nevra = dnf_package_get_nevra (pkg); - - /* did we expect this package to be removed? */ - if (rpmostree_str_ptrarray_contains (removed_pkgnames, name)) - g_hash_table_insert (self->pkgs_to_remove, g_strdup (name), - gv_nevra_from_pkg (pkg)); - else - g_ptr_array_add (forbidden, g_strdup (nevra)); - } - - if (forbidden->len > 0) - return throw_package_list (error, "Base packages would be removed", forbidden); - } - - /* check that all the pkgs we expect to remove are marked for removal */ - { g_autoptr(GPtrArray) forbidden = g_ptr_array_new (); - - for (guint i = 0; i < removed_pkgnames->len; i++) - { - auto pkgname = static_cast(removed_pkgnames->pdata[i]); - if (!g_hash_table_contains (self->pkgs_to_remove, pkgname)) - g_ptr_array_add (forbidden, (gpointer)pkgname); - } - - if (forbidden->len > 0) - return throw_package_list (error, "Base packages not marked to be removed", forbidden); - } - - /* REINSTALLs should never happen since it doesn't make sense in the rpm-ostree flow, and - * we check very early whether a package is already in the rootfs or not, but let's check - * for it anyway so that we get a bug report in case it somehow happens. */ - { g_autoptr(GPtrArray) packages = - dnf_goal_get_packages (goal, DNF_PACKAGE_INFO_REINSTALL, -1); - g_assert_cmpint (packages->len, ==, 0); - } - - /* Look at UPDATE and DOWNGRADE, and see whether they're doing what we expect */ - { g_autoptr(GHashTable) forbidden_replacements = - g_hash_table_new_full (NULL, NULL, (GDestroyNotify)g_object_unref, - (GDestroyNotify)g_object_unref); - - /* also collect info about those we're replacing */ - g_assert (!self->pkgs_to_replace); - self->pkgs_to_replace = g_hash_table_new_full (gv_nevra_hash, g_variant_equal, - (GDestroyNotify)g_variant_unref, - (GDestroyNotify)g_variant_unref); - g_autoptr(GPtrArray) packages = dnf_goal_get_packages (goal, - DNF_PACKAGE_INFO_UPDATE, - DNF_PACKAGE_INFO_DOWNGRADE, -1); - for (guint i = 0; i < packages->len; i++) - { - auto pkg = static_cast(packages->pdata[i]); - const char *nevra = dnf_package_get_nevra (pkg); - - /* just pick the first pkg */ - g_autoptr(GPtrArray) old = hy_goal_list_obsoleted_by_package (goal, pkg); - g_assert_cmpint (old->len, >, 0); - auto old_pkg = static_cast(old->pdata[0]); - - /* did we expect this nevra to replace a base pkg? */ - if (rpmostree_str_ptrarray_contains (replaced_nevras, nevra)) - g_hash_table_insert (self->pkgs_to_replace, gv_nevra_from_pkg (pkg), - gv_nevra_from_pkg (old_pkg)); - else - g_hash_table_insert (forbidden_replacements, g_object_ref (old_pkg), - g_object_ref (pkg)); - } - - if (g_hash_table_size (forbidden_replacements) > 0) - { - rpmostree_output_message ("Forbidden base package replacements:"); - GLNX_HASH_TABLE_FOREACH_KV (forbidden_replacements, DnfPackage*, old_pkg, - DnfPackage*, new_pkg) - { - const char *old_name = dnf_package_get_name (old_pkg); - const char *new_name = dnf_package_get_name (new_pkg); - const char *new_repo = dnf_package_get_reponame (new_pkg); - if (g_str_equal (old_name, new_name)) - rpmostree_output_message (" %s %s -> %s (%s)", old_name, - dnf_package_get_evr (old_pkg), - dnf_package_get_evr (new_pkg), new_repo); - else - rpmostree_output_message (" %s -> %s (%s)", - dnf_package_get_nevra (old_pkg), - dnf_package_get_nevra (new_pkg), new_repo); - } - rpmostree_output_message ("This likely means that some of your layered packages " - "have requirements on newer or older versions of some " - "base packages. Doing `rpm-ostree cleanup -m` and " - "`rpm-ostree upgrade` first may help. For " - "more details, see: " - "https://github.com/projectatomic/rpm-ostree/issues/415"); - - return glnx_throw (error, "Some base packages would be replaced"); - } - } - - /* check that all the pkgs we expect to replace are marked for replacement */ - { g_autoptr(GPtrArray) forbidden = g_ptr_array_new_with_free_func (g_free); - - GLNX_HASH_TABLE_FOREACH_KV (self->pkgs_to_replace, GVariant*, newv, GVariant*, old) - { - g_autoptr(GVariant) nevra_v = g_variant_get_child_value (newv, 0); - const char *nevra = g_variant_get_string (nevra_v, NULL); - if (!rpmostree_str_ptrarray_contains (replaced_nevras, nevra)) - g_ptr_array_add (forbidden, g_strdup (nevra)); - } - - if (forbidden->len > 0) - return throw_package_list (error, "Base packages not marked to be installed", forbidden); - } +// HyGoal goal = dnf_context_get_goal (self->dnfctx); +// +// /* check that we're not removing anything we didn't expect */ +// { g_autoptr(GPtrArray) forbidden = g_ptr_array_new_with_free_func (g_free); +// +// /* also collect info about those we're removing */ +// g_assert (!self->pkgs_to_remove); +// self->pkgs_to_remove = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, +// (GDestroyNotify)g_variant_unref); +// g_autoptr(GPtrArray) packages = dnf_goal_get_packages (goal, +// DNF_PACKAGE_INFO_REMOVE, +// DNF_PACKAGE_INFO_OBSOLETE, -1); +// for (guint i = 0; i < packages->len; i++) +// { +// auto pkg = static_cast(packages->pdata[i]); +// const char *name = dnf_package_get_name (pkg); +// const char *nevra = dnf_package_get_nevra (pkg); +// +// /* did we expect this package to be removed? */ +// if (rpmostree_str_ptrarray_contains (removed_pkgnames, name)) +// g_hash_table_insert (self->pkgs_to_remove, g_strdup (name), +// gv_nevra_from_pkg (pkg)); +// else +// g_ptr_array_add (forbidden, g_strdup (nevra)); +// } +// +// if (forbidden->len > 0) +// return throw_package_list (error, "Base packages would be removed", forbidden); +// } +// +// /* check that all the pkgs we expect to remove are marked for removal */ +// { g_autoptr(GPtrArray) forbidden = g_ptr_array_new (); +// +// for (guint i = 0; i < removed_pkgnames->len; i++) +// { +// auto pkgname = static_cast(removed_pkgnames->pdata[i]); +// if (!g_hash_table_contains (self->pkgs_to_remove, pkgname)) +// g_ptr_array_add (forbidden, (gpointer)pkgname); +// } +// +// if (forbidden->len > 0) +// return throw_package_list (error, "Base packages not marked to be removed", forbidden); +// } +// +// /* REINSTALLs should never happen since it doesn't make sense in the rpm-ostree flow, and +// * we check very early whether a package is already in the rootfs or not, but let's check +// * for it anyway so that we get a bug report in case it somehow happens. */ +// { g_autoptr(GPtrArray) packages = +// dnf_goal_get_packages (goal, DNF_PACKAGE_INFO_REINSTALL, -1); +// g_assert_cmpint (packages->len, ==, 0); +// } +// +// /* Look at UPDATE and DOWNGRADE, and see whether they're doing what we expect */ +// { g_autoptr(GHashTable) forbidden_replacements = +// g_hash_table_new_full (NULL, NULL, (GDestroyNotify)g_object_unref, +// (GDestroyNotify)g_object_unref); +// +// /* also collect info about those we're replacing */ +// g_assert (!self->pkgs_to_replace); +// self->pkgs_to_replace = g_hash_table_new_full (gv_nevra_hash, g_variant_equal, +// (GDestroyNotify)g_variant_unref, +// (GDestroyNotify)g_variant_unref); +// g_autoptr(GPtrArray) packages = dnf_goal_get_packages (goal, +// DNF_PACKAGE_INFO_UPDATE, +// DNF_PACKAGE_INFO_DOWNGRADE, -1); +// for (guint i = 0; i < packages->len; i++) +// { +// auto pkg = static_cast(packages->pdata[i]); +// const char *nevra = dnf_package_get_nevra (pkg); +// +// /* just pick the first pkg */ +// g_autoptr(GPtrArray) old = hy_goal_list_obsoleted_by_package (goal, pkg); +// g_assert_cmpint (old->len, >, 0); +// auto old_pkg = static_cast(old->pdata[0]); +// +// /* did we expect this nevra to replace a base pkg? */ +// if (rpmostree_str_ptrarray_contains (replaced_nevras, nevra)) +// g_hash_table_insert (self->pkgs_to_replace, gv_nevra_from_pkg (pkg), +// gv_nevra_from_pkg (old_pkg)); +// else +// g_hash_table_insert (forbidden_replacements, g_object_ref (old_pkg), +// g_object_ref (pkg)); +// } +// +// if (g_hash_table_size (forbidden_replacements) > 0) +// { +// rpmostree_output_message ("Forbidden base package replacements:"); +// GLNX_HASH_TABLE_FOREACH_KV (forbidden_replacements, DnfPackage*, old_pkg, +// DnfPackage*, new_pkg) +// { +// const char *old_name = dnf_package_get_name (old_pkg); +// const char *new_name = dnf_package_get_name (new_pkg); +// const char *new_repo = dnf_package_get_reponame (new_pkg); +// if (g_str_equal (old_name, new_name)) +// rpmostree_output_message (" %s %s -> %s (%s)", old_name, +// dnf_package_get_evr (old_pkg), +// dnf_package_get_evr (new_pkg), new_repo); +// else +// rpmostree_output_message (" %s -> %s (%s)", +// dnf_package_get_nevra (old_pkg), +// dnf_package_get_nevra (new_pkg), new_repo); +// } +// rpmostree_output_message ("This likely means that some of your layered packages " +// "have requirements on newer or older versions of some " +// "base packages. Doing `rpm-ostree cleanup -m` and " +// "`rpm-ostree upgrade` first may help. For " +// "more details, see: " +// "https://github.com/projectatomic/rpm-ostree/issues/415"); +// +// return glnx_throw (error, "Some base packages would be replaced"); +// } +// } +// +// /* check that all the pkgs we expect to replace are marked for replacement */ +// { g_autoptr(GPtrArray) forbidden = g_ptr_array_new_with_free_func (g_free); +// +// GLNX_HASH_TABLE_FOREACH_KV (self->pkgs_to_replace, GVariant*, newv, GVariant*, old) +// { +// g_autoptr(GVariant) nevra_v = g_variant_get_child_value (newv, 0); +// const char *nevra = g_variant_get_string (nevra_v, NULL); +// if (!rpmostree_str_ptrarray_contains (replaced_nevras, nevra)) +// g_ptr_array_add (forbidden, g_strdup (nevra)); +// } +// +// if (forbidden->len > 0) +// return throw_package_list (error, "Base packages not marked to be installed", forbidden); +// } return TRUE; } @@ -1696,12 +1697,12 @@ add_pkg_from_cache (RpmOstreeContext *self, * DnfRepo. We could do this all in-memory though it doesn't seem like libsolv has an * appropriate API for this. */ g_autofree char *rpm = g_strdup_printf ("%s/metarpm/%s.rpm", self->tmpdir.path, nevra); - g_autoptr(DnfPackage) pkg = - dnf_sack_add_cmdline_package (dnf_context_get_sack (self->dnfctx), rpm); - if (!pkg) - return glnx_throw (error, "Failed to add local pkg %s to sack", nevra); - - *out_pkg = util::move_nullify (pkg); +// g_autoptr(DnfPackage) pkg = +// dnf_sack_add_cmdline_package (dnf_context_get_sack (self->dnfctx), rpm); +// if (!pkg) +// return glnx_throw (error, "Failed to add local pkg %s to sack", nevra); +// +// *out_pkg = util::move_nullify (pkg); return TRUE; } @@ -1719,8 +1720,8 @@ add_remaining_pkgcache_pkgs (RpmOstreeContext *self, g_assert (pkgcache_repo); g_assert (self->pkgcache_only); - DnfSack *sack = dnf_context_get_sack (self->dnfctx); - g_assert (sack); +// DnfSack *sack = dnf_context_get_sack (self->dnfctx); +// g_assert (sack); g_autoptr(GHashTable) refs = NULL; if (!ostree_repo_list_refs_ext (pkgcache_repo, "rpmostree/pkg", &refs, @@ -1741,9 +1742,9 @@ add_remaining_pkgcache_pkgs (RpmOstreeContext *self, return FALSE; g_autofree char *rpm = g_strdup_printf ("%s/metarpm/%s.rpm", self->tmpdir.path, nevra.c_str()); - g_autoptr(DnfPackage) pkg = dnf_sack_add_cmdline_package (sack, rpm); - if (!pkg) - return glnx_throw (error, "Failed to add local pkg %s to sack", nevra.c_str()); +// g_autoptr(DnfPackage) pkg = dnf_sack_add_cmdline_package (sack, rpm); +// if (!pkg) +// return glnx_throw (error, "Failed to add local pkg %s to sack", nevra.c_str()); } return TRUE; @@ -1755,94 +1756,95 @@ static GPtrArray* find_locked_packages (RpmOstreeContext *self, GError **error) { - g_assert (self->lockfile); - DnfContext *dnfctx = self->dnfctx; - DnfSack *sack = dnf_context_get_sack (dnfctx); - - g_autoptr(GPtrArray) pkgs = - g_ptr_array_new_with_free_func ((GDestroyNotify)g_object_unref); - - auto locked_src_pkgs = (*self->lockfile)->get_locked_src_packages(); - std::set locked_src_pkgnames; - for (auto & pkg : locked_src_pkgs) - { - g_autofree char *srpm = g_strdup_printf ("%s-%s.src.rpm", pkg.name.c_str(), pkg.evr.c_str()); - hy_autoquery HyQuery query = hy_query_create (sack); - hy_query_filter (query, HY_PKG_SOURCERPM, HY_EQ, srpm); - g_autoptr(GPtrArray) matches = hy_query_run (query); - if (matches->len == 0) - { - return (GPtrArray*)glnx_null_throw (error, "Couldn't find locked source package '%s-%s'", - pkg.name.c_str(), pkg.evr.c_str()); - } - for (guint i = 0; i < matches->len; i++) - { - auto match = static_cast(matches->pdata[i]); - /* we could optimize this path outside the loop in the future using the - * g_ptr_array_extend_and_steal API, though that's still too new for e.g. el8 */ - g_ptr_array_add (pkgs, g_object_ref (match)); - } - locked_src_pkgnames.insert(pkg.name); - } - - auto locked_pkgs = (*self->lockfile)->get_locked_packages(); - for (auto & pkg : locked_pkgs) - { - /* This essentially makes `source-packages` have higher priority than `packages`. This - * isn't technically correct: what we should do in lockfile.rs is to convert - * `source-packages` to `packages` *before* merging all the lockfiles, so that e.g. a - * `packages` in a higher-level lockfile can override a `source-packages` in a lower - * level. For now this is fine because the primary use case is humans typing source - * packages where we want it to have the highest precedence. */ - if (locked_src_pkgnames.count(pkg.name)) - continue; - - hy_autoquery HyQuery query = hy_query_create (sack); - hy_query_filter (query, HY_PKG_NAME, HY_EQ, pkg.name.c_str()); - hy_query_filter (query, HY_PKG_EVR, HY_EQ, pkg.evr.c_str()); - if (pkg.arch.length() > 0) - hy_query_filter (query, HY_PKG_ARCH, HY_EQ, pkg.arch.c_str()); - g_autoptr(GPtrArray) matches = hy_query_run (query); - - gboolean at_least_one = FALSE; - guint n_checksum_mismatches = 0; - for (guint i = 0; i < matches->len; i++) - { - auto match = static_cast(matches->pdata[i]); - if (pkg.digest.length() == 0) - { - /* we could optimize this path outside the loop in the future using the - * g_ptr_array_extend_and_steal API, though that's still too new for e.g. el8 */ - g_ptr_array_add (pkgs, g_object_ref (match)); - at_least_one = TRUE; - } - else - { - auto repodata_chksum = rpmostreecxx::get_repodata_chksum_repr(*match); - if (pkg.digest != repodata_chksum) /* we're comparing two rust::String here */ - n_checksum_mismatches++; - else - { - g_ptr_array_add (pkgs, g_object_ref (match)); - at_least_one = TRUE; - } - } - } - if (!at_least_one) - { - g_autofree char *spec = - g_strdup_printf ("%s-%s%s%s", pkg.name.c_str(), pkg.evr.c_str(), - pkg.arch.length() > 0 ? "." : "", - pkg.arch.length() > 0 ? pkg.arch.c_str() : ""); - return (GPtrArray*)glnx_null_throw (error, "Couldn't find locked package '%s'%s%s " - "(pkgs matching NEVRA: %d; mismatched checksums: %d)", - spec, pkg.digest.length() > 0 ? " with checksum " : "", - pkg.digest.length() > 0 ? pkg.digest.c_str() : "", - matches->len, n_checksum_mismatches); - } - } - - return util::move_nullify (pkgs); +// g_assert (self->lockfile); +// DnfContext *dnfctx = self->dnfctx; +// DnfSack *sack = dnf_context_get_sack (dnfctx); +// +// g_autoptr(GPtrArray) pkgs = +// g_ptr_array_new_with_free_func ((GDestroyNotify)g_object_unref); +// +// auto locked_src_pkgs = (*self->lockfile)->get_locked_src_packages(); +// std::set locked_src_pkgnames; +// for (auto & pkg : locked_src_pkgs) +// { +// g_autofree char *srpm = g_strdup_printf ("%s-%s.src.rpm", pkg.name.c_str(), pkg.evr.c_str()); +// hy_autoquery HyQuery query = hy_query_create (sack); +// hy_query_filter (query, HY_PKG_SOURCERPM, HY_EQ, srpm); +// g_autoptr(GPtrArray) matches = hy_query_run (query); +// if (matches->len == 0) +// { +// return (GPtrArray*)glnx_null_throw (error, "Couldn't find locked source package '%s-%s'", +// pkg.name.c_str(), pkg.evr.c_str()); +// } +// for (guint i = 0; i < matches->len; i++) +// { +// auto match = static_cast(matches->pdata[i]); +// /* we could optimize this path outside the loop in the future using the +// * g_ptr_array_extend_and_steal API, though that's still too new for e.g. el8 */ +// g_ptr_array_add (pkgs, g_object_ref (match)); +// } +// locked_src_pkgnames.insert(pkg.name); +// } +// +// auto locked_pkgs = (*self->lockfile)->get_locked_packages(); +// for (auto & pkg : locked_pkgs) +// { +// /* This essentially makes `source-packages` have higher priority than `packages`. This +// * isn't technically correct: what we should do in lockfile.rs is to convert +// * `source-packages` to `packages` *before* merging all the lockfiles, so that e.g. a +// * `packages` in a higher-level lockfile can override a `source-packages` in a lower +// * level. For now this is fine because the primary use case is humans typing source +// * packages where we want it to have the highest precedence. */ +// if (locked_src_pkgnames.count(pkg.name)) +// continue; +// +// hy_autoquery HyQuery query = hy_query_create (sack); +// hy_query_filter (query, HY_PKG_NAME, HY_EQ, pkg.name.c_str()); +// hy_query_filter (query, HY_PKG_EVR, HY_EQ, pkg.evr.c_str()); +// if (pkg.arch.length() > 0) +// hy_query_filter (query, HY_PKG_ARCH, HY_EQ, pkg.arch.c_str()); +// g_autoptr(GPtrArray) matches = hy_query_run (query); +// +// gboolean at_least_one = FALSE; +// guint n_checksum_mismatches = 0; +// for (guint i = 0; i < matches->len; i++) +// { +// auto match = static_cast(matches->pdata[i]); +// if (pkg.digest.length() == 0) +// { +// /* we could optimize this path outside the loop in the future using the +// * g_ptr_array_extend_and_steal API, though that's still too new for e.g. el8 */ +// g_ptr_array_add (pkgs, g_object_ref (match)); +// at_least_one = TRUE; +// } +// else +// { +// auto repodata_chksum = rpmostreecxx::get_repodata_chksum_repr(*match); +// if (pkg.digest != repodata_chksum) /* we're comparing two rust::String here */ +// n_checksum_mismatches++; +// else +// { +// g_ptr_array_add (pkgs, g_object_ref (match)); +// at_least_one = TRUE; +// } +// } +// } +// if (!at_least_one) +// { +// g_autofree char *spec = +// g_strdup_printf ("%s-%s%s%s", pkg.name.c_str(), pkg.evr.c_str(), +// pkg.arch.length() > 0 ? "." : "", +// pkg.arch.length() > 0 ? pkg.arch.c_str() : ""); +// return (GPtrArray*)glnx_null_throw (error, "Couldn't find locked package '%s'%s%s " +// "(pkgs matching NEVRA: %d; mismatched checksums: %d)", +// spec, pkg.digest.length() > 0 ? " with checksum " : "", +// pkg.digest.length() > 0 ? pkg.digest.c_str() : "", +// matches->len, n_checksum_mismatches); +// } +// } +// +// return util::move_nullify (pkgs); + return NULL; } /* Check for/download new rpm-md, then depsolve */ @@ -1874,275 +1876,275 @@ rpmostree_context_prepare (RpmOstreeContext *self, "^a&s", &removed_base_pkgnames)); /* setup sack if not yet set up */ - if (dnf_context_get_sack (dnfctx) == NULL) - { - /* default to loading updateinfo in this path; this allows the sack to be used later - * on for advisories -- it's always downloaded anyway */ - if (!rpmostree_context_download_metadata (self, - DNF_CONTEXT_SETUP_SACK_FLAG_LOAD_UPDATEINFO, - cancellable, error)) - return FALSE; - journal_rpmmd_info (self); - } - DnfSack *sack = dnf_context_get_sack (dnfctx); - HyGoal goal = dnf_context_get_goal (dnfctx); - - /* Don't try to keep multiple kernels per root; that's a traditional thing, - * ostree binds kernel + userspace. - */ - dnf_sack_set_installonly (sack, NULL); - dnf_sack_set_installonly_limit (sack, 0); - - - if (self->lockfile) - { - /* we only support pure installs for now (compose case) */ - g_assert_cmpint (g_strv_length (cached_pkgnames), ==, 0); - g_assert_cmpint (g_strv_length (cached_replace_pkgs), ==, 0); - g_assert_cmpint (g_strv_length (removed_base_pkgnames), ==, 0); - } - - /* track cached pkgs already added to the sack so far */ - g_autoptr(GHashTable) local_pkgs_to_install = - g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref); - - /* Handle packages to replace; only add them to the sack for now */ - g_autoptr(GPtrArray) replaced_nevras = g_ptr_array_new (); - g_autoptr(GPtrArray) replaced_pkgnames = g_ptr_array_new_with_free_func (g_free); - for (char **it = cached_replace_pkgs; it && *it; it++) - { - const char *nevra = *it; - g_autofree char *sha256 = NULL; - if (!rpmostree_decompose_sha256_nevra (&nevra, &sha256, error)) - return FALSE; - - g_autoptr(DnfPackage) pkg = NULL; - if (!add_pkg_from_cache (self, nevra, sha256, &pkg, cancellable, error)) - return FALSE; - - const char *name = dnf_package_get_name (pkg); - g_assert (name); - - g_ptr_array_add (replaced_nevras, (gpointer)nevra); - // this is a bit wasteful, but for locking purposes, we need the pkgname to match - // against the base, not the nevra which naturally will be different - g_ptr_array_add (replaced_pkgnames, g_strdup (name)); - g_hash_table_insert (local_pkgs_to_install, (gpointer)nevra, g_steal_pointer (&pkg)); - } - - /* Now handle local package; only add them to the sack for now */ - for (char **it = cached_pkgnames; it && *it; it++) - { - const char *nevra = *it; - g_autofree char *sha256 = NULL; - if (!rpmostree_decompose_sha256_nevra (&nevra, &sha256, error)) - return FALSE; - - g_autoptr(DnfPackage) pkg = NULL; - if (!add_pkg_from_cache (self, nevra, sha256, &pkg, cancellable, error)) - return FALSE; - - g_hash_table_insert (local_pkgs_to_install, (gpointer)nevra, g_steal_pointer (&pkg)); - } - - /* If we're in cache-only mode, add all the remaining pkgs now. We do this *after* the - * replace & local pkgs since they already handle a subset of the cached pkgs and have - * SHA256 checks. But we do it *before* dnf_context_install() since those subjects are not - * directly linked to a cached pkg, so we need to teach libdnf about them beforehand. */ - if (self->pkgcache_only) - { - if (!add_remaining_pkgcache_pkgs (self, local_pkgs_to_install, cancellable, error)) - return FALSE; - } - - /* Now that we're done adding stuff to the sack, we can actually mark pkgs for install and - * uninstall. We don't want to mix those two steps, otherwise we might confuse libdnf, - * see: https://github.com/rpm-software-management/libdnf/issues/700 */ - - if (self->lockfile) - { - /* first, find our locked pkgs in the rpmmd */ - g_autoptr(GPtrArray) locked_pkgs = find_locked_packages (self, error); - if (!locked_pkgs) - return FALSE; - - /* build a packageset from it */ - DnfPackageSet *locked_pset = dnf_packageset_new (sack); - for (guint i = 0; i < locked_pkgs->len; i++) - dnf_packageset_add (locked_pset, static_cast(locked_pkgs->pdata[i])); - - if (self->lockfile_strict) - { - /* In strict mode, we basically *only* want locked packages to be considered, so - * exclude everything else. Note we still don't directly do `hy_goal_install` - * here; we want the treefile to still be canonical, but we just make sure that - * the end result matches what we expect. */ - DnfPackageSet *pset = dnf_packageset_new (sack); - Map *map = dnf_packageset_get_map (pset); - map_setall (map); - map_subtract (map, dnf_packageset_get_map (locked_pset)); - dnf_sack_add_excludes (sack, pset); - dnf_packageset_free (pset); - } - else - { - /* Exclude all the packages in lockfile repos except locked packages. */ - g_autofree char **lockfile_repos = NULL; - g_variant_dict_lookup (self->spec->dict, "lockfile-repos", "^a&s", &lockfile_repos); - for (char **it = lockfile_repos; it && *it; it++) - { - const char *repo = *it; - hy_autoquery HyQuery query = hy_query_create (sack); - hy_query_filter (query, HY_PKG_REPONAME, HY_EQ, repo); - DnfPackageSet *pset = hy_query_run_set (query); - Map *map = dnf_packageset_get_map (pset); - map_subtract (map, dnf_packageset_get_map (locked_pset)); - dnf_sack_add_excludes (sack, pset); - dnf_packageset_free (pset); - } - - /* In relaxed mode, we allow packages to be added or removed without having to - * edit lockfiles. However, we still want to make sure that if a package does get - * installed which is in the lockfile, it can only pick that NEVRA. To do this, we - * filter out from the sack all pkgs which don't match. */ - - /* map of all packages with names found in the lockfile (note here we derive this - * from `locked_pkgs` instead of from the lockfile again to account for - * source-packages too (which have been resolved to packages in `locked_pkgs`) */ - DnfPackageSet *named_pkgs = dnf_packageset_new (sack); - Map *named_pkgs_map = dnf_packageset_get_map (named_pkgs); - for (guint i = 0; i < locked_pkgs->len; i++) - { - DnfPackage *pkg = (DnfPackage*)locked_pkgs->pdata[i]; - hy_autoquery HyQuery query = hy_query_create (sack); - hy_query_filter (query, HY_PKG_NAME, HY_EQ, dnf_package_get_name (pkg)); - DnfPackageSet *pset = hy_query_run_set (query); - map_or (named_pkgs_map, dnf_packageset_get_map (pset)); - dnf_packageset_free (pset); - } - - /* remove our locked packages from the exclusion set */ - map_subtract (named_pkgs_map, dnf_packageset_get_map (locked_pset)); - dnf_sack_add_excludes (sack, named_pkgs); - dnf_packageset_free (named_pkgs); - } - - dnf_packageset_free (locked_pset); - } - - /* Process excludes */ - for (char **iter = exclude_packages; iter && *iter; iter++) - { - const char *pkgname = *iter; - hy_autoquery HyQuery query = hy_query_create (sack); - hy_query_filter (query, HY_PKG_NAME, HY_EQ, pkgname); - DnfPackageSet *pset = hy_query_run_set (query); - dnf_sack_add_excludes (sack, pset); - dnf_packageset_free (pset); - } - - /* First, handle packages to remove */ - g_autoptr(GPtrArray) removed_pkgnames = g_ptr_array_new (); - for (char **it = removed_base_pkgnames; it && *it; it++) - { - const char *pkgname = *it; - if (!dnf_context_remove (dnfctx, pkgname, error)) - return FALSE; - - g_ptr_array_add (removed_pkgnames, (gpointer)pkgname); - } - - /* Then, handle local packages to install */ - GLNX_HASH_TABLE_FOREACH_V (local_pkgs_to_install, DnfPackage*, pkg) - hy_goal_install (goal, pkg); - - /* Now repo-packages; only supported during server composes for now. */ - if (!self->is_system) - { - auto repo_pkgs = self->treefile_rs->get_repo_packages(); - for (auto & repo_pkg : repo_pkgs) - { - auto repo = std::string(repo_pkg.get_repo()); - auto pkgs = repo_pkg.get_packages(); - for (auto & pkg_str : pkgs) - { - auto pkg = std::string(pkg_str); - g_auto(HySubject) subject = hy_subject_create(pkg.c_str()); - /* this is basically like a slightly customized dnf_context_install() */ - HyNevra nevra = NULL; - hy_autoquery HyQuery query = - hy_subject_get_best_solution(subject, sack, NULL, &nevra, FALSE, TRUE, TRUE, TRUE, FALSE); - hy_query_filter (query, HY_PKG_REPONAME, HY_EQ, repo.c_str()); - g_autoptr(DnfPackageSet) pset = hy_query_run_set (query); - if (dnf_packageset_count (pset) == 0) - return glnx_throw (error, "No matches for '%s' in repo '%s'", pkg.c_str(), repo.c_str()); - - g_auto(HySelector) selector = hy_selector_create (sack); - hy_selector_pkg_set (selector, pset); - if (!hy_goal_install_selector (goal, selector, error)) - return FALSE; - } - } - } - - /* And finally, handle repo packages to install */ - g_autoptr(GPtrArray) missing_pkgs = NULL; - for (char **it = pkgnames; it && *it; it++) - { - const char *pkgname = *it; - g_autoptr(GError) local_error = NULL; - if (!dnf_context_install (dnfctx, pkgname, &local_error)) - { - /* Only keep going if it's ENOENT, so we coalesce into one msg at the end */ - if (!g_error_matches (local_error, DNF_ERROR, DNF_ERROR_PACKAGE_NOT_FOUND)) - { - g_propagate_error (error, util::move_nullify (local_error)); - return FALSE; - } - /* lazy init since it's unlikely in the common case (e.g. upgrades) */ - if (!missing_pkgs) - missing_pkgs = g_ptr_array_new (); - g_ptr_array_add (missing_pkgs, (gpointer)pkgname); - } - } - - if (missing_pkgs && missing_pkgs->len > 0) - return throw_package_list (error, "Packages not found", missing_pkgs); - - /* And lock all the base packages we don't expect to be replaced. */ - { hy_autoquery HyQuery query = hy_query_create (sack); - hy_query_filter (query, HY_PKG_REPONAME, HY_EQ, HY_SYSTEM_REPO_NAME); - g_autoptr(GPtrArray) pkgs = hy_query_run (query); - for (guint i = 0; i < pkgs->len; i++) - { - auto pkg = static_cast(pkgs->pdata[i]); - const char *pkgname = dnf_package_get_name (pkg); - g_assert (pkgname); - - if (rpmostree_str_ptrarray_contains (removed_pkgnames, pkgname) || - rpmostree_str_ptrarray_contains (replaced_pkgnames, pkgname)) - continue; - if (hy_goal_lock (goal, pkg, error) != 0) - return glnx_prefix_error (error, "while locking pkg '%s'", pkgname); - } - } - - auto actions = static_cast(DNF_INSTALL | DNF_ALLOW_UNINSTALL); - if (self->treefile_rs && !self->treefile_rs->get_recommends()) - actions = static_cast(static_cast(actions) | DNF_IGNORE_WEAK_DEPS); - auto task = rpmostreecxx::progress_begin_task("Resolving dependencies"); - /* XXX: consider a --allow-uninstall switch? */ - if (!dnf_goal_depsolve (goal, actions, error) || - !check_goal_solution (self, removed_pkgnames, replaced_nevras, error)) - return FALSE; - g_clear_pointer (&self->pkgs, (GDestroyNotify)g_ptr_array_unref); - self->pkgs = dnf_goal_get_packages (goal, - DNF_PACKAGE_INFO_INSTALL, - DNF_PACKAGE_INFO_UPDATE, - DNF_PACKAGE_INFO_DOWNGRADE, -1); - if (!sort_packages (self, self->pkgs, cancellable, error)) - return glnx_prefix_error (error, "Sorting packages"); - +// if (dnf_context_get_sack (dnfctx) == NULL) +// { +// /* default to loading updateinfo in this path; this allows the sack to be used later +// * on for advisories -- it's always downloaded anyway */ +// if (!rpmostree_context_download_metadata (self, +// DNF_CONTEXT_SETUP_SACK_FLAG_LOAD_UPDATEINFO, +// cancellable, error)) +// return FALSE; +// journal_rpmmd_info (self); +// } +// DnfSack *sack = dnf_context_get_sack (dnfctx); +// HyGoal goal = dnf_context_get_goal (dnfctx); +// +// /* Don't try to keep multiple kernels per root; that's a traditional thing, +// * ostree binds kernel + userspace. +// */ +// dnf_sack_set_installonly (sack, NULL); +// dnf_sack_set_installonly_limit (sack, 0); +// +// +// if (self->lockfile) +// { +// /* we only support pure installs for now (compose case) */ +// g_assert_cmpint (g_strv_length (cached_pkgnames), ==, 0); +// g_assert_cmpint (g_strv_length (cached_replace_pkgs), ==, 0); +// g_assert_cmpint (g_strv_length (removed_base_pkgnames), ==, 0); +// } +// +// /* track cached pkgs already added to the sack so far */ +// g_autoptr(GHashTable) local_pkgs_to_install = +// g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref); +// +// /* Handle packages to replace; only add them to the sack for now */ +// g_autoptr(GPtrArray) replaced_nevras = g_ptr_array_new (); +// g_autoptr(GPtrArray) replaced_pkgnames = g_ptr_array_new_with_free_func (g_free); +// for (char **it = cached_replace_pkgs; it && *it; it++) +// { +// const char *nevra = *it; +// g_autofree char *sha256 = NULL; +// if (!rpmostree_decompose_sha256_nevra (&nevra, &sha256, error)) +// return FALSE; +// +// g_autoptr(DnfPackage) pkg = NULL; +// if (!add_pkg_from_cache (self, nevra, sha256, &pkg, cancellable, error)) +// return FALSE; +// +// const char *name = dnf_package_get_name (pkg); +// g_assert (name); +// +// g_ptr_array_add (replaced_nevras, (gpointer)nevra); +// // this is a bit wasteful, but for locking purposes, we need the pkgname to match +// // against the base, not the nevra which naturally will be different +// g_ptr_array_add (replaced_pkgnames, g_strdup (name)); +// g_hash_table_insert (local_pkgs_to_install, (gpointer)nevra, g_steal_pointer (&pkg)); +// } +// +// /* Now handle local package; only add them to the sack for now */ +// for (char **it = cached_pkgnames; it && *it; it++) +// { +// const char *nevra = *it; +// g_autofree char *sha256 = NULL; +// if (!rpmostree_decompose_sha256_nevra (&nevra, &sha256, error)) +// return FALSE; +// +// g_autoptr(DnfPackage) pkg = NULL; +// if (!add_pkg_from_cache (self, nevra, sha256, &pkg, cancellable, error)) +// return FALSE; +// +// g_hash_table_insert (local_pkgs_to_install, (gpointer)nevra, g_steal_pointer (&pkg)); +// } +// +// /* If we're in cache-only mode, add all the remaining pkgs now. We do this *after* the +// * replace & local pkgs since they already handle a subset of the cached pkgs and have +// * SHA256 checks. But we do it *before* dnf_context_install() since those subjects are not +// * directly linked to a cached pkg, so we need to teach libdnf about them beforehand. */ +// if (self->pkgcache_only) +// { +// if (!add_remaining_pkgcache_pkgs (self, local_pkgs_to_install, cancellable, error)) +// return FALSE; +// } +// +// /* Now that we're done adding stuff to the sack, we can actually mark pkgs for install and +// * uninstall. We don't want to mix those two steps, otherwise we might confuse libdnf, +// * see: https://github.com/rpm-software-management/libdnf/issues/700 */ +// +// if (self->lockfile) +// { +// /* first, find our locked pkgs in the rpmmd */ +// g_autoptr(GPtrArray) locked_pkgs = find_locked_packages (self, error); +// if (!locked_pkgs) +// return FALSE; +// +// /* build a packageset from it */ +// DnfPackageSet *locked_pset = dnf_packageset_new (sack); +// for (guint i = 0; i < locked_pkgs->len; i++) +// dnf_packageset_add (locked_pset, static_cast(locked_pkgs->pdata[i])); +// +// if (self->lockfile_strict) +// { +// /* In strict mode, we basically *only* want locked packages to be considered, so +// * exclude everything else. Note we still don't directly do `hy_goal_install` +// * here; we want the treefile to still be canonical, but we just make sure that +// * the end result matches what we expect. */ +// DnfPackageSet *pset = dnf_packageset_new (sack); +// Map *map = dnf_packageset_get_map (pset); +// map_setall (map); +// map_subtract (map, dnf_packageset_get_map (locked_pset)); +// dnf_sack_add_excludes (sack, pset); +// dnf_packageset_free (pset); +// } +// else +// { +// /* Exclude all the packages in lockfile repos except locked packages. */ +// g_autofree char **lockfile_repos = NULL; +// g_variant_dict_lookup (self->spec->dict, "lockfile-repos", "^a&s", &lockfile_repos); +// for (char **it = lockfile_repos; it && *it; it++) +// { +// const char *repo = *it; +// hy_autoquery HyQuery query = hy_query_create (sack); +// hy_query_filter (query, HY_PKG_REPONAME, HY_EQ, repo); +// DnfPackageSet *pset = hy_query_run_set (query); +// Map *map = dnf_packageset_get_map (pset); +// map_subtract (map, dnf_packageset_get_map (locked_pset)); +// dnf_sack_add_excludes (sack, pset); +// dnf_packageset_free (pset); +// } +// +// /* In relaxed mode, we allow packages to be added or removed without having to +// * edit lockfiles. However, we still want to make sure that if a package does get +// * installed which is in the lockfile, it can only pick that NEVRA. To do this, we +// * filter out from the sack all pkgs which don't match. */ +// +// /* map of all packages with names found in the lockfile (note here we derive this +// * from `locked_pkgs` instead of from the lockfile again to account for +// * source-packages too (which have been resolved to packages in `locked_pkgs`) */ +// DnfPackageSet *named_pkgs = dnf_packageset_new (sack); +// Map *named_pkgs_map = dnf_packageset_get_map (named_pkgs); +// for (guint i = 0; i < locked_pkgs->len; i++) +// { +// DnfPackage *pkg = (DnfPackage*)locked_pkgs->pdata[i]; +// hy_autoquery HyQuery query = hy_query_create (sack); +// hy_query_filter (query, HY_PKG_NAME, HY_EQ, dnf_package_get_name (pkg)); +// DnfPackageSet *pset = hy_query_run_set (query); +// map_or (named_pkgs_map, dnf_packageset_get_map (pset)); +// dnf_packageset_free (pset); +// } +// +// /* remove our locked packages from the exclusion set */ +// map_subtract (named_pkgs_map, dnf_packageset_get_map (locked_pset)); +// dnf_sack_add_excludes (sack, named_pkgs); +// dnf_packageset_free (named_pkgs); +// } +// +// dnf_packageset_free (locked_pset); +// } +// +// /* Process excludes */ +// for (char **iter = exclude_packages; iter && *iter; iter++) +// { +// const char *pkgname = *iter; +// hy_autoquery HyQuery query = hy_query_create (sack); +// hy_query_filter (query, HY_PKG_NAME, HY_EQ, pkgname); +// DnfPackageSet *pset = hy_query_run_set (query); +// dnf_sack_add_excludes (sack, pset); +// dnf_packageset_free (pset); +// } +// +// /* First, handle packages to remove */ +// g_autoptr(GPtrArray) removed_pkgnames = g_ptr_array_new (); +// for (char **it = removed_base_pkgnames; it && *it; it++) +// { +// const char *pkgname = *it; +// if (!dnf_context_remove (dnfctx, pkgname, error)) +// return FALSE; +// +// g_ptr_array_add (removed_pkgnames, (gpointer)pkgname); +// } +// +// /* Then, handle local packages to install */ +// GLNX_HASH_TABLE_FOREACH_V (local_pkgs_to_install, DnfPackage*, pkg) +// hy_goal_install (goal, pkg); +// +// /* Now repo-packages; only supported during server composes for now. */ +// if (!self->is_system) +// { +// auto repo_pkgs = self->treefile_rs->get_repo_packages(); +// for (auto & repo_pkg : repo_pkgs) +// { +// auto repo = std::string(repo_pkg.get_repo()); +// auto pkgs = repo_pkg.get_packages(); +// for (auto & pkg_str : pkgs) +// { +// auto pkg = std::string(pkg_str); +// g_auto(HySubject) subject = hy_subject_create(pkg.c_str()); +// /* this is basically like a slightly customized dnf_context_install() */ +// HyNevra nevra = NULL; +// hy_autoquery HyQuery query = +// hy_subject_get_best_solution(subject, sack, NULL, &nevra, FALSE, TRUE, TRUE, TRUE, FALSE); +// hy_query_filter (query, HY_PKG_REPONAME, HY_EQ, repo.c_str()); +// g_autoptr(DnfPackageSet) pset = hy_query_run_set (query); +// if (dnf_packageset_count (pset) == 0) +// return glnx_throw (error, "No matches for '%s' in repo '%s'", pkg.c_str(), repo.c_str()); +// +// g_auto(HySelector) selector = hy_selector_create (sack); +// hy_selector_pkg_set (selector, pset); +// if (!hy_goal_install_selector (goal, selector, error)) +// return FALSE; +// } +// } +// } +// +// /* And finally, handle repo packages to install */ +// g_autoptr(GPtrArray) missing_pkgs = NULL; +// for (char **it = pkgnames; it && *it; it++) +// { +// const char *pkgname = *it; +// g_autoptr(GError) local_error = NULL; +// if (!dnf_context_install (dnfctx, pkgname, &local_error)) +// { +// /* Only keep going if it's ENOENT, so we coalesce into one msg at the end */ +// if (!g_error_matches (local_error, DNF_ERROR, DNF_ERROR_PACKAGE_NOT_FOUND)) +// { +// g_propagate_error (error, util::move_nullify (local_error)); +// return FALSE; +// } +// /* lazy init since it's unlikely in the common case (e.g. upgrades) */ +// if (!missing_pkgs) +// missing_pkgs = g_ptr_array_new (); +// g_ptr_array_add (missing_pkgs, (gpointer)pkgname); +// } +// } +// +// if (missing_pkgs && missing_pkgs->len > 0) +// return throw_package_list (error, "Packages not found", missing_pkgs); +// +// /* And lock all the base packages we don't expect to be replaced. */ +// { hy_autoquery HyQuery query = hy_query_create (sack); +// hy_query_filter (query, HY_PKG_REPONAME, HY_EQ, HY_SYSTEM_REPO_NAME); +// g_autoptr(GPtrArray) pkgs = hy_query_run (query); +// for (guint i = 0; i < pkgs->len; i++) +// { +// auto pkg = static_cast(pkgs->pdata[i]); +// const char *pkgname = dnf_package_get_name (pkg); +// g_assert (pkgname); +// +// if (rpmostree_str_ptrarray_contains (removed_pkgnames, pkgname) || +// rpmostree_str_ptrarray_contains (replaced_pkgnames, pkgname)) +// continue; +// if (hy_goal_lock (goal, pkg, error) != 0) +// return glnx_prefix_error (error, "while locking pkg '%s'", pkgname); +// } +// } +// +// auto actions = static_cast(DNF_INSTALL | DNF_ALLOW_UNINSTALL); +// if (self->treefile_rs && !self->treefile_rs->get_recommends()) +// actions = static_cast(static_cast(actions) | DNF_IGNORE_WEAK_DEPS); +// auto task = rpmostreecxx::progress_begin_task("Resolving dependencies"); +// /* XXX: consider a --allow-uninstall switch? */ +// if (!dnf_goal_depsolve (goal, actions, error) || +// !check_goal_solution (self, removed_pkgnames, replaced_nevras, error)) +// return FALSE; +// g_clear_pointer (&self->pkgs, (GDestroyNotify)g_ptr_array_unref); +// self->pkgs = dnf_goal_get_packages (goal, +// DNF_PACKAGE_INFO_INSTALL, +// DNF_PACKAGE_INFO_UPDATE, +// DNF_PACKAGE_INFO_DOWNGRADE, -1); +// if (!sort_packages (self, self->pkgs, cancellable, error)) +// return glnx_prefix_error (error, "Sorting packages"); +// return TRUE; } @@ -2211,55 +2213,55 @@ rpmostree_dnf_add_checksum_goal (GChecksum *checksum, OstreeRepo *pkgcache, GError **error) { - g_autoptr(GPtrArray) pkglist = dnf_goal_get_packages (goal, DNF_PACKAGE_INFO_INSTALL, - DNF_PACKAGE_INFO_UPDATE, - DNF_PACKAGE_INFO_DOWNGRADE, - DNF_PACKAGE_INFO_REMOVE, - DNF_PACKAGE_INFO_OBSOLETE, - -1); - g_assert (pkglist); - g_ptr_array_sort (pkglist, compare_pkgs); - for (guint i = 0; i < pkglist->len; i++) - { - auto pkg = static_cast(pkglist->pdata[i]); - DnfStateAction action = dnf_package_get_action (pkg); - const char *action_str = convert_dnf_action_to_string (action); - g_checksum_update (checksum, (guint8*)action_str, strlen (action_str)); - - /* For pkgs that were added from the pkgcache repo (e.g. local RPMs and replacement - * overrides), make sure to pick up the SHA256 from the pkg metadata, rather than what - * libsolv figured out (which is based on our chopped off fake RPM, which clearly will - * not match what's in the repo). This ensures that two goals are equivalent whether - * the same RPM comes from a yum repo or from the pkgcache. */ - const char *reponame = NULL; - if (pkgcache) - reponame = dnf_package_get_reponame (pkg); - if (g_strcmp0 (reponame, HY_CMDLINE_REPO_NAME) == 0) - { - g_autofree char *cachebranch = rpmostree_get_cache_branch_pkg (pkg); - g_autofree char *cached_rev = NULL; - if (!ostree_repo_resolve_rev (pkgcache, cachebranch, FALSE, &cached_rev, error)) - return FALSE; - - g_autoptr(GVariant) commit = NULL; - if (!ostree_repo_load_commit (pkgcache, cached_rev, &commit, NULL, error)) - return FALSE; - - g_autofree char *chksum_repr = NULL; - if (!get_pkgcache_repodata_chksum_repr (commit, &chksum_repr, TRUE, error)) - return FALSE; - - if (chksum_repr) - { - g_checksum_update (checksum, (guint8*)chksum_repr, strlen (chksum_repr)); - continue; - } - } - - auto chksum_repr = rpmostreecxx::get_repodata_chksum_repr(*pkg); - g_checksum_update (checksum, (guint8*)chksum_repr.data(), chksum_repr.size()); - } - +// g_autoptr(GPtrArray) pkglist = dnf_goal_get_packages (goal, DNF_PACKAGE_INFO_INSTALL, +// DNF_PACKAGE_INFO_UPDATE, +// DNF_PACKAGE_INFO_DOWNGRADE, +// DNF_PACKAGE_INFO_REMOVE, +// DNF_PACKAGE_INFO_OBSOLETE, +// -1); +// g_assert (pkglist); +// g_ptr_array_sort (pkglist, compare_pkgs); +// for (guint i = 0; i < pkglist->len; i++) +// { +// auto pkg = static_cast(pkglist->pdata[i]); +// DnfStateAction action = dnf_package_get_action (pkg); +// const char *action_str = convert_dnf_action_to_string (action); +// g_checksum_update (checksum, (guint8*)action_str, strlen (action_str)); +// +// /* For pkgs that were added from the pkgcache repo (e.g. local RPMs and replacement +// * overrides), make sure to pick up the SHA256 from the pkg metadata, rather than what +// * libsolv figured out (which is based on our chopped off fake RPM, which clearly will +// * not match what's in the repo). This ensures that two goals are equivalent whether +// * the same RPM comes from a yum repo or from the pkgcache. */ +// const char *reponame = NULL; +// if (pkgcache) +// reponame = dnf_package_get_reponame (pkg); +// if (g_strcmp0 (reponame, HY_CMDLINE_REPO_NAME) == 0) +// { +// g_autofree char *cachebranch = rpmostree_get_cache_branch_pkg (pkg); +// g_autofree char *cached_rev = NULL; +// if (!ostree_repo_resolve_rev (pkgcache, cachebranch, FALSE, &cached_rev, error)) +// return FALSE; +// +// g_autoptr(GVariant) commit = NULL; +// if (!ostree_repo_load_commit (pkgcache, cached_rev, &commit, NULL, error)) +// return FALSE; +// +// g_autofree char *chksum_repr = NULL; +// if (!get_pkgcache_repodata_chksum_repr (commit, &chksum_repr, TRUE, error)) +// return FALSE; +// +// if (chksum_repr) +// { +// g_checksum_update (checksum, (guint8*)chksum_repr, strlen (chksum_repr)); +// continue; +// } +// } +// +// auto chksum_repr = rpmostreecxx::get_repodata_chksum_repr(*pkg); +// g_checksum_update (checksum, (guint8*)chksum_repr.data(), chksum_repr.size()); +// } +// return TRUE; } @@ -2274,10 +2276,10 @@ rpmostree_context_get_state_sha512 (RpmOstreeContext *self, if (!self->empty) { - if (!rpmostree_dnf_add_checksum_goal (state_checksum, - dnf_context_get_goal (self->dnfctx), - get_pkgcache_repo (self), error)) - return FALSE; +// if (!rpmostree_dnf_add_checksum_goal (state_checksum, +// dnf_context_get_goal (self->dnfctx), +// get_pkgcache_repo (self), error)) +// return FALSE; } *out_checksum = g_strdup (g_checksum_get_string (state_checksum)); @@ -2298,18 +2300,18 @@ gather_source_to_packages (GPtrArray *packages) if (rpmostree_pkg_is_local (pkg)) continue; - DnfRepo *src = dnf_package_get_repo (pkg); - GPtrArray *source_packages; - - g_assert (src); - - source_packages = static_cast(g_hash_table_lookup (source_to_packages, src)); - if (!source_packages) - { - source_packages = g_ptr_array_new (); - g_hash_table_insert (source_to_packages, src, source_packages); - } - g_ptr_array_add (source_packages, pkg); +// DnfRepo *src = dnf_package_get_repo (pkg); +// GPtrArray *source_packages; +// +// g_assert (src); +// +// source_packages = static_cast(g_hash_table_lookup (source_to_packages, src)); +// if (!source_packages) +// { +// source_packages = g_ptr_array_new (); +// g_hash_table_insert (source_to_packages, src, source_packages); +// } +// g_ptr_array_add (source_packages, pkg); } return util::move_nullify (source_to_packages); @@ -2322,24 +2324,24 @@ rpmostree_download_packages (GPtrArray *packages, { guint progress_sigid; g_autoptr(GHashTable) source_to_packages = gather_source_to_packages (packages); - GLNX_HASH_TABLE_FOREACH_KV (source_to_packages, DnfRepo*, src, GPtrArray*, src_packages) - { - glnx_unref_object DnfState *hifstate = dnf_state_new (); - auto msg = g_strdup_printf("Downloading from '%s'", dnf_repo_get_id(src)); - auto progress = rpmostreecxx::progress_percent_begin(msg); - progress_sigid = g_signal_connect (hifstate, "percentage-changed", - G_CALLBACK (on_hifstate_percentage_changed), - (void*)progress.get()); - g_autofree char *target_dir = g_build_filename (dnf_repo_get_location (src), "/packages/", NULL); - if (!glnx_shutil_mkdir_p_at (AT_FDCWD, target_dir, 0755, cancellable, error)) - return FALSE; - - if (!dnf_repo_download_packages (src, src_packages, target_dir, - hifstate, error)) - return FALSE; - - g_signal_handler_disconnect (hifstate, progress_sigid); - } +// GLNX_HASH_TABLE_FOREACH_KV (source_to_packages, DnfRepo*, src, GPtrArray*, src_packages) +// { +// glnx_unref_object DnfState *hifstate = dnf_state_new (); +// auto msg = g_strdup_printf("Downloading from '%s'", dnf_repo_get_id(src)); +// auto progress = rpmostreecxx::progress_percent_begin(msg); +// progress_sigid = g_signal_connect (hifstate, "percentage-changed", +// G_CALLBACK (on_hifstate_percentage_changed), +// (void*)progress.get()); +// g_autofree char *target_dir = g_build_filename (dnf_repo_get_location (src), "/packages/", NULL); +// if (!glnx_shutil_mkdir_p_at (AT_FDCWD, target_dir, 0755, cancellable, error)) +// return FALSE; +// +// if (!dnf_repo_download_packages (src, src_packages, target_dir, +// hifstate, error)) +// return FALSE; +// +// g_signal_handler_disconnect (hifstate, progress_sigid); +// } return TRUE; } @@ -2353,10 +2355,10 @@ rpmostree_context_download (RpmOstreeContext *self, if (n > 0) { - guint64 size = - dnf_package_array_get_download_size (self->pkgs_to_download); - g_autofree char *sizestr = g_format_size (size); - rpmostree_output_message ("Will download: %u package%s (%s)", n, _NS(n), sizestr); +// guint64 size = +// dnf_package_array_get_download_size (self->pkgs_to_download); +// g_autofree char *sizestr = g_format_size (size); +// rpmostree_output_message ("Will download: %u package%s (%s)", n, _NS(n), sizestr); } else return TRUE; @@ -2407,28 +2409,28 @@ start_async_import_one_package (RpmOstreeContext *self, DnfPackage *pkg, * people doing custom composes don't have files silently discarded. * (This will also likely need to be configurable). */ - const char *pkg_name = dnf_package_get_name (pkg); - - int flags = 0; - if (g_str_equal (pkg_name, "filesystem") || - g_str_equal (pkg_name, "rootfiles")) - flags |= RPMOSTREE_IMPORTER_FLAGS_SKIP_EXTRANEOUS; - - if (self->treefile_rs && !self->treefile_rs->get_documentation()) - flags |= RPMOSTREE_IMPORTER_FLAGS_NODOCS; - - if (self->treefile_rs && self->treefile_rs->get_readonly_executables()) - flags |= RPMOSTREE_IMPORTER_FLAGS_RO_EXECUTABLES; - - /* TODO - tweak the unpacker flags for containers */ - OstreeRepo *ostreerepo = get_pkgcache_repo (self); - g_autoptr(RpmOstreeImporter) unpacker = - rpmostree_importer_new_take_fd (&fd, ostreerepo, pkg, static_cast(flags), - self->sepolicy, error); - if (!unpacker) - return glnx_prefix_error (error, "creating importer"); - - rpmostree_importer_run_async (unpacker, cancellable, on_async_import_done, self); +// const char *pkg_name = dnf_package_get_name (pkg); +// +// int flags = 0; +// if (g_str_equal (pkg_name, "filesystem") || +// g_str_equal (pkg_name, "rootfiles")) +// flags |= RPMOSTREE_IMPORTER_FLAGS_SKIP_EXTRANEOUS; +// +// if (self->treefile_rs && !self->treefile_rs->get_documentation()) +// flags |= RPMOSTREE_IMPORTER_FLAGS_NODOCS; +// +// if (self->treefile_rs && self->treefile_rs->get_readonly_executables()) +// flags |= RPMOSTREE_IMPORTER_FLAGS_RO_EXECUTABLES; +// +// /* TODO - tweak the unpacker flags for containers */ +// OstreeRepo *ostreerepo = get_pkgcache_repo (self); +// g_autoptr(RpmOstreeImporter) unpacker = +// rpmostree_importer_new_take_fd (&fd, ostreerepo, pkg, static_cast(flags), +// self->sepolicy, error); +// if (!unpacker) +// return glnx_prefix_error (error, "creating importer"); +// +// rpmostree_importer_run_async (unpacker, cancellable, on_async_import_done, self); return TRUE; } @@ -2478,8 +2480,8 @@ rpmostree_context_import (RpmOstreeContext *self, OstreeRepo *repo = get_pkgcache_repo (self); g_assert (repo != NULL); - if (!dnf_transaction_import_keys (dnf_context_get_transaction (dnfctx), error)) - return FALSE; +// if (!dnf_transaction_import_keys (dnf_context_get_transaction (dnfctx), error)) +// return FALSE; g_auto(RpmOstreeRepoAutoTransaction) txn = { 0, }; /* Note use of commit-on-failure */ @@ -2537,7 +2539,7 @@ rpmostree_context_consume_package (RpmOstreeContext *self, GError **error) { /* Verify signatures if enabled */ - if (!dnf_transaction_gpgcheck_package (dnf_context_get_transaction (self->dnfctx), pkg, error)) +// if (!dnf_transaction_gpgcheck_package (dnf_context_get_transaction (self->dnfctx), pkg, error)) return FALSE; g_autofree char *pkg_path = rpmostree_pkg_get_local_path (pkg); @@ -2817,15 +2819,15 @@ checkout_package_into_root (RpmOstreeContext *self, g_autoptr(GPtrArray) files_remove_regex = NULL; if (self->treefile_rs) { - auto files_remove_regex_patterns = self->treefile_rs->get_files_remove_regex(dnf_package_get_name (pkg)); - files_remove_regex = g_ptr_array_new_full (files_remove_regex_patterns.size(), (GDestroyNotify)g_regex_unref); - for (auto pattern : files_remove_regex_patterns) - { - GRegex *regex = g_regex_new (pattern.c_str(), G_REGEX_JAVASCRIPT_COMPAT, static_cast(0), NULL); - if (!regex) - return FALSE; - g_ptr_array_add (files_remove_regex, regex); - } +// auto files_remove_regex_patterns = self->treefile_rs->get_files_remove_regex(dnf_package_get_name (pkg)); +// files_remove_regex = g_ptr_array_new_full (files_remove_regex_patterns.size(), (GDestroyNotify)g_regex_unref); +// for (auto pattern : files_remove_regex_patterns) +// { +// GRegex *regex = g_regex_new (pattern.c_str(), G_REGEX_JAVASCRIPT_COMPAT, static_cast(0), NULL); +// if (!regex) +// return FALSE; +// g_ptr_array_add (files_remove_regex, regex); +// } } OstreeRepo *pkgcache_repo = get_pkgcache_repo (self); @@ -2839,16 +2841,16 @@ checkout_package_into_root (RpmOstreeContext *self, if (!rpmostree_pull_content_only (self->ostreerepo, pkgcache_repo, pkg_commit, cancellable, error)) { - g_prefix_error (error, "Linking cached content for %s: ", dnf_package_get_nevra (pkg)); +// g_prefix_error (error, "Linking cached content for %s: ", dnf_package_get_nevra (pkg)); return FALSE; } } - if (!checkout_package (pkgcache_repo, dfd, path, - devino_cache, pkg_commit, files_skip, files_remove_regex, ovwmode, - !self->enable_rofiles, - cancellable, error)) - return glnx_prefix_error (error, "Checkout %s", dnf_package_get_nevra (pkg)); +// if (!checkout_package (pkgcache_repo, dfd, path, +// devino_cache, pkg_commit, files_skip, files_remove_regex, ovwmode, +// !self->enable_rofiles, +// cancellable, error)) +// return glnx_prefix_error (error, "Checkout %s", dnf_package_get_nevra (pkg)); return TRUE; } @@ -2864,17 +2866,17 @@ get_rpmdb_pkg_header (rpmts rpmdb_ts, rpmdb_ts = rpmdb_ts_owned = rpmtsCreate (); (void)rpmdb_ts_owned; /* Pacify static analysis */ - unsigned int dbid = dnf_package_get_rpmdbid (pkg); - g_assert (dbid > 0); - - g_auto(rpmdbMatchIterator) it = - rpmtsInitIterator (rpmdb_ts, RPMDBI_PACKAGES, &dbid, sizeof(dbid)); - - Header hdr = it ? rpmdbNextIterator (it) : NULL; - if (hdr == NULL) - return (Header)glnx_null_throw (error, "Failed to find package '%s' in rpmdb", - dnf_package_get_nevra (pkg)); - +// unsigned int dbid = dnf_package_get_rpmdbid (pkg); +// g_assert (dbid > 0); +// +// g_auto(rpmdbMatchIterator) it = +// rpmtsInitIterator (rpmdb_ts, RPMDBI_PACKAGES, &dbid, sizeof(dbid)); +// +// Header hdr = it ? rpmdbNextIterator (it) : NULL; +// if (hdr == NULL) +// return (Header)glnx_null_throw (error, "Failed to find package '%s' in rpmdb", +// dnf_package_get_nevra (pkg)); + Header hdr = NULL; return headerLink (hdr); } @@ -3188,9 +3190,9 @@ relabel_package_async (RpmOstreeContext *self, RelabelTaskData *tdata = g_new (RelabelTaskData, 1); /* We can assume lifetime is greater than the task */ tdata->tmpdir_dfd = tmpdir_dfd; - tdata->name = dnf_package_get_name (pkg); - tdata->evr = dnf_package_get_evr (pkg); - tdata->arch = dnf_package_get_arch (pkg); +// tdata->name = dnf_package_get_name (pkg); +// tdata->evr = dnf_package_get_evr (pkg); +// tdata->arch = dnf_package_get_arch (pkg); g_task_set_task_data (task, tdata, g_free); g_task_run_in_thread (task, relabel_in_thread); } @@ -3317,27 +3319,27 @@ rpmostree_context_force_relabel (RpmOstreeContext *self, g_clear_pointer (&self->pkgs_to_relabel, (GDestroyNotify)g_ptr_array_unref); self->pkgs_to_relabel = g_ptr_array_new_with_free_func ((GDestroyNotify)g_object_unref); - g_autoptr(GPtrArray) packages = dnf_goal_get_packages (dnf_context_get_goal (self->dnfctx), - DNF_PACKAGE_INFO_INSTALL, - DNF_PACKAGE_INFO_UPDATE, - DNF_PACKAGE_INFO_DOWNGRADE, -1); - - for (guint i = 0; i < packages->len; i++) - { - auto pkg = static_cast(packages->pdata[i]); - - if (g_cancellable_set_error_if_cancelled (cancellable, error)) - return FALSE; - - /* This logic is equivalent to that in sort_packages() */ - gboolean in_ostree, selinux_match; - if (!find_pkg_in_ostree (self, pkg, self->sepolicy, - &in_ostree, &selinux_match, error)) - return FALSE; - - if (in_ostree && !selinux_match) - g_ptr_array_add (self->pkgs_to_relabel, g_object_ref (pkg)); - } +// g_autoptr(GPtrArray) packages = dnf_goal_get_packages (dnf_context_get_goal (self->dnfctx), +// DNF_PACKAGE_INFO_INSTALL, +// DNF_PACKAGE_INFO_UPDATE, +// DNF_PACKAGE_INFO_DOWNGRADE, -1); +// +// for (guint i = 0; i < packages->len; i++) +// { +// auto pkg = static_cast(packages->pdata[i]); +// +// if (g_cancellable_set_error_if_cancelled (cancellable, error)) +// return FALSE; +// +// /* This logic is equivalent to that in sort_packages() */ +// gboolean in_ostree, selinux_match; +// if (!find_pkg_in_ostree (self, pkg, self->sepolicy, +// &in_ostree, &selinux_match, error)) +// return FALSE; +// +// if (in_ostree && !selinux_match) +// g_ptr_array_add (self->pkgs_to_relabel, g_object_ref (pkg)); +// } return relabel_if_necessary (self, cancellable, error); } @@ -3424,9 +3426,9 @@ rpmts_add_install (RpmOstreeContext *self, } const gboolean is_upgrade = (flags & RPMOSTREE_TS_FLAG_UPGRADE) > 0; - if (rpmtsAddInstallElement (ts, hdr, pkg, is_upgrade, NULL) != 0) - return glnx_throw (error, "Failed to add install element for %s", - dnf_package_get_filename (pkg)); +// if (rpmtsAddInstallElement (ts, hdr, pkg, is_upgrade, NULL) != 0) +// return glnx_throw (error, "Failed to add install element for %s", +// dnf_package_get_filename (pkg)); return TRUE; } @@ -3443,9 +3445,9 @@ rpmts_add_erase (RpmOstreeContext *self, if (hdr == NULL) return FALSE; - if (rpmtsAddEraseElement (ts, hdr, -1)) - return glnx_throw (error, "Failed to add erase element for package '%s'", - dnf_package_get_nevra (pkg)); +// if (rpmtsAddEraseElement (ts, hdr, -1)) +// return glnx_throw (error, "Failed to add erase element for package '%s'", +// dnf_package_get_nevra (pkg)); return TRUE; } @@ -3580,10 +3582,10 @@ apply_rpmfi_overrides (RpmOstreeContext *self, if ((S_IFMT & stbuf.st_mode) != (S_IFMT & mode)) { - g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, - "Inconsistent file type between RPM and checkout " - "for file '%s' in package '%s'", fn, - dnf_package_get_name (pkg)); +// g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, +// "Inconsistent file type between RPM and checkout " +// "for file '%s' in package '%s'", fn, +// dnf_package_get_name (pkg)); return FALSE; } @@ -3892,7 +3894,7 @@ rpmostree_context_assemble (RpmOstreeContext *self, DnfPackage *setup_package = NULL; /* Also special due to composes needing to inject /etc/passwd */ g_auto(rpmts) ordering_ts = rpmtsCreate (); - rpmtsSetRootDir (ordering_ts, dnf_context_get_install_root (dnfctx)); +// rpmtsSetRootDir (ordering_ts, dnf_context_get_install_root (dnfctx)); /* First for the ordering TS, set the dbpath to relative, which will also gain * the root dir. Note we should be able to drop this in the future now that we @@ -3914,91 +3916,91 @@ rpmostree_context_assemble (RpmOstreeContext *self, */ rpmtsSetVSFlags (ordering_ts, _RPMVSF_NOSIGNATURES | _RPMVSF_NODIGESTS | RPMTRANS_FLAG_TEST); - g_autoptr(GPtrArray) overlays = - dnf_goal_get_packages (dnf_context_get_goal (dnfctx), - DNF_PACKAGE_INFO_INSTALL, - -1); - - g_autoptr(GPtrArray) overrides_replace = - dnf_goal_get_packages (dnf_context_get_goal (dnfctx), - DNF_PACKAGE_INFO_UPDATE, - DNF_PACKAGE_INFO_DOWNGRADE, - -1); - - g_autoptr(GPtrArray) overrides_remove = - dnf_goal_get_packages (dnf_context_get_goal (dnfctx), - DNF_PACKAGE_INFO_REMOVE, - DNF_PACKAGE_INFO_OBSOLETE, - -1); - - if (overlays->len == 0 && overrides_remove->len == 0 && overrides_replace->len == 0) - return glnx_throw (error, "No packages in transaction"); +// g_autoptr(GPtrArray) overlays = +// dnf_goal_get_packages (dnf_context_get_goal (dnfctx), +// DNF_PACKAGE_INFO_INSTALL, +// -1); +// +// g_autoptr(GPtrArray) overrides_replace = +// dnf_goal_get_packages (dnf_context_get_goal (dnfctx), +// DNF_PACKAGE_INFO_UPDATE, +// DNF_PACKAGE_INFO_DOWNGRADE, +// -1); +// +// g_autoptr(GPtrArray) overrides_remove = +// dnf_goal_get_packages (dnf_context_get_goal (dnfctx), +// DNF_PACKAGE_INFO_REMOVE, +// DNF_PACKAGE_INFO_OBSOLETE, +// -1); +// +// if (overlays->len == 0 && overrides_remove->len == 0 && overrides_replace->len == 0) +// return glnx_throw (error, "No packages in transaction"); /* Tell librpm about each one so it can tsort them. What we really * want is to do this from the rpm-md metadata so that we can fully * parallelize download + unpack. */ - for (guint i = 0; i < overrides_remove->len; i++) - { - auto pkg = static_cast(overrides_remove->pdata[i]); - if (!rpmts_add_erase (self, ordering_ts, pkg, cancellable, error)) - return FALSE; - } - - for (guint i = 0; i < overrides_replace->len; i++) - { - auto pkg = static_cast(overrides_replace->pdata[i]); - if (!add_install (self, pkg, ordering_ts, TRUE, pkg_to_ostree_commit, - cancellable, error)) - return FALSE; - } - - for (guint i = 0; i < overlays->len; i++) - { - auto pkg = static_cast(overlays->pdata[i]); - if (!add_install (self, pkg, ordering_ts, FALSE, - pkg_to_ostree_commit, cancellable, error)) - return FALSE; - - if (strcmp (dnf_package_get_name (pkg), "filesystem") == 0) - filesystem_package = (DnfPackage*)g_object_ref (pkg); - else if (strcmp (dnf_package_get_name (pkg), "setup") == 0) - setup_package = (DnfPackage*)g_object_ref (pkg); - } +// for (guint i = 0; i < overrides_remove->len; i++) +// { +// auto pkg = static_cast(overrides_remove->pdata[i]); +// if (!rpmts_add_erase (self, ordering_ts, pkg, cancellable, error)) +// return FALSE; +// } +// +// for (guint i = 0; i < overrides_replace->len; i++) +// { +// auto pkg = static_cast(overrides_replace->pdata[i]); +// if (!add_install (self, pkg, ordering_ts, TRUE, pkg_to_ostree_commit, +// cancellable, error)) +// return FALSE; +// } +// +// for (guint i = 0; i < overlays->len; i++) +// { +// auto pkg = static_cast(overlays->pdata[i]); +// if (!add_install (self, pkg, ordering_ts, FALSE, +// pkg_to_ostree_commit, cancellable, error)) +// return FALSE; +// +// if (strcmp (dnf_package_get_name (pkg), "filesystem") == 0) +// filesystem_package = (DnfPackage*)g_object_ref (pkg); +// else if (strcmp (dnf_package_get_name (pkg), "setup") == 0) +// setup_package = (DnfPackage*)g_object_ref (pkg); +// } { DECLARE_RPMSIGHANDLER_RESET; rpmtsOrder (ordering_ts); } - guint overrides_total = overrides_remove->len + overrides_replace->len; - const char *progress_msg = "Checking out packages"; - if (!layering_on_base) - { - g_assert_cmpint (overrides_total, ==, 0); - } - else if (overrides_total > 0) - { - g_assert (layering_on_base); - progress_msg = "Processing packages"; - if (overlays->len > 0) - rpmostree_output_message ("Applying %u override%s and %u overlay%s", - overrides_total, _NS(overrides_total), - overlays->len, _NS(overlays->len)); - else - rpmostree_output_message ("Applying %u override%s", overrides_total, - _NS(overrides_total)); - } - else if (overlays->len > 0) - ; - else - g_assert_not_reached (); +// guint overrides_total = overrides_remove->len + overrides_replace->len; +// const char *progress_msg = "Checking out packages"; +// if (!layering_on_base) +// { +// g_assert_cmpint (overrides_total, ==, 0); +// } +// else if (overrides_total > 0) +// { +// g_assert (layering_on_base); +// progress_msg = "Processing packages"; +// if (overlays->len > 0) +// rpmostree_output_message ("Applying %u override%s and %u overlay%s", +// overrides_total, _NS(overrides_total), +// overlays->len, _NS(overlays->len)); +// else +// rpmostree_output_message ("Applying %u override%s", overrides_total, +// _NS(overrides_total)); +// } +// else if (overlays->len > 0) +// ; +// else +// g_assert_not_reached (); const guint n_rpmts_elements = (guint)rpmtsNElements (ordering_ts); g_assert (n_rpmts_elements > 0); guint n_rpmts_done = 0; - auto progress = rpmostreecxx::progress_nitems_begin(n_rpmts_elements, progress_msg); +// auto progress = rpmostreecxx::progress_nitems_begin(n_rpmts_elements, progress_msg); /* Okay so what's going on in Fedora with incestuous relationship * between the `filesystem`, `setup`, `libgcc` RPMs is actively @@ -4012,16 +4014,16 @@ rpmostree_context_assemble (RpmOstreeContext *self, */ if (filesystem_package) { - progress->set_sub_message("filesystem"); - auto c = static_cast(g_hash_table_lookup (pkg_to_ostree_commit, filesystem_package)); - if (!checkout_package_into_root (self, filesystem_package, - tmprootfs_dfd, ".", self->devino_cache, - c, NULL, - OSTREE_REPO_CHECKOUT_OVERWRITE_UNION_IDENTICAL, - cancellable, error)) - return FALSE; - n_rpmts_done++; - progress->nitems_update(n_rpmts_done); +// progress->set_sub_message("filesystem"); +// auto c = static_cast(g_hash_table_lookup (pkg_to_ostree_commit, filesystem_package)); +// if (!checkout_package_into_root (self, filesystem_package, +// tmprootfs_dfd, ".", self->devino_cache, +// c, NULL, +// OSTREE_REPO_CHECKOUT_OVERWRITE_UNION_IDENTICAL, +// cancellable, error)) +// return FALSE; +// n_rpmts_done++; +// progress->nitems_update(n_rpmts_done); } g_autoptr(GHashTable) files_skip_add = NULL; @@ -4056,7 +4058,7 @@ rpmostree_context_assemble (RpmOstreeContext *self, dirs_to_remove, cancellable, error)) return FALSE; n_rpmts_done++; - progress->nitems_update(n_rpmts_done); +// progress->nitems_update(n_rpmts_done); } g_clear_pointer (&files_skip_delete, g_hash_table_unref); @@ -4088,16 +4090,16 @@ rpmostree_context_assemble (RpmOstreeContext *self, (pkg == setup_package) ? OSTREE_REPO_CHECKOUT_OVERWRITE_ADD_FILES : OSTREE_REPO_CHECKOUT_OVERWRITE_UNION_IDENTICAL; - progress->set_sub_message(dnf_package_get_name (pkg)); +// progress->set_sub_message(dnf_package_get_name (pkg)); if (!checkout_package_into_root (self, pkg, tmprootfs_dfd, ".", self->devino_cache, static_cast(g_hash_table_lookup (pkg_to_ostree_commit, pkg)), files_skip_add, ovwmode, cancellable, error)) return FALSE; n_rpmts_done++; - progress->nitems_update(n_rpmts_done); +// progress->nitems_update(n_rpmts_done); } - progress->end(""); +// progress->end(""); /* Some packages expect to be able to make temporary files here * for obvious reasons, but we otherwise make `/var` read-only. @@ -4113,208 +4115,208 @@ rpmostree_context_assemble (RpmOstreeContext *self, /* NB: we're not running scripts right now for removals, so this is only for overlays and * replacements */ - if (overlays->len > 0 || overrides_replace->len > 0) - { - gboolean have_passwd; - gboolean have_systemctl; - - auto passwd_entries = rpmostreecxx::new_passwd_entries(); - - std::string passwd_dir(self->passwd_dir ?: ""); - have_passwd = rpmostreecxx::prepare_rpm_layering (tmprootfs_dfd, passwd_dir); - - /* Also neuter systemctl - at least glusterfs for example calls `systemctl - * start` in its %post which both violates Fedora policy and also will not - * work with the rpm-ostree model. - * See also https://github.com/projectatomic/rpm-ostree/issues/550 - * - * See also the SYSTEMD_OFFLINE bits in rpmostree-scripts.c; at some - * point in the far future when we don't support CentOS7 we can drop - * our wrapper script. If we remember. - */ - if (renameat (tmprootfs_dfd, "usr/bin/systemctl", - tmprootfs_dfd, "usr/bin/systemctl.rpmostreesave") < 0) - { - if (errno == ENOENT) - have_systemctl = FALSE; - else - return glnx_throw_errno_prefix (error, "rename(usr/bin/systemctl)"); - } - else - { - have_systemctl = TRUE; - auto systemctl_wrapper = rpmostreecxx::get_systemctl_wrapper (); - if (!glnx_file_replace_contents_with_perms_at (tmprootfs_dfd, "usr/bin/systemctl", - systemctl_wrapper.data(), systemctl_wrapper.length(), 0755, (uid_t) -1, (gid_t) -1, - GLNX_FILE_REPLACE_NODATASYNC, - cancellable, error)) - return FALSE; - } - - /* Necessary for unified core to work with semanage calls in %post, like container-selinux */ - if (!rpmostree_rootfs_fixup_selinux_store_root (tmprootfs_dfd, cancellable, error)) - return FALSE; - - g_auto(GLnxTmpDir) var_lib_rpm_statedir = { 0, }; - if (!glnx_mkdtempat (AT_FDCWD, "/tmp/rpmostree-state.XXXXXX", 0700, - &var_lib_rpm_statedir, error)) - return FALSE; - /* We need to pre-create this dir */ - if (!glnx_ensure_dir (tmprootfs_dfd, "var/lib/rpm-state", 0755, error)) - return FALSE; - - /* Workaround for https://github.com/projectatomic/rpm-ostree/issues/1804 */ - gboolean created_etc_selinux_config = FALSE; - static const char usr_etc_selinux_config[] = "usr/etc/selinux/config"; - if (!glnx_fstatat_allow_noent (tmprootfs_dfd, "usr/etc/selinux", NULL, 0, error)) - return FALSE; - if (errno == 0) - { - if (!glnx_fstatat_allow_noent (tmprootfs_dfd, usr_etc_selinux_config, NULL, 0, error)) - return FALSE; - if (errno == ENOENT) - { - if (!glnx_file_replace_contents_at (tmprootfs_dfd, usr_etc_selinux_config, (guint8*)"", 0, - GLNX_FILE_REPLACE_NODATASYNC, - cancellable, error)) - return FALSE; - created_etc_selinux_config = TRUE; - } - } - - /* We're technically deviating from RPM here by running all the %pre's - * beforehand, rather than each package's %pre & %post in order. Though I - * highly doubt this should cause any issues. The advantage of doing it - * this way is that we only need to read the passwd/group files once - * before applying the overrides, rather than after each %pre. - */ - { auto task = rpmostreecxx::progress_begin_task("Running pre scripts"); - guint n_pre_scripts_run = 0; - for (guint i = 0; i < n_rpmts_elements; i++) - { - rpmte te = rpmtsElement (ordering_ts, i); - if (rpmteType (te) != TR_ADDED) - continue; - - DnfPackage *pkg = (DnfPackage*)rpmteKey (te); - g_assert (pkg); - - task->set_sub_message(dnf_package_get_name(pkg)); - if (!run_script_sync (self, tmprootfs_dfd, &var_lib_rpm_statedir, - pkg, RPMOSTREE_SCRIPT_PREIN, - &n_pre_scripts_run, cancellable, error)) - return FALSE; - } - auto msg = g_strdup_printf ("%u done", n_pre_scripts_run); - task->end(msg); - } - - /* Now undo our hack above */ - if (created_etc_selinux_config) - { - if (!glnx_unlinkat (tmprootfs_dfd, usr_etc_selinux_config, 0, error)) - return FALSE; - } - - if (faccessat (tmprootfs_dfd, "etc/passwd", F_OK, 0) == 0) - { - passwd_entries->add_passwd_content(tmprootfs_dfd, "etc/passwd"); - } - - if (faccessat (tmprootfs_dfd, "etc/group", F_OK, 0) == 0) - { - passwd_entries->add_group_content(tmprootfs_dfd, "etc/group"); - } - - { - auto task = rpmostreecxx::progress_begin_task("Running post scripts"); - guint n_post_scripts_run = 0; - - /* %post */ - for (guint i = 0; i < n_rpmts_elements; i++) - { - rpmte te = rpmtsElement (ordering_ts, i); - if (rpmteType (te) != TR_ADDED) - continue; - - auto pkg = (DnfPackage *)(rpmteKey (te)); - g_assert (pkg); - - task->set_sub_message(dnf_package_get_name(pkg)); - if (!apply_rpmfi_overrides (self, tmprootfs_dfd, pkg, *passwd_entries, - cancellable, error)) - return glnx_prefix_error (error, "While applying overrides for pkg %s", - dnf_package_get_name (pkg)); - - if (!run_script_sync (self, tmprootfs_dfd, &var_lib_rpm_statedir, - pkg, RPMOSTREE_SCRIPT_POSTIN, - &n_post_scripts_run, cancellable, error)) - return FALSE; - } - } - - /* Any ostree refs to overlay */ - if (!process_ostree_layers (self, tmprootfs_dfd, cancellable, error)) - return FALSE; - - { - auto task = rpmostreecxx::progress_begin_task("Running posttrans scripts"); - guint n_posttrans_scripts_run = 0; - - /* %posttrans */ - for (guint i = 0; i < n_rpmts_elements; i++) - { - rpmte te = rpmtsElement (ordering_ts, i); - if (rpmteType (te) != TR_ADDED) - continue; - - auto pkg = (DnfPackage *)(rpmteKey (te)); - g_assert (pkg); - - task->set_sub_message(dnf_package_get_name(pkg)); - if (!run_script_sync (self, tmprootfs_dfd, &var_lib_rpm_statedir, - pkg, RPMOSTREE_SCRIPT_POSTTRANS, - &n_posttrans_scripts_run, cancellable, error)) - return FALSE; - } - - /* file triggers */ - if (!run_all_transfiletriggers (self, ordering_ts, tmprootfs_dfd, - &n_posttrans_scripts_run, cancellable, error)) - return FALSE; - - auto msg = g_strdup_printf ("%u done", n_posttrans_scripts_run); - task->end(msg); - } - - /* We want this to be the first error message if something went wrong - * with a script; see https://github.com/projectatomic/rpm-ostree/pull/888 - * (otherwise, on a script that did `rm -rf`, we'd fail first on the renameat below) - */ - if (!skip_sanity_check && - !rpmostree_deployment_sanitycheck_true (tmprootfs_dfd, cancellable, error)) - return FALSE; - - if (have_systemctl) - { - if (!glnx_renameat (tmprootfs_dfd, "usr/bin/systemctl.rpmostreesave", - tmprootfs_dfd, "usr/bin/systemctl", error)) - return FALSE; - } - - if (have_passwd) - { - rpmostreecxx::complete_rpm_layering (tmprootfs_dfd); - } - } - else - { - /* Also do a sanity check even if we have no layered packages */ - if (!skip_sanity_check && - !rpmostree_deployment_sanitycheck_true (tmprootfs_dfd, cancellable, error)) - return FALSE; - } - +// if (overlays->len > 0 || overrides_replace->len > 0) +// { +// gboolean have_passwd; +// gboolean have_systemctl; +// +// auto passwd_entries = rpmostreecxx::new_passwd_entries(); +// +// std::string passwd_dir(self->passwd_dir ?: ""); +// have_passwd = rpmostreecxx::prepare_rpm_layering (tmprootfs_dfd, passwd_dir); +// +// /* Also neuter systemctl - at least glusterfs for example calls `systemctl +// * start` in its %post which both violates Fedora policy and also will not +// * work with the rpm-ostree model. +// * See also https://github.com/projectatomic/rpm-ostree/issues/550 +// * +// * See also the SYSTEMD_OFFLINE bits in rpmostree-scripts.c; at some +// * point in the far future when we don't support CentOS7 we can drop +// * our wrapper script. If we remember. +// */ +// if (renameat (tmprootfs_dfd, "usr/bin/systemctl", +// tmprootfs_dfd, "usr/bin/systemctl.rpmostreesave") < 0) +// { +// if (errno == ENOENT) +// have_systemctl = FALSE; +// else +// return glnx_throw_errno_prefix (error, "rename(usr/bin/systemctl)"); +// } +// else +// { +// have_systemctl = TRUE; +// auto systemctl_wrapper = rpmostreecxx::get_systemctl_wrapper (); +// if (!glnx_file_replace_contents_with_perms_at (tmprootfs_dfd, "usr/bin/systemctl", +// systemctl_wrapper.data(), systemctl_wrapper.length(), 0755, (uid_t) -1, (gid_t) -1, +// GLNX_FILE_REPLACE_NODATASYNC, +// cancellable, error)) +// return FALSE; +// } +// +// /* Necessary for unified core to work with semanage calls in %post, like container-selinux */ +// if (!rpmostree_rootfs_fixup_selinux_store_root (tmprootfs_dfd, cancellable, error)) +// return FALSE; +// +// g_auto(GLnxTmpDir) var_lib_rpm_statedir = { 0, }; +// if (!glnx_mkdtempat (AT_FDCWD, "/tmp/rpmostree-state.XXXXXX", 0700, +// &var_lib_rpm_statedir, error)) +// return FALSE; +// /* We need to pre-create this dir */ +// if (!glnx_ensure_dir (tmprootfs_dfd, "var/lib/rpm-state", 0755, error)) +// return FALSE; +// +// /* Workaround for https://github.com/projectatomic/rpm-ostree/issues/1804 */ +// gboolean created_etc_selinux_config = FALSE; +// static const char usr_etc_selinux_config[] = "usr/etc/selinux/config"; +// if (!glnx_fstatat_allow_noent (tmprootfs_dfd, "usr/etc/selinux", NULL, 0, error)) +// return FALSE; +// if (errno == 0) +// { +// if (!glnx_fstatat_allow_noent (tmprootfs_dfd, usr_etc_selinux_config, NULL, 0, error)) +// return FALSE; +// if (errno == ENOENT) +// { +// if (!glnx_file_replace_contents_at (tmprootfs_dfd, usr_etc_selinux_config, (guint8*)"", 0, +// GLNX_FILE_REPLACE_NODATASYNC, +// cancellable, error)) +// return FALSE; +// created_etc_selinux_config = TRUE; +// } +// } +// +// /* We're technically deviating from RPM here by running all the %pre's +// * beforehand, rather than each package's %pre & %post in order. Though I +// * highly doubt this should cause any issues. The advantage of doing it +// * this way is that we only need to read the passwd/group files once +// * before applying the overrides, rather than after each %pre. +// */ +// { auto task = rpmostreecxx::progress_begin_task("Running pre scripts"); +// guint n_pre_scripts_run = 0; +// for (guint i = 0; i < n_rpmts_elements; i++) +// { +// rpmte te = rpmtsElement (ordering_ts, i); +// if (rpmteType (te) != TR_ADDED) +// continue; +// +// DnfPackage *pkg = (DnfPackage*)rpmteKey (te); +// g_assert (pkg); +// +// task->set_sub_message(dnf_package_get_name(pkg)); +// if (!run_script_sync (self, tmprootfs_dfd, &var_lib_rpm_statedir, +// pkg, RPMOSTREE_SCRIPT_PREIN, +// &n_pre_scripts_run, cancellable, error)) +// return FALSE; +// } +// auto msg = g_strdup_printf ("%u done", n_pre_scripts_run); +// task->end(msg); +// } +// +// /* Now undo our hack above */ +// if (created_etc_selinux_config) +// { +// if (!glnx_unlinkat (tmprootfs_dfd, usr_etc_selinux_config, 0, error)) +// return FALSE; +// } +// +// if (faccessat (tmprootfs_dfd, "etc/passwd", F_OK, 0) == 0) +// { +// passwd_entries->add_passwd_content(tmprootfs_dfd, "etc/passwd"); +// } +// +// if (faccessat (tmprootfs_dfd, "etc/group", F_OK, 0) == 0) +// { +// passwd_entries->add_group_content(tmprootfs_dfd, "etc/group"); +// } +// +// { +// auto task = rpmostreecxx::progress_begin_task("Running post scripts"); +// guint n_post_scripts_run = 0; +// +// /* %post */ +// for (guint i = 0; i < n_rpmts_elements; i++) +// { +// rpmte te = rpmtsElement (ordering_ts, i); +// if (rpmteType (te) != TR_ADDED) +// continue; +// +// auto pkg = (DnfPackage *)(rpmteKey (te)); +// g_assert (pkg); +// +// task->set_sub_message(dnf_package_get_name(pkg)); +// if (!apply_rpmfi_overrides (self, tmprootfs_dfd, pkg, *passwd_entries, +// cancellable, error)) +// return glnx_prefix_error (error, "While applying overrides for pkg %s", +// dnf_package_get_name (pkg)); +// +// if (!run_script_sync (self, tmprootfs_dfd, &var_lib_rpm_statedir, +// pkg, RPMOSTREE_SCRIPT_POSTIN, +// &n_post_scripts_run, cancellable, error)) +// return FALSE; +// } +// } +// +// /* Any ostree refs to overlay */ +// if (!process_ostree_layers (self, tmprootfs_dfd, cancellable, error)) +// return FALSE; +// +// { +// auto task = rpmostreecxx::progress_begin_task("Running posttrans scripts"); +// guint n_posttrans_scripts_run = 0; +// +// /* %posttrans */ +// for (guint i = 0; i < n_rpmts_elements; i++) +// { +// rpmte te = rpmtsElement (ordering_ts, i); +// if (rpmteType (te) != TR_ADDED) +// continue; +// +// auto pkg = (DnfPackage *)(rpmteKey (te)); +// g_assert (pkg); +// +// task->set_sub_message(dnf_package_get_name(pkg)); +// if (!run_script_sync (self, tmprootfs_dfd, &var_lib_rpm_statedir, +// pkg, RPMOSTREE_SCRIPT_POSTTRANS, +// &n_posttrans_scripts_run, cancellable, error)) +// return FALSE; +// } +// +// /* file triggers */ +// if (!run_all_transfiletriggers (self, ordering_ts, tmprootfs_dfd, +// &n_posttrans_scripts_run, cancellable, error)) +// return FALSE; +// +// auto msg = g_strdup_printf ("%u done", n_posttrans_scripts_run); +// task->end(msg); +// } +// +// /* We want this to be the first error message if something went wrong +// * with a script; see https://github.com/projectatomic/rpm-ostree/pull/888 +// * (otherwise, on a script that did `rm -rf`, we'd fail first on the renameat below) +// */ +// if (!skip_sanity_check && +// !rpmostree_deployment_sanitycheck_true (tmprootfs_dfd, cancellable, error)) +// return FALSE; +// +// if (have_systemctl) +// { +// if (!glnx_renameat (tmprootfs_dfd, "usr/bin/systemctl.rpmostreesave", +// tmprootfs_dfd, "usr/bin/systemctl", error)) +// return FALSE; +// } +// +// if (have_passwd) +// { +// rpmostreecxx::complete_rpm_layering (tmprootfs_dfd); +// } +// } +// else +// { +// /* Also do a sanity check even if we have no layered packages */ +// if (!skip_sanity_check && +// !rpmostree_deployment_sanitycheck_true (tmprootfs_dfd, cancellable, error)) +// return FALSE; +// } +// if (self->treefile_rs && self->treefile_rs->get_cliwrap()) rpmostreecxx::cliwrap_write_wrappers (tmprootfs_dfd); @@ -4364,7 +4366,7 @@ rpmostree_context_assemble (RpmOstreeContext *self, * just the header in metadata - we don't have the exact original content to * provide again. */ - rpmtsSetVfyLevel (rpmdb_ts, 0); +// rpmtsSetVfyLevel (rpmdb_ts, 0); /* We're just writing the rpmdb, hence _JUSTDB. Also disable the librpm * SELinux plugin since rpm-ostree (and ostree) have fundamentally better * code. @@ -4376,32 +4378,32 @@ rpmostree_context_assemble (RpmOstreeContext *self, /* Skip validating scripts since we already validated them above */ RpmOstreeTsAddInstallFlags rpmdb_instflags = RPMOSTREE_TS_FLAG_NOVALIDATE_SCRIPTS; - for (guint i = 0; i < overlays->len; i++) - { - auto pkg = static_cast(overlays->pdata[i]); - - if (!rpmts_add_install (self, rpmdb_ts, pkg, rpmdb_instflags, - cancellable, error)) - return FALSE; - } - - for (guint i = 0; i < overrides_replace->len; i++) - { - auto pkg = static_cast(overrides_replace->pdata[i]); - - if (!rpmts_add_install (self, rpmdb_ts, pkg, - static_cast(rpmdb_instflags | RPMOSTREE_TS_FLAG_UPGRADE), - cancellable, error)) - return FALSE; - } - - /* and mark removed packages as such so they drop out of rpmdb */ - for (guint i = 0; i < overrides_remove->len; i++) - { - auto pkg = static_cast(overrides_remove->pdata[i]); - if (!rpmts_add_erase (self, rpmdb_ts, pkg, cancellable, error)) - return FALSE; - } +// for (guint i = 0; i < overlays->len; i++) +// { +// auto pkg = static_cast(overlays->pdata[i]); +// +// if (!rpmts_add_install (self, rpmdb_ts, pkg, rpmdb_instflags, +// cancellable, error)) +// return FALSE; +// } +// +// for (guint i = 0; i < overrides_replace->len; i++) +// { +// auto pkg = static_cast(overrides_replace->pdata[i]); +// +// if (!rpmts_add_install (self, rpmdb_ts, pkg, +// static_cast(rpmdb_instflags | RPMOSTREE_TS_FLAG_UPGRADE), +// cancellable, error)) +// return FALSE; +// } +// +// /* and mark removed packages as such so they drop out of rpmdb */ +// for (guint i = 0; i < overrides_remove->len; i++) +// { +// auto pkg = static_cast(overrides_remove->pdata[i]); +// if (!rpmts_add_erase (self, rpmdb_ts, pkg, cancellable, error)) +// return FALSE; +// } rpmtsOrder (rpmdb_ts); @@ -4418,8 +4420,8 @@ rpmostree_context_assemble (RpmOstreeContext *self, return glnx_throw (error, "Failed to update rpmdb (rpmtsRun code %d)", r); if (r > 0) { - if (!dnf_rpmts_look_for_problems (rpmdb_ts, error)) - return FALSE; +// if (!dnf_rpmts_look_for_problems (rpmdb_ts, error)) +// return FALSE; } task->end(""); @@ -4431,9 +4433,9 @@ rpmostree_context_assemble (RpmOstreeContext *self, /* And now also sanity check the rpmdb */ if (!skip_sanity_check) { - if (!rpmostree_deployment_sanitycheck_rpmdb (tmprootfs_dfd, overlays, - overrides_replace, cancellable, error)) - return FALSE; +// if (!rpmostree_deployment_sanitycheck_rpmdb (tmprootfs_dfd, overlays, +// overrides_replace, cancellable, error)) +// return FALSE; } return TRUE; diff --git a/src/libpriv/rpmostree-core.h b/src/libpriv/rpmostree-core.h index 1db1014c..c02a07dc 100644 --- a/src/libpriv/rpmostree-core.h +++ b/src/libpriv/rpmostree-core.h @@ -21,12 +21,12 @@ #pragma once #include -#include #include #include #include "rpmostree-cxxrs.h" #include "libglnx.h" +#include "libdnf_stub.h" // C++ APIs diff --git a/src/libpriv/rpmostree-cxxrs-prelude.h b/src/libpriv/rpmostree-cxxrs-prelude.h index ae83391a..ba1c3067 100644 --- a/src/libpriv/rpmostree-cxxrs-prelude.h +++ b/src/libpriv/rpmostree-cxxrs-prelude.h @@ -36,7 +36,7 @@ namespace rpmostreecxx { } // XXX: really should just include! libdnf.hxx in the bridge -#include +#include "libdnf_stub.h" namespace dnfcxx { typedef ::DnfPackage DnfPackage; typedef ::DnfRepo DnfRepo; diff --git a/src/libpriv/rpmostree-importer.cxx b/src/libpriv/rpmostree-importer.cxx index 08be1a6b..27c921e1 100644 --- a/src/libpriv/rpmostree-importer.cxx +++ b/src/libpriv/rpmostree-importer.cxx @@ -362,10 +362,10 @@ repo_metadata_for_package (DnfRepo *repo) /* For now, just the id...in the future maybe we'll add more, but this is * enough to provide useful semantics. */ - g_variant_builder_add (&builder, "{sv}", - "id", g_variant_new_string (dnf_repo_get_id (repo))); - g_variant_builder_add (&builder, "{sv}", - "timestamp", g_variant_new_uint64 (dnf_repo_get_timestamp_generated (repo))); +// g_variant_builder_add (&builder, "{sv}", +// "id", g_variant_new_string (dnf_repo_get_id (repo))); +// g_variant_builder_add (&builder, "{sv}", +// "timestamp", g_variant_new_uint64 (dnf_repo_get_timestamp_generated (repo))); return g_variant_builder_end (&builder); } @@ -438,12 +438,12 @@ build_metadata_variant (RpmOstreeImporter *self, if (self->pkg) { - DnfRepo *repo = dnf_package_get_repo (self->pkg); - if (repo) - { - g_variant_builder_add (&metadata_builder, "{sv}", "rpmostree.repo", - repo_metadata_for_package (repo)); - } +// DnfRepo *repo = dnf_package_get_repo (self->pkg); +// if (repo) +// { +// g_variant_builder_add (&metadata_builder, "{sv}", "rpmostree.repo", +// repo_metadata_for_package (repo)); +// } /* include a checksum of the RPM as a whole; the actual algo used depends * on how the repodata was created, so just keep a repr */ diff --git a/src/libpriv/rpmostree-importer.h b/src/libpriv/rpmostree-importer.h index 6b52d1ef..8b8a9096 100644 --- a/src/libpriv/rpmostree-importer.h +++ b/src/libpriv/rpmostree-importer.h @@ -24,7 +24,7 @@ #include "libglnx.h" #include -#include +#include "libdnf_stub.h" G_BEGIN_DECLS diff --git a/src/libpriv/rpmostree-refsack.h b/src/libpriv/rpmostree-refsack.h index e22b16a9..c16b93da 100644 --- a/src/libpriv/rpmostree-refsack.h +++ b/src/libpriv/rpmostree-refsack.h @@ -22,7 +22,8 @@ #pragma once #include -#include +//#include +#include "libdnf_stub.h" #include "libglnx.h" G_BEGIN_DECLS diff --git a/src/libpriv/rpmostree-refts.h b/src/libpriv/rpmostree-refts.h index f28d36fd..dcdc8464 100644 --- a/src/libpriv/rpmostree-refts.h +++ b/src/libpriv/rpmostree-refts.h @@ -22,7 +22,8 @@ #pragma once #include -#include +#include +//#include #include "libglnx.h" G_BEGIN_DECLS diff --git a/src/libpriv/rpmostree-rpm-util.cxx b/src/libpriv/rpmostree-rpm-util.cxx index 57bdda4e..f805f4e6 100644 --- a/src/libpriv/rpmostree-rpm-util.cxx +++ b/src/libpriv/rpmostree-rpm-util.cxx @@ -853,16 +853,16 @@ get_sack_for_root (int dfd, g_autofree char *fullpath = glnx_fdrel_abspath (dfd, path); - g_autoptr(DnfSack) sack = dnf_sack_new (); - dnf_sack_set_rootdir (sack, fullpath); - - if (!dnf_sack_setup (sack, 0, error)) - return FALSE; - - if (!dnf_sack_load_system_repo (sack, NULL, 0, error)) - return FALSE; - - *out_sack = util::move_nullify (sack); +// g_autoptr(DnfSack) sack = dnf_sack_new (); +// dnf_sack_set_rootdir (sack, fullpath); +// +// if (!dnf_sack_setup (sack, 0, error)) +// return FALSE; +// +// if (!dnf_sack_load_system_repo (sack, NULL, 0, error)) +// return FALSE; +// +// *out_sack = util::move_nullify (sack); return TRUE; } @@ -873,10 +873,11 @@ rpmostree_get_refsack_for_root (int dfd, const char *path, GError **error) { - g_autoptr(DnfSack) sack = NULL; /* NB: refsack adds a ref to it */ - if (!get_sack_for_root (dfd, path, &sack, error)) +// g_autoptr(DnfSack) sack = NULL; /* NB: refsack adds a ref to it */ +// if (!get_sack_for_root (dfd, path, &sack, error)) +// return NULL; +// return rpmostree_refsack_new (sack, NULL); return NULL; - return rpmostree_refsack_new (sack, NULL); } /* Given @dfd + @path, return a sack corresponding to the base layer (which is the same as @@ -911,11 +912,11 @@ rpmostree_get_base_refsack_for_root (int dfd, if (!mk_rpmdb_compat_symlinks (tmpdir.fd, cancellable, error)) return FALSE; - g_autoptr(DnfSack) sack = NULL; /* NB: refsack adds a ref to it */ - if (!get_sack_for_root (tmpdir.fd, ".", &sack, error)) - return FALSE; - - *out_sack = rpmostree_refsack_new (sack, &tmpdir); +// g_autoptr(DnfSack) sack = NULL; /* NB: refsack adds a ref to it */ +// if (!get_sack_for_root (tmpdir.fd, ".", &sack, error)) +// return FALSE; +// +// *out_sack = rpmostree_refsack_new (sack, &tmpdir); return TRUE; } @@ -936,12 +937,12 @@ rpmostree_get_refsack_for_commit (OstreeRepo *repo, &tmpdir, cancellable, error)) return NULL; - g_autoptr(DnfSack) hsack = NULL; /* NB: refsack adds a ref to it */ - if (!get_sack_for_root (tmpdir.fd, ".", &hsack, error)) +// g_autoptr(DnfSack) hsack = NULL; /* NB: refsack adds a ref to it */ +// if (!get_sack_for_root (tmpdir.fd, ".", &hsack, error)) return NULL; /* Ownership of tmpdir is transferred */ - return rpmostree_refsack_new (hsack, &tmpdir); +// return rpmostree_refsack_new (hsack, &tmpdir); } /* Return a sack for the "base" rpmdb without any layering/overrides/etc. @@ -965,12 +966,12 @@ rpmostree_get_base_refsack_for_commit (OstreeRepo *repo, &tmpdir, cancellable, error)) return NULL; - g_autoptr(DnfSack) hsack = NULL; /* NB: refsack adds a ref to it */ - if (!get_sack_for_root (tmpdir.fd, ".", &hsack, error)) +// g_autoptr(DnfSack) hsack = NULL; /* NB: refsack adds a ref to it */ +// if (!get_sack_for_root (tmpdir.fd, ".", &hsack, error)) return NULL; /* Ownership of tmpdir is transferred */ - return rpmostree_refsack_new (hsack, &tmpdir); +// return rpmostree_refsack_new (hsack, &tmpdir); } static RpmOstreeRefTs* @@ -1015,7 +1016,7 @@ gint rpmostree_pkg_array_compare (DnfPackage **p_pkg1, DnfPackage **p_pkg2) { - return dnf_package_cmp (*p_pkg1, *p_pkg2); + return 0;//dnf_package_cmp (*p_pkg1, *p_pkg2); } void @@ -1031,9 +1032,9 @@ print_pkglist (GPtrArray *pkglist) for (guint i = 0; i < pkglist->len; i++) { - auto pkg = static_cast(pkglist->pdata[i]); - rpmostree_output_message (" %s (%s)", dnf_package_get_nevra (pkg), - dnf_package_get_reponame (pkg)); +// auto pkg = static_cast(pkglist->pdata[i]); +// rpmostree_output_message (" %s (%s)", dnf_package_get_nevra (pkg), +// dnf_package_get_reponame (pkg)); } } @@ -1043,33 +1044,33 @@ rpmostree_print_transaction (DnfContext *dnfctx) gboolean empty = TRUE; { g_autoptr(GPtrArray) packages = NULL; - packages = dnf_goal_get_packages (dnf_context_get_goal (dnfctx), - DNF_PACKAGE_INFO_INSTALL, - DNF_PACKAGE_INFO_REINSTALL, - DNF_PACKAGE_INFO_DOWNGRADE, - DNF_PACKAGE_INFO_UPDATE, - -1); - - if (packages->len > 0) - { - empty = FALSE; - rpmostree_output_message ("Installing %u packages:", packages->len); - print_pkglist (packages); - } +// packages = dnf_goal_get_packages (dnf_context_get_goal (dnfctx), +// DNF_PACKAGE_INFO_INSTALL, +// DNF_PACKAGE_INFO_REINSTALL, +// DNF_PACKAGE_INFO_DOWNGRADE, +// DNF_PACKAGE_INFO_UPDATE, +// -1); +// +// if (packages->len > 0) +// { +// empty = FALSE; +// rpmostree_output_message ("Installing %u packages:", packages->len); +// print_pkglist (packages); +// } } { g_autoptr(GPtrArray) packages = NULL; - packages = dnf_goal_get_packages (dnf_context_get_goal (dnfctx), - DNF_PACKAGE_INFO_REMOVE, - DNF_PACKAGE_INFO_OBSOLETE, - -1); - - if (packages->len > 0) - { - empty = FALSE; - rpmostree_output_message ("Removing %u packages:", packages->len); - print_pkglist (packages); - } +// packages = dnf_goal_get_packages (dnf_context_get_goal (dnfctx), +// DNF_PACKAGE_INFO_REMOVE, +// DNF_PACKAGE_INFO_OBSOLETE, +// -1); +// +// if (packages->len > 0) +// { +// empty = FALSE; +// rpmostree_output_message ("Removing %u packages:", packages->len); +// print_pkglist (packages); +// } } if (empty) @@ -1157,23 +1158,23 @@ get_repodata_chksum_repr (DnfPackage &pkg) const unsigned char *chksum_raw = NULL; /* for rpmdb packages, use the hdr checksum */ - if (dnf_package_installed (&pkg)) - chksum_raw = dnf_package_get_hdr_chksum (&pkg, &chksum_type); - else - chksum_raw = dnf_package_get_chksum (&pkg, &chksum_type); - if (chksum_raw) - chksum = hy_chksum_str (chksum_raw, chksum_type); - - if (chksum == NULL) - { - // TODO try out the tinyformat.hpp in libdnf - g_autofree char *msg = g_strdup_printf ("Couldn't get chksum for pkg %s", dnf_package_get_nevra(&pkg)); - throw std::runtime_error (msg); - } +// if (dnf_package_installed (&pkg)) +// chksum_raw = dnf_package_get_hdr_chksum (&pkg, &chksum_type); +// else +// chksum_raw = dnf_package_get_chksum (&pkg, &chksum_type); +// if (chksum_raw) +// chksum = hy_chksum_str (chksum_raw, chksum_type); +// +// if (chksum == NULL) +// { +// // TODO try out the tinyformat.hpp in libdnf +// g_autofree char *msg = g_strdup_printf ("Couldn't get chksum for pkg %s", dnf_package_get_nevra(&pkg)); +// throw std::runtime_error (msg); +// } // Would be nice to expose a format!() equivalent on rust::String std::ostringstream ss; - ss << hy_chksum_name (chksum_type) << ":" << chksum; +// ss << hy_chksum_name (chksum_type) << ":" << chksum; return rust::String(ss.str()); } } @@ -1184,15 +1185,15 @@ rpmostree_get_matching_packages (DnfSack *sack, { /* mimic dnf_context_install() */ g_autoptr(GPtrArray) matches = NULL; - HySelector selector = NULL; - HySubject subject = NULL; - - subject = hy_subject_create (pattern); - selector = hy_subject_get_best_selector (subject, sack, NULL, FALSE, NULL); - matches = hy_selector_matches (selector); - - hy_selector_free (selector); - hy_subject_free (subject); +// HySelector selector = NULL; +// HySubject subject = NULL; +// +// subject = hy_subject_create (pattern); +// selector = hy_subject_get_best_selector (subject, sack, NULL, FALSE, NULL); +// matches = hy_selector_matches (selector); +// +// hy_selector_free (selector); +// hy_subject_free (subject); return util::move_nullify (matches); } @@ -1213,28 +1214,28 @@ rpmostree_sack_get_by_pkgname (DnfSack *sack, DnfPackage **out_pkg, GError **error) { - g_autoptr(DnfPackage) ret_pkg = NULL; - hy_autoquery HyQuery query = hy_query_create (sack); - hy_query_filter (query, HY_PKG_NAME, HY_EQ, pkgname); - g_autoptr(GPtrArray) pkgs = hy_query_run (query); +// g_autoptr(DnfPackage) ret_pkg = NULL; +// hy_autoquery HyQuery query = hy_query_create (sack); +// hy_query_filter (query, HY_PKG_NAME, HY_EQ, pkgname); +// g_autoptr(GPtrArray) pkgs = hy_query_run (query); +// +// if (pkgs->len > 1) +// return glnx_throw (error, "Multiple packages match \"%s\"", pkgname); +// else if (pkgs->len == 1) +// ret_pkg = (DnfPackage*)g_object_ref (pkgs->pdata[0]); +// else /* for obviousness */ +// ret_pkg = NULL; - if (pkgs->len > 1) - return glnx_throw (error, "Multiple packages match \"%s\"", pkgname); - else if (pkgs->len == 1) - ret_pkg = (DnfPackage*)g_object_ref (pkgs->pdata[0]); - else /* for obviousness */ - ret_pkg = NULL; - - *out_pkg = util::move_nullify (ret_pkg); +// *out_pkg = util::move_nullify (ret_pkg); return TRUE; } GPtrArray* rpmostree_sack_get_packages (DnfSack *sack) { - hy_autoquery HyQuery query = hy_query_create (sack); - hy_query_filter (query, HY_PKG_REPONAME, HY_EQ, HY_SYSTEM_REPO_NAME); - return hy_query_run (query); +// hy_autoquery HyQuery query = hy_query_create (sack); +// hy_query_filter (query, HY_PKG_REPONAME, HY_EQ, HY_SYSTEM_REPO_NAME); + return NULL;// hy_query_run (query); } GPtrArray* @@ -1257,16 +1258,16 @@ rpmostree_variant_pkgs_from_sack (RpmOstreeRefSack *refsack) const guint n = pkglist->len; for (guint i = 0; i < n; i++) { - auto pkg = static_cast(pkglist->pdata[i]); - - /* put epoch as a string so we're indifferent to endianness -- also note that unlike - * librpm, libdnf doesn't care about unset vs 0 epoch and neither do we */ - g_autofree char *epoch = g_strdup_printf ("%" PRIu64, dnf_package_get_epoch (pkg)); - g_variant_builder_add (&pkglist_v_builder, "(sssss)", - dnf_package_get_name (pkg), epoch, - dnf_package_get_version (pkg), - dnf_package_get_release (pkg), - dnf_package_get_arch (pkg)); +// auto pkg = static_cast(pkglist->pdata[i]); +// +// /* put epoch as a string so we're indifferent to endianness -- also note that unlike +// * librpm, libdnf doesn't care about unset vs 0 epoch and neither do we */ +// g_autofree char *epoch = g_strdup_printf ("%" PRIu64, dnf_package_get_epoch (pkg)); +// g_variant_builder_add (&pkglist_v_builder, "(sssss)", +// dnf_package_get_name (pkg), epoch, +// dnf_package_get_version (pkg), +// dnf_package_get_release (pkg), +// dnf_package_get_arch (pkg)); } return g_variant_ref_sink (g_variant_builder_end (&pkglist_v_builder)); @@ -1303,7 +1304,7 @@ rpmostree_decompose_nevra (const char *nevra, g_autofree char *release = NULL; g_autofree char *arch = NULL; - if (hy_split_nevra (nevra, &name, &epoch, &version, &release, &arch) != 0) +// if (hy_split_nevra (nevra, &name, &epoch, &version, &release, &arch) != 0) return glnx_throw (error, "Failed to decompose NEVRA string '%s'", nevra); if (out_name) @@ -1422,9 +1423,10 @@ rpmostree_get_cache_branch_header (Header hdr) char * rpmostree_get_cache_branch_pkg (DnfPackage *pkg) { - return rpmostree_get_cache_branch_for_n_evr_a (dnf_package_get_name (pkg), - dnf_package_get_evr (pkg), - dnf_package_get_arch (pkg)); +// return rpmostree_get_cache_branch_for_n_evr_a (dnf_package_get_name (pkg), +// dnf_package_get_evr (pkg), +// dnf_package_get_arch (pkg)); + return NULL; } GPtrArray* @@ -1432,14 +1434,14 @@ rpmostree_get_enabled_rpmmd_repos (DnfContext *dnfctx, DnfRepoEnabled enablement) { g_autoptr(GPtrArray) ret = g_ptr_array_new (); - GPtrArray *repos = dnf_context_get_repos (dnfctx); - - for (guint i = 0; i < repos->len; i++) - { - auto repo = static_cast(repos->pdata[i]); - if (dnf_repo_get_enabled (repo) & enablement) - g_ptr_array_add (ret, repo); - } +// GPtrArray *repos = dnf_context_get_repos (dnfctx); +// +// for (guint i = 0; i < repos->len; i++) +// { +// auto repo = static_cast(repos->pdata[i]); +// if (dnf_repo_get_enabled (repo) & enablement) +// g_ptr_array_add (ret, repo); +// } return util::move_nullify (ret); } @@ -1471,136 +1473,136 @@ compare_advisory_refs (gconstpointer ap, /* We use URLs to sort here; often CVE RHBZs will have multiple duplicates for each stream * affected (e.g. Fedora, EPEL, RHEL, etc...), but we want the first one, which contains * all the juicy details. A naive strcmp() sort on the URL gives us this. */ - DnfAdvisoryRef *a = *((DnfAdvisoryRef**)ap); - DnfAdvisoryRef *b = *((DnfAdvisoryRef**)bp); - - g_assert (a); - g_assert (b); - - /* just use g_strcmp0() here to tolerate NULL URLs for now if that somehow happens... we - * filter them out later when going through all the references */ - return g_strcmp0 (dnf_advisoryref_get_url (a), dnf_advisoryref_get_url (b)); +// DnfAdvisoryRef *a = *((DnfAdvisoryRef**)ap); +// DnfAdvisoryRef *b = *((DnfAdvisoryRef**)bp); +// +// g_assert (a); +// g_assert (b); +// +// /* just use g_strcmp0() here to tolerate NULL URLs for now if that somehow happens... we +// * filter them out later when going through all the references */ + return 0;// g_strcmp0 (dnf_advisoryref_get_url (a), dnf_advisoryref_get_url (b)); } /* Returns a *floating* variant ref representing the advisory */ -static GVariant* -advisory_variant_new (DnfAdvisory *adv, - GPtrArray *pkgs) -{ - static gsize cve_regex_initialized; - static GRegex *cve_regex; - -#define CVE_REGEXP "CVE-[0-9]+-[0-9]+" - - if (g_once_init_enter (&cve_regex_initialized)) - { - cve_regex = g_regex_new ("\\b" CVE_REGEXP "\\b", static_cast(0), static_cast(0), NULL); - g_assert (cve_regex); - g_once_init_leave (&cve_regex_initialized, 1); - } - -#undef CVE_REGEXP - - g_auto(GVariantBuilder) builder; - g_variant_builder_init (&builder, G_VARIANT_TYPE_TUPLE); - g_variant_builder_add (&builder, "s", dnf_advisory_get_id (adv)); - g_variant_builder_add (&builder, "u", dnf_advisory_get_kind (adv)); - g_variant_builder_add (&builder, "u", str2severity (dnf_advisory_get_severity (adv))); - - { g_auto(GVariantBuilder) pkgs_array; - g_variant_builder_init (&pkgs_array, G_VARIANT_TYPE ("as")); - for (guint i = 0; i < pkgs->len; i++) - g_variant_builder_add (&pkgs_array, "s", dnf_package_get_nevra (static_cast(pkgs->pdata[i]))); - g_variant_builder_add_value (&builder, g_variant_builder_end (&pkgs_array)); - } - - /* final a{sv} for any additional metadata */ - g_auto(GVariantDict) dict; - g_variant_dict_init (&dict, NULL); - - { g_auto(GVariantBuilder) cve_references; - g_variant_builder_init (&cve_references, G_VARIANT_TYPE ("a(ss)")); - - /* we maintain a set to make sure we only add the earliest ref for each CVE */ - g_autoptr(GHashTable) created_cves = - g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); - - g_autoptr(GPtrArray) refs = dnf_advisory_get_references (adv); - g_ptr_array_sort (refs, compare_advisory_refs); - - /* for each ref, look for CVEs in their title, and add an (ss) for refs which mention - * new CVEs. */ - for (guint i = 0; i < refs->len; i++) - { - auto ref = static_cast(refs->pdata[i]); - if (dnf_advisoryref_get_kind (ref) != DNF_REFERENCE_KIND_BUGZILLA) - continue; - - g_autoptr(GMatchInfo) match = NULL; - const char *title = dnf_advisoryref_get_title (ref); - const char *url = dnf_advisoryref_get_url (ref); - - if (!url || !title) - continue; - - if (!g_regex_match (cve_regex, title, static_cast(0), &match)) - continue; - - /* collect all the found CVEs first */ - g_autoptr(GPtrArray) found_cves = g_ptr_array_new_with_free_func (g_free); - while (g_match_info_matches (match)) - { - g_ptr_array_add (found_cves, g_match_info_fetch (match, 0)); - g_match_info_next (match, NULL); - } - - gboolean has_new_cve = FALSE; - for (guint i = 0; i < found_cves->len && !has_new_cve; i++) - has_new_cve = !g_hash_table_contains (created_cves, found_cves->pdata[i]); - - /* if a single CVE is new, make a GVariant for it */ - if (has_new_cve) - { - g_variant_builder_add (&cve_references, "(ss)", url, title); - /* steal all the cves and transfer to set, autofree'ing dupes */ - g_ptr_array_add (found_cves, NULL); - g_autofree char **cves = - (char**)g_ptr_array_free (util::move_nullify (found_cves), FALSE); - for (char **cve = cves; cve && *cve; cve++) - g_hash_table_add (created_cves, *cve); - } - } - g_variant_dict_insert_value (&dict, "cve_references", - g_variant_builder_end (&cve_references)); - } - g_variant_builder_add_value (&builder, g_variant_dict_end (&dict)); - - return g_variant_builder_end (&builder); -} +//static GVariant* +//advisory_variant_new (DnfAdvisory *adv, +// GPtrArray *pkgs) +//{ +// static gsize cve_regex_initialized; +// static GRegex *cve_regex; +// +//#define CVE_REGEXP "CVE-[0-9]+-[0-9]+" +// +// if (g_once_init_enter (&cve_regex_initialized)) +// { +// cve_regex = g_regex_new ("\\b" CVE_REGEXP "\\b", static_cast(0), static_cast(0), NULL); +// g_assert (cve_regex); +// g_once_init_leave (&cve_regex_initialized, 1); +// } +// +//#undef CVE_REGEXP +// +// g_auto(GVariantBuilder) builder; +// g_variant_builder_init (&builder, G_VARIANT_TYPE_TUPLE); +// g_variant_builder_add (&builder, "s", dnf_advisory_get_id (adv)); +// g_variant_builder_add (&builder, "u", dnf_advisory_get_kind (adv)); +// g_variant_builder_add (&builder, "u", str2severity (dnf_advisory_get_severity (adv))); +// +// { g_auto(GVariantBuilder) pkgs_array; +// g_variant_builder_init (&pkgs_array, G_VARIANT_TYPE ("as")); +// for (guint i = 0; i < pkgs->len; i++) +// g_variant_builder_add (&pkgs_array, "s", dnf_package_get_nevra (static_cast(pkgs->pdata[i]))); +// g_variant_builder_add_value (&builder, g_variant_builder_end (&pkgs_array)); +// } +// +// /* final a{sv} for any additional metadata */ +// g_auto(GVariantDict) dict; +// g_variant_dict_init (&dict, NULL); +// +// { g_auto(GVariantBuilder) cve_references; +// g_variant_builder_init (&cve_references, G_VARIANT_TYPE ("a(ss)")); +// +// /* we maintain a set to make sure we only add the earliest ref for each CVE */ +// g_autoptr(GHashTable) created_cves = +// g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); +// +// g_autoptr(GPtrArray) refs = dnf_advisory_get_references (adv); +// g_ptr_array_sort (refs, compare_advisory_refs); +// +// /* for each ref, look for CVEs in their title, and add an (ss) for refs which mention +// * new CVEs. */ +// for (guint i = 0; i < refs->len; i++) +// { +// auto ref = static_cast(refs->pdata[i]); +// if (dnf_advisoryref_get_kind (ref) != DNF_REFERENCE_KIND_BUGZILLA) +// continue; +// +// g_autoptr(GMatchInfo) match = NULL; +// const char *title = dnf_advisoryref_get_title (ref); +// const char *url = dnf_advisoryref_get_url (ref); +// +// if (!url || !title) +// continue; +// +// if (!g_regex_match (cve_regex, title, static_cast(0), &match)) +// continue; +// +// /* collect all the found CVEs first */ +// g_autoptr(GPtrArray) found_cves = g_ptr_array_new_with_free_func (g_free); +// while (g_match_info_matches (match)) +// { +// g_ptr_array_add (found_cves, g_match_info_fetch (match, 0)); +// g_match_info_next (match, NULL); +// } +// +// gboolean has_new_cve = FALSE; +// for (guint i = 0; i < found_cves->len && !has_new_cve; i++) +// has_new_cve = !g_hash_table_contains (created_cves, found_cves->pdata[i]); +// +// /* if a single CVE is new, make a GVariant for it */ +// if (has_new_cve) +// { +// g_variant_builder_add (&cve_references, "(ss)", url, title); +// /* steal all the cves and transfer to set, autofree'ing dupes */ +// g_ptr_array_add (found_cves, NULL); +// g_autofree char **cves = +// (char**)g_ptr_array_free (util::move_nullify (found_cves), FALSE); +// for (char **cve = cves; cve && *cve; cve++) +// g_hash_table_add (created_cves, *cve); +// } +// } +// g_variant_dict_insert_value (&dict, "cve_references", +// g_variant_builder_end (&cve_references)); +// } +// g_variant_builder_add_value (&builder, g_variant_dict_end (&dict)); +// +// return g_variant_builder_end (&builder); +//} /* libdnf creates new DnfAdvisory objects on request */ static guint advisory_hash (gconstpointer v) { - return g_str_hash (dnf_advisory_get_id ((DnfAdvisory*)v)); + return 0;//g_str_hash (dnf_advisory_get_id ((DnfAdvisory*)v)); } static gboolean advisory_equal (gconstpointer v1, gconstpointer v2) { - return g_str_equal (dnf_advisory_get_id ((DnfAdvisory*)v1), - dnf_advisory_get_id ((DnfAdvisory*)v2)); + return FALSE;//g_str_equal (dnf_advisory_get_id ((DnfAdvisory*)v1), + // dnf_advisory_get_id ((DnfAdvisory*)v2)); } /* adds noop-on-NULL semantics so we can steal in advisories_variant() */ static void advisory_free (gpointer p) { - auto adv = static_cast(p); - if (adv) - dnf_advisory_free (adv); +// auto adv = static_cast(p); +// if (adv) +// dnf_advisory_free (adv); } /* Go through the list of @pkgs and check if there are any advisories open for them. If @@ -1617,39 +1619,39 @@ rpmostree_advisories_variant (DnfSack *sack, /* libdnf provides pkg -> set of advisories, but we want advisory -> set of pkgs; * making sure we only keep the pkgs we actually care about */ - for (guint i = 0; i < pkgs->len; i++) - { - auto pkg = static_cast(pkgs->pdata[i]); - g_autoptr(GPtrArray) advisories_with_pkg = dnf_package_get_advisories (pkg, HY_EQ); - for (guint j = 0; j < advisories_with_pkg->len; j++) - { - auto advisory = static_cast(advisories_with_pkg->pdata[j]); - - /* for now we're only interested in security erratas */ - if (dnf_advisory_get_kind (advisory) != DNF_ADVISORY_KIND_SECURITY) - continue; - - /* reverse mapping */ - auto pkgs_in_advisory = static_cast(g_hash_table_lookup (advisories, advisory)); - if (!pkgs_in_advisory) - { - /* take it out of the array, transferring ownership to the hash table; there's - * g_ptr_array_steal_index() we could use, but it's still very new */ - advisories_with_pkg->pdata[j] = NULL; - pkgs_in_advisory = - g_ptr_array_new_with_free_func ((GDestroyNotify)g_object_unref); - g_hash_table_insert (advisories, advisory, pkgs_in_advisory); - } - g_ptr_array_add (pkgs_in_advisory, g_object_ref (pkg)); - } - } +// for (guint i = 0; i < pkgs->len; i++) +// { +// auto pkg = static_cast(pkgs->pdata[i]); +// g_autoptr(GPtrArray) advisories_with_pkg = dnf_package_get_advisories (pkg, HY_EQ); +// for (guint j = 0; j < advisories_with_pkg->len; j++) +// { +// auto advisory = static_cast(advisories_with_pkg->pdata[j]); +// +// /* for now we're only interested in security erratas */ +// if (dnf_advisory_get_kind (advisory) != DNF_ADVISORY_KIND_SECURITY) +// continue; +// +// /* reverse mapping */ +// auto pkgs_in_advisory = static_cast(g_hash_table_lookup (advisories, advisory)); +// if (!pkgs_in_advisory) +// { +// /* take it out of the array, transferring ownership to the hash table; there's +// * g_ptr_array_steal_index() we could use, but it's still very new */ +// advisories_with_pkg->pdata[j] = NULL; +// pkgs_in_advisory = +// g_ptr_array_new_with_free_func ((GDestroyNotify)g_object_unref); +// g_hash_table_insert (advisories, advisory, pkgs_in_advisory); +// } +// g_ptr_array_add (pkgs_in_advisory, g_object_ref (pkg)); +// } +// } if (g_hash_table_size (advisories) == 0) return NULL; g_auto(GVariantBuilder) builder; g_variant_builder_init (&builder, RPMOSTREE_UPDATE_ADVISORY_GVARIANT_FORMAT); - GLNX_HASH_TABLE_FOREACH_KV (advisories, DnfAdvisory*, advisory, GPtrArray*, pkgs) - g_variant_builder_add_value (&builder, advisory_variant_new (advisory, pkgs)); +// GLNX_HASH_TABLE_FOREACH_KV (advisories, DnfAdvisory*, advisory, GPtrArray*, pkgs) +// g_variant_builder_add_value (&builder, advisory_variant_new (advisory, pkgs)); return g_variant_ref_sink (g_variant_builder_end (&builder)); } diff --git a/src/libpriv/rpmostree-rpm-util.h b/src/libpriv/rpmostree-rpm-util.h index cdc39367..1db4ee72 100644 --- a/src/libpriv/rpmostree-rpm-util.h +++ b/src/libpriv/rpmostree-rpm-util.h @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include "libglnx.h" #include "rpmostree-util.h" #include "rpmostree-refsack.h" diff --git a/src/libpriv/rpmostree-scripts.cxx b/src/libpriv/rpmostree-scripts.cxx index 5b52803e..b7bd0a27 100644 --- a/src/libpriv/rpmostree-scripts.cxx +++ b/src/libpriv/rpmostree-scripts.cxx @@ -244,11 +244,11 @@ rpmostree_script_txn_validate (DnfPackage *package, if (!(headerIsEntry (hdr, tagval) || headerIsEntry (hdr, progtagval))) continue; - if (!rpmostreecxx::script_is_ignored (dnf_package_get_name (package), desc)) - { - return glnx_throw (error, "Package '%s' has (currently) unsupported script of type '%s'; see https://github.com/coreos/rpm-ostree/issues/749", - dnf_package_get_name (package), desc); - } +// if (!rpmostreecxx::script_is_ignored (dnf_package_get_name (package), desc)) +// { +// return glnx_throw (error, "Package '%s' has (currently) unsupported script of type '%s'; see https://github.com/coreos/rpm-ostree/issues/749", +// dnf_package_get_name (package), desc); +// } } return TRUE; @@ -485,7 +485,7 @@ impl_run_rpm_script (const KnownRpmScriptKind *rpmscript, const rpmFlags flags = headerGetNumber (hdr, rpmscript->flagtag); const char *script; const char *interp = (args && args[0]) ? args[0] : "/bin/sh"; - const char *pkg_scriptid = glnx_strjoina (dnf_package_get_name (pkg), ".", rpmscript->desc + 1); +// const char *pkg_scriptid = glnx_strjoina (dnf_package_get_name (pkg), ".", rpmscript->desc + 1); gboolean expand = (flags & RPMSCRIPT_FLAG_EXPAND) > 0; if (g_str_equal (interp, lua_builtin)) { @@ -494,8 +494,8 @@ impl_run_rpm_script (const KnownRpmScriptKind *rpmscript, for (guint i = 0; i < G_N_ELEMENTS (lua_replacements); i++) { const RpmOstreeLuaReplacement *repl = &lua_replacements[i]; - if (!g_str_equal (repl->pkgname_script, pkg_scriptid)) - continue; +// if (!g_str_equal (repl->pkgname_script, pkg_scriptid)) +// continue; found_replacement = TRUE; interp = repl->interp; script = repl->replacement; @@ -504,13 +504,13 @@ impl_run_rpm_script (const KnownRpmScriptKind *rpmscript, if (!found_replacement) { /* No override found, throw an error and return */ - g_assert (!fail_if_interp_is_lua (interp, dnf_package_get_name (pkg), rpmscript->desc, error)); +// g_assert (!fail_if_interp_is_lua (interp, dnf_package_get_name (pkg), rpmscript->desc, error)); return FALSE; } /* Hack around RHEL7's glibc-locales, which uses rpm-expand in the Lua script */ - if (strcmp (pkg_scriptid, "glibc-common.post") == 0) - expand = TRUE; +// if (strcmp (pkg_scriptid, "glibc-common.post") == 0) +// expand = TRUE; } else { @@ -519,11 +519,11 @@ impl_run_rpm_script (const KnownRpmScriptKind *rpmscript, for (guint i = 0; i < G_N_ELEMENTS (script_replacements); i++) { const RpmOstreeScriptReplacement *repl = &script_replacements[i]; - if (!g_str_equal (repl->pkgname_script, pkg_scriptid)) - continue; - if (repl->release_suffix && - !g_str_has_suffix (dnf_package_get_release (pkg), repl->release_suffix)) - continue; +// if (!g_str_equal (repl->pkgname_script, pkg_scriptid)) +// continue; +// if (repl->release_suffix && +// !g_str_has_suffix (dnf_package_get_release (pkg), repl->release_suffix)) +// continue; /* Is this completely suppressing the script? If so, we're done */ if (!repl->interp) return TRUE; @@ -540,44 +540,44 @@ impl_run_rpm_script (const KnownRpmScriptKind *rpmscript, /* http://ftp.rpm.org/max-rpm/s1-rpm-inside-scripts.html#S2-RPM-INSIDE-ERASE-TIME-SCRIPTS */ const char *script_arg = NULL; - switch (dnf_package_get_action (pkg)) - { - /* XXX: we're not running *un scripts for removals yet, though it'd look like: - case DNF_STATE_ACTION_REMOVE: - case DNF_STATE_ACTION_OBSOLETE: - script_arg = obsoleted_by_update ? "1" : "0"; - break; - */ - case DNF_STATE_ACTION_INSTALL: - script_arg = "1"; - break; - case DNF_STATE_ACTION_UPDATE: - script_arg = "2"; - break; - case DNF_STATE_ACTION_DOWNGRADE: - script_arg = "2"; - break; - default: - /* we shouldn't have been asked to perform for any other kind of action */ - g_assert_not_reached (); - break; - } +// switch (dnf_package_get_action (pkg)) +// { +// /* XXX: we're not running *un scripts for removals yet, though it'd look like: +// case DNF_STATE_ACTION_REMOVE: +// case DNF_STATE_ACTION_OBSOLETE: +// script_arg = obsoleted_by_update ? "1" : "0"; +// break; +// */ +// case DNF_STATE_ACTION_INSTALL: +// script_arg = "1"; +// break; +// case DNF_STATE_ACTION_UPDATE: +// script_arg = "2"; +// break; +// case DNF_STATE_ACTION_DOWNGRADE: +// script_arg = "2"; +// break; +// default: +// /* we shouldn't have been asked to perform for any other kind of action */ +// g_assert_not_reached (); +// break; +// } guint64 start_time_ms = g_get_monotonic_time () / 1000; - if (!rpmostree_run_script_in_bwrap_container (rootfs_fd, var_lib_rpm_statedir, enable_fuse, - dnf_package_get_name (pkg), - rpmscript->desc, interp, script, script_arg, - -1, cancellable, error)) - return glnx_prefix_error (error, "Running %s for %s", rpmscript->desc, dnf_package_get_name (pkg)); +// if (!rpmostree_run_script_in_bwrap_container (rootfs_fd, var_lib_rpm_statedir, enable_fuse, +// dnf_package_get_name (pkg), +// rpmscript->desc, interp, script, script_arg, +// -1, cancellable, error)) +// return glnx_prefix_error (error, "Running %s for %s", rpmscript->desc, dnf_package_get_name (pkg)); guint64 end_time_ms = g_get_monotonic_time () / 1000; guint64 elapsed_ms = end_time_ms - start_time_ms; - sd_journal_send ("MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(RPMOSTREE_MESSAGE_PREPOST), - "MESSAGE=Executed %s for %s in %" G_GUINT64_FORMAT " ms", rpmscript->desc, dnf_package_get_name (pkg), elapsed_ms, - "SCRIPT_TYPE=%s", rpmscript->desc, - "PKG=%s", dnf_package_get_name (pkg), - "EXEC_TIME_MS=%" G_GUINT64_FORMAT, elapsed_ms, - NULL); +// sd_journal_send ("MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(RPMOSTREE_MESSAGE_PREPOST), +// "MESSAGE=Executed %s for %s in %" G_GUINT64_FORMAT " ms", rpmscript->desc, dnf_package_get_name (pkg), elapsed_ms, +// "SCRIPT_TYPE=%s", rpmscript->desc, +// "PKG=%s", dnf_package_get_name (pkg), +// "EXEC_TIME_MS=%" G_GUINT64_FORMAT, elapsed_ms, +// NULL); return TRUE; } @@ -609,8 +609,8 @@ run_script (const KnownRpmScriptKind *rpmscript, return TRUE; const char *desc = rpmscript->desc; - if (rpmostreecxx::script_is_ignored (dnf_package_get_name (pkg), desc)) - return TRUE; /* Note early return */ +// if (rpmostreecxx::script_is_ignored (dnf_package_get_name (pkg), desc)) +// return TRUE; /* Note early return */ *out_did_run = TRUE; return impl_run_rpm_script (rpmscript, pkg, hdr, rootfs_fd, var_lib_rpm_statedir, @@ -982,9 +982,9 @@ verify_packages_in_sack (DnfSack *sack, for (guint i = 0; i < pkgs->len; i++) { auto pkg = static_cast(pkgs->pdata[i]); - const char *nevra = dnf_package_get_nevra (pkg); - if (!rpmostree_sack_has_subject (sack, nevra)) - return glnx_throw (error, "Didn't find package '%s'", nevra); +// const char *nevra = dnf_package_get_nevra (pkg); +// if (!rpmostree_sack_has_subject (sack, nevra)) +// return glnx_throw (error, "Didn't find package '%s'", nevra); } return TRUE; @@ -1019,11 +1019,11 @@ rpmostree_deployment_sanitycheck_rpmdb (int rootfs_fd, else { /* OK, let's just sanity check that there are *some* packages in the rpmdb */ - hy_autoquery HyQuery query = hy_query_create (sack->sack); - hy_query_filter (query, HY_PKG_REPONAME, HY_EQ, HY_SYSTEM_REPO_NAME); - g_autoptr(GPtrArray) pkgs = hy_query_run (query); - if (pkgs->len == 0) - return glnx_throw (error, "No packages found in rpmdb!"); +// hy_autoquery HyQuery query = hy_query_create (sack->sack); +// hy_query_filter (query, HY_PKG_REPONAME, HY_EQ, HY_SYSTEM_REPO_NAME); +// g_autoptr(GPtrArray) pkgs = hy_query_run (query); +// if (pkgs->len == 0) +// return glnx_throw (error, "No packages found in rpmdb!"); } sd_journal_print (LOG_INFO, "sanitycheck(rpmdb) successful"); diff --git a/src/libpriv/rpmostree-scripts.h b/src/libpriv/rpmostree-scripts.h index e6aabcad..3a19aabb 100644 --- a/src/libpriv/rpmostree-scripts.h +++ b/src/libpriv/rpmostree-scripts.h @@ -28,8 +28,8 @@ #include #include #include -#include +#include "libdnf_stub.h" #include "libglnx.h" G_BEGIN_DECLS diff --git a/src/libpriv/rpmostree-unpacker-core.h b/src/libpriv/rpmostree-unpacker-core.h index 5d23e32d..d6f40dbb 100644 --- a/src/libpriv/rpmostree-unpacker-core.h +++ b/src/libpriv/rpmostree-unpacker-core.h @@ -24,7 +24,7 @@ #include "libglnx.h" #include -#include +#include "libdnf_stub.h" #include #include diff --git a/src/libpriv/rpmostree-util.cxx b/src/libpriv/rpmostree-util.cxx index 7b3cf733..937b765c 100644 --- a/src/libpriv/rpmostree-util.cxx +++ b/src/libpriv/rpmostree-util.cxx @@ -87,9 +87,10 @@ _rpmostree_util_update_checksum_from_file (GChecksum *checksum, gboolean rpmostree_pkg_is_local (DnfPackage *pkg) { - const char *reponame = dnf_package_get_reponame (pkg); - return (g_strcmp0 (reponame, HY_CMDLINE_REPO_NAME) == 0 || - dnf_repo_is_local (dnf_package_get_repo (pkg))); +// const char *reponame = dnf_package_get_reponame (pkg); +// return (g_strcmp0 (reponame, HY_CMDLINE_REPO_NAME) == 0 || +// dnf_repo_is_local (dnf_package_get_repo (pkg))); + return FALSE; } /* Returns the local filesystem path for a package; for non-local packages, @@ -98,16 +99,17 @@ rpmostree_pkg_is_local (DnfPackage *pkg) char * rpmostree_pkg_get_local_path (DnfPackage *pkg) { - DnfRepo *pkg_repo = dnf_package_get_repo (pkg); - const gboolean is_local = rpmostree_pkg_is_local (pkg); - if (is_local) - return g_strdup (dnf_package_get_filename (pkg)); - else - { - const char *pkg_location = dnf_package_get_location (pkg); - return g_build_filename (dnf_repo_get_location (pkg_repo), - "packages", glnx_basename (pkg_location), NULL); - } + return NULL; +// DnfRepo *pkg_repo = dnf_package_get_repo (pkg); +// const gboolean is_local = rpmostree_pkg_is_local (pkg); +// if (is_local) +// return g_strdup (dnf_package_get_filename (pkg)); +// else +// { +// const char *pkg_location = dnf_package_get_location (pkg); +// return g_build_filename (dnf_repo_get_location (pkg_repo), +// "packages", glnx_basename (pkg_location), NULL); +// } } gboolean diff --git a/src/libpriv/rpmostree-util.h b/src/libpriv/rpmostree-util.h index 1d759659..778c95a3 100644 --- a/src/libpriv/rpmostree-util.h +++ b/src/libpriv/rpmostree-util.h @@ -29,8 +29,9 @@ #include #include #include -#include +//#include +#include "libdnf_stub.h" #include "libglnx.h" #include "rpmostree.h" #include "rpmostree-types.h"