chiark / gitweb /
Pseudo-merge of mariner/msriner
[ian-dotfiles.git] / infra / makelinks
index 20faafc592912d757c74acf5b4de56e381d45e2e..46c901e9b0c0a3d17a62abac41802243d6e6e231 100755 (executable)
@@ -76,6 +76,18 @@ process_object () {
     inhome="$HOME/$underhome"
     prhome="~/$underhome"
     linktarget="$basepath/$ours"
     inhome="$HOME/$underhome"
     prhome="~/$underhome"
     linktarget="$basepath/$ours"
+    chompy="$underhome"
+    while true; do
+       case "$chompy" in
+        *?/?*)
+           linktarget="../$linktarget"
+           chompy="${chompy%/*}"
+           ;;
+       *)
+           break
+           ;;
+       esac
+    done
     if [ "$inhome" -ef "$ours" ]; then
        good "already symlinked here"
     elif [ -h "$inhome" ]; then
     if [ "$inhome" -ef "$ours" ]; then
        good "already symlinked here"
     elif [ -h "$inhome" ]; then
@@ -121,6 +133,31 @@ for ours in $nondots; do
     process_object
 done
 
     process_object
 done
 
+exec 3<correspondences
+while read <&3 ours underhome; do
+    case "$ours" in
+    ''|'#'*) ;;
+    *)
+       case "$underhome" in
+       */*)
+           parent=${underhome%/*}
+           punderhome="$HOME/$parent"
+           prhome="~/${underhome%/*}"
+           if [ -d "$punderhome" ]; then
+               good "directory exists"
+           elif ! [ -e "$punderhome" ]; then
+               needs setup "directory does not exist"
+               $act mkdir -p "$punderhome"
+           else
+               bad "ought to be director but isn't"
+           fi
+           ;;
+       esac
+       process_object
+       ;;
+    esac
+done
+
 brokens=$(
     cd $HOME
     find -L .[0-9a-zA-Z]* -maxdepth 0 -xdev -type l \
 brokens=$(
     cd $HOME
     find -L .[0-9a-zA-Z]* -maxdepth 0 -xdev -type l \