diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2014-09-19 12:22:35 +0100 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2014-09-19 12:15:47 +0000 |
commit | 6cb1a8772364e96e62cfda74490db9848c885635 (patch) | |
tree | 1dbc6c1058475fa4f74f7524f1d52686e57843ce /baserock-system-config-sync | |
parent | a6c4f3b9a1d7cb509ccce670c7d2ee4048e56525 (diff) | |
download | tbdiff-6cb1a8772364e96e62cfda74490db9848c885635.tar.gz |
Allow replacing a file with a compatibility symlink
This means we can do stuff like moving /etc/os-release into /usr/lib
and leaving a compatibility symlink where the file was.
Previously baserock-system-config-sync would fail with the following:
ERROR: found two different types for 'os-release': regular and
symlink
One of the 'failure' test cases now passes, and I've added a specific
test for our 'os-release' case to the 'symblinks' test case too.
Diffstat (limited to 'baserock-system-config-sync')
-rwxr-xr-x | baserock-system-config-sync/baserock-system-config-sync | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/baserock-system-config-sync/baserock-system-config-sync b/baserock-system-config-sync/baserock-system-config-sync index 7b7c697..2cd9807 100755 --- a/baserock-system-config-sync/baserock-system-config-sync +++ b/baserock-system-config-sync/baserock-system-config-sync @@ -54,8 +54,17 @@ check_same_type() { type1="$(file_type $1)" type2="$(file_type $2)" if [ "$type1" != "$type2" ]; then - die "ERROR: found two different types for '$3':" \ - "$type1 and $type2" + if [ "$type1" == symlink ] || [ "$type2" == symlink ]; then + # We allow moving content and leaving a compatibility symlink, as + # long as the content of the file didn't change. + if ! cmp -s "$1" "$2"; then + die "ERROR: $3: replacing a file with a symlink is only " \ + "supported if there are no changes to the content." + fi + else + die "ERROR: found two different types for '$3':" \ + "$type1 and $type2" + fi fi } |