Skip to content

Commit

Permalink
Add arch as a parameter to package_meta
Browse files Browse the repository at this point in the history
Without this, `package_meta` is unable to distinguish between copies of
the same package installed for different architectures; for example,
many systems need both the `x86_64` and `i686` version of glibc.
  • Loading branch information
jordemort committed Jul 11, 2024
1 parent 8df0f59 commit 3919eaa
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 16 deletions.
5 changes: 3 additions & 2 deletions rpmostree-cxxrs.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3246,15 +3246,16 @@ extern "C"

::rust::repr::PtrLen
rpmostreecxx$cxxbridge1$RpmTs$package_meta (::rpmostreecxx::RpmTs const &self, ::rust::Str name,
::rust::Str arch,
::rpmostreecxx::PackageMeta **return$) noexcept
{
::std::unique_ptr< ::rpmostreecxx::PackageMeta> (::rpmostreecxx::RpmTs::*package_meta$) (
::rust::Str) const
::rust::Str, ::rust::Str) const
= &::rpmostreecxx::RpmTs::package_meta;
::rust::repr::PtrLen throw$;
::rust::behavior::trycatch (
[&] {
new (return$)::rpmostreecxx::PackageMeta *((self.*package_meta$) (name).release ());
new (return$)::rpmostreecxx::PackageMeta *((self.*package_meta$) (name, arch).release ());
throw$.ptr = nullptr;
},
::rust::detail::Fail (throw$));
Expand Down
4 changes: 3 additions & 1 deletion rust/src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,10 @@ pub fn container_encapsulate(args: Vec<String>) -> CxxResult<()> {
for pkg in pkglist.iter() {
let name = pkg.child_value(0);
let name = name.str().unwrap();
let arch = pkg.child_value(4);
let arch = arch.str().unwrap();
let nevra = Rc::from(gv_nevra_to_string(&pkg).into_boxed_str());
let pkgmeta = q.package_meta(name)?;
let pkgmeta = q.package_meta(name, arch)?;
let buildtime = pkgmeta.buildtime();
if let Some((lowid, lowtime)) = lowest_change_time.as_mut() {
if *lowtime > buildtime {
Expand Down
2 changes: 1 addition & 1 deletion rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ pub mod ffi {
fn rpmdb_package_name_list(dfd: i32, path: String) -> Result<Vec<String>>;

// Methods on RpmTs
fn package_meta(self: &RpmTs, name: &str) -> Result<UniquePtr<PackageMeta>>;
fn package_meta(self: &RpmTs, name: &str, arch: &str) -> Result<UniquePtr<PackageMeta>>;

// Methods on PackageMeta
fn size(self: &PackageMeta) -> u64;
Expand Down
26 changes: 15 additions & 11 deletions src/libpriv/rpmostree-refts.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,10 @@ RpmTs::RpmTs (RpmOstreeRefTs *ts) { _ts = ts; }
RpmTs::~RpmTs () { rpmostree_refts_unref (_ts); }

std::unique_ptr<PackageMeta>
RpmTs::package_meta (const rust::Str name) const
RpmTs::package_meta (const rust::Str name, const rust::Str arch) const
{
auto name_c = std::string (name);
auto arch_c = std::string (arch);
g_auto (rpmdbMatchIterator) mi = rpmtsInitIterator (_ts->ts, RPMDBI_NAME, name_c.c_str (), 0);
if (mi == NULL)
{
Expand All @@ -163,18 +164,21 @@ RpmTs::package_meta (const rust::Str name) const
std::unique_ptr<PackageMeta> retval;
while ((h = rpmdbNextIterator (mi)) != NULL)
{
// TODO: Somehow we get two `libgcc-8.5.0-10.el8.x86_64` in current RHCOS, I don't
// understand that.
if (retval != nullptr)
if (strcmp (headerGetString (h, RPMTAG_ARCH), arch_c.c_str ()) == 0)
{
auto nevra = header_get_nevra (h);
g_autofree char *buf
= g_strdup_printf ("Multiple installed '%s' (%s, %s)", name_c.c_str (),
retval->nevra ().c_str (), nevra.c_str ());
throw std::runtime_error (buf);
// TODO: Somehow we get two `libgcc-8.5.0-10.el8.x86_64` in current RHCOS, I don't
// understand that.
if (retval != nullptr)
{
auto nevra = header_get_nevra (h);
g_autofree char *buf
= g_strdup_printf ("Multiple installed '%s' (%s, %s)", name_c.c_str (),
retval->nevra ().c_str (), nevra.c_str ());
throw std::runtime_error (buf);
}

retval = std::make_unique<PackageMeta> (h);
}

retval = std::make_unique<PackageMeta> (h);
}
if (retval == nullptr)
g_assert_not_reached ();
Expand Down
2 changes: 1 addition & 1 deletion src/libpriv/rpmostree-refts.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class RpmTs
RpmTs (::RpmOstreeRefTs *ts);
~RpmTs ();
rpmts get_ts () const;
std::unique_ptr<PackageMeta> package_meta (const rust::Str package) const;
std::unique_ptr<PackageMeta> package_meta (const rust::Str name, const rust::Str arch) const;

private:
::RpmOstreeRefTs *_ts;
Expand Down
1 change: 1 addition & 0 deletions tests/compose-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ packages:
- vim-minimal
- coreutils
- dnf dnf-yum
- glibc glibc.i686
- sudo
repos:
- fedora # Intentially using frozen GA repo
Expand Down

0 comments on commit 3919eaa

Please sign in to comment.