busybox-initramfs: init: support update from .tar files

closes #2732
This commit is contained in:
Stefan Saraev 2013-11-02 16:02:19 +02:00
parent 7a8bb83c80
commit 5450520500
2 changed files with 22 additions and 3 deletions

View File

@ -151,7 +151,7 @@ CONFIG_GZIP_FAST=0
# CONFIG_LZOP_COMPR_HIGH is not set # CONFIG_LZOP_COMPR_HIGH is not set
# CONFIG_RPM2CPIO is not set # CONFIG_RPM2CPIO is not set
# CONFIG_RPM is not set # CONFIG_RPM is not set
# CONFIG_TAR is not set CONFIG_TAR=y
# CONFIG_FEATURE_TAR_CREATE is not set # CONFIG_FEATURE_TAR_CREATE is not set
# CONFIG_FEATURE_TAR_AUTODETECT is not set # CONFIG_FEATURE_TAR_AUTODETECT is not set
# CONFIG_FEATURE_TAR_FROM is not set # CONFIG_FEATURE_TAR_FROM is not set
@ -227,7 +227,7 @@ CONFIG_FEATURE_FANCY_ECHO=y
# CONFIG_FALSE is not set # CONFIG_FALSE is not set
# CONFIG_FOLD is not set # CONFIG_FOLD is not set
# CONFIG_FSYNC is not set # CONFIG_FSYNC is not set
# CONFIG_HEAD is not set CONFIG_HEAD=y
# CONFIG_FEATURE_FANCY_HEAD is not set # CONFIG_FEATURE_FANCY_HEAD is not set
# CONFIG_INSTALL is not set # CONFIG_INSTALL is not set
# CONFIG_FEATURE_INSTALL_LONG_OPTIONS is not set # CONFIG_FEATURE_INSTALL_LONG_OPTIONS is not set

View File

@ -495,7 +495,8 @@
UPDATE_KERNEL="MACH_KERNEL" UPDATE_KERNEL="MACH_KERNEL"
fi fi
if [ -f "$UPDATE_DIR/$UPDATE_KERNEL" -a -f "$UPDATE_DIR/$UPDATE_SYSTEM" ] ; then UPDATE_TAR=`ls -1 "$UPDATE_DIR"/*.tar 2>/dev/null | head -n 1`
if [ -f "$UPDATE_DIR/$UPDATE_KERNEL" -a -f "$UPDATE_DIR/$UPDATE_SYSTEM" -o -f "$UPDATE_TAR" ] ; then
if [ "$UPDATE_DISABLED" = "yes" ] ; then if [ "$UPDATE_DISABLED" = "yes" ] ; then
rm -rf $UPDATE_DIR/[0-9a-zA-Z]* &>/dev/null rm -rf $UPDATE_DIR/[0-9a-zA-Z]* &>/dev/null
echo "Updating not supported on netboot. normal startup in 10s..." echo "Updating not supported on netboot. normal startup in 10s..."
@ -503,6 +504,24 @@
usleep 10000000 usleep 10000000
return 0 return 0
fi fi
# check for .tar
if [ -f "$UPDATE_TAR" ] ; then
echo "Found new .tar archive. extracting..."
mkdir -p $UPDATE_DIR/.tmp &>/dev/null
tar -xf "$UPDATE_TAR" -C $UPDATE_DIR/.tmp &>/dev/null
mv $UPDATE_DIR/.tmp/*/target/* $UPDATE_DIR &>/dev/null
rm -f "$UPDATE_TAR" &>/dev/null
rm -rf $UPDATE_DIR/.tmp &>/dev/null
sync
if [ ! -f "$UPDATE_DIR/$UPDATE_KERNEL" -o ! -f "$UPDATE_DIR/$UPDATE_SYSTEM" ] ; then
echo "missing ${UPDATE_KERNEL} or ${UPDATE_SYSTEM}... normal startup in 10s"
sync
usleep 10000000
return 0
fi
fi
if [ -f "$UPDATE_DIR/.nocheck" ] ; then if [ -f "$UPDATE_DIR/.nocheck" ] ; then
MD5_NOCHECK="1" MD5_NOCHECK="1"
fi fi