summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alvarez <pedro.alvarez@codethink.co.uk>2014-02-19 13:03:39 +0000
committerPedro Alvarez <pedro.alvarez@codethink.co.uk>2014-02-20 15:42:06 +0000
commitd71ff3eaa4a55b32659e165efe4b78149ef240cb (patch)
tree0d89f7495dd2704d28d9d090f261c352a2675e02
parentf5723961ef7fc9c71222e8b45e0de39e7f15e90e (diff)
downloadtbdiff-d71ff3eaa4a55b32659e165efe4b78149ef240cb.tar.gz
Modify the way to use 'patch' in 'baserock-system-config-sync'.
baserock-sytem-config-sync: Changes here are caused by a bug found in GNU patch managing the permissions of the files when using the patch command like: patch <file_to_apply_patch> -t -o <output_file> To reproduce the bug: echo foo > file1 echo bar > file2 diff -u file1 file2 | patch 1 -t -o file3 ls -l You can check that the permissions of 'file3' are different than the permissions of 'file1' or 'file2'. To avoid the bug, this patch changes the way we are using patch, using it as following: patch <file_to_apply_patch> -t Since the output file is not specified, the output file will be the file in which we want to apply the patch. And due we cannot specify the output file, we are copying the file to the destination directory, and then applying the patch there. As a consequence of changing the way of using patch, now 'patch' generates an extra file when patching fails. This file is added in the test suite also in this commit.
-rwxr-xr-xbaserock-system-config-sync/baserock-system-config-sync8
-rw-r--r--tests/bscs-merge.pass/upgrades.out/systems/version2/run/etc/file7.orig2
2 files changed, 8 insertions, 2 deletions
diff --git a/baserock-system-config-sync/baserock-system-config-sync b/baserock-system-config-sync/baserock-system-config-sync
index cb5984d..a093b15 100755
--- a/baserock-system-config-sync/baserock-system-config-sync
+++ b/baserock-system-config-sync/baserock-system-config-sync
@@ -151,13 +151,17 @@ merge_regular_file() {
cp -a "$vu" "$vt"
;;
'none exists exists')
- if ! (diff -u "$v2" --label="$v2" "$vu" --label="$vu" | patch "$v2" -t -o "$vt"); then
+ cp -a "$v2" "$vt"
+ if ! (diff -u "$v2" --label="$v2" "$vu" --label="$vu" | patch "$vt" -t); then
cp -a "$v2" "$vt" # merge failed, use v2
+ # 'patch' creates a file '.rej' with the diff that did not apply
fi
;;
'exists exists exists')
- if ! (diff -u "$v1" --label="$v1" "$vu" --label="$vu" | patch "$v2" -t -o "$vt"); then
+ cp -a "$v2" "$vt"
+ if ! (diff -u "$v1" --label="$v1" "$vu" --label="$vu" | patch "$vt" -t); then
cp -a "$v2" "$vt" # merge failed, use v2
+ # 'patch' creates a file '.rej' with the diff that did not apply
fi
;;
*)
diff --git a/tests/bscs-merge.pass/upgrades.out/systems/version2/run/etc/file7.orig b/tests/bscs-merge.pass/upgrades.out/systems/version2/run/etc/file7.orig
new file mode 100644
index 0000000..93c46eb
--- /dev/null
+++ b/tests/bscs-merge.pass/upgrades.out/systems/version2/run/etc/file7.orig
@@ -0,0 +1,2 @@
+whereami=v1,vu,v2
+version=v2