From 50e59b7111fcce1cb2fe1a8b2cb18056cd00f4ee Mon Sep 17 00:00:00 2001 From: Faik Uygur Date: Mon, 26 Mar 2007 12:14:15 +0000 Subject: [PATCH] * [MERGE] forward port changes in pisi-delta trunk. --- pisi/atomicoperations.py | 22 ++++++++++++++++++++-- pisi/delta.py | 2 +- pisi/index.py | 4 ++-- pisi/metadata.py | 6 +++--- pisi/operations.py | 2 +- pisi/util.py | 8 ++++---- 6 files changed, 31 insertions(+), 13 deletions(-) diff --git a/pisi/atomicoperations.py b/pisi/atomicoperations.py index 579e2130..96a904d6 100644 --- a/pisi/atomicoperations.py +++ b/pisi/atomicoperations.py @@ -69,7 +69,7 @@ class Install(AtomicOperation): # Package is installed. This is an upgrade. Check delta. if ctx.installdb.is_installed(pkg.name): (version, release, build) = ctx.installdb.get_version(pkg.name) - delta = pkg.get_delta(releaseFrom=release) + delta = pkg.get_delta(buildFrom=build) # If delta exists than use the delta uri. if delta: @@ -295,7 +295,22 @@ class Install(AtomicOperation): oldconfig = path + '.old' if os.path.exists(newconfig): os.unlink(newconfig) - os.rename(path, newconfig) + + # In the case of delta packages: the old package and the new package + # may contain same config typed files with same hashes, so the delta + # package will not have that config file. In order to protect user + # changed config files, they are renamed with ".old" prefix in case + # of the hashes of these files on the filesystem and the new config + # file that is coming from the new package. But in delta package case + # with the given scenario there wont be any, so we can pass this one. + # If the config files were not be the same between these packages the + # delta package would have it and extract it and the path would point + # to that new config file. If they are same and the user had changed + # that file and using the changed config file, there is no problem + # here. + if os.path.exists(path): + os.rename(path, newconfig) + os.rename(oldconfig, path) # Delta package does not contain the files that have the same hash as in @@ -347,6 +362,9 @@ class Install(AtomicOperation): # there may be left over config files check_config_changed(file) + if self.package_fname.endswith(ctx.const.delta_package_suffix): + relocate_files() + self.package.extract_install(ctx.config.dest_dir()) if config_changed: diff --git a/pisi/delta.py b/pisi/delta.py index 56f88c3d..e9dd29fb 100644 --- a/pisi/delta.py +++ b/pisi/delta.py @@ -49,7 +49,7 @@ def create_delta_package(old_package, new_package): tar.unpack_dir(newpkg_path) # Create delta package - deltaname = "%s-%s-%s%s" % (oldmd.package.name, oldmd.package.release, newmd.package.release, ctx.const.delta_package_suffix) + deltaname = "%s-%s-%s%s" % (oldmd.package.name, oldmd.package.build, newmd.package.build, ctx.const.delta_package_suffix) outdir = ctx.get_option("output_dir") if outdir: diff --git a/pisi/index.py b/pisi/index.py index eae7b919..cf774881 100644 --- a/pisi/index.py +++ b/pisi/index.py @@ -166,8 +166,8 @@ class Index(XmlFile): delta.packageURI = util.removepathprefix(repo_uri, delta_path) delta.packageSize = os.path.getsize(delta_path) delta.packageHash = util.sha1_file(delta_path) - name, relFrom, relTo = util.parse_delta_package_name(delta_path) - delta.releaseFrom = relFrom + name, buildFrom, buildTo = util.parse_delta_package_name(delta_path) + delta.buildFrom = buildFrom md.package.deltaPackages.append(delta) self.packages.append(md.package) diff --git a/pisi/metadata.py b/pisi/metadata.py index 1ab289de..0320bb64 100644 --- a/pisi/metadata.py +++ b/pisi/metadata.py @@ -33,7 +33,7 @@ class Delta: t_PackageURI = [ autoxml.String, autoxml.optional] t_PackageSize = [ autoxml.Long, autoxml.optional] t_PackageHash = [ autoxml.String, autoxml.optional, "SHA1Sum" ] - a_releaseFrom = [autoxml.String, autoxml.optional] + a_buildFrom = [autoxml.String, autoxml.optional] class Source: __metaclass__ = autoxml.autoxml @@ -58,9 +58,9 @@ class Package(specfile.Package): t_Source = [ Source, autoxml.optional] - def get_delta(self, releaseFrom): + def get_delta(self, buildFrom): for delta in self.deltaPackages: - if delta.releaseFrom == releaseFrom: + if delta.buildFrom == str(buildFrom): return delta else: return None diff --git a/pisi/operations.py b/pisi/operations.py index 8b89456a..1827e399 100644 --- a/pisi/operations.py +++ b/pisi/operations.py @@ -803,7 +803,7 @@ def calculate_download_sizes(order): delta = None if ctx.installdb.is_installed(pkg.name): (version, release, build) = ctx.installdb.get_version(pkg.name) - delta = pkg.get_delta(releaseFrom=release) + delta = pkg.get_delta(buildFrom=build) if delta: fn = os.path.basename(delta.packageURI) diff --git a/pisi/util.py b/pisi/util.py index 69457798..9a2e332d 100644 --- a/pisi/util.py +++ b/pisi/util.py @@ -645,11 +645,11 @@ def parse_delta_package_name(package_name): example: tasma-5-7.pisi.delta -> (tasma, 5, 7) """ - name, release = parse_package_name(package_name) - release = release[:-len(ctx.const.delta_package_suffix)] - releaseFrom, releaseTo = release.split("-") + name, build = parse_package_name(package_name) + build = build[:-len(ctx.const.delta_package_suffix)] + buildFrom, buildTo = build.split("-") - return name, releaseFrom, releaseTo + return name, buildFrom, buildTo def filter_latest_packages(package_paths): """ For a given pisi package paths list where there may also be multiple versions