equal
deleted
inserted
replaced
1 #!/bin/bash |
1 #!/bin/bash |
2 # vim: set ft=sh : |
2 # vim: set ft=sh : |
3 # |
3 # |
4 # Dependency-based updates + utils |
4 # Dependency-based updates + utils |
|
5 |
|
6 UPDATE_FORCE= |
|
7 UPDATE_NOOP= |
|
8 UPDATE_DIFF= |
5 |
9 |
6 ## Compare the given output file with all given source files: |
10 ## Compare the given output file with all given source files: |
7 # |
11 # |
8 # check_update $out ${deps[@]} && do_update $out ... || ... |
12 # check_update $out ${deps[@]} && do_update $out ... || ... |
9 # |
13 # |
93 # check_link $lnk $tgt && do_link $lnk $tgt || ... |
97 # check_link $lnk $tgt && do_link $lnk $tgt || ... |
94 # |
98 # |
95 # Tests if the symlink exists, and the target matches. |
99 # Tests if the symlink exists, and the target matches. |
96 # Fails if the target does not exist. |
100 # Fails if the target does not exist. |
97 function check_link { |
101 function check_link { |
98 local lnk="$1" |
102 local out="$1" |
99 local tgt="$2" |
103 local tgt="$2" |
100 |
104 |
101 [ ! -e "$tgt" ] && fail "$tgt: target does not exist" |
105 [ -e "$out" ] || return 1 |
102 |
106 |
103 [ ! -e "$lnk" ] || [ $(readlink "$lnk") != "$tgt" ] |
107 [ -L "$out" ] || fail "$out: is not a link" |
|
108 |
|
109 [ "$(readlink "$out")" == "$tgt" ] || return 1 |
|
110 |
|
111 return 0 |
104 } |
112 } |
105 |
113 |
106 ## Update symlink to point to target: |
114 ## Update symlink to point to target: |
107 # |
115 # |
108 # do_link $lnk $tgt |
116 # do_link $lnk $tgt |
109 # |
117 # |
110 function do_link { |
118 function do_link { |
111 local lnk="$1" |
119 local out="$1" |
112 local tgt="$2" |
120 local tgt="$2" |
113 |
121 |
114 cmd ln -sf "$tgt" "$lnk" |
122 cmd ln -sf "$tgt" "$out" |
|
123 |
|
124 [ -e "$out" ] || fail "$out: given target does not exist: $tgt" |
115 } |
125 } |
116 |
126 |
117 ## Read include paths from file |
127 ## Read include paths from file |
118 function read_zone_includes { |
128 function read_zone_includes { |
119 cmd sed -n -E 's/^\$INCLUDE\s+"(.+)"/\1/p' "$@" |
129 cmd sed -n -E 's/^\$INCLUDE\s+"(.+)"/\1/p' "$@" |