Patchwork [17/20] udev-cache: fix udev-cache changes to work with busybox tar

login
register
mail settings
Submitter Ben Shelton
Date Aug. 4, 2014, 6:41 p.m.
Message ID <7b6bd6dce94e0b3d570dd2a710a44fe3c6092346.1407177403.git.ben.shelton@ni.com>
Download mbox | patch
Permalink /patch/77219/
State New
Headers show

Comments

Ben Shelton - Aug. 4, 2014, 6:41 p.m.
busybox tar does not support the --one-file-system option that we use to
keep tar from archiving unnecessary files that live under /dev but are
not mounted under the devtmpfs.  Instead, when GNU tar is not present,
use find to pass tar a list of the files that need to be cached.

Additionally, busybox tar does not complain when timestamps are in the
future, and the OE busybox defconfig does not have the
TAR_NOPRESERVE_TIME option enabled, so don't use the '-m' option with
busybox tar.

Signed-off-by: Ben Shelton <ben.shelton@ni.com>
---
 meta/recipes-core/udev/udev/init               | 14 +++++++++-----
 meta/recipes-core/udev/udev/udev-cache         | 12 ++++++++++--
 meta/recipes-core/udev/udev/udev-cache.default |  4 ++++
 3 files changed, 23 insertions(+), 7 deletions(-)

Patch

diff --git a/meta/recipes-core/udev/udev/init b/meta/recipes-core/udev/udev/init
index 3a52e98..6caf7d5 100644
--- a/meta/recipes-core/udev/udev/init
+++ b/meta/recipes-core/udev/udev/init
@@ -70,11 +70,15 @@  case "$1" in
 		    readfiles "$DEVCACHE_SYSCONF"
 		    OLDDATA="$READDATA"
 		    if [ "$OLDDATA" = "$NEWDATA" -a -f "$DEVCACHE" ]; then
-                            tar xzf $DEVCACHE -C / $DEVCACHE_EXTRACT_OPTS
-                            not_first_boot=1
-                            [ "$VERBOSE" != "no" ] && echo "udev: using cache file $DEVCACHE"
-                            [ -e "$DEVCACHE_CURRENT_SYSCONF" ] && rm -f "$DEVCACHE_CURRENT_SYSCONF"
-                    else
+			    if [ ! `readlink -f /bin/tar` = "/bin/tar.tar" ]; then
+				    tar xzf $DEVCACHE -C / $BUSYBOX_DEVCACHE_EXTRACT_OPTS
+			    else
+				    tar xzf $DEVCACHE -C / $DEVCACHE_EXTRACT_OPTS
+			    fi
+			    not_first_boot=1
+			    [ "$VERBOSE" != "no" ] && echo "udev: using cache file $DEVCACHE"
+			    [ -e "$DEVCACHE_CURRENT_SYSCONF" ] && rm -f "$DEVCACHE_CURRENT_SYSCONF"
+		    else
 			    # Output detailed reason why the cached /dev is not used
 			    if [ "$VERBOSE" != "no" ]; then
 				    echo "udev: udev cache not used"
diff --git a/meta/recipes-core/udev/udev/udev-cache b/meta/recipes-core/udev/udev/udev-cache
index 7eea5fb..43bc67a 100644
--- a/meta/recipes-core/udev/udev/udev-cache
+++ b/meta/recipes-core/udev/udev/udev-cache
@@ -28,10 +28,18 @@  fi
 [ -e "$DEVCACHE_CURRENT_SYSCONF" ] || { echo "not found"; exit 0; }
 [ "${VERBOSE}" == "no" ] || echo "found; building cache."
 
-(
+if [ ! `readlink -f /bin/tar` = "/bin/tar.tar" ]; then
+	(
+	find /dev \( -type b -o -type c -o -type l \) -xdev | cut -c 2- | xargs tar czf "${DEVCACHE}.tmp" -C / $BUSYBOX_DEVCACHE_CREATE_OPTS && \
+		mv -f "${DEVCACHE}.tmp" "$DEVCACHE" && \
+		mv "$DEVCACHE_CURRENT_SYSCONF" "$DEVCACHE_SYSCONF"
+	) &
+else
+	(
 	tar czf "${DEVCACHE}.tmp" dev -C / $DEVCACHE_CREATE_OPTS && \
 		mv -f "${DEVCACHE}.tmp" "$DEVCACHE" && \
 		mv "$DEVCACHE_CURRENT_SYSCONF" "$DEVCACHE_SYSCONF"
-) &
+	) &
+fi
 
 exit 0
diff --git a/meta/recipes-core/udev/udev/udev-cache.default b/meta/recipes-core/udev/udev/udev-cache.default
index c71826e..d2c1e5c 100644
--- a/meta/recipes-core/udev/udev/udev-cache.default
+++ b/meta/recipes-core/udev/udev/udev-cache.default
@@ -12,4 +12,8 @@  DEVCACHE_CURRENT_SYSCONF="/dev/shm/udev.cache"
 DEVCACHE_EXTRACT_OPTS="--exclude=log -m --exclude=udev.cache --one-file-system"
 DEVCACHE_CREATE_OPTS="--exclude=log --exclude=udev.cache --one-file-system"
 
+# Busybox tar does not support --one-file-system option
+BUSYBOX_DEVCACHE_EXTRACT_OPTS="--exclude=log --exclude=udev.cache"
+BUSYBOX_DEVCACHE_CREATE_OPTS="--exclude=log --exclude=udev.cache"
+
 PROBE_PLATFORM_BUS="yes"