packages/sysutils/busybox/scripts/init: Add the ability to update the kernel that resides on a block device, such as NAND partition

This commit is contained in:
Alex Deryskyba 2015-05-28 18:18:21 +02:00
parent 2495d063e8
commit 68754ae925

View File

@ -332,7 +332,7 @@
$MOUNT_CMD "$MOUNT_TARGET" "$2" "$3" "$4"
}
update() {
update_file() {
if [ -f "$UPDATE_DIR/$2" -a -f "$3" ]; then
echo "updating $1..."
mount -o remount,rw /flash
@ -345,6 +345,13 @@
fi
}
update_partition() {
if [ -f "$UPDATE_DIR/$2" -a -b "$3" ]; then
echo "updating $1..."
dd if="$UPDATE_DIR/$2" of="$3"
fi
}
update_bootloader() {
export BOOT_ROOT="/flash"
export SYSTEM_ROOT="/sysroot"
@ -602,7 +609,12 @@
# get sizes
FLASH_FREE=$(df /flash/ | awk '/[0-9]%/{print $4}')
FLASH_FREE=$(( $FLASH_FREE * 1024 ))
OLD_KERNEL=$(stat -t "/flash/$IMAGE_KERNEL" | awk '{print $2}')
OLD_KERNEL="0"
if [ ! -b $IMAGE_KERNEL ]; then
OLD_KERNEL=$(stat -t "/flash/$IMAGE_KERNEL" | awk '{print $2}')
fi
OLD_SYSTEM=$(stat -t "/flash/$IMAGE_SYSTEM" | awk '{print $2}')
NEW_KERNEL=$(stat -t "$UPDATE_DIR/$UPDATE_KERNEL" | awk '{print $2}')
NEW_SYSTEM=$(stat -t "$UPDATE_DIR/$UPDATE_SYSTEM" | awk '{print $2}')
@ -624,8 +636,12 @@
if [ "$SIZE_FAILED" -eq "0" ] ; then
# update if md5 check is ok or .nocheck exists
if [ "$MD5_FAILED" -eq "0" -o "$MD5_NOCHECK" -eq "1" ] ; then
update "Kernel" "$UPDATE_KERNEL" "/flash/$IMAGE_KERNEL"
update "System" "$UPDATE_SYSTEM" "/flash/$IMAGE_SYSTEM"
if [ -b $IMAGE_KERNEL ]; then
update_partition "Kernel" "$UPDATE_KERNEL" "$IMAGE_KERNEL"
else
update_file "Kernel" "$UPDATE_KERNEL" "/flash/$IMAGE_KERNEL"
fi
update_file "System" "$UPDATE_SYSTEM" "/flash/$IMAGE_SYSTEM"
update_bootloader
rm -rf $UPDATE_DIR/[0-9a-zA-Z]* &>/dev/null
do_reboot