Skip to content

Instantly share code, notes, and snippets.

@DALDEI
Created October 5, 2016 00:48
Show Gist options
  • Save DALDEI/738fc960a006fda29a923850358a426a to your computer and use it in GitHub Desktop.
Save DALDEI/738fc960a006fda29a923850358a426a to your computer and use it in GitHub Desktop.
rpm utils - print how yum and rpmUtils parses an RPM filename as a 'NVREA'
#! /usr/bin/python
# Print the 'NEVRA' of an rpm file using its path only
# This is what yum tools does when given only an rpm filename
import sys
import re
from rpmUtils.miscutils import splitFilename
for path in sys.argv[1:]:
x = path[path.rfind( '/' )+1:]
# print "Path: {0} File: {1}".format(path,x)
(n, v, r, e, a) = splitFilename(x)
print "Path: {5}\nName: {0}\nEpoch: {1}\nVersion: {2}\nRelease: {3}\nArch: {4}".format(n,e,v,r,a,x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment