--- a/lib/pvl/hosts/dhcp.sh Tue Mar 03 12:08:58 2015 +0200
+++ b/lib/pvl/hosts/dhcp.sh Tue Mar 03 12:09:22 2015 +0200
@@ -11,10 +11,11 @@
function update_hosts_dhcp {
local out="$1"
local src="$2"
- local srcs=($(list_tree $src))
local msg="$out: Generating DHCP hosts: $src"
+ local include_cache=$(include_cache_path $src)
+ local srcs=($(include_cache $include_cache))
- if apply_check "$out" "${srcs[@]}"; then
+ if apply_check "$out" ${srcs[@]:-}; then
log_skip "$msg"
else
log_apply "$msg"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/pvl/hosts/include_cache.sh Tue Mar 03 12:09:22 2015 +0200
@@ -0,0 +1,26 @@
+INCLUDE_CACHE='var/include-cache'
+
+## Normalize a given source path for use in the include-cache
+function include_cache_path {
+ local src="$1"
+ local cache="$src"
+
+ cache="${cache//_/__}"
+ cache="${cache//\//_}"
+
+ echo "$INCLUDE_CACHE/$cache"
+}
+
+## Read the include cache for given path
+function include_cache {
+ local cache="$1"
+
+ if [ ! -e "$cache" ]; then
+ debug "missing: $cache"
+
+ return 0
+ fi
+
+ cat $cache
+}
+
--- a/lib/pvl/hosts/update.sh Tue Mar 03 12:08:58 2015 +0200
+++ b/lib/pvl/hosts/update.sh Tue Mar 03 12:09:22 2015 +0200
@@ -4,6 +4,7 @@
UPDATE_RELOAD=
UPDATE_INCLUDES=
+. $LIB/pvl/hosts/include_cache.sh
. $LIB/pvl/hosts/dhcp.sh
. $LIB/pvl/hosts/zone.sh
--- a/lib/pvl/hosts/zone.sh Tue Mar 03 12:08:58 2015 +0200
+++ b/lib/pvl/hosts/zone.sh Tue Mar 03 12:09:22 2015 +0200
@@ -13,16 +13,18 @@
function update_hosts_forward {
local out="$1"
local src="$2"
- local srcs=($(list_tree $src))
local msg="$out: Generating forward hosts zone: $src"
+ local include_cache=$(include_cache_path $src)
+ local srcs=($(include_cache $include_cache))
- if apply_check "$out" "${srcs[@]}"; then
+ if apply_check "$out" ${srcs[@]:-}; then
log_skip "$msg"
else
log_apply "$msg"
apply_cmd "$out" $OPT/bin/pvl.hosts-forward \
- --hosts-include="$HOSTS_INCLUDE" \
+ --hosts-include=$HOSTS_INCLUDE \
+ --hosts-include-trace=$include_cache \
"$src"
fi
}
@@ -33,16 +35,18 @@
function update_hosts_reverse {
local out="$1"
local src="$2"
- local srcs=($(list_tree $src))
local msg="$out: Generating reverse hosts zone: $src"
+ local include_cache=$(include_cache_path $src)
+ local srcs=($(include_cache $include_cache))
- if apply_check "$out" "${srcs[@]}"; then
+ if apply_check "$out" ${srcs[@]:-}; then
log_skip "$msg"
else
log_apply "$msg"
apply_cmd "$out" $OPT/bin/pvl.hosts-reverse \
--hosts-include="$HOSTS_INCLUDE" \
+ --hosts-include-trace=$include_cache \
"$src"
fi
}