From faeff1759cab4ff8e53a8f3f89f66febae5ea9e5 Mon Sep 17 00:00:00 2001 From: Shaun Inman Date: Mon, 6 Feb 2023 21:01:27 -0500 Subject: [PATCH] update updates misc if anything changed --- makefile | 1 + src/boot/boot.sh | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/makefile b/makefile index cdfb40f..2311b4d 100644 --- a/makefile +++ b/makefile @@ -54,6 +54,7 @@ bundle: cp ./src/boot/output/dmenu.bin ./build/BASE cp ./src/boot/output/dmenu.bin ./build/SYSTEM/rg35xx/dat + echo "$(BUILD_HASH)" > ./build/SYSTEM/commit.txt # populate system cp ~/buildroot/output/images/rootfs.ext2 ./build/SYSTEM/rg35xx diff --git a/src/boot/boot.sh b/src/boot/boot.sh index d1def6e..44e7c07 100755 --- a/src/boot/boot.sh +++ b/src/boot/boot.sh @@ -35,6 +35,7 @@ fi # is there an update available? if [ -f $UPDATE_PATH ]; then + { FLAG_PATH=/misc/.minstalled if [ ! -f $FLAG_PATH ]; then ACTION=installing @@ -51,6 +52,8 @@ if [ -f $UPDATE_PATH ]; then dd if=/tmp/$ACTION of=/dev/fb0 sync + # TODO: move this logic into MinUI.zip contents? + busybox unzip -o $UPDATE_PATH -d $SDCARD_PATH rm -f $UPDATE_PATH if [ ! -f $FLAG_PATH ]; then @@ -60,15 +63,44 @@ if [ -f $UPDATE_PATH ]; then cp /misc/boot_logo.bmp.gz $BAK_PATH cp /misc/kernel.dtb $BAK_PATH cp /misc/uImage $BAK_PATH + fi + + was_updated() { + for FILE in /misc/* /misc/*/*; do + A_PATH=$FILE + B_PATH=$SYSTEM_PATH/dat/$(busybox basename "$A_PATH") + + if [ ! -f "$B_PATH" ]; then + continue + fi + + A_SUM=$(busybox md5sum $A_PATH | busybox cut -d ' ' -f 1) + B_SUM=$(busybox md5sum $B_PATH | busybox cut -d ' ' -f 1) + + if [[ "$A_SUM" != "$B_SUM" ]]; then + return 0 + fi + done + + return 1 + } + + if [ ! -f $FLAG_PATH ] || was_updated; then + echo "updating misc partition" mount -o remount,rw /dev/block/actb /misc rm -f /misc/uImage cp $SYSTEM_PATH/dat/uImage /misc - cp $SYSTEM_PATH/dat/boot_logo.bmp.gz /misc + cp $SYSTEM_PATH/dat/dmenu.bin /misc + if [ ! -f $FLAG_PATH ]; then + # only replace boot logo on install not update + cp $SYSTEM_PATH/dat/boot_logo.bmp.gz /misc + fi cp $SYSTEM_PATH/dat/kernel.dtb /misc cp $SYSTEM_PATH/dat/gpio_keys_polled.ko /misc/modules touch $FLAG_PATH sync && reboot fi + } &> /mnt/sdcard/install.txt fi ROOTFS_IMAGE=$SYSTEM_PATH/rootfs.ext2