freeze_command: update the version in the Test DVD product's KIWI file
to match the version of openSUSE-release https://progress.opensuse.org/issues/5958
This commit is contained in:
parent
31e32421cd
commit
35ec3f368b
@ -122,6 +122,23 @@ class FreezeCommand(object):
|
||||
self.set_links()
|
||||
self.freeze_prjlinks()
|
||||
|
||||
# Update the version information found in the Test-DVD package, to match openSUSE-release
|
||||
version = self.api.package_version(prj, 'openSUSE-release')
|
||||
self.update_product_version(prj + ':DVD', 'Test-DVD-x86_64', version)
|
||||
|
||||
def update_product_version(self, project, product, version):
|
||||
if not self.api.item_exists(project, product):
|
||||
return None
|
||||
|
||||
kiwifile = self.api.load_file_content(project, product, 'PRODUCT-x86_64.kiwi')
|
||||
root = ET.fromstring(kiwifile)
|
||||
prodvar = root.find(".//productvar[@name='VERSION']")
|
||||
prodvar.text = version
|
||||
prodinfoversion = root.find(".//productinfo[@name='VERSION']")
|
||||
prodinfoversion.text = version
|
||||
|
||||
self.api.save_file_content(project, product, 'PRODUCT-x86_64.kiwi', ET.tostring(root))
|
||||
|
||||
def prj_meta_for_bootstrap_copy(self, prj):
|
||||
root = ET.Element('project', {'name': prj})
|
||||
ET.SubElement(root, 'title')
|
||||
|
@ -907,6 +907,50 @@ class StagingAPI(object):
|
||||
return False
|
||||
return True
|
||||
|
||||
def package_version(self, project, package):
|
||||
"""
|
||||
Return the version of a package, None in case the package does not exist
|
||||
The first non-commented Version: tag found is used.
|
||||
:param project: the project the package resides in
|
||||
:param package: the package to check
|
||||
:param product: if passed, the package to be checked is considered to be part of _product
|
||||
"""
|
||||
if not self.item_exists(project, package):
|
||||
return None
|
||||
|
||||
version = None
|
||||
|
||||
specfile = self.api.load_file_content(project, package, '{}.spec'.format(package))
|
||||
if specfile:
|
||||
try:
|
||||
version = re.findall("^Version:(.*)",specfile,re.MULTILINE)[0].strip()
|
||||
except:
|
||||
pass
|
||||
return version
|
||||
|
||||
def load_file_content(self, project, package, filename):
|
||||
"""
|
||||
Load the content of a file and return the content as data. If the package is a link, it will be expanded
|
||||
:param project: The project to query
|
||||
:param package: The package to quert
|
||||
:param filename: The filename to query
|
||||
"""
|
||||
url = self.api.makeurl(['source', project, package, '{}?expand=1'.format(filename)])
|
||||
try:
|
||||
return http_GET(url).read()
|
||||
except:
|
||||
return None
|
||||
|
||||
def save_file_content(self, project, package, filename, content):
|
||||
"""
|
||||
Save content to a project/package/file
|
||||
:param project: The project containing the package
|
||||
:param package: the package to update
|
||||
:param filename: the filename to save the data to
|
||||
:param content: the content to write to the file
|
||||
"""
|
||||
url = self.api.makeurl(['source', project, package, filename])
|
||||
http_PUT(url + '?comment=scripted+update', data=content)
|
||||
|
||||
def update_status_comments(self, project, command):
|
||||
"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user