--- elwix/install2img.sh 2013/08/01 15:02:06 1.6.2.2 +++ 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.6.2.2 2013/08/01 15:02:06 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,21 +153,26 @@ gencksum() ### main() -if [ ! -r ${REL}/${BASE_OS} ]; 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}/${BASE_OS} +install2 $1 umountdev #enablejfs $DEV boot2dev $DEV cleandev $DEV gencksum $IMG $MD5CHK $SHA1CHK -echo "ELWIX OS image complete." +echo "ELWIX OS image $IMGNAME complete."