From a4ed2778ab73d3e058bed9c621222774d45bfe32 Mon Sep 17 00:00:00 2001 From: Oleg Gelbukh Date: Mon, 11 Apr 2016 10:34:03 +0000 Subject: [PATCH] Generalize the patch application procedure Current depth for the patch command (-p3) is tied to historical format of patches to Puppet manifests which used to be based from /etc/puppet/modules directory. Change the depth to -p1 generalize patching approach for other paths in the host file system. Change-Id: I8538af2192aa29987404fbe130934122997a2625 --- octane/tests/test_patch_puppet.py | 4 ++-- octane/util/patch.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/octane/tests/test_patch_puppet.py b/octane/tests/test_patch_puppet.py index b88134b3..84a22eba 100644 --- a/octane/tests/test_patch_puppet.py +++ b/octane/tests/test_patch_puppet.py @@ -36,9 +36,9 @@ class MockFile(mock.MagicMock): def assert_calls(self): kwargs = {'stdin': self, 'cwd': magic_consts.PUPPET_DIR} - args = [((["patch", "-R", "-p3"], ), kwargs), ] + args = [((["patch", "-R", "-p1"], ), kwargs), ] if not self.revert: - args.append(((["patch", "-N", "-p3"], ), kwargs)) + args.append(((["patch", "-N", "-p1"], ), kwargs)) assert args == self.call_args diff --git a/octane/util/patch.py b/octane/util/patch.py index 6614e9b7..2b5a1559 100644 --- a/octane/util/patch.py +++ b/octane/util/patch.py @@ -17,7 +17,7 @@ def patch_apply(cwd, patches, revert=False): for path in patches: with open(path, 'rb') as patch: try: - subprocess.call(["patch", "-R", "-p3"], stdin=patch, cwd=cwd) + subprocess.call(["patch", "-R", "-p1"], stdin=patch, cwd=cwd) except subprocess.CalledProcessError: if not revert: pass @@ -25,4 +25,4 @@ def patch_apply(cwd, patches, revert=False): raise if not revert: patch.seek(0) - subprocess.call(["patch", "-N", "-p3"], stdin=patch, cwd=cwd) + subprocess.call(["patch", "-N", "-p1"], stdin=patch, cwd=cwd)