aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChen Qi <Qi.Chen@windriver.com>2015-03-20 13:51:20 +0800
committerChen Qi <Qi.Chen@windriver.com>2015-03-20 14:19:28 +0800
commit90fb0fe5d4a4139729dbaf7ba39191bf8c9608a8 (patch)
tree7c308436975b754dd8bef678f5708895143c4555
parent0752c79282b1cc9699743e719518e6c341d50a3a (diff)
downloadopenembedded-core-contrib-ChenQi/populate-volatile-cache.tar.gz
populate-volatile.sh: detect the change of configuration filesChenQi/populate-volatile-cache
In case the configuration files are modified by user, the cached script, /etc/volatile.cache should not be executed. Instead, the configuration files should be parsed again and generate the new cache. Otherwise, the user modifications take no effect which would obviously confuse users. Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
-rwxr-xr-xmeta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh19
1 files changed, 18 insertions, 1 deletions
diff --git a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
index 904037eeaa..eaf0f1c557 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
+++ b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
@@ -204,9 +204,25 @@ do
done
exec 9>&-
-if test -e ${ROOT_DIR}/etc/volatile.cache -a "$VOLATILE_ENABLE_CACHE" = "yes" -a "x$1" != "xupdate" -a "x$clearcache" = "x0"
+# Check whether configuration files have changed, if so, the cache needs to be removed
+# and generated again
+CACHE_MATCH="no"
+CACHE_DATA="${ROOT_DIR}/etc/.volatile.cache.data"
+CACHE_TMP="${ROOT_DIR}/etc/.volatile.cache.tmp"
+VOLATILE_CONFFILES="${ROOT_DIR}/etc/default/volatiles/*"
+if [ "$VOLATILE_ENABLE_CACHE" = "yes" ]; then
+ stat -c '%s %Y %n' $VOLATILE_CONFFILES | awk -F/ '{print $1 " " $NF;}' > $CACHE_TMP
+ if [ -e $CACHE_DATA ]; then
+ if cmp $CACHE_DATA $CACHE_TMP > /dev/null; then
+ CACHE_MATCH="yes"
+ fi
+ fi
+fi
+
+if test -e ${ROOT_DIR}/etc/volatile.cache -a "$VOLATILE_ENABLE_CACHE" = "yes" -a "x$1" != "xupdate" -a "x$clearcache" = "x0" -a "$CACHE_MATCH" = "yes"
then
sh ${ROOT_DIR}/etc/volatile.cache
+ [ -e $CACHE_TMP ] && rm $CACHE_TMP
else
rm -f ${ROOT_DIR}/etc/volatile.cache ${ROOT_DIR}/etc/volatile.cache.build
for file in `ls -1 "${CFGDIR}" | sort`; do
@@ -214,6 +230,7 @@ else
done
[ -e ${ROOT_DIR}/etc/volatile.cache.build ] && sync && mv ${ROOT_DIR}/etc/volatile.cache.build ${ROOT_DIR}/etc/volatile.cache
+ [ -e $CACHE_TMP ] && mv $CACHE_TMP $CACHE_DATA
fi
if [ -z "${ROOT_DIR}" ] && [ -f /etc/ld.so.cache ] && [ ! -f /var/run/ld.so.cache ]