Re: How do I get the source package _name_ from an RPM?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I think I might have a solution for you. In our team, we are using a small utility called pkgname (see attachment).

On Tue, Nov 23, 2021 at 1:33 AM Matthew Miller <mattdm@xxxxxxxxxxxxxxxxx> wrote:
On Mon, Nov 22, 2021 at 04:46:05PM -0500, Nico Kadel-Garcia wrote:
> To get the list of installed RPMs:
>
>             rpm -qa --qf '%{name}-%{version}-%{release}.%{arch}\n'
>
> For matching SRPMs?
>
>             rpm -qa --qf '%{name}-%{version}-%{release}.%{arch}\n' |
> LANG=C sort | while read name; do echo "$name.rpm:       `rpm -qi
> $name  | grep '^Source RPM'`"; done

This doesn't work, and also seems unnecessarily complicated. (Why not just
use `--qf '%{sourcerpm}` as in my original question?)

But in any case, it doesn't solve my problem, as it just gives filenames,
and there's no way to know when a name ends and a version starts, as they
both use - as a separator.

> Do not bother with yum or dnf, they pull information from the rpm
> database and burn cycles on unnecessary metadata updates from
> updstreams.

rpm would be a tiny bit faster, if it could tell this. But it seems to not
have an easy way. And in fact if you use `dnf repoquery --installed`, it
is smart enough to just work from what's there locally. (You can use -C if
you want, but you don't have to.)


--
Matthew Miller
<mattdm@xxxxxxxxxxxxxxxxx>
Fedora Project Leader
_______________________________________________
packaging mailing list -- packaging@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to packaging-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/packaging@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure
#!/usr/bin/python3
"""
Pipe package NEVRAs into this script to get package names.

NEVRA stands for Name, Epoch, Version, Release, Architecture. E.g.:

    $ echo fedora-packager-0:0.6.0.4-1.fc32.noarch | pkgname
    fedora-packager

You can omit epoch and/or architecture:

    $ echo fedora-packager-0.6.0.4-1.fc32 | pkgname
    fedora-packager

But, if version and release is omitted, the script can produce invalid results:

    $ echo fedora-packager | pkgname
    fedora

Created by Miro Hrončok, with suggestions from Adam Williamson.

This script is trivial, consider it Public Domain.
"""
import fileinput
import sys


if len(sys.argv) > 1:
    sys.exit(__doc__.strip())

for line in fileinput.input():
    print(line.rsplit("-", 2)[0])

_______________________________________________
packaging mailing list -- packaging@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to packaging-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/packaging@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure

[Index of Archives]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite Forum]     [KDE Users]

  Powered by Linux