chiark / gitweb /
Merge old CVS `ian-dotfiles' repo, as a subtree where we can pick bits
[ian-dotfiles.git] / infra / makelinks
index dd167d31a200fcda856a91e3568a4a79670c275c..20faafc592912d757c74acf5b4de56e381d45e2e 100755 (executable)
@@ -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 () {
@@ -72,11 +72,7 @@ with_log () {
     "$@"
 }
 
-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/}"
+process_object () {
     inhome="$HOME/$underhome"
     prhome="~/$underhome"
     linktarget="$basepath/$ours"
@@ -86,10 +82,10 @@ for dot in $dots; do
         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"
@@ -100,7 +96,7 @@ for dot in $dots; do
            $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,11 +105,26 @@ for dot in $dots; do
     else
        bad "mismatched file types"
     fi
+}
+
+dots=$( find dot -mindepth 1 -maxdepth 1 -name '[0-9a-zA-Z]*[0-9a-zA-Z]' )
+
+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
 
 brokens=$(
     cd $HOME
-    find -L .[0-9a-zA-Z]* -maxdepth 0 -xdev -type l -lname "$basepath/dot/*"
+    find -L .[0-9a-zA-Z]* -maxdepth 0 -xdev -type l \
+        \( -lname "$basepath/dot/*" -o -lname "$basepath/home/*" \)
 )
 for underhome in $brokens; do
     inhome="$HOME/$underhome"