diff --git a/ChangeLog b/ChangeLog index 377625a4..0d4ac50e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-01-23 Ozan Çağlayan + * Add support for optional reverse="[tT]rue" in for reverse applying + a patch. + 2010-01-22 Gökçen Eraslan * pisi/actionsapi/perlmodules.py: Do not ignore parameter in make method (eg. perl Build test). Tests of some perl modules have never run diff --git a/pisi-spec.dtd b/pisi-spec.dtd index 9dd53354..8cf183b3 100644 --- a/pisi-spec.dtd +++ b/pisi-spec.dtd @@ -63,6 +63,7 @@ + diff --git a/pisi-spec.rng b/pisi-spec.rng index 85c17d96..1c72dfe7 100644 --- a/pisi-spec.rng +++ b/pisi-spec.rng @@ -1372,6 +1372,9 @@ + + + diff --git a/pisi/operations/build.py b/pisi/operations/build.py index 4f51c6c6..27b8ec92 100644 --- a/pisi/operations/build.py +++ b/pisi/operations/build.py @@ -613,6 +613,7 @@ class Builder: for patch in self.spec.source.patches: patchFile = pisi.util.join_path(files_dir, patch.filename) relativePath = patch.filename + reverseApply = patch.reverse.lower() == "true" if patch.compressionType: patchFile = pisi.util.uncompress(patchFile, compressType=patch.compressionType, @@ -620,7 +621,7 @@ class Builder: relativePath = relativePath.rsplit(".%s" % patch.compressionType, 1)[0] ctx.ui.action(_("* Applying patch: %s") % patch.filename) - pisi.util.do_patch(self.srcDir, patchFile, level=patch.level, name=relativePath) + pisi.util.do_patch(self.srcDir, patchFile, level=patch.level, name=relativePath, reverse=reverseApply) return True def generate_static_package_object(self): diff --git a/pisi/specfile.py b/pisi/specfile.py index d9bdf3ff..48755b9d 100644 --- a/pisi/specfile.py +++ b/pisi/specfile.py @@ -83,6 +83,7 @@ class Patch: s_Filename = [autoxml.String, autoxml.mandatory] a_compressionType = [autoxml.String, autoxml.optional] a_level = [autoxml.Integer, autoxml.optional] + a_reverse = [autoxml.String, autoxml.optional] #FIXME: what's the cleanest way to give a default value for reading level? #def decode_hook(self, node, errs, where): diff --git a/pisi/util.py b/pisi/util.py index af00d136..668353cd 100644 --- a/pisi/util.py +++ b/pisi/util.py @@ -463,7 +463,7 @@ def uncompress(patchFile, compressType="gz", targetDir=None): return filePath -def do_patch(sourceDir, patchFile, level=0, name=None): +def do_patch(sourceDir, patchFile, level=0, name=None, reverse=False): """Apply given patch to the sourceDir.""" cwd = os.getcwd() if os.path.exists(sourceDir): @@ -485,12 +485,12 @@ def do_patch(sourceDir, patchFile, level=0, name=None): if not os.path.exists(patchesDir): os.makedirs(patchesDir) # Import original patch into quilt tree - (ret, out, err) = run_batch('quilt import -p %d -P %s \"%s\"' % (level, name, patchFile)) + (ret, out, err) = run_batch('quilt import %s -p %d -P %s \"%s\"' % (("-R" if reverse else ""), level, name, patchFile)) # run quilt push to apply original patch into tree (ret, out, err) = run_batch('quilt push') else: # run GNU patch to apply original patch into tree - (ret, out, err) = run_batch("patch --remove-empty-files --no-backup-if-mismatch -p%d < \"%s\"" % (level, patchFile)) + (ret, out, err) = run_batch("patch --remove-empty-files --no-backup-if-mismatch %s -p%d < \"%s\"" % (("-R" if reverse else ""), level, patchFile)) if ret: if out is None and err is None: