Check-in [2bd2a350d2]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview

SHA1 Hash:2bd2a350d214a16d7a60d7da0dd49f57ba4d5571
Date: 2012-05-05 22:49:34
User: BarryK
Comment:3builddistro will now write to an sd-card and create an sd-card compressed image, for arm board

Tags And Properties
Changes

Changes to woof-code/3builddistro

@@ -105,10 +105,11 @@
 #120312 removed Packages-puppy-common-official from ppm default selection.
 #120315 Ubuntu Precise Pangolin has done a big move of files from /lib to /lib/i386-linux-gnu and /usr/lib to /usr/lib/i386-linuxgnu
 #120331 bugfix generating README.HTM on cd.
 #120401 improve choosing locale.
 #120502 more support for arm build.
+#120506 support creation of SD-card image (for arm build).
 
 #v431 accepts passed params, from woof_gui_tabs:
 #$1=$CHOICE_KERNELPKG $2=$CHOICE_SCSI $3=$CHOICE_BIGMODEM $4=$CHK_FB_STATE $5=$CHK_EXOTIC_STATE $6=$CHK_RADICAL_STATE
 #100912 add $7=CHK_SIMPLE_FILENAMES
 
@@ -2442,41 +2443,178 @@
 cut3PATTERN="s%CUT3INSERT%${CUT3INSERT}%"
 sed -e "$verPATTERN" -e "$prefixPATTERN" -e "$cut2PATTERN" -e "$cut3PATTERN" ../boot/README.HTM > build/README.HTM
 
 sync
 
-$MKISOFS -D -R -o ${DISTRO_FILE_PREFIX}-${DISTRO_VERSION}${SCSIFLAG}.iso -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table ./build/
-sync
-md5sum ${DISTRO_FILE_PREFIX}-${DISTRO_VERSION}${SCSIFLAG}.iso > ${DISTRO_FILE_PREFIX}-${DISTRO_VERSION}${SCSIFLAG}.iso.md5.txt
+#120506
 echo
-echo "Would you like to burn it to a CD? "
-echo -n "ENTER only for yes, or any printable char then ENTER not to: "
-read writeitnow
-if [ "$writeitnow" = "" ];then
- CDR=""
- [ -f /etc/cdburnerdevice ] && CDR="/dev/`cat /etc/cdburnerdevice`"
- [ "$CDR" = "" ] && CDR='/dev/sr0'
- CDDESCR="`probedisk2 | grep '|optical|' | grep "$CDR" | cut -f 3 -d '|'`"
- echo -n 'Type "y" for multisession, else just ENTER: '
- read BURNMULTI
- if [ "$BURNMULTI" = "y" ];then
-  BURNMULTI="-multi -tao -pad"
- else
-  BURNMULTI="-dao"
- fi
- echo "Please insert blank CD into $CDR
+echo "Do you want to create a live-CD .iso file, which is the normal choice for a
+PC-compatible target, or is your target an SD-card for an ARM-based board?
+In the latter case, you would already have downloaded an SD-card skeleton image
+file into folder 'sd-skeleton-images' (done by script '1download') -- if there
+is no image file in that folder, you cannot choose the SD-card option.
+The latter choice will also require an SD card to write to, and you must have
+it available now."
+echo "WARNING: for the SD-card option, you must have enough free space in the
+current directory ${WKGDIR}/sandbox3
+to expand the SD image file, typically 4GB."
+echo "Press ENTER only for normal .iso creation, or "
+echo -n "any other printable character for SD-card: "
+read SDFLAG
+
+if [ "$SDFLAG" = "" ];then #120506
+ $MKISOFS -D -R -o ${DISTRO_FILE_PREFIX}-${DISTRO_VERSION}${SCSIFLAG}.iso -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table ./build/
+ sync
+ md5sum ${DISTRO_FILE_PREFIX}-${DISTRO_VERSION}${SCSIFLAG}.iso > ${DISTRO_FILE_PREFIX}-${DISTRO_VERSION}${SCSIFLAG}.iso.md5.txt
+ echo
+ echo "Would you like to burn it to a CD? "
+ echo -n "ENTER only for yes, or any printable char then ENTER not to: "
+ read writeitnow
+ if [ "$writeitnow" = "" ];then
+  CDR=""
+  [ -f /etc/cdburnerdevice ] && CDR="/dev/`cat /etc/cdburnerdevice`"
+  [ "$CDR" = "" ] && CDR='/dev/sr0'
+  CDDESCR="`probedisk2 | grep '|optical|' | grep "$CDR" | cut -f 3 -d '|'`"
+  echo -n 'Type "y" for multisession, else just ENTER: '
+  read BURNMULTI
+  if [ "$BURNMULTI" = "y" ];then
+   BURNMULTI="-multi -tao -pad"
+  else
+   BURNMULTI="-dao"
+  fi
+  echo "Please insert blank CD into $CDR
 (which is described as: ${CDDESCR})
 -- also be sure that it is unmounted."
