#!/bin/sh # buildoe -- build openembedded via ec2 usage() { echo "Usage: buildoe INSTANCETYPE" 1>&2 exit 1 } if test -z "$1"; then usage fi if ! ssh-add -l | grep -q ' id_dsa_ec2 '; then echo "Adding the EC2 SSH key." ssh-add ~/id_dsa_ec2 fi if test -z "$JAVA_HOME"; then source ~/ec2.sh fi case "$1" in m1.small|c1.medium) image=ami-bb709dd2 ;; *) image=ami-55739e3c ;; esac # Ubuntu 9.10 server amd64: ami-55739e3c # Ubuntu 9.10 server i386: ami-bb709dd2 echo -n 'Starting instance...' instancerequest="`ec2-request-spot-instances "$image" -z us-east-1a -r one-time -p 1.00 -k id_dsa_ec2 -t "$1" | awk '/^SPOTINSTANCEREQUEST/ { print $2 }'`" while true; do instance="`ec2-describe-spot-instance-requests "$instancerequest" | awk '/^SPOTINSTANCEREQUEST/ { print $8; exit 0; }'`" if test "$?" -ne 0; then exit 1 fi if echo "$instance" | grep '^i-........$'; then break fi echo -n '.' done #instance="`ec2run "$image" -k id_dsa_ec2 -z us-east-1a -t "$1" | awk '/^INSTANCE/ { print $2 }'`" while true; do addr="`ec2din $instance | awk '/^INSTANCE/ { if($4 != "terminated" && $4 != "pending") { print $4; exit 0; } }'`" if test "$?" -ne 0; then exit 1 fi if test 'xpending' != "x$addr"; then break fi sleep 10 echo -n '!' done ec2-attach-volume vol-3d13bf54 -i $instance -d /dev/sdf ssh -o 'StrictHostKeyChecking no' -fN ubuntu@$addr if test "$?" -ne 0; then exit 1 fi cat <<"EOF" | ssh ubuntu@$addr 'cat > buildit.sh' sudo apt-get update -y if test `uname -m` != x86_64; then psyco="python-psyco" else psyco="" fi sudo modprobe dm_mod sudo apt-get -y install git-core subversion gcc build-essential diffstat texinfo help2man texi2html gawk chrpath lvm2 $psyco echo 'Yes, do as I say!' | sudo apt-get install xz-utils sudo ln -fs /bin/bash /bin/sh mkdir ~/overo-oe sudo mount /dev/sda2 ~/overo-oe #sudo mount /dev/mapper/storageVG-storageFS ~/overo-oe cd ~/overo-oe sudo chmod 777 ~/overo-oe #sudo lvchange -a y /dev/storageVG/storageFS git clone git://gitorious.org/gumstix-oe/mainline.git org.openembedded.dev cd org.openembedded.dev git checkout --track -b overo origin/overo cd ~/overo-oe git clone git://git.openembedded.net/bitbake bitbake cd bitbake git checkout 1.8.18 cd ~/overo-oe cp -r org.openembedded.dev/contrib/gumstix/build . . ~/overo-oe/build/profile # 84 is _SC_NPROCESSORS_ONLN NCPU=`python -c 'import ctypes; print ctypes.cdll.LoadLibrary("libc.so.6").sysconf(84)'` echo PARALLEL_MAKE = \"-j $NCPU\" >> ~/overo-oe/build/conf/site.conf echo BB_NUMBER_THREADS = \"$NCPU\" >> ~/overo-oe/build/conf/site.conf bitbake omap3-console-image EOF ssh ubuntu@$addr 'screen -dmS build ; screen -r build -X exec echo /usr/bin/time sh ~/buildit.sh' # source this to set up environment for EC2 tools export EC2_PRIVATE_KEY=~/Downloads/pk-XXX.pem export EC2_PRIVATE_KEY=~/Downloads/pk-XXX.pem export EC2_CERT=~/Downloads/cert-XXX.pem export JAVA_HOME=/Library/Java/Home export EC2_HOME=~/Downloads/ec2-api-tools-1.3-46266 export PATH=$PATH:$EC2_HOME/bin