From: Andres Salomon Date: Sat, 6 Jun 2009 01:52:09 +0000 (-0400) Subject: mkjffs2: convert to reading partition info from config/*/fstab-jffs2 X-Git-Tag: v0.6~43 X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?p=xodist;a=commitdiff_plain;h=121cf26fb386251b9086284b8091878090faab36 mkjffs2: convert to reading partition info from config/*/fstab-jffs2 Signed-off-by: Andres Salomon --- diff --git a/mkjffs2.sh b/mkjffs2.sh index 7d907f7..2b839db 100755 --- a/mkjffs2.sh +++ b/mkjffs2.sh @@ -97,53 +97,91 @@ create_jffs2() rm -f ${out}.pre } -do_sha256() -{ - f=$1 - eblocks=$((`stat --printf "%s\n" $f` / (128*1024))) - for b in $(seq 0 $(($eblocks - 1))); do - sha=$(dd status=noxfer bs=128KiB skip=$b count=1 if=$f 2>/dev/null | sha256sum | cut -d\ -f1) - echo "eblock: `printf '%x' $b` sha256 $sha" >> ${IMG_NAME} - done -} - partition_map() { - # 0x190 * 128KiB = 50MiB boot, and the rest for root cat >${IMG_NAME}<>${IMG_NAME}<> ${IMG_NAME} + sed -ne 's/^mtd://p' configs/${CONFIG_TYPE}/fstab-jffs2 | \ + while read name mntpt fstype extra; do + size=$(echo $extra | sed -ne 's/.*[[:space:]]\+#[[:space:]]\+//p') + if [ "${size}" = "" ]; then + size="-1" + else + # size in fstab is in MB; convert to 128KiB chunks (in hex) + # MB * (1024/128) + size=$((size * 8)) + size=`printf "%x\n" $size` + fi + printf " $name $size" >> ${IMG_NAME} + done + printf "\n" >> ${IMG_NAME} + + # individual partitions + sed -ne 's/^mtd://p' configs/${CONFIG_TYPE}/fstab-jffs2 | \ + while read name mntpt fstype extra; do + cat >>${IMG_NAME}<>${IMG_NAME}</dev/null \ + | sha256sum | cut -d\ -f1) + echo "eblock: `printf '%x' $b` sha256 $sha" >> ${IMG_NAME} + done + cat >>${IMG_NAME}< ${DAT_NAME} -rm -f _boot.img _root.img + +# concat partitions, finish up +rm -f ${DAT_NAME} +sed -ne 's/^mtd://p' configs/${CONFIG_TYPE}/fstab-jffs2 | \ + while read name mntpt fstype extra; do + cat "_${name}.img" >> ${DAT_NAME} + rm -f "_${name}.img" +done