From 6cb1a8772364e96e62cfda74490db9848c885635 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Fri, 19 Sep 2014 12:22:35 +0100 Subject: 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. --- baserock-system-config-sync/baserock-system-config-sync | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'baserock-system-config-sync/baserock-system-config-sync') 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 } -- cgit v1.2.1 From fef35900a703ac8401e60a2fb89166b3a7e7a27b Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Tue, 23 Sep 2014 11:47:42 +0100 Subject: Use = not == with `test` to be POSIX compatible --- baserock-system-config-sync/baserock-system-config-sync | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'baserock-system-config-sync/baserock-system-config-sync') diff --git a/baserock-system-config-sync/baserock-system-config-sync b/baserock-system-config-sync/baserock-system-config-sync index 2cd9807..061c86c 100755 --- a/baserock-system-config-sync/baserock-system-config-sync +++ b/baserock-system-config-sync/baserock-system-config-sync @@ -54,7 +54,7 @@ check_same_type() { type1="$(file_type $1)" type2="$(file_type $2)" if [ "$type1" != "$type2" ]; then - if [ "$type1" == symlink ] || [ "$type2" == symlink ]; then + 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 -- cgit v1.2.1