* We will chop off these ugliness later. Not touching it right now, just moving
around to easily port these changes to maintanence.
This commit is contained in:
+28
-18
@@ -635,16 +635,7 @@ class Builder:
|
|||||||
files.write(files_xml_path)
|
files.write(files_xml_path)
|
||||||
self.files = files
|
self.files = files
|
||||||
|
|
||||||
def calc_build_no(self, package_name):
|
def find_old_package_info(self, package_name):
|
||||||
"""Calculate build number"""
|
|
||||||
|
|
||||||
def metadata_changed(old_metadata, new_metadata):
|
|
||||||
for key in old_metadata.package.__dict__.keys():
|
|
||||||
if old_metadata.package.__dict__[key] != new_metadata.package.__dict__[key]:
|
|
||||||
if key != "build":
|
|
||||||
return True
|
|
||||||
|
|
||||||
return False
|
|
||||||
|
|
||||||
# find previous build in packages dir
|
# find previous build in packages dir
|
||||||
found = []
|
found = []
|
||||||
@@ -674,17 +665,35 @@ class Builder:
|
|||||||
if os.path.isfile(file):
|
if os.path.isfile(file):
|
||||||
locate_old_package(file)
|
locate_old_package(file)
|
||||||
|
|
||||||
if not found:
|
if found:
|
||||||
return (1, None)
|
|
||||||
ctx.ui.warning(_('(no previous build found, setting build no to 1.)'))
|
|
||||||
else:
|
|
||||||
a = filter(lambda (x,y): y != None, found)
|
a = filter(lambda (x,y): y != None, found)
|
||||||
ctx.ui.debug(str(a))
|
ctx.ui.debug(str(a))
|
||||||
|
|
||||||
if a:
|
if a:
|
||||||
# sort in order of increasing build number
|
# sort in order of increasing build number
|
||||||
a.sort(lambda x,y : cmp(x[1],y[1]))
|
a.sort(lambda x,y : cmp(x[1],y[1]))
|
||||||
old_package_fn = a[-1][0] # get the last one
|
old_package_fn = a[-1][0] # get the last one
|
||||||
old_build = a[-1][1]
|
old_build = a[-1][1]
|
||||||
|
return (old_package_fn, old_build)
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
def calc_build_no(self, old_package_info):
|
||||||
|
"""Calculate build number"""
|
||||||
|
|
||||||
|
def metadata_changed(old_metadata, new_metadata):
|
||||||
|
for key in old_metadata.package.__dict__.keys():
|
||||||
|
if old_metadata.package.__dict__[key] != new_metadata.package.__dict__[key]:
|
||||||
|
if key != "build":
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
if not old_package_info:
|
||||||
|
return (1, None)
|
||||||
|
ctx.ui.warning(_('(no previous build no info found, setting build no to 1.)'))
|
||||||
|
else:
|
||||||
|
old_package_fn, old_build = old_package_info
|
||||||
|
|
||||||
# compare old files.xml with the new one..
|
# compare old files.xml with the new one..
|
||||||
old_pkg = Package(old_package_fn, 'r')
|
old_pkg = Package(old_package_fn, 'r')
|
||||||
@@ -712,10 +721,7 @@ class Builder:
|
|||||||
|
|
||||||
if metadata_changed(old_pkg.metadata, self.metadata):
|
if metadata_changed(old_pkg.metadata, self.metadata):
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
self.old_packages.append(os.path.basename(old_package_fn))
|
self.old_packages.append(os.path.basename(old_package_fn))
|
||||||
else: # no old build had a build number
|
|
||||||
old_build = None
|
|
||||||
|
|
||||||
ctx.ui.debug('old build number: %s' % old_build)
|
ctx.ui.debug('old build number: %s' % old_build)
|
||||||
|
|
||||||
@@ -808,12 +814,16 @@ class Builder:
|
|||||||
ctx.ui.info(_("Generating %s,") % ctx.const.metadata_xml)
|
ctx.ui.info(_("Generating %s,") % ctx.const.metadata_xml)
|
||||||
self.gen_metadata_xml(package)
|
self.gen_metadata_xml(package)
|
||||||
|
|
||||||
|
# find the latest build info if any with build no.
|
||||||
|
# old_package_info = (old_package_file_name, old_build_no)
|
||||||
|
old_package_info = self.find_old_package_info(package.name)
|
||||||
|
|
||||||
# build number
|
# build number
|
||||||
if ctx.config.options.ignore_build_no or not ctx.config.values.build.buildno:
|
if ctx.config.options.ignore_build_no or not ctx.config.values.build.buildno:
|
||||||
build_no = old_build_no = None
|
build_no = old_build_no = None
|
||||||
ctx.ui.warning(_('Build number is not available. For repo builds you must enable buildno in pisi.conf.'))
|
ctx.ui.warning(_('Build number is not available. For repo builds you must enable buildno in pisi.conf.'))
|
||||||
else:
|
else:
|
||||||
build_no, old_build_no = self.calc_build_no(package.name)
|
build_no, old_build_no = self.calc_build_no(old_package_info)
|
||||||
|
|
||||||
self.metadata.package.build = build_no
|
self.metadata.package.build = build_no
|
||||||
self.metadata.write(util.join_path(self.pkg_dir(), ctx.const.metadata_xml))
|
self.metadata.write(util.join_path(self.pkg_dir(), ctx.const.metadata_xml))
|
||||||
|
|||||||
Reference in New Issue
Block a user