I see a possible solution:

a = base.sack.query().filter(name='TestA')
for pkg in a:
    print([pkg])
    if pkg.installed:
        yumdb_info = base._yumdb.get_package(pkg)
        print(yumdb_info.checksum_type, yumdb_info.checksum_data)
    else:
        try:
            type, checksum = pkg.returnIdSum()
            print(type, checksum)
        except AttributeError:
            print('returnIdSum()_error')

But it uses private object _yumdb. In near future we will replace it with SWDB.

Have a nice time

     Jaroslav


On Wed, Aug 2, 2017 at 5:52 PM, Ian Pilcher <[email protected]> wrote:

> I would like to the the DNF API (python-dnf) to determine the source
> repository for the packages that are installed on a system.  (I am aware
> that this is not necessarily possible for every package, but it should
> be possible for the vast majority of packages on an up-to-date system.)
>
> It is straightforward to iterate through the installed packages and
> search for matching packages in a sack that was filled with
> fill_sack(load_system_repo=False, load_available_repos=True) --
> filtering on either NVRA or NEVRA.
>
> If possible, I would like to take the further step of validating that
> checksum of the installed package matches that of any available
> packages.  However, I'm having trouble figuring out how to do this.  It
> seems that installed packages have only a hdr_chksum attribute while
> available packages have only a chksum attribute.  (Attempting to read
> the hdr_chksum of an available package or the chksum attribute of an
> installed packages raises a "No such checksum" AttributeError.
>
> Is the NVRA/NEVRA match the best that can be done?
>
> --
> ========================================================================
> Ian Pilcher                                         [email protected]
> -------- "I grew up before Mark Zuckerberg invented friendship" --------
> ========================================================================
> _______________________________________________
> Rpm-ecosystem mailing list
> [email protected]
> http://lists.rpm.org/mailman/listinfo/rpm-ecosystem
>
_______________________________________________
Rpm-ecosystem mailing list
[email protected]
http://lists.rpm.org/mailman/listinfo/rpm-ecosystem

Reply via email to