scripts/om-fwupgradecfg-gen.sh: Generate checksum over whole squashfs
[openwrt/staging/dedeckeh.git] / scripts / om-fwupgradecfg-gen.sh
index 915fbd05ab48a701b6abcf30891e8ebcdf4fec55..ce33454a24657b48b44dcf133b2ff4c0d3ce121b 100755 (executable)
@@ -23,28 +23,24 @@ case $CE_TYPE in
        OM2P)
                MAX_PART_SIZE=7168
                KERNEL_FLASH_ADDR=0x1c0000
-               MD5_SKIP_BLOCKS=4
                SIZE_FACTOR=1
                SIZE_FORMAT="%d"
                ;;
        OM5P|OM5PAC|MR600|MR900|MR1750|A60)
                MAX_PART_SIZE=7808
                KERNEL_FLASH_ADDR=0xb0000
-               MD5_SKIP_BLOCKS=4
                SIZE_FACTOR=1
                SIZE_FORMAT="%d"
                ;;
        A42)
                MAX_PART_SIZE=15616
                KERNEL_FLASH_ADDR=0x180000
-               MD5_SKIP_BLOCKS=4
                SIZE_FACTOR=1024
                SIZE_FORMAT="0x%08x"
                ;;
        A62)
                MAX_PART_SIZE=15552
                KERNEL_FLASH_ADDR=0x1a0000
-               MD5_SKIP_BLOCKS=4
                SIZE_FACTOR=1024
                SIZE_FORMAT="0x%08x"
                ;;
@@ -64,11 +60,12 @@ KERNEL_PART_SIZE=$(printf $SIZE_FORMAT $(($KERNEL_PART_SIZE_KB * $SIZE_FACTOR)))
 
 ROOTFS_FLASH_ADDR=$(addr=$(($KERNEL_FLASH_ADDR + ($KERNEL_PART_SIZE_KB * 1024))); printf "0x%x" $addr)
 ROOTFS_SIZE=$(stat -c%s "$ROOTFS_PATH")
-ROOTFS_CHECK_BLOCKS=$((($ROOTFS_SIZE / $CHECK_BS) - $MD5_SKIP_BLOCKS))
+ROOTFS_SQUASHFS_SIZE=$((ROOTFS_SIZE-4))
+ROOTFS_CHECK_BLOCKS=$((ROOTFS_SQUASHFS_SIZE / CHECK_BS))
 ROOTFS_MD5=$(dd if=$ROOTFS_PATH bs=$CHECK_BS count=$ROOTFS_CHECK_BLOCKS 2>&- | mkhash md5)
 ROOTFS_MD5_FULL=$(mkhash md5 $ROOTFS_PATH)
 ROOTFS_SHA256_FULL=$(mkhash sha256 $ROOTFS_PATH)
-ROOTFS_CHECK_SIZE=$(printf '0x%x' $(($ROOTFS_CHECK_BLOCKS * $CHECK_BS)))
+ROOTFS_CHECK_SIZE=$(printf '0x%x' $ROOTFS_SQUASHFS_SIZE)
 ROOTFS_PART_SIZE_KB=$(($MAX_PART_SIZE - $KERNEL_PART_SIZE_KB))
 ROOTFS_PART_SIZE=$(printf $SIZE_FORMAT $(($ROOTFS_PART_SIZE_KB * $SIZE_FACTOR)))