Re: How to parse an RPM file name?

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

 



On Tue, Nov 26, 2013 at 10:46 AM, Greg Swift <gregswift@xxxxxxxxx> wrote:
> the -p switch allows you to query the RPM file, rather than the installed
> RPM.  This method is what I would recommend to minimize your headaches, but
> it does require you to have all the files (which it appears you do)

Sadly I don't have the files either.  The project I'm working on is
auditing and cross-checking information about internal repos.  I have
the information, not the packages nor the repos.  (well, technically I
*have* the packages but they're not on the machine that is doing the
work)

How's this for a regular expression?  It works on all the test cases
I've written so far.

#! /usr/bin/python

import sys
import re

for x in sys.argv[1:]:
    m = re.search(r'(.*)/*(.*)-(.*)-(.*?)\.(.*)(\.rpm)', x)
    if m:
        (path, name, version, release, platform, _) = m.groups()
        path = path or ''
        verrel = version + '-' + release
        print "\t".join([path, name, verrel, version, release, platform])
    else:
      sys.stderr.write('ERROR: Invalid name: %s\n' % x)
      sys.exit(1)


Tom
_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxxxxx
http://lists.rpm.org/mailman/listinfo/rpm-list




[Index of Archives]     [RPM Ecosystem]     [Linux Kernel]     [Red Hat Install]     [PAM]     [Red Hat Watch]     [Red Hat Development]     [Red Hat]     [Gimp]     [Yosemite News]     [IETF Discussion]

  Powered by Linux