1
0
mirror of https://github.com/ilyakooo0/urbit.git synced 2024-12-23 06:42:09 +03:00
urbit/pkg/symbolic-merge.sh
2021-08-30 20:19:16 +03:00

27 lines
609 B
Bash
Executable File

#!/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 {}" \;