X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=ian-dotfiles.git;a=blobdiff_plain;f=infra%2Fmakelinks;h=46c901e9b0c0a3d17a62abac41802243d6e6e231;hp=d6b6186f6bcc91903b18f87d3c62c102105ef54d;hb=86343534d2cf39cde05d8524f6eafca054d0030e;hpb=e4b92f44b5884bae02a32d307468097725f0e781 diff --git a/infra/makelinks b/infra/makelinks index d6b6186..46c901e 100755 --- a/infra/makelinks +++ b/infra/makelinks @@ -44,13 +44,13 @@ show () { good () { if [ $mode = list ]; then - show "good: $dot: $1" + show "good: $prhome: $1" fi } bad () { estatus=16 - show "bad: $dot: $1" >&2 + show "bad: $prhome: $1" >&2 } needs () { @@ -76,16 +76,28 @@ process_object () { 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 bad "wrong symlink target" elif ! [ -e "$inhome" ]; then needs setup "absent here" - $act ln -s "$basepath/$dot" "$inhome" + $act ln -s "$linktarget" "$inhome" elif [ -f "$inhome" ] && [ -f "$ours" ]; then if cmp -s "$ours" "$inhome"; then - needs setup "identical here but not yet symlinked" + needs setup "identical in this ~ but not yet symlinked" $act rm -f "$inhome"~ $act ln -s "$linktarget" "$inhome"~ $act mv -f "$inhome"~ "$inhome" @@ -96,7 +108,7 @@ process_object () { $act mv -f "$ours"~ "$ours" fi elif [ -d "$inhome" ] && [ -d "$ours" ]; then - needs dirimport "directory here not yet symlinked" + needs dirimport "directory in this ~, not yet symlinked" $act mv "$ours" "$ours~" $act ln -s "$linktarget" "$inhome"~ $act mv "$inhome" "$ours" @@ -109,15 +121,47 @@ process_object () { dots=$( find dot -mindepth 1 -maxdepth 1 -name '[0-9a-zA-Z]*[0-9a-zA-Z]' ) -for dot in $dots; do - ours="$dot" - underhome=".${dot#dot/}" +for ours in $dots; do + underhome=".${ours#dot/}" process_object done +nondots=$( find home -mindepth 1 -maxdepth 1 -name '[0-9a-zA-Z]*[0-9a-zA-Z]' ) + +for ours in $nondots; do + underhome="${ours#home/}" + process_object +done + +exec 3