lib/update.updates
changeset 624 889ecd6dcb4e
parent 610 cb4607af8663
child 625 57e4f48a7140
--- a/lib/update.updates	Sat Apr 26 23:55:18 2014 +0300
+++ b/lib/update.updates	Thu Sep 18 21:13:23 2014 +0300
@@ -3,6 +3,10 @@
 #
 # Dependency-based updates + utils
 
+UPDATE_FORCE=
+UPDATE_NOOP=
+UPDATE_DIFF=
+
 ## Compare the given output file with all given source files:
 #
 #   check_update $out ${deps[@]} && do_update $out ... || ...
@@ -95,12 +99,16 @@
 # Tests if the symlink exists, and the target matches.
 # Fails if the target does not exist.
 function check_link {
-    local lnk="$1"
+    local out="$1"
     local tgt="$2"
 
-    [ ! -e "$tgt" ] && fail "$tgt: target does not exist"
-    
-    [ ! -e "$lnk" ] || [ $(readlink "$lnk") != "$tgt" ]
+    [ -e "$out" ] || return 1
+
+    [ -L "$out" ] || fail "$out: is not a link"
+
+    [ "$(readlink "$out")" == "$tgt" ] || return 1
+
+    return 0
 }
 
 ## Update symlink to point to target:
@@ -108,10 +116,12 @@
 #   do_link $lnk $tgt
 #
 function do_link {
-    local lnk="$1"
+    local out="$1"
     local tgt="$2"
 
-    cmd ln -sf "$tgt" "$lnk"
+    cmd ln -sf "$tgt" "$out"
+
+    [ -e "$out" ] || fail "$out: given target does not exist: $tgt"
 }
 
 ## Read include paths from file