From b68c136010e4a7113f65a7a7bf5c52dc29c35b91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Gross?= Date: Fri, 20 Mar 2015 17:17:16 +0100 Subject: [PATCH 1/3] [patch] Make sure patch command is found on remote system. --- files/patch.py | 2 ++ 1 file changed, 2 insertions(+) mode change 100644 => 100755 files/patch.py diff --git a/files/patch.py b/files/patch.py old mode 100644 new mode 100755 index cd4b3130079..314a1bc37db --- a/files/patch.py +++ b/files/patch.py @@ -141,6 +141,8 @@ def main(): p.basedir = path.dirname(p.dest) patch_bin = module.get_bin_path('patch') + if patch_bin is None: + module.fail_json(msg="patch command not found") patch_func = lambda opts: module.run_command("%s %s" % (patch_bin, ' '.join(opts))) changed = False From 84eb895a06c8819ed5d8aea06672a69add2b9d37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Gross?= Date: Fri, 20 Mar 2015 17:19:15 +0100 Subject: [PATCH 2/3] [patch] Make sure the absolute patch file is passed to the patch command. According the patch(1) manpage: The --directory option change to the directory dir immediately, before doing anything else. Thus if file is not relative to dir and making file absolute ensure that patch will find it. --- files/patch.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/files/patch.py b/files/patch.py index 314a1bc37db..78bcefe6d31 100755 --- a/files/patch.py +++ b/files/patch.py @@ -145,6 +145,9 @@ def main(): module.fail_json(msg="patch command not found") patch_func = lambda opts: module.run_command("%s %s" % (patch_bin, ' '.join(opts))) + # patch need an absolute file name + p.src = os.path.abspath(p.src) + changed = False if not is_already_applied(patch_func, p.src, p.basedir, dest_file=p.dest, strip=p.strip): try: From 08702e44bf5dfb1cee66b0b8cebd6717f9a366fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Gross?= Date: Fri, 20 Mar 2015 17:36:33 +0100 Subject: [PATCH 3/3] [patch] Update documentation for src parameter. --- files/patch.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/files/patch.py b/files/patch.py index 78bcefe6d31..2f2894a6508 100755 --- a/files/patch.py +++ b/files/patch.py @@ -43,7 +43,9 @@ options: aliases: [ "originalfile" ] src: description: - - Path of the patch file as accepted by the GNU patch tool. + - Path of the patch file as accepted by the GNU patch tool. If + C(remote_src) is False, the patch source file is looked up from the + module's "files" directory. required: true aliases: [ "patchfile" ] remote_src: