From f277c9f1aeaef317957520bf8321070e7889a7ac Mon Sep 17 00:00:00 2001 From: Ted Blackman Date: Mon, 30 Aug 2021 20:19:16 +0300 Subject: [PATCH] pkg/symbolic-merge.sh from @Fang- --- pkg/symbolic-merge.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 pkg/symbolic-merge.sh diff --git a/pkg/symbolic-merge.sh b/pkg/symbolic-merge.sh new file mode 100755 index 0000000000..aced17a00d --- /dev/null +++ b/pkg/symbolic-merge.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# call from within pkg/ as ./symbolic-merge.sh source-pkg target-pkg + +function link() { # source desk, target desk, filepath + local src=${3:2}; # strip leading ./ + local pax=$src; + local rel=$1; + while [[ "." != $(dirname "$pax") ]]; do + pax=$(dirname "$pax"); + rel="../$rel"; + done; + ln -sf "../$rel/$src" "../$2/$src"; +} + +# mirror directory structure +cd $1; +find . -type d -exec mkdir -p ../$2/{} \; + +# symlink all files, overwriting existing ones +export -f link +find . -type f \ + -not -name '*.bill' \ + -not -name '*.kelvin' \ + -exec bash -c "link $1 $2 {}" \; +