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"]
path = libglnx
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",
]
[[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"

View File

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

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) \
-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)

1
libdnf

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

View File

@ -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<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
*/
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<P: AsRef<Path>>(filename: P) -> Result<LockfileConfig> {
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<P: AsRef<Path>>(filename: P) -> Result<LockfileConfig> {
// 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<P: AsRef<Path>>(filenames: &[P]) -> Result<LockfileConfig> {
let mut final_lockfile: Option<LockfileConfig> = 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<P: AsRef<Path>>(filenames: &[P]) -> Result<LockfileCo
} else {
final_lockfile = Some(lf);
}
}
} */
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();
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_ref = unsafe { &mut *(&mut pkg.0 as *mut _ as *mut libdnf_sys::DnfPackage) };
let name = dnf_package_get_name(pkg_ref).unwrap();
@ -382,7 +382,7 @@ pub(crate) fn lockfile_write(
metadata: None,
},
);
}
}*/
/* just take the ref here to be less verbose */
let lockfile_repos = lockfile
@ -393,27 +393,27 @@ pub(crate) fn lockfile_write(
.as_mut()
.unwrap();
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 });
}
// 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("/")))?;

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.
* `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

View File

@ -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"))
{

View File

@ -26,8 +26,8 @@
#include <glib-unix.h>
#include <gio/gunixoutputstream.h>
#include <json-glib/json-glib.h>
#include <libdnf/libdnf.h>
#include "libdnf_stub.h"
#include "rpmostree-builtins.h"
#include "rpmostree-ex-builtins.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_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)

View File

@ -25,8 +25,8 @@
#include <json-glib/json-glib.h>
#include <gio/gunixinputstream.h>
#include <gio/gunixoutputstream.h>
#include <libdnf/libdnf.h>
#include <libdnf/dnf-repo.h>
//#include <libdnf/libdnf.h>
//#include <libdnf/dnf-repo.h>
#include <sys/mount.h>
#include <stdio.h>
#include <linux/magic.h>
@ -37,6 +37,7 @@
#include <utility>
#include <optional>
#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<GCallback>(on_hifstate_percentage_changed),
(void*)"Installing packages:");
// guint progress_sigid = g_signal_connect (hifstate, "percentage-changed",
// reinterpret_cast<GCallback>(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<GLnxFileCopyFlags>(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<GLnxFileCopyFlags>(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<GLnxFileCopyFlags>(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<GLnxFileCopyFlags>(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

View File

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

View File

@ -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<DnfPackage *>(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<DnfPackage *>(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

View File

@ -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<DnfPackage*>(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<DnfPackage*>(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<DnfPackage*>(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<DnfPackage*>(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
{

View File

@ -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<RpmOstreePackage *>(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<RpmOstreePackage*>(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);

View File

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

View File

@ -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<DnfPackage *>(pkgs->pdata[i]);
g_string_append_printf (pkgnames, " %s", dnf_package_get_nevra (p));
// auto p = static_cast<DnfPackage *>(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<DnfPackage*>(pkgs->pdata[0]));
g_ptr_array_add (pkgnames, (void*)pkgname);
// 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, 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<DnfRepo *>(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<DnfRepo *>(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;

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
#include <gio/gio.h>
#include <libdnf/libdnf.h>
#include <ostree.h>
#include <memory>
#include "rpmostree-cxxrs.h"
#include "libglnx.h"
#include "libdnf_stub.h"
// C++ APIs

View File

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

View File

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

View File

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

View File

@ -22,7 +22,8 @@
#pragma once
#include <gio/gio.h>
#include <libdnf/libdnf.h>
#include <rpm/rpmtypes.h>
//#include <libdnf/libdnf.h>
#include "libglnx.h"
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_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<DnfPackage *>(pkglist->pdata[i]);
rpmostree_output_message (" %s (%s)", dnf_package_get_nevra (pkg),
dnf_package_get_reponame (pkg));
// auto pkg = static_cast<DnfPackage *>(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<DnfPackage *>(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<DnfPackage *>(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<DnfRepo *>(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<DnfRepo *>(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<GRegexCompileFlags>(0), static_cast<GRegexMatchFlags>(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<DnfPackage*>(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<DnfAdvisoryRef *>(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<GRegexMatchFlags>(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<GRegexCompileFlags>(0), static_cast<GRegexMatchFlags>(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<DnfPackage*>(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<DnfAdvisoryRef *>(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<GRegexMatchFlags>(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<DnfAdvisory*>(p);
if (adv)
dnf_advisory_free (adv);
// auto adv = static_cast<DnfAdvisory*>(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<DnfPackage *>(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<DnfAdvisory *>(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<GPtrArray *>(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<DnfPackage *>(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<DnfAdvisory *>(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<GPtrArray *>(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));
}

View File

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

View File

@ -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<DnfPackage *>(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");

View File

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

View File

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

View File

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

View File

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