summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alvarez <pedro.alvarez@codethink.co.uk>2016-09-22 14:04:19 +0000
committerPedro Alvarez <pedro.alvarez@codethink.co.uk>2016-09-22 14:11:47 +0000
commite17a444c651451724046e7da1ae2559e71478b3a (patch)
treec3a74bd35d3ff997e25038f6b373e8865512ef39
parent06f3271314b72e0065cc638fcfa7695d56ddb2e2 (diff)
downloadtbdiff-e17a444c651451724046e7da1ae2559e71478b3a.tar.gz
Handle better the case where a symlink disappears in v2HEADmaster
When a symlink hasn't changed from v1 to vu, we were using by default v2. But this was failing in some cases where v2 didn't include this symlink. Now, if v2 doesn't have that file, we use vu, to be consistent with the behaviour of merging regular files. Change-Id: I8741e0bd0722d48d3d031a779f5fbde6a4e86df7
-rwxr-xr-xbaserock-system-config-sync/baserock-system-config-sync10
1 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 8bc4790..7e02fc1 100755
--- a/baserock-system-config-sync/baserock-system-config-sync
+++ b/baserock-system-config-sync/baserock-system-config-sync
@@ -107,8 +107,14 @@ merge() {
if [ -h "$vu" -a -h "$v1" ]; then
if [ "$(readlink $v1)" == "$(readlink $vu)" ]; then
# User hasn't overriden the old v1 value: switch
- # to v2.
- cp -a "$v2" "$vt"
+ # to v2 if possible, or to vu if v2 doesn't have the
+ # symlink (This behaivour tries to be consistent with
+ # the table in 'merge_regular_file').
+ if [ -e "$v2" ]; then
+ cp -a "$v2" "$vt"
+ else
+ cp -a "$vu" "$vt"
+ fi
else
# User overwrote the v1 value; keep what they did
cp -a "$vu" "$vt"