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

Commit

Permalink
bug 551315 - updating n810 imaging tools
Browse files Browse the repository at this point in the history
  • Loading branch information
John Ford committed May 17, 2010
1 parent 034f814 commit ac0c427
Show file tree
Hide file tree
Showing 13 changed files with 303 additions and 526 deletions.
17 changes: 7 additions & 10 deletions buildfarm/mobile/n810-imaging/bulk-image.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
#!/bin/bash
# Useful for finding out which devices: find /dev | grep "/dev/sd.[0-9]"
ROOTFSDIR='moz-ref-sd-v5'
ROOTFSDIR='moz-n810-v1'

EXCLUDE_FILE=/flashing/exclude_list.txt

if [ $# -eq 0 ] ; then
echo Please specify devices from this list
devlist=`find /dev -maxdepth 1 -name sd?`
for i in $devlist; do
grep -q "$i" $EXCLUDE_FILE
if [ $? -ne 0 ] ; then
echo $i
fi
done
echo "WARNING: DO NOT SELECT A NON-SD CARD DRIVE LETTER"
find /dev -maxdepth 1 -name sda -o -name sd? -print
fi

for i in "$@" ; do
BATCH='yes' ./moz-image.sh $ROOTFSDIR /dev/sd${i} maemo-n810-ref &
if [[ "$i" == "a" || "$i" == "A" ]] ; then
echo Ignoring /dev/sda
fi
BATCH='yes' ./moz-image.sh $ROOTFSDIR /dev/sd${i} maemo-n810-XX &
done

wait
Expand Down
13 changes: 0 additions & 13 deletions buildfarm/mobile/n810-imaging/flashing.rc

This file was deleted.

63 changes: 63 additions & 0 deletions buildfarm/mobile/n810-imaging/moz-get-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash
SDDEV=$1
IMGNAME=$2
RSYNC=rsync2

function info {
echo "INFO($SDDEV): $1"
}

function warn {
echo "WARN($SDDEV): $1"
}

function error {
echo "ERROR!($SDDEV): $1"
exit
}

function copy {
info "Copying data from card"
if [[ -d $IMGNAME ]] ; then
error 'I will not overwrite another image'
fi
mkdir $IMGNAME $MOUNT || error "could not create $MOUNT directory"
mount -t ext2 ${SDDEV}1 $MOUNT || error "could not mount $SDDEV on $MOUNT"
$RSYNC -a $MOUNT/. $IMGNAME/. || error "could not copy files to $IMGNAME"
}

function clean_image {
info "Cleaning up image"
rm -f $IMGNAME/var/log/uptime.log
rm -f $IMGNAME/sentinel

}

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
}


if [[ $EUID -ne 0 ]]; then
error "This script must be run as root"
fi
if [[ "x$1" == "x" || "x$2" == "x" ]] ; then
error "Usage: moz-get-image.sh <sd card dev> <image name>"
else
MOUNT="`basename $SDDEV `-$$"
eject
copy
clean_image
eject
sleep 2
rm -rf $MOUNT
echo "All done on $SDDEV"
fi
50 changes: 27 additions & 23 deletions buildfarm/mobile/n810-imaging/moz-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@
ROOTFS=$1
SDDEV=$2
UNITNAME=$3
RSYNC=./moz-rsync
RSYNC=rsync2

function info {
echo "INFO: $1"
echo "INFO($SDDEV): $1"
}

function warn {
echo "WARN: $1"
echo "WARN($SDDEV): $1"
}

function error {
echo "ERROR! $1"
echo "ERROR!($SDDEV): $1"
if [[ x"$MOUNT" != "x" ]] ; then
if [[ `mount | grep $MOUNT` ]] ; then
echo "This card is defective! Imaging attempted `date`" > ${MOUNT}/sentinel
fi
fi
exit
}

Expand All @@ -31,30 +36,20 @@ function warning {
fi
}

function dual_partition {
function partition {
info "Partitioning $SDDEV"
dd if=/dev/zero of=${SDDEV} bs=512 count=1 > /dev/null
dd if=/dev/zero of=${SDDEV} bs=512 count=1 &> /dev/null || error "failed to reset partition table"
parted --script ${SDDEV} mktable msdos || error "failed creating partition table"
parted --script ${SDDEV} mkpart primary 0 1800 || error "failed to create root partition"
parted --script ${SDDEV} mkpart primary 1801 3800 || error "failed to create data partition"
sync
sleep 2
sleep 5
info "Formatting Drives"
mkfs.ext2 ${SDDEV}1 -L $UNITNAME
mkfs.ext2 ${SDDEV}2 -L $UNITNAME
mkfs.ext2 -q ${SDDEV}1 -L root-fs || error 'failed to format rootfs'
mkfs.ext2 -q ${SDDEV}2 -L scratch || error 'failed to format scratch'
sync
sleep 2
}
function single_partition {
info "Partitioning $SDDEV"
dd if=/dev/zero of=${SDDEV} bs=512 count=1 > /dev/null
parted --script ${SDDEV} mktable msdos || error "failed creating partition table"
info "Formatting ${SDDEV}1"
parted --script ${SDDEV} mkpartfs primary ext2 0 3900 || error "failed to create data partition"
info "Syncing FS"
sync
sleep 1
}

function copy {
info "Copying data to card"
Expand All @@ -65,16 +60,23 @@ function copy {

function modify_image {
info "Modifying Image"
if [[ -d rootfs ]] ; then
info 'rsyncing rootfs dir into image'
$RSYNC -a rootfs/. ${MOUNT}/.
fi
echo $UNITNAME > ${MOUNT}/etc/hostname
echo "Imaged from \"${ROOTFS}\" at `date`" > ${MOUNT}/tools/buildbot/info/admin

}

function eject {
info "Unmounting"
sync
umount ${SDDEV}1 || warn "could not umount rootfs partition ${SDDEV}1"
umount ${SDDEV}2 || warn "could not umount data partition ${SDDEV}2"
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
}

Expand All @@ -87,9 +89,11 @@ else
warning
MOUNT="`basename $SDDEV `-$$"
eject
dual_partition
partition
copy
modify_image
eject
sleep 2
rm -rf $MOUNT
echo "All done on $SDDEV"
fi
98 changes: 0 additions & 98 deletions buildfarm/mobile/n810-imaging/rootfs/bin/maemo4-monitor.sh

This file was deleted.

39 changes: 39 additions & 0 deletions buildfarm/mobile/n810-imaging/rootfs/bin/run-ntp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env python

import os, sys, time, subprocess

NTPCOMMAND = '/usr/local/bin/ntpdate'
NTPSERVER = 'ntp1.build.mozilla.org'
LOG_FILE = '/var/log/ntpdate.log'

def main():
log = open(LOG_FILE, 'w+') #don't care for long logs
print >>log, '%s - starting up' % time.asctime(time.localtime())
log.flush()
while True:
rv = subprocess.call([NTPCOMMAND, NTPSERVER], stdout=log,
stderr=log)
if rv is 0:
sys.exit(0)
time.sleep(5)

if __name__=="__main__":
try:
pid = os.fork()
if pid > 0:
sys.exit(0)
except OSError, e:
print >>sys.stderr, 'first fork failed %d %s' %(e.errno, e.strerror)
sys.exit(1)

os.chdir("/")
os.setsid()
try:
pid = os.fork()
if pid > 0:
sys.exit(0)
else:
main()
except OSError, e:
print >>sys.stderr, 'second fork failed %d %s' %(e.errno, e.strerror)
sys.exit(1)
Loading

0 comments on commit ac0c427

Please sign in to comment.