From 229d84a144114b27e6769542db34a11a6bcb46dd Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Fri, 9 Mar 2018 17:51:40 +0000 Subject: [PATCH] Added a patch to patch.py to not change directories during patching. - Legacy-Id: 14755 --- ietf/settings.py | 1 + patch/fix-patch-no-chdir.patch | 47 ++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 patch/fix-patch-no-chdir.patch diff --git a/ietf/settings.py b/ietf/settings.py index 575d42efd..58fad852a 100644 --- a/ietf/settings.py +++ b/ietf/settings.py @@ -946,6 +946,7 @@ CHECKS_LIBRARY_PATCHES_TO_APPLY = [ 'patch/fix-unidecode-argument-warning.patch', 'patch/fix-faker-provider-ro-RO-string.patch', 'patch/add-patch-already-patched-flag.patch', + 'patch/fix-patch-no-chdir.patch', ] STATS_NAMES_LIMIT = 25 diff --git a/patch/fix-patch-no-chdir.patch b/patch/fix-patch-no-chdir.patch new file mode 100644 index 000000000..178aef950 --- /dev/null +++ b/patch/fix-patch-no-chdir.patch @@ -0,0 +1,47 @@ +--- patch.py.old 2018-03-09 07:53:37.586201595 -0800 ++++ patch.py 2018-03-09 09:17:25.017418754 -0800 +@@ -804,10 +804,10 @@ + + def findfile(self, old, new): + """ return name of file to be patched or None """ +- if exists(old): +- return old +- elif exists(new): ++ if exists(new): + return new ++ elif exists(old): ++ return old + else: + # [w] Google Code generates broken patches with its online editor + debug("broken patch from Google Code, stripping prefixes..") + +@@ -827,9 +827,6 @@ + from file paths. `root` parameter specifies working dir. + return True on success + """ +- if root: +- prevdir = os.getcwd() +- os.chdir(root) + + total = len(self.items) + errors = 0 + +@@ -854,6 +851,8 @@ + new = pathstrip(p.target, strip) + else: + old, new = p.source, p.target ++ old = os.path.join(root, old) ++ new = os.path.join(root, new) + + filename = self.findfile(old, new) + + +@@ -956,9 +955,6 @@ + # todo: proper rejects + shutil.move(backupname, filename) + +- if root: +- os.chdir(prevdir) +- + # todo: check for premature eof + return (errors == 0)