Add a utility for extracting patch software version
Added a new utility in cgcs_patch/patch_functions.py that extracts only the metadata (and only to stdout) in order to parse it and provide the software release version. Signed-off-by: Jessica Castelino <jessica.castelino@windriver.com> Partial-Bug: 1934674 Change-Id: I39cbc67c5ed8822fe2a21630eec380a43c09de95
This commit is contained in:
parent
49e39fa949
commit
37e68c0d54
|
@ -199,6 +199,24 @@ def parse_pkgver(pkgver):
|
|||
return (epoch, version, release)
|
||||
|
||||
|
||||
def get_release_from_patch(patchfile):
|
||||
rel = ""
|
||||
try:
|
||||
cmd = "tar xf %s -O metadata.tar | tar x -O" % patchfile
|
||||
metadata_str = subprocess.check_output(cmd, shell=True)
|
||||
root = ElementTree.fromstring(metadata_str)
|
||||
# Extract release version
|
||||
rel = root.findtext('sw_version')
|
||||
except subprocess.CalledProcessError as e:
|
||||
LOG.error("Failed to run tar command")
|
||||
LOG.error("Command output: %s", e.output)
|
||||
raise e
|
||||
except Exception as e:
|
||||
print("Failed to parse patch software version")
|
||||
raise e
|
||||
return rel
|
||||
|
||||
|
||||
class PackageVersion(object):
|
||||
"""
|
||||
The PackageVersion class provides a structure for RPM version information,
|
||||
|
|
Loading…
Reference in New Issue