Remove libndf

This commit is contained in:
Andrey Sokolov 2021-06-08 12:32:27 +03:00
parent 15e945ce6e
commit eb0fb5f1fc
33 changed files with 1914 additions and 1907 deletions

3
.gitmodules vendored
View File

@ -1,6 +1,3 @@
[submodule "libglnx"] [submodule "libglnx"]
path = libglnx path = libglnx
url = https://gitlab.gnome.org/GNOME/libglnx.git url = https://gitlab.gnome.org/GNOME/libglnx.git
[submodule "libdnf"]
path = libdnf
url = https://github.com/rpm-software-management/libdnf

53
Cargo.lock generated
View File

@ -175,25 +175,6 @@ dependencies = [
"vec_map", "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]] [[package]]
name = "console" name = "console"
version = "0.14.0" version = "0.14.0"
@ -322,21 +303,6 @@ dependencies = [
"link-cplusplus", "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]] [[package]]
name = "cxxbridge-flags" name = "cxxbridge-flags"
version = "1.0.49" version = "1.0.49"
@ -811,18 +777,6 @@ version = "0.2.95"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "789da6d93f1b866ffe175afc5322a4d76c038605a1c3319bb57b06967ca98a36" checksum = "789da6d93f1b866ffe175afc5322a4d76c038605a1c3319bb57b06967ca98a36"
[[package]]
name = "libdnf-sys"
version = "0.1.0"
dependencies = [
"anyhow",
"cmake",
"cxx",
"cxx-build",
"glib",
"system-deps 3.1.1",
]
[[package]] [[package]]
name = "libsystemd-sys" name = "libsystemd-sys"
version = "0.8.0" version = "0.8.0"
@ -1542,7 +1496,6 @@ dependencies = [
"indoc", "indoc",
"lazy_static", "lazy_static",
"libc", "libc",
"libdnf-sys",
"maplit", "maplit",
"memfd", "memfd",
"nix", "nix",
@ -1604,12 +1557,6 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "scratch"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e114536316b51a5aa7a0e59fc49661fd263c5507dd08bd28de052e57626ce69"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.126" version = "1.0.126"

View File

@ -45,7 +45,7 @@ indoc = "1.0.3"
indicatif = "0.15.0" indicatif = "0.15.0"
lazy_static = "1.4.0" lazy_static = "1.4.0"
libc = "0.2.95" 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" maplit = "1.0"
memfd = "0.4.0" memfd = "0.4.0"
nix = "0.20.0" nix = "0.20.0"

View File

@ -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) \ -I$(srcdir)/src/lib -I$(srcdir)/src/libpriv -I$(libglnx_srcpath) \
-DG_LOG_DOMAIN=\"rpm-ostreed\" \ -DG_LOG_DOMAIN=\"rpm-ostreed\" \
-DLIBDIR=\"$(libdir)\" -DPKGLIBDIR=\"$(pkglibdir)\" \ -DLIBDIR=\"$(libdir)\" -DPKGLIBDIR=\"$(pkglibdir)\" \
-I $(top_srcdir)/libdnf \
-D_RPMOSTREE_EXTERN= \ -D_RPMOSTREE_EXTERN= \
$(PKGDEP_LIBRPMOSTREE_CFLAGS) $(PKGDEP_RPMOSTREE_CFLAGS) $(PKGDEP_LIBRPMOSTREE_CFLAGS) $(PKGDEP_RPMOSTREE_CFLAGS)
rpmostree_bin_common_cflags = $(rpmostree_common_cflags) rpmostree_bin_common_cflags = $(rpmostree_common_cflags)

1
libdnf

@ -1 +0,0 @@
Subproject commit 6c2ac6786a423c00750a44805ade0268dd6d19e5

View File

@ -41,10 +41,10 @@ pub mod ffi {
type GVariant = crate::FFIGVariant; type GVariant = crate::FFIGVariant;
type GVariantDict = crate::FFIGVariantDict; type GVariantDict = crate::FFIGVariantDict;
#[namespace = "dnfcxx"] // #[namespace = "dnfcxx"]
type DnfPackage = libdnf_sys::DnfPackage; // type DnfPackage = libdnf_sys::DnfPackage;
#[namespace = "dnfcxx"] // #[namespace = "dnfcxx"]
type DnfRepo = libdnf_sys::DnfRepo; // type DnfRepo = libdnf_sys::DnfRepo;
} }
/// Currently cxx-rs doesn't support mappings; like probably most projects, /// Currently cxx-rs doesn't support mappings; like probably most projects,
@ -506,7 +506,7 @@ pub mod ffi {
// Currently only used in unit tests // Currently only used in unit tests
#[allow(dead_code)] #[allow(dead_code)]
fn nevra_to_cache_branch(nevra: &CxxString) -> Result<UniquePtr<CxxString>>; fn nevra_to_cache_branch(nevra: &CxxString) -> Result<UniquePtr<CxxString>>;
fn get_repodata_chksum_repr(pkg: &mut DnfPackage) -> Result<String>; //fn get_repodata_chksum_repr(pkg: &mut DnfPackage) -> Result<String>;
} }
} }

View File

@ -10,8 +10,8 @@
/* Copied and adapted from: treefile.rs /* Copied and adapted from: treefile.rs
*/ */
pub use self::ffi::*; //pub use self::ffi::*;
use crate::utils; //use crate::utils;
use anyhow::{anyhow, bail, Result}; use anyhow::{anyhow, bail, Result};
use chrono::prelude::*; use chrono::prelude::*;
use openat_ext::OpenatDirExt; use openat_ext::OpenatDirExt;
@ -24,26 +24,26 @@ use std::path::Path;
use std::pin::Pin; use std::pin::Pin;
use crate::cxxrsutil::CxxResult; use crate::cxxrsutil::CxxResult;
use libdnf_sys::*; //use libdnf_sys::*;
/// Given a lockfile filename, parse it /// Given a lockfile filename, parse it
fn lockfile_parse<P: AsRef<Path>>(filename: P) -> Result<LockfileConfig> { //fn lockfile_parse<P: AsRef<Path>>(filename: P) -> Result<LockfileConfig> {
let filename = filename.as_ref(); // let filename = filename.as_ref();
let fmt = utils::InputFormat::detect_from_filename(filename)?; // let fmt = utils::InputFormat::detect_from_filename(filename)?;
let mut f = io::BufReader::new(utils::open_file(filename)?); // let mut f = io::BufReader::new(utils::open_file(filename)?);
let lf = utils::parse_stream(&fmt, &mut f).map_err(|e| { // let lf = utils::parse_stream(&fmt, &mut f).map_err(|e| {
io::Error::new( // io::Error::new(
io::ErrorKind::InvalidInput, // io::ErrorKind::InvalidInput,
format!("Parsing {}: {}", filename.to_string_lossy(), e.to_string()), // format!("Parsing {}: {}", filename.to_string_lossy(), e.to_string()),
) // )
})?; // })?;
Ok(lf) // Ok(lf)
} //}
/// Given lockfile filenames, parse them. Later lockfiles may override packages from earlier ones. /// Given lockfile filenames, parse them. Later lockfiles may override packages from earlier ones.
fn lockfile_parse_multiple<P: AsRef<Path>>(filenames: &[P]) -> Result<LockfileConfig> { fn lockfile_parse_multiple<P: AsRef<Path>>(filenames: &[P]) -> Result<LockfileConfig> {
let mut final_lockfile: Option<LockfileConfig> = None; let mut final_lockfile: Option<LockfileConfig> = None;
for filename in filenames { /* for filename in filenames {
let lf = lockfile_parse(filename)?; let lf = lockfile_parse(filename)?;
if lf.packages.is_none() && lf.source_packages.is_none() { if lf.packages.is_none() && lf.source_packages.is_none() {
bail!( bail!(
@ -56,7 +56,7 @@ fn lockfile_parse_multiple<P: AsRef<Path>>(filenames: &[P]) -> Result<LockfileCo
} else { } else {
final_lockfile = Some(lf); final_lockfile = Some(lf);
} }
} } */
Ok(final_lockfile.expect("lockfile_parse: at least one lockfile")) Ok(final_lockfile.expect("lockfile_parse: at least one lockfile"))
} }
@ -366,7 +366,7 @@ pub(crate) fn lockfile_write(
}; };
let output_pkgs = lockfile.packages.as_mut().unwrap(); let output_pkgs = lockfile.packages.as_mut().unwrap();
for i in 0..(packages.as_mut().length()) { /* for i in 0..(packages.as_mut().length()) {
let pkg = packages.as_mut().get(i); let pkg = packages.as_mut().get(i);
let pkg_ref = unsafe { &mut *(&mut pkg.0 as *mut _ as *mut libdnf_sys::DnfPackage) }; let pkg_ref = unsafe { &mut *(&mut pkg.0 as *mut _ as *mut libdnf_sys::DnfPackage) };
let name = dnf_package_get_name(pkg_ref).unwrap(); let name = dnf_package_get_name(pkg_ref).unwrap();
@ -382,7 +382,7 @@ pub(crate) fn lockfile_write(
metadata: None, metadata: None,
}, },
); );
} }*/
/* just take the ref here to be less verbose */ /* just take the ref here to be less verbose */
let lockfile_repos = lockfile let lockfile_repos = lockfile
@ -393,27 +393,27 @@ pub(crate) fn lockfile_write(
.as_mut() .as_mut()
.unwrap(); .unwrap();
for i in 0..rpmmd_repos.as_mut().length() { // for i in 0..rpmmd_repos.as_mut().length() {
let repo_ref = rpmmd_repos.as_mut().get(i); // 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 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 id = dnf_repo_get_id(repo_ref).unwrap();
let generated = dnf_repo_get_timestamp_generated(repo_ref).unwrap(); // let generated = dnf_repo_get_timestamp_generated(repo_ref).unwrap();
let generated: i64 = match generated.try_into() { // let generated: i64 = match generated.try_into() {
Ok(t) => t, // Ok(t) => t,
Err(e) => { // Err(e) => {
eprintln!("Invalid rpm-md repo {} timestamp: {}: {}", id, generated, e); // eprintln!("Invalid rpm-md repo {} timestamp: {}: {}", id, generated, e);
0 // 0
} // }
}; // };
let generated = match Utc.timestamp_opt(generated, 0) { // let generated = match Utc.timestamp_opt(generated, 0) {
chrono::offset::LocalResult::Single(t) => t, // chrono::offset::LocalResult::Single(t) => t,
_ => { // _ => {
eprintln!("Invalid rpm-md repo {} timestamp: {}", id, generated); // eprintln!("Invalid rpm-md repo {} timestamp: {}", id, generated);
Utc.timestamp(0, 0) // Utc.timestamp(0, 0)
} // }
}; // };
lockfile_repos.insert(id, LockfileRepoMetadata { generated }); // lockfile_repos.insert(id, LockfileRepoMetadata { generated });
} // }
let filename = Path::new(filename); let filename = Path::new(filename);
let lockfile_dir = openat::Dir::open(filename.parent().unwrap_or_else(|| Path::new("/")))?; let lockfile_dir = openat::Dir::open(filename.parent().unwrap_or_else(|| Path::new("/")))?;

View File

@ -465,7 +465,7 @@ early_main (void)
* controls a global var. And it's not just the `DnfContext` that uses it, but e.g. * 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 * `DnfSack` and Repo too. So just do this upfront. XXX: Clean up that API so it's always
* attached to a context object. */ * attached to a context object. */
dnf_context_set_config_file_path(""); // dnf_context_set_config_file_path("");
} }
static int static int

View File

@ -99,16 +99,16 @@ rpmostree_builtin_shlib_backend (int argc,
if (g_str_equal (arg, "get-basearch")) if (g_str_equal (arg, "get-basearch"))
{ {
g_autoptr(DnfContext) ctx = dnf_context_new (); // g_autoptr(DnfContext) ctx = dnf_context_new ();
ret = g_variant_new_string (dnf_context_get_base_arch (ctx)); // ret = g_variant_new_string (dnf_context_get_base_arch (ctx));
} }
else if (g_str_equal (arg, "varsubst-basearch")) else if (g_str_equal (arg, "varsubst-basearch"))
{ {
const char *src = argv[2]; const char *src = argv[2];
g_autoptr(DnfContext) ctx = dnf_context_new (); // g_autoptr(DnfContext) ctx = dnf_context_new ();
auto varsubsts = rpmostree_dnfcontext_get_varsubsts (ctx); // auto varsubsts = rpmostree_dnfcontext_get_varsubsts (ctx);
auto rets = rpmostreecxx::varsubstitute (src, *varsubsts); // auto rets = rpmostreecxx::varsubstitute (src, *varsubsts);
ret = g_variant_new_string (rets.c_str()); // ret = g_variant_new_string (rets.c_str());
} }
else if (g_str_equal (arg, "packagelist-from-commit")) else if (g_str_equal (arg, "packagelist-from-commit"))
{ {

View File

@ -26,8 +26,8 @@
#include <glib-unix.h> #include <glib-unix.h>
#include <gio/gunixoutputstream.h> #include <gio/gunixoutputstream.h>
#include <json-glib/json-glib.h> #include <json-glib/json-glib.h>
#include <libdnf/libdnf.h>
#include "libdnf_stub.h"
#include "rpmostree-builtins.h" #include "rpmostree-builtins.h"
#include "rpmostree-ex-builtins.h" #include "rpmostree-ex-builtins.h"
#include "rpmostree-libbuiltin.h" #include "rpmostree-libbuiltin.h"

View File

@ -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_autoptr(GPtrArray) repo_pkgs = g_ptr_array_new_with_free_func (g_free);
g_auto(GVariantBuilder) builder; g_auto(GVariantBuilder) builder;
// TODO: better API/cache for this // TODO: better API/cache for this
g_autoptr(DnfContext) ctx = dnf_context_new (); // g_autoptr(DnfContext) ctx = dnf_context_new ();
auto basearch = dnf_context_get_base_arch (ctx); // auto basearch = dnf_context_get_base_arch (ctx);
g_variant_builder_init (&builder, G_VARIANT_TYPE ("ah")); g_variant_builder_init (&builder, G_VARIANT_TYPE ("ah"));
for (const char *const* pkgiter = pkgs; pkgiter && *pkgiter; pkgiter++) for (const char *const* pkgiter = pkgs; pkgiter && *pkgiter; pkgiter++)
{ {
auto pkg = *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) if (fds.size() > 0)
{ {
for (const auto & fd: fds) for (const auto & fd: fds)

View File

@ -25,8 +25,8 @@
#include <json-glib/json-glib.h> #include <json-glib/json-glib.h>
#include <gio/gunixinputstream.h> #include <gio/gunixinputstream.h>
#include <gio/gunixoutputstream.h> #include <gio/gunixoutputstream.h>
#include <libdnf/libdnf.h> //#include <libdnf/libdnf.h>
#include <libdnf/dnf-repo.h> //#include <libdnf/dnf-repo.h>
#include <sys/mount.h> #include <sys/mount.h>
#include <stdio.h> #include <stdio.h>
#include <linux/magic.h> #include <linux/magic.h>
@ -37,6 +37,7 @@
#include <utility> #include <utility>
#include <optional> #include <optional>
#include "libdnf_stub.h"
#include "rpmostree-compose-builtins.h" #include "rpmostree-compose-builtins.h"
#include "rpmostree-util.h" #include "rpmostree-util.h"
#include "rpmostree-composeutil.h" #include "rpmostree-composeutil.h"
@ -274,8 +275,8 @@ install_packages (RpmOstreeTreeComposeContext *self,
{ {
int rootfs_dfd = self->rootfs_dfd; int rootfs_dfd = self->rootfs_dfd;
DnfContext *dnfctx = rpmostree_context_get_dnf (self->corectx); DnfContext *dnfctx = rpmostree_context_get_dnf (self->corectx);
if (opt_proxy) // if (opt_proxy)
dnf_context_set_http_proxy (dnfctx, opt_proxy); // dnf_context_set_http_proxy (dnfctx, opt_proxy);
/* Hack this here... see https://github.com/rpm-software-management/libhif/issues/53 /* 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 * 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"); { const char *debuglevel = getenv ("RPMOSTREE_RPM_VERBOSITY");
if (!debuglevel) if (!debuglevel)
debuglevel = "info"; debuglevel = "info";
dnf_context_set_rpm_verbosity (dnfctx, debuglevel); // dnf_context_set_rpm_verbosity (dnfctx, debuglevel);
rpmlogSetFile(NULL); rpmlogSetFile(NULL);
} }
{ int tf_dfd = (*self->treefile_rs)->get_workdir(); { int tf_dfd = (*self->treefile_rs)->get_workdir();
g_autofree char *abs_tf_path = glnx_fdrel_abspath (tf_dfd, "."); 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 /* 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. * we're doing unified core, in which case the pkgcache repo is the cache.
*/ */
if (opt_cachedir && !opt_unified_core) // if (opt_cachedir && !opt_unified_core)
dnf_context_set_keep_cache (dnfctx, TRUE); // dnf_context_set_keep_cache (dnfctx, TRUE);
/* For compose, always try to refresh metadata; we're used in build servers /* 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 * 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 * 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 */ /* FIXME - just do a depsolve here before we compute download requirements */
g_autofree char *ret_new_inputhash = NULL; g_autofree char *ret_new_inputhash = NULL;
if (!rpmostree_composeutil_checksum (dnf_context_get_goal (dnfctx), self->repo, // if (!rpmostree_composeutil_checksum (dnf_context_get_goal (dnfctx), self->repo,
**self->treefile_rs, self->treefile, // **self->treefile_rs, self->treefile,
&ret_new_inputhash, error)) // &ret_new_inputhash, error))
return FALSE; // return FALSE;
g_print ("Input state hash: %s\n", ret_new_inputhash); g_print ("Input state hash: %s\n", ret_new_inputhash);
@ -402,11 +403,11 @@ install_packages (RpmOstreeTreeComposeContext *self,
if (previous_inputhash) if (previous_inputhash)
{ {
if (strcmp (previous_inputhash, ret_new_inputhash) == 0) // if (strcmp (previous_inputhash, ret_new_inputhash) == 0)
{ // {
*out_unmodified = TRUE; // *out_unmodified = TRUE;
return TRUE; /* NB: early return */ // return TRUE; /* NB: early return */
} // }
} }
else else
g_print ("Previous commit found, but without rpmostree.inputhash metadata key\n"); 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 * https://github.com/projectatomic/rpm-ostree/issues/729
*/ */
g_auto(GLnxConsoleRef) console = { 0, }; 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", // guint progress_sigid = g_signal_connect (hifstate, "percentage-changed",
reinterpret_cast<GCallback>(on_hifstate_percentage_changed), // reinterpret_cast<GCallback>(on_hifstate_percentage_changed),
(void*)"Installing packages:"); // (void*)"Installing packages:");
glnx_console_lock (&console); glnx_console_lock (&console);
if (!rpmostree_composeutil_legacy_prep_dev (rootfs_dfd, error)) if (!rpmostree_composeutil_legacy_prep_dev (rootfs_dfd, error))
return FALSE; return FALSE;
if (!dnf_transaction_commit (dnf_context_get_transaction (dnfctx), // if (!dnf_transaction_commit (dnf_context_get_transaction (dnfctx),
dnf_context_get_goal (dnfctx), // dnf_context_get_goal (dnfctx),
hifstate, error)) // hifstate, error))
return FALSE; // return FALSE;
g_signal_handler_disconnect (hifstate, progress_sigid); // g_signal_handler_disconnect (hifstate, progress_sigid);
} }
if (out_unmodified) 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 */ /* FIXME refactor things to break the dependency of DnfContext -> arch -> treefile */
std::string arch; std::string arch;
{ {
g_autoptr(DnfContext) ctx = dnf_context_new (); // g_autoptr(DnfContext) ctx = dnf_context_new ();
arch = dnf_context_get_base_arch (ctx); // arch = dnf_context_get_base_arch (ctx);
} }
self->treefile_path = g_file_new_for_path (treefile_pathstr); 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); 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) GError **error)
{ {
g_autoptr(GPtrArray) pkgs = rpmostree_context_get_packages (self->corectx); g_autoptr(GPtrArray) pkgs = rpmostree_context_get_packages (self->corectx);
DnfContext *dnfctx = rpmostree_context_get_dnf (self->corectx); // DnfContext *dnfctx = rpmostree_context_get_dnf (self->corectx);
DnfSack *yum_sack = dnf_context_get_sack (dnfctx); // DnfSack *yum_sack = dnf_context_get_sack (dnfctx);
g_autoptr(GVariant) advisories = rpmostree_advisories_variant (yum_sack, pkgs); // g_autoptr(GVariant) advisories = rpmostree_advisories_variant (yum_sack, pkgs);
if (advisories && g_variant_n_children (advisories) > 0) // if (advisories && g_variant_n_children (advisories) > 0)
g_hash_table_insert (self->metadata, g_strdup ("rpmostree.advisories"), g_steal_pointer (&advisories)); // g_hash_table_insert (self->metadata, g_strdup ("rpmostree.advisories"), g_steal_pointer (&advisories));
return TRUE; return TRUE;
} }
@ -1535,7 +1536,7 @@ rpmostree_compose_builtin_extensions (int argc,
{ int tf_dfd = treefile->get_workdir(); { int tf_dfd = treefile->get_workdir();
g_autofree char *abs_tf_path = glnx_fdrel_abspath (tf_dfd, "."); 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" #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); g_autoptr(GPtrArray) extensions_pkgs = rpmostree_context_get_packages (ctx);
for (guint i = 0; i < extensions_pkgs->len; i++) for (guint i = 0; i < extensions_pkgs->len; i++)
{ {
DnfPackage *pkg = (DnfPackage*)extensions_pkgs->pdata[i]; // DnfPackage *pkg = (DnfPackage*)extensions_pkgs->pdata[i];
const char *src = dnf_package_get_filename (pkg); // const char *src = dnf_package_get_filename (pkg);
const char *basename = glnx_basename (src); // const char *basename = glnx_basename (src);
GLnxFileCopyFlags flags = static_cast<GLnxFileCopyFlags>(GLNX_FILE_COPY_NOXATTRS | GLNX_FILE_COPY_NOCHOWN); // GLnxFileCopyFlags flags = static_cast<GLnxFileCopyFlags>(GLNX_FILE_COPY_NOXATTRS | GLNX_FILE_COPY_NOCHOWN);
if (!glnx_file_copy_at (AT_FDCWD, dnf_package_get_filename (pkg), NULL, output_dfd, // if (!glnx_file_copy_at (AT_FDCWD, dnf_package_get_filename (pkg), NULL, output_dfd,
basename, flags, cancellable, error)) // basename, flags, cancellable, error))
return FALSE; // return FALSE;
} }
/* This is hacky: for "development" extensions, we don't want any depsolving /* 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 * against the base OS. Rather than awkwardly teach the core about this, we
* just reuse its sack and keep all the functionality here. */ * just reuse its sack and keep all the functionality here. */
DnfContext *dnfctx = rpmostree_context_get_dnf (ctx); // DnfContext *dnfctx = rpmostree_context_get_dnf (ctx);
DnfSack *sack = dnf_context_get_sack (dnfctx); // DnfSack *sack = dnf_context_get_sack (dnfctx);
/* disable the system repo; we always want to download, even if already in the base */ /* 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(); auto pkgs = extensions->get_development_packages();
g_autoptr(GPtrArray) devel_pkgs_to_download = g_autoptr(GPtrArray) devel_pkgs_to_download =
g_ptr_array_new_with_free_func (g_object_unref); g_ptr_array_new_with_free_func (g_object_unref);
for (auto & pkg : pkgs) for (auto & pkg : pkgs)
{ {
g_autoptr(GPtrArray) matches = rpmostree_get_matching_packages (sack, pkg.c_str()); // g_autoptr(GPtrArray) matches = rpmostree_get_matching_packages (sack, pkg.c_str());
if (matches->len == 0) // if (matches->len == 0)
return glnx_throw (error, "Package %s not found", pkg.c_str()); // return glnx_throw (error, "Package %s not found", pkg.c_str());
DnfPackage *found_pkg = (DnfPackage*)matches->pdata[0]; // DnfPackage *found_pkg = (DnfPackage*)matches->pdata[0];
g_ptr_array_add (devel_pkgs_to_download, g_object_ref (found_pkg)); // 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)) if (!rpmostree_download_packages (devel_pkgs_to_download, cancellable, error))
return FALSE; return FALSE;
for (guint i = 0; i < devel_pkgs_to_download->len; i++) for (guint i = 0; i < devel_pkgs_to_download->len; i++)
{ {
DnfPackage *pkg = (DnfPackage*)devel_pkgs_to_download->pdata[i]; // DnfPackage *pkg = (DnfPackage*)devel_pkgs_to_download->pdata[i];
const char *src = dnf_package_get_filename (pkg); // const char *src = dnf_package_get_filename (pkg);
const char *basename = glnx_basename (src); // const char *basename = glnx_basename (src);
GLnxFileCopyFlags flags = static_cast<GLnxFileCopyFlags>(GLNX_FILE_COPY_NOXATTRS | GLNX_FILE_COPY_NOCHOWN); // GLnxFileCopyFlags flags = static_cast<GLnxFileCopyFlags>(GLNX_FILE_COPY_NOXATTRS | GLNX_FILE_COPY_NOCHOWN);
if (!glnx_file_copy_at (AT_FDCWD, dnf_package_get_filename (pkg), NULL, output_dfd, // if (!glnx_file_copy_at (AT_FDCWD, dnf_package_get_filename (pkg), NULL, output_dfd,
basename, flags, cancellable, error)) // basename, flags, cancellable, error))
return FALSE; // return FALSE;
} }
// XXX: account for development extensions // XXX: account for development extensions

View File

@ -25,8 +25,8 @@
#include <json-glib/json-glib.h> #include <json-glib/json-glib.h>
#include <gio/gunixinputstream.h> #include <gio/gunixinputstream.h>
#include <gio/gunixoutputstream.h> #include <gio/gunixoutputstream.h>
#include <libdnf/libdnf.h> //#include <libdnf/libdnf.h>
#include <libdnf/dnf-repo.h> //#include <libdnf/dnf-repo.h>
#include <sys/mount.h> #include <sys/mount.h>
#include <stdio.h> #include <stdio.h>
#include <linux/magic.h> #include <linux/magic.h>
@ -35,6 +35,7 @@
#include <libglnx.h> #include <libglnx.h>
#include <rpm/rpmmacro.h> #include <rpm/rpmmacro.h>
#include "libdnf_stub.h"
#include "rpmostree-composeutil.h" #include "rpmostree-composeutil.h"
#include "rpmostree-util.h" #include "rpmostree-util.h"
#include "rpmostree-core.h" #include "rpmostree-core.h"

View File

@ -113,26 +113,26 @@ add_package_refs_to_set (RpmOstreeRefSack *rsack,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
g_autoptr(GPtrArray) pkglist = NULL; // g_autoptr(GPtrArray) pkglist = NULL;
hy_autoquery HyQuery query = hy_query_create (rsack->sack); // hy_autoquery HyQuery query = hy_query_create (rsack->sack);
hy_query_filter (query, HY_PKG_REPONAME, HY_EQ, HY_SYSTEM_REPO_NAME); // hy_query_filter (query, HY_PKG_REPONAME, HY_EQ, HY_SYSTEM_REPO_NAME);
pkglist = hy_query_run (query); // pkglist = hy_query_run (query);
/* TODO: convert this to an iterator to avoid lots of malloc */ /* 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"); return glnx_throw (error, "Failed to find any packages in root");
else // else
{ // {
for (guint i = 0; i < pkglist->len; i++) // for (guint i = 0; i < pkglist->len; i++)
{ // {
auto pkg = static_cast<DnfPackage *>(pkglist->pdata[i]); // auto pkg = static_cast<DnfPackage *>(pkglist->pdata[i]);
g_autofree char *pkgref = rpmostree_get_cache_branch_pkg (pkg); // g_autofree char *pkgref = rpmostree_get_cache_branch_pkg (pkg);
g_hash_table_add (referenced_pkgs, util::move_nullify (pkgref)); // g_hash_table_add (referenced_pkgs, util::move_nullify (pkgref));
} // }
} // }
return TRUE; // return TRUE;
} }
/* Loop over all deployments, gathering all referenced NEVRAs for /* Loop over all deployments, gathering all referenced NEVRAs for

View File

@ -689,14 +689,14 @@ finalize_removal_overrides (RpmOstreeSysrootUpgrader *self,
g_autoptr(GPtrArray) inactive_removals = g_ptr_array_new (); g_autoptr(GPtrArray) inactive_removals = g_ptr_array_new ();
GLNX_HASH_TABLE_FOREACH (removals, const char*, pkgname) GLNX_HASH_TABLE_FOREACH (removals, const char*, pkgname)
{ {
g_autoptr(DnfPackage) pkg = NULL; // g_autoptr(DnfPackage) pkg = NULL;
if (!rpmostree_sack_get_by_pkgname (self->rsack->sack, pkgname, &pkg, error)) // if (!rpmostree_sack_get_by_pkgname (self->rsack->sack, pkgname, &pkg, error))
return FALSE; // return FALSE;
//
if (pkg) // if (pkg)
g_ptr_array_add (ret_final_removals, g_strdup (pkgname)); // g_ptr_array_add (ret_final_removals, g_strdup (pkgname));
else // else
g_ptr_array_add (inactive_removals, (gpointer)pkgname); // g_ptr_array_add (inactive_removals, (gpointer)pkgname);
} }
if (inactive_removals->len > 0) 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)) if (!rpmostree_decompose_nevra (nevra, &pkgname, NULL, NULL, NULL, NULL, error))
return FALSE; return FALSE;
g_autoptr(DnfPackage) pkg = NULL; // g_autoptr(DnfPackage) pkg = NULL;
if (!rpmostree_sack_get_by_pkgname (self->rsack->sack, pkgname, &pkg, error)) // if (!rpmostree_sack_get_by_pkgname (self->rsack->sack, pkgname, &pkg, error))
return FALSE; // return FALSE;
//
/* make inactive if it's missing or if that exact nevra is already present */ // /* make inactive if it's missing or if that exact nevra is already present */
if (pkg && !rpmostree_sack_has_subject (self->rsack->sack, nevra)) // if (pkg && !rpmostree_sack_has_subject (self->rsack->sack, nevra))
{ // {
g_ptr_array_add (ret_final_local_replacements, // g_ptr_array_add (ret_final_local_replacements,
g_strconcat (sha256, ":", nevra, NULL)); // g_strconcat (sha256, ":", nevra, NULL));
} // }
else // else
g_ptr_array_add (inactive_replacements, (gpointer)nevra); // g_ptr_array_add (inactive_replacements, (gpointer)nevra);
} }
if (inactive_replacements->len > 0) if (inactive_replacements->len > 0)
@ -820,7 +820,7 @@ finalize_overlays (RpmOstreeSysrootUpgrader *self,
if (rpmostree_sack_has_subject (self->rsack->sack, nevra)) if (rpmostree_sack_has_subject (self->rsack->sack, nevra))
return glnx_throw (error, "Package '%s' is already in the base", 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. */ * that might be confusing to users. */
for (guint i = 0; i < matches->len; i++) for (guint i = 0; i < matches->len; i++)
{ {
auto pkg = static_cast<DnfPackage*>(matches->pdata[i]); // auto pkg = static_cast<DnfPackage*>(matches->pdata[i]);
const char *name = dnf_package_get_name (pkg); // const char *name = dnf_package_get_name (pkg);
const char *repo = dnf_package_get_reponame (pkg); // const char *repo = dnf_package_get_reponame (pkg);
//
if (g_strcmp0 (repo, HY_CMDLINE_REPO_NAME) == 0) // if (g_strcmp0 (repo, HY_CMDLINE_REPO_NAME) == 0)
continue; /* local RPM added up above */ // continue; /* local RPM added up above */
//
if (g_hash_table_contains (removals, name)) // if (g_hash_table_contains (removals, name))
return glnx_throw (error, // return glnx_throw (error,
"Cannot request '%s' provided by removed package '%s'", // "Cannot request '%s' provided by removed package '%s'",
pattern, dnf_package_get_nevra (pkg)); // pattern, dnf_package_get_nevra (pkg));
} }
/* Otherwise, it's an inactive request: remember them so we can print a nice notice. /* Otherwise, it's an inactive request: remember them so we can print a nice notice.
* Just use the first package as the "providing" pkg. */ * Just use the first package as the "providing" pkg. */
const char *providing_nevra = dnf_package_get_nevra (static_cast<DnfPackage*>(matches->pdata[0])); // const char *providing_nevra = dnf_package_get_nevra (static_cast<DnfPackage*>(matches->pdata[0]));
g_hash_table_insert (inactive_requests, (gpointer)pattern, // g_hash_table_insert (inactive_requests, (gpointer)pattern,
g_strdup (providing_nevra)); // g_strdup (providing_nevra));
} }
if (g_hash_table_size (inactive_requests) > 0) 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; self->layering_type = RPMOSTREE_SYSROOT_UPGRADER_LAYERING_RPMMD_REPOS;
/* keep a ref on it in case the level higher up needs it */ /* keep a ref on it in case the level higher up needs it */
self->rpmmd_sack = // self->rpmmd_sack =
(DnfSack*)g_object_ref (dnf_context_get_sack (rpmostree_context_get_dnf (self->ctx))); // (DnfSack*)g_object_ref (dnf_context_get_sack (rpmostree_context_get_dnf (self->ctx)));
} }
else else
{ {

View File

@ -536,15 +536,16 @@ modified_dnfpkg_variant_new (RpmOstreePkgTypes type,
RpmOstreePackage *pkg_old, RpmOstreePackage *pkg_old,
DnfPackage *pkg_new) DnfPackage *pkg_new)
{ {
const char *name_old = rpm_ostree_package_get_name (pkg_old); // const char *name_old = rpm_ostree_package_get_name (pkg_old);
const char *name_new = dnf_package_get_name (pkg_new); // const char *name_new = dnf_package_get_name (pkg_new);
g_assert_cmpstr (name_old, ==, name_new); // g_assert_cmpstr (name_old, ==, name_new);
return g_variant_ref_sink ( // return g_variant_ref_sink (
g_variant_new ("(us(ss)(ss))", type, name_old, // g_variant_new ("(us(ss)(ss))", type, name_old,
rpm_ostree_package_get_evr (pkg_old), // rpm_ostree_package_get_evr (pkg_old),
rpm_ostree_package_get_arch (pkg_old), // rpm_ostree_package_get_arch (pkg_old),
dnf_package_get_evr (pkg_new), // dnf_package_get_evr (pkg_new),
dnf_package_get_arch (pkg_new))); // dnf_package_get_arch (pkg_new)));
return NULL;
} }
static gboolean static gboolean
@ -668,24 +669,25 @@ find_package (DnfSack *sack,
gboolean newer, gboolean newer,
RpmOstreePackage *pkg) RpmOstreePackage *pkg)
{ {
hy_autoquery HyQuery query = hy_query_create (sack); // 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_NAME, HY_EQ, rpm_ostree_package_get_name (pkg));
if (newer) // if (newer)
{ // {
hy_query_filter (query, HY_PKG_EVR, HY_GT, rpm_ostree_package_get_evr (pkg)); // 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 (query, HY_PKG_ARCH, HY_NEQ, "src");
hy_query_filter_latest (query, TRUE); // hy_query_filter_latest (query, TRUE);
} // }
else // else
{ // {
/* we want an exact match */ // /* we want an exact match */
hy_query_filter (query, HY_PKG_NEVRA, HY_EQ, rpm_ostree_package_get_nevra (pkg)); // hy_query_filter (query, HY_PKG_NEVRA, HY_EQ, rpm_ostree_package_get_nevra (pkg));
} // }
g_autoptr(GPtrArray) pkgs = hy_query_run (query); // g_autoptr(GPtrArray) pkgs = hy_query_run (query);
if (pkgs->len == 0) // if (pkgs->len == 0)
return NULL; /* canonicalize to NULL */ // return NULL; /* canonicalize to NULL */
g_ptr_array_sort (pkgs, (GCompareFunc)rpmostree_pkg_array_compare); // g_ptr_array_sort (pkgs, (GCompareFunc)rpmostree_pkg_array_compare);
return (DnfPackage*)g_object_ref (pkgs->pdata[pkgs->len-1]); // 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 /* 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++) for (guint i = 0; i < all_layered_pkgs->len; i++)
{ {
auto pkg = static_cast<RpmOstreePackage *>(all_layered_pkgs->pdata[i]); auto pkg = static_cast<RpmOstreePackage *>(all_layered_pkgs->pdata[i]);
g_autoptr(DnfPackage) newer_pkg = find_package (sack, TRUE, pkg); // g_autoptr(DnfPackage) newer_pkg = find_package (sack, TRUE, pkg);
if (!newer_pkg) // if (!newer_pkg)
continue; // continue;
//
g_ptr_array_add (newer_packages, g_object_ref (newer_pkg)); // g_ptr_array_add (newer_packages, g_object_ref (newer_pkg));
rpm_diff_add_layered_diff (rpm_diff, pkg, newer_pkg); // rpm_diff_add_layered_diff (rpm_diff, pkg, newer_pkg);
} }
/* canonicalize to NULL if there's nothing new */ /* 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++) for (guint i = 0; i < n; i++)
{ {
auto pkg = static_cast<RpmOstreePackage*>(rpm_ostree_pkgs->pdata[i]); auto pkg = static_cast<RpmOstreePackage*>(rpm_ostree_pkgs->pdata[i]);
hy_autoquery HyQuery query = hy_query_create (sack); // 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_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_EVR, HY_EQ, rpm_ostree_package_get_evr (pkg));
hy_query_filter (query, HY_PKG_ARCH, HY_EQ, rpm_ostree_package_get_arch (pkg)); // hy_query_filter (query, HY_PKG_ARCH, HY_EQ, rpm_ostree_package_get_arch (pkg));
g_autoptr(GPtrArray) pkgs = hy_query_run (query); // g_autoptr(GPtrArray) pkgs = hy_query_run (query);
//
/* 0 --> ostree stream is out of sync with rpmmd repos probably? */ // /* 0 --> ostree stream is out of sync with rpmmd repos probably? */
if (pkgs->len > 0) // if (pkgs->len > 0)
g_ptr_array_add (dnf_pkgs, g_object_ref (pkgs->pdata[0])); // g_ptr_array_add (dnf_pkgs, g_object_ref (pkgs->pdata[0]));
} }
return util::move_nullify (dnf_pkgs); return util::move_nullify (dnf_pkgs);

View File

@ -19,8 +19,9 @@
#pragma once #pragma once
#include <ostree.h> #include <ostree.h>
#include <libdnf/libdnf.h> //#include <libdnf/libdnf.h>
#include "libdnf_stub.h"
#include "rpmostreed-types.h" #include "rpmostreed-types.h"
G_BEGIN_DECLS G_BEGIN_DECLS

View File

@ -740,13 +740,13 @@ get_sack_for_booted (OstreeSysroot *sysroot,
rpmostree_context_configure_from_deployment (ctx, sysroot, booted_deployment); rpmostree_context_configure_from_deployment (ctx, sysroot, booted_deployment);
/* streamline: we don't need rpmdb or filelists, but we *do* need updateinfo */ /* streamline: we don't need rpmdb or filelists, but we *do* need updateinfo */
if (!rpmostree_context_download_metadata (ctx, // if (!rpmostree_context_download_metadata (ctx,
(DnfContextSetupSackFlags)(DNF_CONTEXT_SETUP_SACK_FLAG_SKIP_RPMDB | // (DnfContextSetupSackFlags)(DNF_CONTEXT_SETUP_SACK_FLAG_SKIP_RPMDB |
DNF_CONTEXT_SETUP_SACK_FLAG_SKIP_FILELISTS | // DNF_CONTEXT_SETUP_SACK_FLAG_SKIP_FILELISTS |
DNF_CONTEXT_SETUP_SACK_FLAG_LOAD_UPDATEINFO), cancellable, error)) // DNF_CONTEXT_SETUP_SACK_FLAG_LOAD_UPDATEINFO), cancellable, error))
return FALSE; // return FALSE;
//
*out_sack = (DnfSack*)g_object_ref (dnf_context_get_sack (dnfctx)); // *out_sack = (DnfSack*)g_object_ref (dnf_context_get_sack (dnfctx));
return TRUE; return TRUE;
} }
@ -1155,8 +1155,8 @@ deploy_transaction_execute (RpmostreedTransaction *transaction,
g_autoptr(GString) pkgnames = g_string_new (""); g_autoptr(GString) pkgnames = g_string_new ("");
for (guint i = 0; i < pkgs->len; i++) for (guint i = 0; i < pkgs->len; i++)
{ {
auto p = static_cast<DnfPackage *>(pkgs->pdata[i]); // auto p = static_cast<DnfPackage *>(pkgs->pdata[i]);
g_string_append_printf (pkgnames, " %s", dnf_package_get_nevra (p)); // g_string_append_printf (pkgnames, " %s", dnf_package_get_nevra (p));
} }
return glnx_throw (error, "\"%s\" is already provided by:%s. Use " return glnx_throw (error, "\"%s\" is already provided by:%s. Use "
"--allow-inactive to explicitly " "--allow-inactive to explicitly "
@ -1363,8 +1363,8 @@ deploy_transaction_execute (RpmostreedTransaction *transaction,
return glnx_throw (error, "Multiple packages match \"%s\"", pkg); return glnx_throw (error, "Multiple packages match \"%s\"", pkg);
/* canonicalize to just the pkg name */ /* canonicalize to just the pkg name */
const char *pkgname = dnf_package_get_name (static_cast<DnfPackage*>(pkgs->pdata[0])); // const char *pkgname = dnf_package_get_name (static_cast<DnfPackage*>(pkgs->pdata[0]));
g_ptr_array_add (pkgnames, (void*)pkgname); // g_ptr_array_add (pkgnames, (void*)pkgname);
} }
g_ptr_array_add (pkgnames, NULL); 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'", return glnx_throw (error, "Refusing to download rpm-md for offline OS '%s'",
self->osname); self->osname);
g_autoptr(DnfSack) sack = NULL; // g_autoptr(DnfSack) sack = NULL;
if (g_hash_table_size (rpmostree_origin_get_packages (origin)) > 0) // if (g_hash_table_size (rpmostree_origin_get_packages (origin)) > 0)
{ // {
if (!get_sack_for_booted (sysroot, repo, booted_deployment, &sack, // if (!get_sack_for_booted (sysroot, repo, booted_deployment, &sack,
cancellable, error)) // cancellable, error))
return FALSE; // return FALSE;
} // }
//
if (!generate_update_variant (repo, booted_deployment, NULL, sack, // if (!generate_update_variant (repo, booted_deployment, NULL, sack,
cancellable, error)) // cancellable, error))
return FALSE; // return FALSE;
/* Note early return */ /* Note early return */
return TRUE; return TRUE;
@ -2305,9 +2305,9 @@ refresh_md_transaction_execute (RpmostreedTransaction *transaction,
rpmostree_context_configure_from_deployment (ctx, sysroot, cfg_merge_deployment); rpmostree_context_configure_from_deployment (ctx, sysroot, cfg_merge_deployment);
/* don't even bother loading the rpmdb */ /* don't even bother loading the rpmdb */
if (!rpmostree_context_download_metadata (ctx, DNF_CONTEXT_SETUP_SACK_FLAG_SKIP_RPMDB, // if (!rpmostree_context_download_metadata (ctx, DNF_CONTEXT_SETUP_SACK_FLAG_SKIP_RPMDB,
cancellable, error)) // cancellable, error))
return FALSE; // return FALSE;
return TRUE; return TRUE;
} }
@ -2386,21 +2386,21 @@ modify_yum_repo_transaction_finalize (GObject *object)
G_OBJECT_CLASS (modify_yum_repo_transaction_parent_class)->finalize (object); G_OBJECT_CLASS (modify_yum_repo_transaction_parent_class)->finalize (object);
} }
static DnfRepo * //static DnfRepo *
get_dnf_repo_by_id (RpmOstreeContext *ctx, const char *repo_id) //get_dnf_repo_by_id (RpmOstreeContext *ctx, const char *repo_id)
{ //{
DnfContext *dnfctx = rpmostree_context_get_dnf (ctx); // DnfContext *dnfctx = rpmostree_context_get_dnf (ctx);
//
GPtrArray *repos = dnf_context_get_repos (dnfctx); // GPtrArray *repos = dnf_context_get_repos (dnfctx);
for (guint i = 0; i < repos->len; i++) // for (guint i = 0; i < repos->len; i++)
{ // {
auto repo = static_cast<DnfRepo *>(repos->pdata[i]); // auto repo = static_cast<DnfRepo *>(repos->pdata[i]);
if (g_strcmp0 (dnf_repo_get_id (repo), repo_id) == 0) // if (g_strcmp0 (dnf_repo_get_id (repo), repo_id) == 0)
return repo; // return repo;
} // }
//
return NULL; // return NULL;
} //}
static gboolean static gboolean
modify_yum_repo_transaction_execute (RpmostreedTransaction *transaction, modify_yum_repo_transaction_execute (RpmostreedTransaction *transaction,
@ -2427,8 +2427,8 @@ modify_yum_repo_transaction_execute (RpmostreedTransaction *transaction,
/* point libdnf to our repos dir */ /* point libdnf to our repos dir */
rpmostree_context_configure_from_deployment (ctx, sysroot, cfg_merge_deployment); rpmostree_context_configure_from_deployment (ctx, sysroot, cfg_merge_deployment);
DnfRepo *repo = get_dnf_repo_by_id (ctx, self->repo_id); // DnfRepo *repo = get_dnf_repo_by_id (ctx, self->repo_id);
if (repo == NULL) // if (repo == NULL)
return glnx_throw (error, "Yum repo '%s' not found", self->repo_id); return glnx_throw (error, "Yum repo '%s' not found", self->repo_id);
GVariantIter iter; GVariantIter iter;
@ -2450,11 +2450,11 @@ modify_yum_repo_transaction_execute (RpmostreedTransaction *transaction,
g_strcmp0 (value, "1") != 0) g_strcmp0 (value, "1") != 0)
return glnx_throw (error, "Only '0' and '1' are allowed for the '%s' key", parameter); 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; return FALSE;
} }
if (!dnf_repo_commit (repo, error)) // if (!dnf_repo_commit (repo, error))
return FALSE; return FALSE;
return TRUE; return TRUE;

49
src/libpriv/libdnf_stub.h Normal file
View File

@ -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;

File diff suppressed because it is too large Load Diff

View File

@ -21,12 +21,12 @@
#pragma once #pragma once
#include <gio/gio.h> #include <gio/gio.h>
#include <libdnf/libdnf.h>
#include <ostree.h> #include <ostree.h>
#include <memory> #include <memory>
#include "rpmostree-cxxrs.h" #include "rpmostree-cxxrs.h"
#include "libglnx.h" #include "libglnx.h"
#include "libdnf_stub.h"
// C++ APIs // C++ APIs

View File

@ -36,7 +36,7 @@ namespace rpmostreecxx {
} }
// XXX: really should just include! libdnf.hxx in the bridge // XXX: really should just include! libdnf.hxx in the bridge
#include <libdnf/libdnf.h> #include "libdnf_stub.h"
namespace dnfcxx { namespace dnfcxx {
typedef ::DnfPackage DnfPackage; typedef ::DnfPackage DnfPackage;
typedef ::DnfRepo DnfRepo; typedef ::DnfRepo DnfRepo;

View File

@ -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 /* For now, just the id...in the future maybe we'll add more, but this is
* enough to provide useful semantics. * enough to provide useful semantics.
*/ */
g_variant_builder_add (&builder, "{sv}", // g_variant_builder_add (&builder, "{sv}",
"id", g_variant_new_string (dnf_repo_get_id (repo))); // "id", g_variant_new_string (dnf_repo_get_id (repo)));
g_variant_builder_add (&builder, "{sv}", // g_variant_builder_add (&builder, "{sv}",
"timestamp", g_variant_new_uint64 (dnf_repo_get_timestamp_generated (repo))); // "timestamp", g_variant_new_uint64 (dnf_repo_get_timestamp_generated (repo)));
return g_variant_builder_end (&builder); return g_variant_builder_end (&builder);
} }
@ -438,12 +438,12 @@ build_metadata_variant (RpmOstreeImporter *self,
if (self->pkg) if (self->pkg)
{ {
DnfRepo *repo = dnf_package_get_repo (self->pkg); // DnfRepo *repo = dnf_package_get_repo (self->pkg);
if (repo) // if (repo)
{ // {
g_variant_builder_add (&metadata_builder, "{sv}", "rpmostree.repo", // g_variant_builder_add (&metadata_builder, "{sv}", "rpmostree.repo",
repo_metadata_for_package (repo)); // repo_metadata_for_package (repo));
} // }
/* include a checksum of the RPM as a whole; the actual algo used depends /* 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 */ * on how the repodata was created, so just keep a repr */

View File

@ -24,7 +24,7 @@
#include "libglnx.h" #include "libglnx.h"
#include <rpm/rpmlib.h> #include <rpm/rpmlib.h>
#include <libdnf/libdnf.h> #include "libdnf_stub.h"
G_BEGIN_DECLS G_BEGIN_DECLS

View File

@ -22,7 +22,8 @@
#pragma once #pragma once
#include <gio/gio.h> #include <gio/gio.h>
#include <libdnf/libdnf.h> //#include <libdnf/libdnf.h>
#include "libdnf_stub.h"
#include "libglnx.h" #include "libglnx.h"
G_BEGIN_DECLS G_BEGIN_DECLS

View File

@ -22,7 +22,8 @@
#pragma once #pragma once
#include <gio/gio.h> #include <gio/gio.h>
#include <libdnf/libdnf.h> #include <rpm/rpmtypes.h>
//#include <libdnf/libdnf.h>
#include "libglnx.h" #include "libglnx.h"
G_BEGIN_DECLS G_BEGIN_DECLS

View File

@ -853,16 +853,16 @@ get_sack_for_root (int dfd,
g_autofree char *fullpath = glnx_fdrel_abspath (dfd, path); g_autofree char *fullpath = glnx_fdrel_abspath (dfd, path);
g_autoptr(DnfSack) sack = dnf_sack_new (); // g_autoptr(DnfSack) sack = dnf_sack_new ();
dnf_sack_set_rootdir (sack, fullpath); // dnf_sack_set_rootdir (sack, fullpath);
//
if (!dnf_sack_setup (sack, 0, error)) // if (!dnf_sack_setup (sack, 0, error))
return FALSE; // return FALSE;
//
if (!dnf_sack_load_system_repo (sack, NULL, 0, error)) // if (!dnf_sack_load_system_repo (sack, NULL, 0, error))
return FALSE; // return FALSE;
//
*out_sack = util::move_nullify (sack); // *out_sack = util::move_nullify (sack);
return TRUE; return TRUE;
} }
@ -873,10 +873,11 @@ rpmostree_get_refsack_for_root (int dfd,
const char *path, const char *path,
GError **error) GError **error)
{ {
g_autoptr(DnfSack) sack = NULL; /* NB: refsack adds a ref to it */ // g_autoptr(DnfSack) sack = NULL; /* NB: refsack adds a ref to it */
if (!get_sack_for_root (dfd, path, &sack, error)) // if (!get_sack_for_root (dfd, path, &sack, error))
// return NULL;
// return rpmostree_refsack_new (sack, NULL);
return 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 /* 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)) if (!mk_rpmdb_compat_symlinks (tmpdir.fd, cancellable, error))
return FALSE; return FALSE;
g_autoptr(DnfSack) sack = NULL; /* NB: refsack adds a ref to it */ // g_autoptr(DnfSack) sack = NULL; /* NB: refsack adds a ref to it */
if (!get_sack_for_root (tmpdir.fd, ".", &sack, error)) // if (!get_sack_for_root (tmpdir.fd, ".", &sack, error))
return FALSE; // return FALSE;
//
*out_sack = rpmostree_refsack_new (sack, &tmpdir); // *out_sack = rpmostree_refsack_new (sack, &tmpdir);
return TRUE; return TRUE;
} }
@ -936,12 +937,12 @@ rpmostree_get_refsack_for_commit (OstreeRepo *repo,
&tmpdir, cancellable, error)) &tmpdir, cancellable, error))
return NULL; return NULL;
g_autoptr(DnfSack) hsack = NULL; /* NB: refsack adds a ref to it */ // g_autoptr(DnfSack) hsack = NULL; /* NB: refsack adds a ref to it */
if (!get_sack_for_root (tmpdir.fd, ".", &hsack, error)) // if (!get_sack_for_root (tmpdir.fd, ".", &hsack, error))
return NULL; return NULL;
/* Ownership of tmpdir is transferred */ /* 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. /* 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)) &tmpdir, cancellable, error))
return NULL; return NULL;
g_autoptr(DnfSack) hsack = NULL; /* NB: refsack adds a ref to it */ // g_autoptr(DnfSack) hsack = NULL; /* NB: refsack adds a ref to it */
if (!get_sack_for_root (tmpdir.fd, ".", &hsack, error)) // if (!get_sack_for_root (tmpdir.fd, ".", &hsack, error))
return NULL; return NULL;
/* Ownership of tmpdir is transferred */ /* Ownership of tmpdir is transferred */
return rpmostree_refsack_new (hsack, &tmpdir); // return rpmostree_refsack_new (hsack, &tmpdir);
} }
static RpmOstreeRefTs* static RpmOstreeRefTs*
@ -1015,7 +1016,7 @@ gint
rpmostree_pkg_array_compare (DnfPackage **p_pkg1, rpmostree_pkg_array_compare (DnfPackage **p_pkg1,
DnfPackage **p_pkg2) DnfPackage **p_pkg2)
{ {
return dnf_package_cmp (*p_pkg1, *p_pkg2); return 0;//dnf_package_cmp (*p_pkg1, *p_pkg2);
} }
void void
@ -1031,9 +1032,9 @@ print_pkglist (GPtrArray *pkglist)
for (guint i = 0; i < pkglist->len; i++) for (guint i = 0; i < pkglist->len; i++)
{ {
auto pkg = static_cast<DnfPackage *>(pkglist->pdata[i]); // auto pkg = static_cast<DnfPackage *>(pkglist->pdata[i]);
rpmostree_output_message (" %s (%s)", dnf_package_get_nevra (pkg), // rpmostree_output_message (" %s (%s)", dnf_package_get_nevra (pkg),
dnf_package_get_reponame (pkg)); // dnf_package_get_reponame (pkg));
} }
} }
@ -1043,33 +1044,33 @@ rpmostree_print_transaction (DnfContext *dnfctx)
gboolean empty = TRUE; gboolean empty = TRUE;
{ g_autoptr(GPtrArray) packages = NULL; { g_autoptr(GPtrArray) packages = NULL;
packages = dnf_goal_get_packages (dnf_context_get_goal (dnfctx), // packages = dnf_goal_get_packages (dnf_context_get_goal (dnfctx),
DNF_PACKAGE_INFO_INSTALL, // DNF_PACKAGE_INFO_INSTALL,
DNF_PACKAGE_INFO_REINSTALL, // DNF_PACKAGE_INFO_REINSTALL,
DNF_PACKAGE_INFO_DOWNGRADE, // DNF_PACKAGE_INFO_DOWNGRADE,
DNF_PACKAGE_INFO_UPDATE, // DNF_PACKAGE_INFO_UPDATE,
-1); // -1);
//
if (packages->len > 0) // if (packages->len > 0)
{ // {
empty = FALSE; // empty = FALSE;
rpmostree_output_message ("Installing %u packages:", packages->len); // rpmostree_output_message ("Installing %u packages:", packages->len);
print_pkglist (packages); // print_pkglist (packages);
} // }
} }
{ g_autoptr(GPtrArray) packages = NULL; { g_autoptr(GPtrArray) packages = NULL;
packages = dnf_goal_get_packages (dnf_context_get_goal (dnfctx), // packages = dnf_goal_get_packages (dnf_context_get_goal (dnfctx),
DNF_PACKAGE_INFO_REMOVE, // DNF_PACKAGE_INFO_REMOVE,
DNF_PACKAGE_INFO_OBSOLETE, // DNF_PACKAGE_INFO_OBSOLETE,
-1); // -1);
//
if (packages->len > 0) // if (packages->len > 0)
{ // {
empty = FALSE; // empty = FALSE;
rpmostree_output_message ("Removing %u packages:", packages->len); // rpmostree_output_message ("Removing %u packages:", packages->len);
print_pkglist (packages); // print_pkglist (packages);
} // }
} }
if (empty) if (empty)
@ -1157,23 +1158,23 @@ get_repodata_chksum_repr (DnfPackage &pkg)
const unsigned char *chksum_raw = NULL; const unsigned char *chksum_raw = NULL;
/* for rpmdb packages, use the hdr checksum */ /* for rpmdb packages, use the hdr checksum */
if (dnf_package_installed (&pkg)) // if (dnf_package_installed (&pkg))
chksum_raw = dnf_package_get_hdr_chksum (&pkg, &chksum_type); // chksum_raw = dnf_package_get_hdr_chksum (&pkg, &chksum_type);
else // else
chksum_raw = dnf_package_get_chksum (&pkg, &chksum_type); // chksum_raw = dnf_package_get_chksum (&pkg, &chksum_type);
if (chksum_raw) // if (chksum_raw)
chksum = hy_chksum_str (chksum_raw, chksum_type); // chksum = hy_chksum_str (chksum_raw, chksum_type);
//
if (chksum == NULL) // if (chksum == NULL)
{ // {
// TODO try out the tinyformat.hpp in libdnf // // 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)); // g_autofree char *msg = g_strdup_printf ("Couldn't get chksum for pkg %s", dnf_package_get_nevra(&pkg));
throw std::runtime_error (msg); // throw std::runtime_error (msg);
} // }
// Would be nice to expose a format!() equivalent on rust::String // Would be nice to expose a format!() equivalent on rust::String
std::ostringstream ss; std::ostringstream ss;
ss << hy_chksum_name (chksum_type) << ":" << chksum; // ss << hy_chksum_name (chksum_type) << ":" << chksum;
return rust::String(ss.str()); return rust::String(ss.str());
} }
} }
@ -1184,15 +1185,15 @@ rpmostree_get_matching_packages (DnfSack *sack,
{ {
/* mimic dnf_context_install() */ /* mimic dnf_context_install() */
g_autoptr(GPtrArray) matches = NULL; g_autoptr(GPtrArray) matches = NULL;
HySelector selector = NULL; // HySelector selector = NULL;
HySubject subject = NULL; // HySubject subject = NULL;
//
subject = hy_subject_create (pattern); // subject = hy_subject_create (pattern);
selector = hy_subject_get_best_selector (subject, sack, NULL, FALSE, NULL); // selector = hy_subject_get_best_selector (subject, sack, NULL, FALSE, NULL);
matches = hy_selector_matches (selector); // matches = hy_selector_matches (selector);
//
hy_selector_free (selector); // hy_selector_free (selector);
hy_subject_free (subject); // hy_subject_free (subject);
return util::move_nullify (matches); return util::move_nullify (matches);
} }
@ -1213,28 +1214,28 @@ rpmostree_sack_get_by_pkgname (DnfSack *sack,
DnfPackage **out_pkg, DnfPackage **out_pkg,
GError **error) GError **error)
{ {
g_autoptr(DnfPackage) ret_pkg = NULL; // g_autoptr(DnfPackage) ret_pkg = NULL;
hy_autoquery HyQuery query = hy_query_create (sack); // hy_autoquery HyQuery query = hy_query_create (sack);
hy_query_filter (query, HY_PKG_NAME, HY_EQ, pkgname); // hy_query_filter (query, HY_PKG_NAME, HY_EQ, pkgname);
g_autoptr(GPtrArray) pkgs = hy_query_run (query); // 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) // *out_pkg = util::move_nullify (ret_pkg);
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);
return TRUE; return TRUE;
} }
GPtrArray* GPtrArray*
rpmostree_sack_get_packages (DnfSack *sack) rpmostree_sack_get_packages (DnfSack *sack)
{ {
hy_autoquery HyQuery query = hy_query_create (sack); // hy_autoquery HyQuery query = hy_query_create (sack);
hy_query_filter (query, HY_PKG_REPONAME, HY_EQ, HY_SYSTEM_REPO_NAME); // hy_query_filter (query, HY_PKG_REPONAME, HY_EQ, HY_SYSTEM_REPO_NAME);
return hy_query_run (query); return NULL;// hy_query_run (query);
} }
GPtrArray* GPtrArray*
@ -1257,16 +1258,16 @@ rpmostree_variant_pkgs_from_sack (RpmOstreeRefSack *refsack)
const guint n = pkglist->len; const guint n = pkglist->len;
for (guint i = 0; i < n; i++) for (guint i = 0; i < n; i++)
{ {
auto pkg = static_cast<DnfPackage *>(pkglist->pdata[i]); // auto pkg = static_cast<DnfPackage *>(pkglist->pdata[i]);
//
/* put epoch as a string so we're indifferent to endianness -- also note that unlike // /* 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 */ // * 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_autofree char *epoch = g_strdup_printf ("%" PRIu64, dnf_package_get_epoch (pkg));
g_variant_builder_add (&pkglist_v_builder, "(sssss)", // g_variant_builder_add (&pkglist_v_builder, "(sssss)",
dnf_package_get_name (pkg), epoch, // dnf_package_get_name (pkg), epoch,
dnf_package_get_version (pkg), // dnf_package_get_version (pkg),
dnf_package_get_release (pkg), // dnf_package_get_release (pkg),
dnf_package_get_arch (pkg)); // dnf_package_get_arch (pkg));
} }
return g_variant_ref_sink (g_variant_builder_end (&pkglist_v_builder)); 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 *release = NULL;
g_autofree char *arch = 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); return glnx_throw (error, "Failed to decompose NEVRA string '%s'", nevra);
if (out_name) if (out_name)
@ -1422,9 +1423,10 @@ rpmostree_get_cache_branch_header (Header hdr)
char * char *
rpmostree_get_cache_branch_pkg (DnfPackage *pkg) rpmostree_get_cache_branch_pkg (DnfPackage *pkg)
{ {
return rpmostree_get_cache_branch_for_n_evr_a (dnf_package_get_name (pkg), // return rpmostree_get_cache_branch_for_n_evr_a (dnf_package_get_name (pkg),
dnf_package_get_evr (pkg), // dnf_package_get_evr (pkg),
dnf_package_get_arch (pkg)); // dnf_package_get_arch (pkg));
return NULL;
} }
GPtrArray* GPtrArray*
@ -1432,14 +1434,14 @@ rpmostree_get_enabled_rpmmd_repos (DnfContext *dnfctx,
DnfRepoEnabled enablement) DnfRepoEnabled enablement)
{ {
g_autoptr(GPtrArray) ret = g_ptr_array_new (); g_autoptr(GPtrArray) ret = g_ptr_array_new ();
GPtrArray *repos = dnf_context_get_repos (dnfctx); // GPtrArray *repos = dnf_context_get_repos (dnfctx);
//
for (guint i = 0; i < repos->len; i++) // for (guint i = 0; i < repos->len; i++)
{ // {
auto repo = static_cast<DnfRepo *>(repos->pdata[i]); // auto repo = static_cast<DnfRepo *>(repos->pdata[i]);
if (dnf_repo_get_enabled (repo) & enablement) // if (dnf_repo_get_enabled (repo) & enablement)
g_ptr_array_add (ret, repo); // g_ptr_array_add (ret, repo);
} // }
return util::move_nullify (ret); 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 /* 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 * 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. */ * all the juicy details. A naive strcmp() sort on the URL gives us this. */
DnfAdvisoryRef *a = *((DnfAdvisoryRef**)ap); // DnfAdvisoryRef *a = *((DnfAdvisoryRef**)ap);
DnfAdvisoryRef *b = *((DnfAdvisoryRef**)bp); // DnfAdvisoryRef *b = *((DnfAdvisoryRef**)bp);
//
g_assert (a); // g_assert (a);
g_assert (b); // g_assert (b);
//
/* just use g_strcmp0() here to tolerate NULL URLs for now if that somehow happens... we // /* 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 */ // * filter them out later when going through all the references */
return g_strcmp0 (dnf_advisoryref_get_url (a), dnf_advisoryref_get_url (b)); return 0;// g_strcmp0 (dnf_advisoryref_get_url (a), dnf_advisoryref_get_url (b));
} }
/* Returns a *floating* variant ref representing the advisory */ /* Returns a *floating* variant ref representing the advisory */
static GVariant* //static GVariant*
advisory_variant_new (DnfAdvisory *adv, //advisory_variant_new (DnfAdvisory *adv,
GPtrArray *pkgs) // GPtrArray *pkgs)
{ //{
static gsize cve_regex_initialized; // static gsize cve_regex_initialized;
static GRegex *cve_regex; // static GRegex *cve_regex;
//
#define CVE_REGEXP "CVE-[0-9]+-[0-9]+" //#define CVE_REGEXP "CVE-[0-9]+-[0-9]+"
//
if (g_once_init_enter (&cve_regex_initialized)) // if (g_once_init_enter (&cve_regex_initialized))
{ // {
cve_regex = g_regex_new ("\\b" CVE_REGEXP "\\b", static_cast<GRegexCompileFlags>(0), static_cast<GRegexMatchFlags>(0), NULL); // cve_regex = g_regex_new ("\\b" CVE_REGEXP "\\b", static_cast<GRegexCompileFlags>(0), static_cast<GRegexMatchFlags>(0), NULL);
g_assert (cve_regex); // g_assert (cve_regex);
g_once_init_leave (&cve_regex_initialized, 1); // g_once_init_leave (&cve_regex_initialized, 1);
} // }
//
#undef CVE_REGEXP //#undef CVE_REGEXP
//
g_auto(GVariantBuilder) builder; // g_auto(GVariantBuilder) builder;
g_variant_builder_init (&builder, G_VARIANT_TYPE_TUPLE); // 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, "s", dnf_advisory_get_id (adv));
g_variant_builder_add (&builder, "u", dnf_advisory_get_kind (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_variant_builder_add (&builder, "u", str2severity (dnf_advisory_get_severity (adv)));
//
{ g_auto(GVariantBuilder) pkgs_array; // { g_auto(GVariantBuilder) pkgs_array;
g_variant_builder_init (&pkgs_array, G_VARIANT_TYPE ("as")); // g_variant_builder_init (&pkgs_array, G_VARIANT_TYPE ("as"));
for (guint i = 0; i < pkgs->len; i++) // for (guint i = 0; i < pkgs->len; i++)
g_variant_builder_add (&pkgs_array, "s", dnf_package_get_nevra (static_cast<DnfPackage*>(pkgs->pdata[i]))); // g_variant_builder_add (&pkgs_array, "s", dnf_package_get_nevra (static_cast<DnfPackage*>(pkgs->pdata[i])));
g_variant_builder_add_value (&builder, g_variant_builder_end (&pkgs_array)); // g_variant_builder_add_value (&builder, g_variant_builder_end (&pkgs_array));
} // }
//
/* final a{sv} for any additional metadata */ // /* final a{sv} for any additional metadata */
g_auto(GVariantDict) dict; // g_auto(GVariantDict) dict;
g_variant_dict_init (&dict, NULL); // g_variant_dict_init (&dict, NULL);
//
{ g_auto(GVariantBuilder) cve_references; // { g_auto(GVariantBuilder) cve_references;
g_variant_builder_init (&cve_references, G_VARIANT_TYPE ("a(ss)")); // 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 */ // /* we maintain a set to make sure we only add the earliest ref for each CVE */
g_autoptr(GHashTable) created_cves = // g_autoptr(GHashTable) created_cves =
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); // g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
//
g_autoptr(GPtrArray) refs = dnf_advisory_get_references (adv); // g_autoptr(GPtrArray) refs = dnf_advisory_get_references (adv);
g_ptr_array_sort (refs, compare_advisory_refs); // 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 // /* for each ref, look for CVEs in their title, and add an (ss) for refs which mention
* new CVEs. */ // * new CVEs. */
for (guint i = 0; i < refs->len; i++) // for (guint i = 0; i < refs->len; i++)
{ // {
auto ref = static_cast<DnfAdvisoryRef *>(refs->pdata[i]); // auto ref = static_cast<DnfAdvisoryRef *>(refs->pdata[i]);
if (dnf_advisoryref_get_kind (ref) != DNF_REFERENCE_KIND_BUGZILLA) // if (dnf_advisoryref_get_kind (ref) != DNF_REFERENCE_KIND_BUGZILLA)
continue; // continue;
//
g_autoptr(GMatchInfo) match = NULL; // g_autoptr(GMatchInfo) match = NULL;
const char *title = dnf_advisoryref_get_title (ref); // const char *title = dnf_advisoryref_get_title (ref);
const char *url = dnf_advisoryref_get_url (ref); // const char *url = dnf_advisoryref_get_url (ref);
//
if (!url || !title) // if (!url || !title)
continue; // continue;
//
if (!g_regex_match (cve_regex, title, static_cast<GRegexMatchFlags>(0), &match)) // if (!g_regex_match (cve_regex, title, static_cast<GRegexMatchFlags>(0), &match))
continue; // continue;
//
/* collect all the found CVEs first */ // /* collect all the found CVEs first */
g_autoptr(GPtrArray) found_cves = g_ptr_array_new_with_free_func (g_free); // g_autoptr(GPtrArray) found_cves = g_ptr_array_new_with_free_func (g_free);
while (g_match_info_matches (match)) // while (g_match_info_matches (match))
{ // {
g_ptr_array_add (found_cves, g_match_info_fetch (match, 0)); // g_ptr_array_add (found_cves, g_match_info_fetch (match, 0));
g_match_info_next (match, NULL); // g_match_info_next (match, NULL);
} // }
//
gboolean has_new_cve = FALSE; // gboolean has_new_cve = FALSE;
for (guint i = 0; i < found_cves->len && !has_new_cve; i++) // 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]); // 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 a single CVE is new, make a GVariant for it */
if (has_new_cve) // if (has_new_cve)
{ // {
g_variant_builder_add (&cve_references, "(ss)", url, title); // g_variant_builder_add (&cve_references, "(ss)", url, title);
/* steal all the cves and transfer to set, autofree'ing dupes */ // /* steal all the cves and transfer to set, autofree'ing dupes */
g_ptr_array_add (found_cves, NULL); // g_ptr_array_add (found_cves, NULL);
g_autofree char **cves = // g_autofree char **cves =
(char**)g_ptr_array_free (util::move_nullify (found_cves), FALSE); // (char**)g_ptr_array_free (util::move_nullify (found_cves), FALSE);
for (char **cve = cves; cve && *cve; cve++) // for (char **cve = cves; cve && *cve; cve++)
g_hash_table_add (created_cves, *cve); // g_hash_table_add (created_cves, *cve);
} // }
} // }
g_variant_dict_insert_value (&dict, "cve_references", // g_variant_dict_insert_value (&dict, "cve_references",
g_variant_builder_end (&cve_references)); // g_variant_builder_end (&cve_references));
} // }
g_variant_builder_add_value (&builder, g_variant_dict_end (&dict)); // g_variant_builder_add_value (&builder, g_variant_dict_end (&dict));
//
return g_variant_builder_end (&builder); // return g_variant_builder_end (&builder);
} //}
/* libdnf creates new DnfAdvisory objects on request */ /* libdnf creates new DnfAdvisory objects on request */
static guint static guint
advisory_hash (gconstpointer v) 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 static gboolean
advisory_equal (gconstpointer v1, advisory_equal (gconstpointer v1,
gconstpointer v2) gconstpointer v2)
{ {
return g_str_equal (dnf_advisory_get_id ((DnfAdvisory*)v1), return FALSE;//g_str_equal (dnf_advisory_get_id ((DnfAdvisory*)v1),
dnf_advisory_get_id ((DnfAdvisory*)v2)); // dnf_advisory_get_id ((DnfAdvisory*)v2));
} }
/* adds noop-on-NULL semantics so we can steal in advisories_variant() */ /* adds noop-on-NULL semantics so we can steal in advisories_variant() */
static void static void
advisory_free (gpointer p) advisory_free (gpointer p)
{ {
auto adv = static_cast<DnfAdvisory*>(p); // auto adv = static_cast<DnfAdvisory*>(p);
if (adv) // if (adv)
dnf_advisory_free (adv); // dnf_advisory_free (adv);
} }
/* Go through the list of @pkgs and check if there are any advisories open for them. If /* 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; /* libdnf provides pkg -> set of advisories, but we want advisory -> set of pkgs;
* making sure we only keep the pkgs we actually care about */ * making sure we only keep the pkgs we actually care about */
for (guint i = 0; i < pkgs->len; i++) // for (guint i = 0; i < pkgs->len; i++)
{ // {
auto pkg = static_cast<DnfPackage *>(pkgs->pdata[i]); // auto pkg = static_cast<DnfPackage *>(pkgs->pdata[i]);
g_autoptr(GPtrArray) advisories_with_pkg = dnf_package_get_advisories (pkg, HY_EQ); // g_autoptr(GPtrArray) advisories_with_pkg = dnf_package_get_advisories (pkg, HY_EQ);
for (guint j = 0; j < advisories_with_pkg->len; j++) // for (guint j = 0; j < advisories_with_pkg->len; j++)
{ // {
auto advisory = static_cast<DnfAdvisory *>(advisories_with_pkg->pdata[j]); // auto advisory = static_cast<DnfAdvisory *>(advisories_with_pkg->pdata[j]);
//
/* for now we're only interested in security erratas */ // /* for now we're only interested in security erratas */
if (dnf_advisory_get_kind (advisory) != DNF_ADVISORY_KIND_SECURITY) // if (dnf_advisory_get_kind (advisory) != DNF_ADVISORY_KIND_SECURITY)
continue; // continue;
//
/* reverse mapping */ // /* reverse mapping */
auto pkgs_in_advisory = static_cast<GPtrArray *>(g_hash_table_lookup (advisories, advisory)); // auto pkgs_in_advisory = static_cast<GPtrArray *>(g_hash_table_lookup (advisories, advisory));
if (!pkgs_in_advisory) // if (!pkgs_in_advisory)
{ // {
/* take it out of the array, transferring ownership to the hash table; there's // /* 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 */ // * g_ptr_array_steal_index() we could use, but it's still very new */
advisories_with_pkg->pdata[j] = NULL; // advisories_with_pkg->pdata[j] = NULL;
pkgs_in_advisory = // pkgs_in_advisory =
g_ptr_array_new_with_free_func ((GDestroyNotify)g_object_unref); // g_ptr_array_new_with_free_func ((GDestroyNotify)g_object_unref);
g_hash_table_insert (advisories, advisory, pkgs_in_advisory); // g_hash_table_insert (advisories, advisory, pkgs_in_advisory);
} // }
g_ptr_array_add (pkgs_in_advisory, g_object_ref (pkg)); // g_ptr_array_add (pkgs_in_advisory, g_object_ref (pkg));
} // }
} // }
if (g_hash_table_size (advisories) == 0) if (g_hash_table_size (advisories) == 0)
return NULL; return NULL;
g_auto(GVariantBuilder) builder; g_auto(GVariantBuilder) builder;
g_variant_builder_init (&builder, RPMOSTREE_UPDATE_ADVISORY_GVARIANT_FORMAT); g_variant_builder_init (&builder, RPMOSTREE_UPDATE_ADVISORY_GVARIANT_FORMAT);
GLNX_HASH_TABLE_FOREACH_KV (advisories, DnfAdvisory*, advisory, GPtrArray*, pkgs) // GLNX_HASH_TABLE_FOREACH_KV (advisories, DnfAdvisory*, advisory, GPtrArray*, pkgs)
g_variant_builder_add_value (&builder, advisory_variant_new (advisory, pkgs)); // g_variant_builder_add_value (&builder, advisory_variant_new (advisory, pkgs));
return g_variant_ref_sink (g_variant_builder_end (&builder)); return g_variant_ref_sink (g_variant_builder_end (&builder));
} }

