build: Add a method to determine delta packages to be created
This will be used by buildfarm. It accepts release numbers to create delta packages for stable distribution releases. If the release number is not given, it searches the binary package dirs for old packages and creates delta packages. max_count can be specified to limit numbers of delta packages. It is possible to override search paths via search_paths parameter. release and max_count parameters cannot be used at the same time. This commit also removes the max_delta_count option from config file since it is useless and confusing.
This commit is contained in:
@@ -91,7 +91,6 @@ class BuildDefaults:
|
||||
buildhelper = None
|
||||
compressionlevel = 1
|
||||
fallback = "ftp://ftp.pardus.org.tr/pub/source/2009"
|
||||
max_delta_count = 0
|
||||
ignored_build_types = ""
|
||||
|
||||
class DirectoriesDefaults:
|
||||
|
||||
+53
-18
@@ -234,6 +234,9 @@ class Builder:
|
||||
self.actionLocals = None
|
||||
self.actionGlobals = None
|
||||
|
||||
self.delta_history_search_paths = []
|
||||
self.delta_search_paths = {}
|
||||
|
||||
self.new_packages = []
|
||||
self.new_debug_packages = []
|
||||
|
||||
@@ -1123,7 +1126,7 @@ class Builder:
|
||||
# FIXME Remove this hack
|
||||
pkg.metadata.package.debug_package = package.debug_package
|
||||
|
||||
delta_packages = self.build_delta_packages(pkg, outdir)
|
||||
delta_packages = self.build_delta_packages(pkg)
|
||||
self.delta_map[name] = delta_packages
|
||||
|
||||
pkg.close()
|
||||
@@ -1144,31 +1147,63 @@ class Builder:
|
||||
os.environ.clear()
|
||||
os.environ.update(ctx.config.environ)
|
||||
|
||||
def build_delta_packages(self, package, outdir):
|
||||
max_delta_count = int(ctx.config.values.build.max_delta_count)
|
||||
def search_old_packages_for_delta(self, release=None, max_count=0,
|
||||
search_paths=None):
|
||||
if search_paths is None:
|
||||
search_paths = (ctx.config.compiled_packages_dir(),
|
||||
ctx.config.debug_packages_dir())
|
||||
|
||||
if not max_delta_count:
|
||||
return []
|
||||
if release is None:
|
||||
self.delta_history_search_paths.append((search_paths, max_count))
|
||||
else:
|
||||
self.delta_search_paths[release] = search_paths
|
||||
|
||||
old_package_dirs = (ctx.config.compiled_packages_dir(),
|
||||
ctx.config.debug_packages_dir(),
|
||||
outdir or ".")
|
||||
def build_delta_packages(self, package):
|
||||
|
||||
old_packages = []
|
||||
for update in self.spec.history[1:]:
|
||||
filename = self.package_filename(package.metadata.package, update)
|
||||
|
||||
for package_dir in old_package_dirs:
|
||||
def find_old_package(filename, search_paths):
|
||||
for package_dir in search_paths:
|
||||
path = util.join_path(package_dir, filename)
|
||||
if os.path.exists(path):
|
||||
old_packages.append(path)
|
||||
break
|
||||
return path
|
||||
|
||||
if len(old_packages) == max_delta_count:
|
||||
break
|
||||
old_packages = {}
|
||||
|
||||
for old_release, search_paths in self.delta_search_paths.items():
|
||||
if old_release in old_packages:
|
||||
continue
|
||||
|
||||
update = None
|
||||
for update_tag in self.spec.history[1:]:
|
||||
if update_tag.release == old_release:
|
||||
update = update_tag
|
||||
break
|
||||
else:
|
||||
continue
|
||||
|
||||
filename = self.package_filename(package.metadata.package, update)
|
||||
old_package = find_old_package(filename, search_paths)
|
||||
if old_package:
|
||||
old_packages[old_release] = old_package
|
||||
|
||||
for search_paths, max_count in self.delta_history_search_paths:
|
||||
found_old_packages = {}
|
||||
for update in self.spec.history[1:]:
|
||||
if update.release in old_packages:
|
||||
continue
|
||||
|
||||
filename = self.package_filename(package.metadata.package,
|
||||
update)
|
||||
old_package = find_old_package(filename, search_paths)
|
||||
if old_package:
|
||||
found_old_packages[old_release] = old_package
|
||||
|
||||
if len(found_old_packages) == max_count:
|
||||
break
|
||||
|
||||
old_packages.update(found_old_packages)
|
||||
|
||||
from pisi.operations.delta import create_delta_packages_from_obj
|
||||
return create_delta_packages_from_obj(old_packages,
|
||||
return create_delta_packages_from_obj(old_packages.values(),
|
||||
package,
|
||||
self.specdir)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user