diff --git a/collective/recipe/patch/README.txt b/collective/recipe/patch/README.txt index d5a94ad..178b625 100644 --- a/collective/recipe/patch/README.txt +++ b/collective/recipe/patch/README.txt @@ -22,6 +22,13 @@ patches patches = patches/my_very_sprecial.patch patches/another_loverly.patch +no-uninstall + If set, patched paths will not be reported to buildout. This way, + the recipe can be used to patch code not installed by buildout. + A log of paths is kept in .patch-cache.txt (the filename can be + changed via 'patch-cache' option). + + Example usage ============= diff --git a/collective/recipe/patch/__init__.py b/collective/recipe/patch/__init__.py index f8502b5..a9b9898 100644 --- a/collective/recipe/patch/__init__.py +++ b/collective/recipe/patch/__init__.py @@ -33,6 +33,7 @@ def __init__(self, buildout, name, options): self.options['executable'] = self.buildout[self.options['python']]['executable'] self.options['eggs-directory'] = buildout['buildout']['eggs-directory'] self.options['develop-eggs-directory'] = buildout['buildout']['develop-eggs-directory'] + self.options['patch-cache'] = options.get("patch-cache", ".patch_cache.txt") def install(self): """Installer""" @@ -124,6 +125,10 @@ def use_patch_binary(self, path, patch): raise zc.buildout.UserError('could not apply %s' % patch) finally: os.chdir(cwd) + + if self.options.get("no-uninstall"): + self.log_patch_entry(path) + return "" return path def use_patch_library(self, path, patch): @@ -135,4 +140,13 @@ def use_patch_library(self, path, patch): logger.info('in %s...' % path) if not patchlib.apply_patch(patch): raise zc.buildout.UserError('could not apply %s' % name) + elif self.options.get("no-uninstall"): + self.log_patch_entry(path) + return "" return path + + def log_patch_entry(self, path): + """log the patched path to $patch-cache""" + cachefilename = self.options.get("patch-cache") + with open(cachefilename, "a") as cachefile: + cachefile.write(path + "\n")