Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.

Commit

Permalink
bug 551315 - improvements to mobile imaging tools r=aki p=jhford
Browse files Browse the repository at this point in the history
  • Loading branch information
John Ford committed May 18, 2010
1 parent 4b79796 commit ac72d3d
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 30 deletions.
61 changes: 48 additions & 13 deletions buildfarm/mobile/n810-imaging/bulk-image.sh
@@ -1,20 +1,55 @@
#!/bin/bash
# Useful for finding out which devices: find /dev | grep "/dev/sd.[0-9]"
ROOTFSDIR='moz-n810-v1'
ROOTFSDIR='moz-n810-v2'

clean_exit () {
for i in ${PIDS[@]} ; do
ps | cut -f1 -d ' ' | grep $i &> /dev/null
if [ $? -eq 0 ] ; then
kill $i
fi
done
echo "Success on 0 out of $COUNT devices"
}

if [ $# -eq 0 ] ; then
echo Please specify devices from this list
echo "WARNING: DO NOT SELECT A NON-SD CARD DRIVE LETTER"
find /dev -maxdepth 1 -name sda -o -name sd? -print
fi
trap clean_exit SIGHUP SIGINT SIGTERM

for i in "$@" ; do
if [[ "$i" == "a" || "$i" == "A" ]] ; then
echo Ignoring /dev/sda
fi
BATCH='yes' ./moz-image.sh $ROOTFSDIR /dev/sd${i} maemo-n810-XX &
COUNT=0
for i in `ls -l /dev/sd? | grep floppy | cut -f9 -d ' ' ` ; do
BATCH='yes' ./moz-image.sh $ROOTFSDIR $i maemo-n810-NNN &
DEVNODES[COUNT]=$i
PIDS[COUNT]=$!
COUNT=$(($COUNT + 1))
done

wait
echo "BULK IMAGING COMPLETED"
spin[0]='\'
spin[1]='|'
spin[2]='/'
spin[3]='-'
i=0
while true ; do
if [ `jobs -r | wc -l` -gt 0 ] ; then
sleep 1
printf "\b%s" ${spin[i]}
i=$(((i + 1) % 4))
else
break
fi
done

SUCCESS=0
for node in ${DEVNODES[@]} ; do
grep "Success on" debug-$(basename $node).log &> /dev/null
if [ $? -eq 0 ] ; then
SUCCESS=$(($SUCCESS + 1))
rm debug-$(basename $node).log
else
echo
echo "ERROR: Imaging failed. Relevant debug log debug-$(basename $node).log"
fi
done

echo "Success on $SUCCESS out of $COUNT devices"

echo
echo "Done"
40 changes: 25 additions & 15 deletions buildfarm/mobile/n810-imaging/moz-image.sh
Expand Up @@ -3,6 +3,7 @@ ROOTFS=$1
SDDEV=$2
UNITNAME=$3
RSYNC=rsync2
LOGFILE="debug-$(basename $SDDEV).log"

function info {
echo "INFO($SDDEV): $1"
Expand All @@ -17,12 +18,17 @@ function error {
if [[ x"$MOUNT" != "x" ]] ; then
if [[ `mount | grep $MOUNT` ]] ; then
echo "This card is defective! Imaging attempted `date`" > ${MOUNT}/sentinel
echo "Copying imaging log to device"
if [[ -f $LOGFILE ]] ; then
cp $LOGFILE ${MOUNT}/imglog
fi
fi
fi
exit
eject
exit 1
}

function warning {
function batchmode {
if [ "x$BATCH" == "x" ] ; then
warn "You are about to ERASE ${SDDEV}. ARE YOU SURE? y/n"
read a
Expand All @@ -32,7 +38,8 @@ function warning {
echo "gonna do it"
fi
else
info "You are formating $SDDEV in batch mode"
info "Imaging in batch mode. Redirecting output to $LOGFILE"
exec &> $LOGFILE
fi
}

Expand All @@ -55,29 +62,31 @@ function copy {
info "Copying data to card"
mkdir $MOUNT || error "could not create $MOUNT directory"
mount -t ext2 ${SDDEV}1 $MOUNT || error "could not mount $SDDEV on $MOUNT"
$RSYNC -a $ROOTFS/. $MOUNT/. || error "could not copy files to $MOUNT"
$RSYNC -a $ROOTFS/. $MOUNT/. &> /dev/null || error "could not copy files to $MOUNT"
}

function modify_image {
info "Modifying Image"
if [[ -d rootfs ]] ; then
info 'rsyncing rootfs dir into image'
$RSYNC -a rootfs/. ${MOUNT}/.
$RSYNC -a rootfs/. ${MOUNT}/. &> /dev/null || error "could not copy mozilla scripts onto card"
else
info 'missing rootfs directory -- no mozilla scripts will be installed'
fi
echo $UNITNAME > ${MOUNT}/etc/hostname

}

function eject {
info "Unmounting"
sync
if [[ `mount | grep ${SDDEV}1` ]] ; then
umount ${SDDEV}1 || warn "could not umount root-fs/${SDDEV}1"
fi
if [[ `mount | grep ${SDDEV}2` ]] ; then
umount ${SDDEV}2 || warn "could not umount root-fs/${SDDEV}2"
fi
rm -rf $MOUNT
STATUS=0
while [ $STATUS -eq 0 ] ; do
for i in `mount | cut -f1 -d ' ' | grep $SDDEV` ; do
umount $i &> /dev/null || warn "could not umount $i"
done
mount | grep $SDDEV > /dev/null
STATUS=$?
done
}

if [[ $EUID -ne 0 ]]; then
Expand All @@ -86,14 +95,15 @@ fi
if [[ "x$1" == "x" || "x$2" == "x" || "x$3" = "x" ]] ; then
error "Usage: moz-image.sh <rootfsdir> <sd card dev> <unit name>"
else
warning
MOUNT="`basename $SDDEV `-$$"
batchmode
eject
partition
copy
modify_image
eject
sleep 2
rm -rf $MOUNT
echo "All done on $SDDEV"
info "Success on $SDDEV"
exit 0
fi
7 changes: 5 additions & 2 deletions buildfarm/mobile/n810-imaging/moz-prep.sh
Expand Up @@ -26,6 +26,8 @@ function flash {
$FLASHER $ARGS &> flasher.log
RC=$?
if [ $RC == 3 ] ; then
echo ; echo ; echo;
echo =============================
cat flasher.log
error "Lost USB Connection while flashing $FILE"
elif [ $RC != 0 ] ; then
Expand Down Expand Up @@ -59,13 +61,14 @@ while [ true ] ; do
flash_image '--rootfs' $IMAGE
set_root
STATUS=0
echo -n "Unplug N810 from computer"
echo "Completed Successfully"
echo -n "Unplug N810 from computer or press CTRL+C to quit"
while [ $STATUS -ne 1 ] ; do
lsusb | grep $USBPATTERN > /dev/null
STATUS=$?
echo -n '.'
sleep 1
done
echo Completed Successfully
echo #for the new line
done

0 comments on commit ac72d3d

Please sign in to comment.