- echo -n "Then hit ENTER key: "
- read yayburn
+  echo -n "Then hit ENTER key: "
+  read yayburn
 # $CDRECORD $BURNMULTI -data -eject -v speed=4 padsize=300k dev=ATAPI:$CDR ${DISTRO_FILE_PREFIX}-${DISTRO_VERSION}${SCSIFLAG}.iso
- $CDRECORD $BURNMULTI -data -eject -v speed=4 padsize=300k dev=$CDR ${DISTRO_FILE_PREFIX}-${DISTRO_VERSION}${SCSIFLAG}.iso
+  $CDRECORD $BURNMULTI -data -eject -v speed=4 padsize=300k dev=$CDR ${DISTRO_FILE_PREFIX}-${DISTRO_VERSION}${SCSIFLAG}.iso
+  sync
+  eject $CDR
+  echo "...done"
+ fi
+else #120506 sd image
+
+ echo
+ echo "Please choose the SD-card skeleton image file, to suit target board."
+ CNT=1
+ echo -n "" > /tmp/3builddistro-probeimage
+ ls -1 ../sd-skeleton-images | grep 'xz$' |
+ while read ONEIMAGE
+ do
+  echo "${CNT} ${ONEIMAGE}" >> /tmp/3builddistro-probeimage
+  CNT=`expr $CNT + 1`
+ done
+ while [ 1 ];do
+  echo
+  echo -n "Type number which is your choice of SD image:"
+  cat /tmp/3builddistro-probeimage
+  read sdnumber
+  SDIMAGE="`cat /tmp/3builddistro-probeimage | head -n $sdnumber | tail -n 1 | cut -f 2 -d ' '`"
+  echo -n "You chose '${SDIMAGE}' Press ENTER if correct: "
+  read sdcorrect
+  [ "$sdcorrect" = "" ] && break
+ done
+ echo
+ echo "Please insert the SD card. Make sure that it is the correct size as
+indicated on the filename of the skeleton image file that you chose."
+ echo -n "Press ENTER after it is inserted: "
+ read waitinsert
+ sleep 2
+ echo
+ while [ 1 ];do
+  CNT=1
+  echo -n "" > /tmp/3builddistro-probedisk
+  probedisk |
+  while read ONEPROBE
+  do
+   echo "${CNT} ${ONEPROBE}" >> /tmp/3builddistro-probedisk
+   CNT=`expr $CNT + 1`
+  done
+  echo
+  echo -n "Type number which is your SD card:"
+  cat /tmp/3builddistro-probedisk
+  read sdnumber
+  SDDEVICE="`cat /tmp/3builddistro-probedisk | head -n $sdnumber | tail -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '|'`"
+  echo -n "You chose ${SDDEVICE} Press ENTER if correct: "
+  read sdcorrect
+  [ "$sdcorrect" = "" ] && break
+ done
+ echo
+ echo "Sanity check: ../sd-skeleton-images/${SDIMAGE}
+is to be written to ${SDDEVICE}."
+ echo -n "Press ENTER to continue: "
+ read yepgo
+ echo
+
+ #need to know uncompressed size of image...
+ echo "Uncompressing image, please wait..."
+ cp -f ../sd-skeleton-images/${SDIMAGE} ./${SDIMAGE}
+ sync
+ unxz ${SDIMAGE}
+ if [ $? -ne 0 ];then
+  echo "Uncompress fail. Aborting."
+  exit 1
+ fi
+ sync
+ SDBASE="`basename $SDIMAGE .xz`"
+ IMGBYTES=`stat --format=%s $SDBASE`
+ echo "Writing skeleton image to ${SDDEVICE}, please wait patiently..."
+ dd if=${SDBASE} of=${SDDEVICE}
+ if [ $? -ne 0 ];then
+  echo "Sorry, operation failure. Aborting script."
+  exit 1
+ fi
+ sync
+ rm -f $SDBASE
+ mkdir -p /mnt/sdimagep1
+ mkdir -p /mnt/sdimagep2
+ mount -t vfat ${SDDEVICE}1 /mnt/sdimagep1
+ MNTSTAT1=$?
+ mount -t ext4 ${SDDEVICE}2 /mnt/sdimagep2
+ MNTSTAT2=$?
+ if [ $MNTSTAT1 -ne 0 -o $MNTSTAT2 -ne 0 ];then
+  echo
+  echo "Something is wrong. There should be two partitions on the SD card,"
+  echo "vfat and ext4. There was an error mounting them. Aborting script."
+  umount /mnt/sdimagep1 2>/dev/null
+  umount /mnt/sdimagep2 2>/dev/null
+  exit 1
+ fi
+ echo
+ echo "Copying Linux kernel to SD card..."
+ cp -f build/vmlinuz /mnt/sdimagep1/uImage
  sync
