Created
October 5, 2016 00:53
-
-
Save DALDEI/b2b1aaac794be2b775708084df5ab89a to your computer and use it in GitHub Desktop.
rpm utils - normalize an rpm path. Given an rpm file print its normalized path as name-version-release-arch.rpm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python | |
# normalize an rpm path. | |
# Given an rpm file print its normalized path as name-version-release-arch.rpm | |
# Note: this reads the metadata from the rpm file itself to generate the path | |
import sys | |
import re | |
import rpmUtils.transaction | |
from rpmUtils.miscutils import splitFilename | |
from rpmUtils.miscutils import hdrFromPackage | |
from rpmUtils.miscutils import pkgTupleFromHeader | |
ts = rpmUtils.transaction.initReadOnlyTransaction() | |
for path in sys.argv[1:]: | |
hdr = hdrFromPackage(ts,path) | |
(n, a, e, v, r) = pkgTupleFromHeader(hdr) | |
print "{0}-{1}-{2}-{3}.rpm".format(n,v,r,a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment