--- elwix/install2img.sh 2013/01/27 22:34:00 1.3.2.3 +++ elwix/install2img.sh 2014/09/12 00:29:27 1.7.6.2 @@ -5,7 +5,7 @@ # (C) AITNET ltd - Sofia/Bulgaria # by Michael Pounov # -# $Id: install2img.sh,v 1.3.2.3 2013/01/27 22:34:00 misho Exp $ +# $Id: install2img.sh,v 1.7.6.2 2014/09/12 00:29:27 misho Exp $ # [ -r ./config/rc.elwix ] && . ./config/rc.elwix @@ -52,6 +52,30 @@ initdev() exit 3 fi + disklabel $1 2>&- | awk -vcfgsize=${CFG_NAND_SIZE:-65536} '($1 == "a:") { + cfgsize /= 512; + for (i = 1; i <= NF; i++) { + if (i == 2) + printf("%s ", $i - cfgsize); + else if (i == 3) { + offset = $i; + printf("%s ", cfgsize + offset); + } else + printf("%s ", $i); + } + printf("\n"); + printf("g: %d %d cfg 0 0 0\n", cfgsize, offset); + next; + } + { printf("%s\n", $0); }' >/tmp/disklabel.tmp + if disklabel -R -m ${TARGET} $1 /tmp/disklabel.tmp; then + rm -f /tmp/disklabel.tmp + echo "OK" + else + echo "Failed!" + exit 3 + fi + if newfs -b8192 -f1024 -m0 -Lelwix ${1}a; then echo "+++ Formatting ... OK" else @@ -129,42 +153,26 @@ gencksum() ### main() -if [ ! -r ${REL}/${OS} -a -r ${REL}/${OS_LITE} ]; then +if [ -z "$1" -o ! -r "$1" ]; then echo - echo "Error:: ELWIX OS file not found!" + echo "Error:: ELWIX OS tar file '$1' not found!" echo exit 2 +else + IMGNAME=$(basename $1 | sed -e "s/.tar.gz//") + MD5CHK="${REL}/${IMGNAME}.md5" + SHA1CHK="${REL}/${IMGNAME}.sha1" + IMG="${REL}/${IMGNAME}.img" fi -mkdevice $IMG ${1:-"${IMG_SIZE}"} +mkdevice $IMG ${2:-"${IMG_SIZE}"} initdev $DEV mountdev $DEV -install2 ${REL}/${OS} +install2 $1 umountdev #enablejfs $DEV boot2dev $DEV cleandev $DEV gencksum $IMG $MD5CHK $SHA1CHK - -mkdevice $IMG_LITE ${1:-"${IMG_SIZE}"} -initdev $DEV -mountdev $DEV -install2 ${REL}/${OS_LITE} -umountdev -#enablejfs $DEV -boot2dev $DEV -cleandev $DEV -gencksum $IMG_LITE $MD5CHK_LITE $SHA1CHK_LITE - -mkdevice $IMG_LITE128 ${1:-"${IMG_SIZE128}"} -initdev $DEV -mountdev $DEV -install2 ${REL}/${OS_LITE128} -umountdev -#enablejfs $DEV -boot2dev $DEV -cleandev $DEV -gencksum $IMG_LITE128 $MD5CHK_LITE128 $SHA1CHK_LITE128 - -echo "ELWIX OS image complete." +echo "ELWIX OS image $IMGNAME complete."