- eject $CDR
+ echo "...done"
+ echo "Copying Puppy filesystem to SD card (this will take awhile)..."
+ cp -a rootfs-complete/* /mnt/sdimagep2/
+ sync
  echo "...done"
-fi
-
+ umount /mnt/sdimagep1 2>/dev/null
+ umount /mnt/sdimagep2 2>/dev/null
+ echo
+ echo "Please type the name that you want to give the SD image file,"
+ echo -n "for example 'mele-sd-4gb-puppy-5.3.img': "
+ read PUPIMG
+ echo
+ echo "Now creating an image file of the SD card, please wait patiently..."
+ IMGK=`expr $IMGBYTES \/ 1024` #assume size divisible by 1024!!!!***WARNING***
+ dd if=$SDDEVICE of=$PUPIMG bs=1024 count=$IMGK
+ sync
+ echo "...done. The image file is named '${PUPIMG}'"
+ echo
+ echo "However, it is ${IMGK}KB, so needs to be compressed for distribution."
+ echo "Compressing, please wait..."
+ xz $PUPIMG
+ sync
+ COMPRIMGBYTES=`stat --format=%s ${PUPIMG}.xz`
+ echo
+ echo "The image is now ${PUPIMG}.xz and is ${COMPRIMGBYTES}bytes."
+ COMPRIMGK=`expr $COMPRIMGBYTES \/ 1024`
+ echo "(${COMPRIMGK}KB)"
+ echo "Image file may be distributed to others!"
+fi
 
 cd $WKGDIR
 
 #now do the devx...
 echo
@@ -2691,12 +2829,13 @@
 echo -n "$IDSTRING" >> ${DEVXSFS} #100911 16-byte id-string appended to file.
 md5sum ${DEVXSFS} > ${DEVXSFS}.md5.txt #100911
 cd ..
 sync
 echo "...done"
+
 
 echo
 echo "Script finished."
 echo -n "Press ENTER key to exit: "
 read yeahgetout
 ###END###