Skip to contentSkip to conversation

populate-volatile.sh: detect the change of configuration files

PATCH In review Chen Qi 2 participants 5 messages Mar 20, 2015 – Apr 21, 2015

lore
Share & tools
lore

Chen Qi

author
#0 lore raw

cover populate-volatile.sh: detect the change of configuration files

The following changes since commit 0752c79282b1cc9699743e719518e6c341d50a3a:

systemd: fix /var/log/journal ownership (2015-03-16 17:38:51 +0000)

are available in the git repository at:

git://git.openembedded.org/openembedded-core-contrib ChenQi/populate-volatile-cache
http://cgit.openembedded.org/cgit.cgi/openembedded-core-contrib/log/?h=ChenQi/populate-volatile-cache

Chen Qi (1):
populate-volatile.sh: detect the change of configuration files

 .../initscripts/initscripts-1.0/populate-volatile.sh  | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH 1/1 populate-volatile.sh: detect the change of configuration files

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.

---
 .../initscripts/initscripts-1.0/populate-volatile.sh  | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +18 -1
index 904037e..eaf0f1c 100755
@@ -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 ]
Signature · 1 line
1.9.1
author
#2 lore raw

ping ...

//Chen Qi

Quoted 49 lines · Chen Qi

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.

---
  .../initscripts/initscripts-1.0/populate-volatile.sh  | 19 ++++++++++++++++++-
  1 file changed, 18 insertions(+), 1 deletion(-)
meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +18 -1
index 904037e..eaf0f1c 100755
@@ -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 ]
#3 lore raw

Chen,

Quoted 67 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of ChenQi
Sent: Tuesday, April 21, 2015 2:00 AM
To: [email protected]
Subject: Re: [OE-core] [PATCH 1/1] populate-volatile.sh: detect the change of configuration files

ping ...

//Chen Qi

Quoted 4 lines · Chen Qi

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.

Quoted 4 lines
---
  .../initscripts/initscripts-1.0/populate-volatile.sh  | 19

++++++++++++++++++-

Quoted 11 lines
  1 file changed, 18 insertions(+), 1 deletion(-)

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 904037e..eaf0f1c 100755
---
a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +++ b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile. +++ sh

meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh do · line 207

Quoted 4 lines
meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +0 -1
@@ -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"

Quoted 8 lines
meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +7 -0
+# 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

meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh do

Quoted 8 lines
meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +8 -0
+	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"

meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh do

Quoted 5 lines
  then
  	sh ${ROOT_DIR}/etc/volatile.cache
meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +1 -0
+	[ -e $CACHE_TMP ] && rm $CACHE_TMP
  else
  	rm -f ${ROOT_DIR}/etc/volatile.cache

${ROOT_DIR}/etc/volatile.cache.build

Quoted 3 lines
  	for file in `ls -1 "${CFGDIR}" | sort`; do @@ -214,6 +230,7 @@ else
  	done
Quoted 8 lines
Quoted 7 lines

[ -e ${ROOT_DIR}/etc/volatile.cache.build ] && sync && mv
${ROOT_DIR}/etc/volatile.cache.build ${ROOT_DIR}/etc/volatile.cache

meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +1 -0
+	[ -e $CACHE_TMP ] && mv $CACHE_TMP $CACHE_DATA
  fi
 
  if [ -z "${ROOT_DIR}" ] && [ -f /etc/ld.so.cache ] && [ ! -f

/var/run/ld.so.cache ]

I didn't see this patch when I was working through my issues. I'll test this patch on my system with my change to pkg_postinst removed and verify I get the same end result.

Regards,
Bryan

Quoted 5 lines

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#4 lore raw

Chen,

Quoted 87 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Bryan Evenson
Sent: Tuesday, April 21, 2015 8:35 AM
To: ChenQi; [email protected]
Subject: Re: [OE-core] [PATCH 1/1] populate-volatile.sh: detect the change of configuration files

Chen,

Quoted 3 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On

Behalf Of

Quoted 36 lines

ChenQi
Sent: Tuesday, April 21, 2015 2:00 AM
To: [email protected]
Subject: Re: [OE-core] [PATCH 1/1] populate-volatile.sh: detect the change of configuration files

ping ...

//Chen Qi

Quoted 5 lines · Chen Qi

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.

Quoted 4 lines
---
  .../initscripts/initscripts-1.0/populate-volatile.sh  | 19

++++++++++++++++++-

Quoted 14 lines
  1 file changed, 18 insertions(+), 1 deletion(-)

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 904037e..eaf0f1c 100755
---
a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +++ b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile. +++ sh

meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +0 -0
@@ -204,9 +204,25 @@ do
  done
  exec 9>&-
 
Quoted 1 line

Review do · line 207

Quoted 1 line
(quoted diff) +0 -1
-if test -e ${ROOT_DIR}/etc/volatile.cache -a

"$VOLATILE_ENABLE_CACHE"

Quoted 17 lines

= "yes" -a "x$1" != "xupdate" -a "x$clearcache" = "x0"

Quoted 8 lines
meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +7 -0
+# 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

meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh do

Quoted 8 lines
meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +8 -0
+	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"

Quoted 16 lines

= "yes" -a "x$1" != "xupdate" -a "x$clearcache" = "x0" -a "$CACHE_MATCH" = "yes"

meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh do

Quoted 5 lines
  then
  	sh ${ROOT_DIR}/etc/volatile.cache
meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +1 -0
+	[ -e $CACHE_TMP ] && rm $CACHE_TMP
  else
  	rm -f ${ROOT_DIR}/etc/volatile.cache

${ROOT_DIR}/etc/volatile.cache.build

Quoted 8 lines
  	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

meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +1 -0
+	[ -e $CACHE_TMP ] && mv $CACHE_TMP $CACHE_DATA
  fi
Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

if [ -z "${ROOT_DIR}" ] && [ -f /etc/ld.so.cache ] && [ ! -f
/var/run/ld.so.cache ]

I didn't see this patch when I was working through my issues. I'll test this patch on my system with my change to pkg_postinst removed and verify I get the same end result.

I reverted commit 167025e6d72c44cacfdc5d8b98e942066df09a4f on my system and applied your patch and applied the upgrade as before. /etc/volatile.cache was updated on my system and I don't see any of the problems I was experiencing previously. This fix works for me.

Regards,
Bryan

Quoted 14 lines

Regards,
Bryan

Quoted 5 lines

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core