summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--functions37
1 files changed, 15 insertions, 22 deletions
diff --git a/functions b/functions
index 662df7b..4219680 100644
--- a/functions
+++ b/functions
@@ -114,33 +114,26 @@ add_symlink ()
#fail quietly
}
-add_file ()
+add_file()
{
- local fil lnk dir dest
- if [[ -f "$1" ]]; then
- fil=$1
- lnk=$(readlink -f "${fil}")
- if [[ ${lnk} ]]; then
- add_symlink "${fil}" "${lnk}"
- fil="${lnk}"
- fi
- if [[ $2 ]]; then
- dest=$2
- else
- dest="${fil##$BASEDIR}"
- if [[ "${dest}" = "${dest#/}" ]]; then
- dest="/${dest}"
- fi
- fi
+ local file dest
- add_dir $(get_dirname "${dest}")
+ file=$1
+ dest=${2:-${file##$BASEDIR}}
- if [[ ! -e $TMPDIR/root/$dest ]]; then
- msg " adding file ${dest}"
- command install -Dm$(stat -c '%a' "$fil") "$fil" "$TMPDIR/root/$dest"
+ if [[ -f "$file" ]]; then
+ if [[ -L "$file" ]]; then
+ add_symlink "$file" "$(readlink -f "$file")"
+ add_file "$(readlink -f "$file")"
+ return
+ fi
+
+ if [[ ! -e "$TMPDIR/root/$dest" ]]; then
+ msg " adding file $dest"
+ command install -Dm$(stat -c '%a' "$file") "$file" "$TMPDIR/root/$dest"
fi
else
- err "file '${1}' does not exist"
+ err "file '$file' does not exist"
return 1
fi
}