[OE-core] [PATCH 14/20] udev-cache: refactor; improve verbosity and error handling

Ben Shelton ben.shelton at ni.com
Mon Aug 4 18:41:06 UTC 2014


From: Richard Tollerton <rich.tollerton at ni.com>

Most of /etc/init.d/udev-cache is in a conditional block which can be
replaced by a `[ ... ] || exit 0` to reduce nesting. This eliminates
a `rm -f` which was dead code anyway.

This also provides the opportunity to emit a few more messages if
VERBOSE is set, which may help with future debugging.

Finally, make installing the new $DEVCACHE_SYSCONF contingent on
successfully creating the cache tarball.

Natinst-Rally-ID: TA44427
Acked-by: Gratian Crisan <gratian.crisan at ni.com>
Natinst-ReviewBoard-ID: 58620
Signed-off-by: Richard Tollerton <rich.tollerton at ni.com>
---
 meta/recipes-core/udev/udev/udev-cache | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/meta/recipes-core/udev/udev/udev-cache b/meta/recipes-core/udev/udev/udev-cache
index 29700e0..7eea5fb 100644
--- a/meta/recipes-core/udev/udev/udev-cache
+++ b/meta/recipes-core/udev/udev/udev-cache
@@ -23,13 +23,15 @@ if [ "$ROOTFS_READ_ONLY" = "yes" ]; then
     exit 0
 fi
 
-if [ "$DEVCACHE" != "" -a -e "$DEVCACHE_CURRENT_SYSCONF" ]; then
-	[ "${VERBOSE}" != "no" ] && echo "Populating dev cache"
-	(
-		tar czf "${DEVCACHE}.tmp" dev -C / $DEVCACHE_CREATE_OPTS
-		mv -f "${DEVCACHE}.tmp" "$DEVCACHE"
+[ "$DEVCACHE" != "" ] || exit 0
+[ "${VERBOSE}" == "no" ] || echo -n "$0: checking for ${DEVCACHE_CURRENT_SYSCONF}... "
+[ -e "$DEVCACHE_CURRENT_SYSCONF" ] || { echo "not found"; exit 0; }
+[ "${VERBOSE}" == "no" ] || echo "found; building cache."
+
+(
+	tar czf "${DEVCACHE}.tmp" dev -C / $DEVCACHE_CREATE_OPTS && \
+		mv -f "${DEVCACHE}.tmp" "$DEVCACHE" && \
 		mv "$DEVCACHE_CURRENT_SYSCONF" "$DEVCACHE_SYSCONF"
-	) &
-fi
+) &
 
 exit 0
-- 
2.0.4




More information about the Openembedded-core mailing list