View File

@ -26,6 +26,8 @@
#include <rpm/rpmlib.h> #include <rpm/rpmlib.h>
#include <rpm/rpmlog.h> #include <rpm/rpmlog.h>
#include <rpm/rpmdb.h> #include <rpm/rpmdb.h>
#include <rpm/rpmfi.h>
#include <rpm/rpmts.h>
#include "libglnx.h" #include "libglnx.h"
#include "rpmostree-util.h" #include "rpmostree-util.h"
#include "rpmostree-refsack.h" #include "rpmostree-refsack.h"

View File

@ -244,11 +244,11 @@ rpmostree_script_txn_validate (DnfPackage *package,
if (!(headerIsEntry (hdr, tagval) || headerIsEntry (hdr, progtagval))) if (!(headerIsEntry (hdr, tagval) || headerIsEntry (hdr, progtagval)))
continue; continue;
if (!rpmostreecxx::script_is_ignored (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", // 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); // dnf_package_get_name (package), desc);
} // }
} }
return TRUE; return TRUE;
@ -485,7 +485,7 @@ impl_run_rpm_script (const KnownRpmScriptKind *rpmscript,
const rpmFlags flags = headerGetNumber (hdr, rpmscript->flagtag); const rpmFlags flags = headerGetNumber (hdr, rpmscript->flagtag);
const char *script; const char *script;
const char *interp = (args && args[0]) ? args[0] : "/bin/sh"; 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; gboolean expand = (flags & RPMSCRIPT_FLAG_EXPAND) > 0;
if (g_str_equal (interp, lua_builtin)) 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++) for (guint i = 0; i < G_N_ELEMENTS (lua_replacements); i++)
{ {
const RpmOstreeLuaReplacement *repl = &lua_replacements[i]; const RpmOstreeLuaReplacement *repl = &lua_replacements[i];
if (!g_str_equal (repl->pkgname_script, pkg_scriptid)) // if (!g_str_equal (repl->pkgname_script, pkg_scriptid))
continue; // continue;
found_replacement = TRUE; found_replacement = TRUE;
interp = repl->interp; interp = repl->interp;
script = repl->replacement; script = repl->replacement;
@ -504,13 +504,13 @@ impl_run_rpm_script (const KnownRpmScriptKind *rpmscript,
if (!found_replacement) if (!found_replacement)
{ {
/* No override found, throw an error and return */ /* 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; return FALSE;
} }
/* Hack around RHEL7's glibc-locales, which uses rpm-expand in the Lua script */ /* Hack around RHEL7's glibc-locales, which uses rpm-expand in the Lua script */
if (strcmp (pkg_scriptid, "glibc-common.post") == 0) // if (strcmp (pkg_scriptid, "glibc-common.post") == 0)
expand = TRUE; // expand = TRUE;
} }
else else
{ {
@ -519,11 +519,11 @@ impl_run_rpm_script (const KnownRpmScriptKind *rpmscript,
for (guint i = 0; i < G_N_ELEMENTS (script_replacements); i++) for (guint i = 0; i < G_N_ELEMENTS (script_replacements); i++)
{ {
const RpmOstreeScriptReplacement *repl = &script_replacements[i]; const RpmOstreeScriptReplacement *repl = &script_replacements[i];
if (!g_str_equal (repl->pkgname_script, pkg_scriptid)) // if (!g_str_equal (repl->pkgname_script, pkg_scriptid))
continue; // continue;
if (repl->release_suffix && // if (repl->release_suffix &&
!g_str_has_suffix (dnf_package_get_release (pkg), repl->release_suffix)) // !g_str_has_suffix (dnf_package_get_release (pkg), repl->release_suffix))
continue; // continue;
/* Is this completely suppressing the script? If so, we're done */ /* Is this completely suppressing the script? If so, we're done */
if (!repl->interp) if (!repl->interp)
return TRUE; 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 */ /* http://ftp.rpm.org/max-rpm/s1-rpm-inside-scripts.html#S2-RPM-INSIDE-ERASE-TIME-SCRIPTS */
const char *script_arg = NULL; const char *script_arg = NULL;
switch (dnf_package_get_action (pkg)) // switch (dnf_package_get_action (pkg))
{ // {
/* XXX: we're not running *un scripts for removals yet, though it'd look like: // /* XXX: we're not running *un scripts for removals yet, though it'd look like:
case DNF_STATE_ACTION_REMOVE: // case DNF_STATE_ACTION_REMOVE:
case DNF_STATE_ACTION_OBSOLETE: // case DNF_STATE_ACTION_OBSOLETE:
script_arg = obsoleted_by_update ? "1" : "0"; // script_arg = obsoleted_by_update ? "1" : "0";
break; // break;
*/ // */
case DNF_STATE_ACTION_INSTALL: // case DNF_STATE_ACTION_INSTALL:
script_arg = "1"; // script_arg = "1";
break; // break;
case DNF_STATE_ACTION_UPDATE: // case DNF_STATE_ACTION_UPDATE:
script_arg = "2"; // script_arg = "2";
break; // break;
case DNF_STATE_ACTION_DOWNGRADE: // case DNF_STATE_ACTION_DOWNGRADE:
script_arg = "2"; // script_arg = "2";
break; // break;
default: // default:
/* we shouldn't have been asked to perform for any other kind of action */ // /* we shouldn't have been asked to perform for any other kind of action */
g_assert_not_reached (); // g_assert_not_reached ();
break; // break;
} // }
guint64 start_time_ms = g_get_monotonic_time () / 1000; guint64 start_time_ms = g_get_monotonic_time () / 1000;
if (!rpmostree_run_script_in_bwrap_container (rootfs_fd, var_lib_rpm_statedir, enable_fuse, // if (!rpmostree_run_script_in_bwrap_container (rootfs_fd, var_lib_rpm_statedir, enable_fuse,
dnf_package_get_name (pkg), // dnf_package_get_name (pkg),
rpmscript->desc, interp, script, script_arg, // rpmscript->desc, interp, script, script_arg,
-1, cancellable, error)) // -1, cancellable, error))
return glnx_prefix_error (error, "Running %s for %s", rpmscript->desc, dnf_package_get_name (pkg)); // 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 end_time_ms = g_get_monotonic_time () / 1000;
guint64 elapsed_ms = end_time_ms - start_time_ms; 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), // 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, // "MESSAGE=Executed %s for %s in %" G_GUINT64_FORMAT " ms", rpmscript->desc, dnf_package_get_name (pkg), elapsed_ms,
"SCRIPT_TYPE=%s", rpmscript->desc, // "SCRIPT_TYPE=%s", rpmscript->desc,
"PKG=%s", dnf_package_get_name (pkg), // "PKG=%s", dnf_package_get_name (pkg),
"EXEC_TIME_MS=%" G_GUINT64_FORMAT, elapsed_ms, // "EXEC_TIME_MS=%" G_GUINT64_FORMAT, elapsed_ms,
NULL); // NULL);
return TRUE; return TRUE;
} }
@ -609,8 +609,8 @@ run_script (const KnownRpmScriptKind *rpmscript,
return TRUE; return TRUE;
const char *desc = rpmscript->desc; const char *desc = rpmscript->desc;
if (rpmostreecxx::script_is_ignored (dnf_package_get_name (pkg), desc)) // if (rpmostreecxx::script_is_ignored (dnf_package_get_name (pkg), desc))
return TRUE; /* Note early return */ // return TRUE; /* Note early return */
*out_did_run = TRUE; *out_did_run = TRUE;
return impl_run_rpm_script (rpmscript, pkg, hdr, rootfs_fd, var_lib_rpm_statedir, 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++) for (guint i = 0; i < pkgs->len; i++)
{ {
auto pkg = static_cast<DnfPackage *>(pkgs->pdata[i]); auto pkg = static_cast<DnfPackage *>(pkgs->pdata[i]);
const char *nevra = dnf_package_get_nevra (pkg); // const char *nevra = dnf_package_get_nevra (pkg);
if (!rpmostree_sack_has_subject (sack, nevra)) // if (!rpmostree_sack_has_subject (sack, nevra))
return glnx_throw (error, "Didn't find package '%s'", nevra); // return glnx_throw (error, "Didn't find package '%s'", nevra);
} }
return TRUE; return TRUE;
@ -1019,11 +1019,11 @@ rpmostree_deployment_sanitycheck_rpmdb (int rootfs_fd,
else else
{ {
/* OK, let's just sanity check that there are *some* packages in the rpmdb */ /* OK, let's just sanity check that there are *some* packages in the rpmdb */
hy_autoquery HyQuery query = hy_query_create (sack->sack); // hy_autoquery HyQuery query = hy_query_create (sack->sack);
hy_query_filter (query, HY_PKG_REPONAME, HY_EQ, HY_SYSTEM_REPO_NAME); // hy_query_filter (query, HY_PKG_REPONAME, HY_EQ, HY_SYSTEM_REPO_NAME);
g_autoptr(GPtrArray) pkgs = hy_query_run (query); // g_autoptr(GPtrArray) pkgs = hy_query_run (query);
if (pkgs->len == 0) // if (pkgs->len == 0)
return glnx_throw (error, "No packages found in rpmdb!"); // return glnx_throw (error, "No packages found in rpmdb!");
} }
sd_journal_print (LOG_INFO, "sanitycheck(rpmdb) successful"); sd_journal_print (LOG_INFO, "sanitycheck(rpmdb) successful");

View File

@ -28,8 +28,8 @@
#include <rpm/rpmfi.h> #include <rpm/rpmfi.h>
#include <rpm/rpmmacro.h> #include <rpm/rpmmacro.h>
#include <rpm/rpmts.h> #include <rpm/rpmts.h>
#include <libdnf/libdnf.h>
#include "libdnf_stub.h"
#include "libglnx.h" #include "libglnx.h"
G_BEGIN_DECLS G_BEGIN_DECLS

View File

@ -24,7 +24,7 @@
#include "libglnx.h" #include "libglnx.h"
#include <rpm/rpmlib.h> #include <rpm/rpmlib.h>
#include <libdnf/libdnf.h> #include "libdnf_stub.h"
#include <archive.h> #include <archive.h>
#include <archive_entry.h> #include <archive_entry.h>

View File

@ -87,9 +87,10 @@ _rpmostree_util_update_checksum_from_file (GChecksum *checksum,
gboolean gboolean
rpmostree_pkg_is_local (DnfPackage *pkg) rpmostree_pkg_is_local (DnfPackage *pkg)
{ {
const char *reponame = dnf_package_get_reponame (pkg); // const char *reponame = dnf_package_get_reponame (pkg);
return (g_strcmp0 (reponame, HY_CMDLINE_REPO_NAME) == 0 || // return (g_strcmp0 (reponame, HY_CMDLINE_REPO_NAME) == 0 ||
dnf_repo_is_local (dnf_package_get_repo (pkg))); // dnf_repo_is_local (dnf_package_get_repo (pkg)));
return FALSE;
} }
/* Returns the local filesystem path for a package; for non-local packages, /* Returns the local filesystem path for a package; for non-local packages,
@ -98,16 +99,17 @@ rpmostree_pkg_is_local (DnfPackage *pkg)
char * char *
rpmostree_pkg_get_local_path (DnfPackage *pkg) rpmostree_pkg_get_local_path (DnfPackage *pkg)
{ {
DnfRepo *pkg_repo = dnf_package_get_repo (pkg); return NULL;
const gboolean is_local = rpmostree_pkg_is_local (pkg); // DnfRepo *pkg_repo = dnf_package_get_repo (pkg);
if (is_local) // const gboolean is_local = rpmostree_pkg_is_local (pkg);
return g_strdup (dnf_package_get_filename (pkg)); // if (is_local)
else // 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), // const char *pkg_location = dnf_package_get_location (pkg);
"packages", glnx_basename (pkg_location), NULL); // return g_build_filename (dnf_repo_get_location (pkg_repo),
} // "packages", glnx_basename (pkg_location), NULL);
// }
} }
gboolean gboolean

View File

@ -29,8 +29,9 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <ostree.h> #include <ostree.h>
#include <libdnf/libdnf.h> //#include <libdnf/libdnf.h>
#include "libdnf_stub.h"
#include "libglnx.h" #include "libglnx.h"
#include "rpmostree.h" #include "rpmostree.h"
#include "rpmostree-types.h" #include "rpmostree-types.h"