From 682635fc2f10171612f894da2dad42f0adad7661 Mon Sep 17 00:00:00 2001 From: Nate Levesque Date: Mon, 19 Sep 2016 21:47:43 -0400 Subject: [PATCH 1/2] Use --dereference flag for cp There's already a CreateLink, so there doesn't seem to be much point in copying symlinks. Using --dereference opens up more possibilities for storing configs. --- src/helpers.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers.bash b/src/helpers.bash index e365b9da..12f1e070 100644 --- a/src/helpers.bash +++ b/src/helpers.bash @@ -80,7 +80,7 @@ function CopyFile() { mkdir --parents "$(dirname "$output_dir"/files/"$file")" - cp --no-dereference \ + cp --dereference \ "$config_dir"/files/"$file" \ "$output_dir"/files/"$file" From 0dc1134eefe34f7f65925a310afcb10e92c243ee Mon Sep 17 00:00:00 2001 From: Nate Levesque Date: Wed, 21 Sep 2016 20:28:59 -0400 Subject: [PATCH 2/2] Add a dedicated copy function for cp --dereference --- src/helpers.bash | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/helpers.bash b/src/helpers.bash index 12f1e070..05300a76 100644 --- a/src/helpers.bash +++ b/src/helpers.bash @@ -80,6 +80,35 @@ function CopyFile() { mkdir --parents "$(dirname "$output_dir"/files/"$file")" + cp --no-dereference \ + "$config_dir"/files/"$file" \ + "$output_dir"/files/"$file" + + SetFileProperty "$file" mode "$mode" + SetFileProperty "$file" owner "$owner" + SetFileProperty "$file" group "$group" +} + +# +# CopyFileDeref PATH [MODE [OWNER [GROUP]]] +# +# Copies a file from the "files" subdirectory to the output, with dereferencing +# if the file is a symlink. +# +# The specified path should be relative to the root of the "files" subdirectory. +# +# If MODE, OWNER and GROUP are unspecified, they default to +# "644", "root" and "root" respectively for new files. +# + +function CopyFileDeref() { + local file="$1" + local mode="${2:-}" + local owner="${3:-}" + local group="${4:-}" + + mkdir --parents "$(dirname "$output_dir"/files/"$file")" + cp --dereference \ "$config_dir"/files/"$file" \ "$output_dir"/files/"$file"