Bug 149017
Summary: | Would like to be able to get version sorted list of install kernels | ||
---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Orion Poplawski <orion> |
Component: | rpm | Assignee: | Jeff Johnson <jbj> |
Status: | CLOSED WONTFIX | QA Contact: | Mike McLean <mikem> |
Severity: | medium | Docs Contact: | |
Priority: | medium | ||
Version: | 3 | CC: | james.oden, nobody+pnasrat |
Target Milestone: | --- | Keywords: | FutureFeature |
Target Release: | --- | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Enhancement | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2005-02-20 18:55:48 UTC | Type: | --- |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Orion Poplawski
2005-02-17 22:36:28 UTC
I know you want a cli switch but: use RPM2; my $db = RPM2->open_rpm_db(); $i = $db->find_by_name_iter("kernel"); @kernels = $i->expand_iter(); @kernels = sort(@kernels); foreach my $p (@kernels) { print $p->as_nvre() . "\n"; } exit(0); Will do the trick. Its a tiny perl script using RPM2 (perl rpm bindings). Its only an example to give you an idea of what you can do. This: @kernels = sort(@kernels); will do a proper RPM version sort, not just alphanumeric? There is no idication in the perl RPM2 documentation that it overrides sort or provides RPM version sorting. I've been using the perl module RPM::VersionSort for this kind of thing but I was hoping to avoid perl scripts and modules and have: lastestkernel=`rpm -q kernel --version-sorted | tail -1` Your right its not documented, but the <=> operator is overloaded to properly compare EVR's (I know its overloaded because I added that patch (-:). So yes it will do what you want (in perl). The docs in RPM2 could be greatly expanded. Cheers...james rpmquery cannot possibly include enough options to satisfy every possible need and taste. Extract the information and sort to taste. |