ec2build.sh: remove non-free license component sources from s3
[beagleboard-validation:scripts.git] / ec2build.sh
1 #!/bin/bash
2 # This file is based on:
3 #  http://code.google.com/p/maemo-sdk-image/
4 #  http://forum.nginx.org/read.php?26,12659,13302
5
6 # Need to get settings for
7 #  EC2_HOME
8 #  EC2_PRIVATE_KEY
9 #  EC2_CERT
10 #  EC2_ID
11 #  AWS_ID
12 #  AWS_PASSWORD
13 #  PATH -- must include EC2_HOME/bin
14 #  S3_BUCKET
15 set -x
16 set -e
17 source $HOME/secret/setup_env.sh
18
19 # These are the git commit ids we want to use to build
20 ANGSTROM_SCRIPT_ID=f593f1c023cd991535c748682ab21154c807385e
21 ANGSTROM_REPO_ID=24805033b1205acc35f8b4d75cc42f8b9c2a1b38
22 USE_EC2="yes"
23 USE_PSTAGE="yes"
24 HALT="no"
25
26 # Setup DEFAULT_AMI
27 # UBUNTU_10_04_64BIT AMI is the original default, but you can seed with others
28 AMI=ami-fd4aa494
29 if [ -e $HOME/ec2build-ami.sh ]; then source $HOME/ec2build-ami.sh; fi
30
31 DATE=`date +%Y%m%d%H%M`
32 KEYPAIR=ec2build-keypair
33 KEYPAIR_FILE=$HOME/secret/$KEYPAIR.txt
34 INSTANCES=$HOME/ec2build-instances.txt
35 VOLUMES=$HOME/ec2build-volumes.txt
36
37 # MACH_TYPEs are m1.large, m2.4xlarge, etc.
38 MACH_TYPE=m1.xlarge
39 DOWNLOAD_EBS=vol-08374961
40 ANGSTROM_EBS=vol-24fa964d
41 DOWNLOAD_DIR=/mnt/downloads
42 OEBB_DIR=/mnt/angstrom-setup-scripts
43 SCRIPT_DIR=/home/ubuntu/scripts
44
45 THIS_FILE=$0
46
47 # Clear any local vars
48 INSTANCE=""
49 MACH_NAME=""
50
51 # host-only
52 # about 200-250 minutes total
53 function run-build {
54 if [ "x$AMI" = "xami-fd4aa494" ]; then
55  build-beagleboard-validation-ami
56  AMI=$NEW_AMI
57  echo "AMI=$NEW_AMI" > $HOME/ec2build-ami.sh
58 fi
59 if [ "x$INSTANCE" = "x" ]; then run-ami; fi
60 remote setup-oe
61 copy-ti-tools
62 if [ "x$USE_PSTAGE" = "xyes" ]; then remote rsync-pstage-from-s3; fi
63 remote rsync-downloads-from-s3
64 remote build-image test
65 remote build-sd test $DATE
66 remote build-image demo
67 remote build-sd demo $DATE
68 remote rsync-pstage-to-s3
69 remote rsync-downloads-to-s3
70 halt-ami
71 }
72
73 function setup-tmp {
74 if [ "x$TMP" = "x" ]; then
75  sudo mkdir -p /mnt/ubuntu-tmp
76  sudo chown ubuntu.ubuntu /mnt/ubuntu-tmp
77  TMP=/mnt/ubuntu-tmp
78 fi
79 }
80
81 # about 30-40 minutes
82 function build-beagleboard-validation-ami {
83 AMI=ami-fd4aa494
84 run-ami
85 remote enable-oe
86 remote enable-s3fuse
87 remote enable-ec2
88 remote bundle-vol
89 halt-ami
90 }
91
92 function halt-ami {
93 if [ "x$HALT" = "xno" ]; then
94  echo "Halt is currently disabled"
95 else
96  find-instance
97  ec2-terminate-instances $INSTANCE;
98  INSTANCE=""
99 fi
100 }
101
102 # run-ami takes about 4 minutes
103 function run-ami {
104 if [ ! -e $KEYPAIR_FILE ]; then make-keypair; fi
105 if [ "x$INSTANCE" = "x" ]; then check-instance; fi
106 if [ "x$INSTANCE" = "x" ]; then
107  if [ "x$MACH_TYPE" = "x" ];
108  then
109   ec2-run-instances $AMI -k $KEYPAIR
110  else
111   ec2-run-instances $AMI -k $KEYPAIR -t $MACH_TYPE
112  fi
113  add-sshkey-ami
114 else
115  echo "Already running instance $INSTANCE."
116 fi
117 }
118
119 function check-instance {
120 ec2-describe-instances > $INSTANCES;
121 INSTANCE=`perl -ne '/^INSTANCE\s+(\S+)\s+'${AMI}'\s+(\S+)\s+\S+\s+running\s+/ && print("$1") && exit 0;' $INSTANCES`
122 MACH_NAME=`perl -ne '/^INSTANCE\s+(\S+)\s+'${AMI}'\s+(\S+)\s+\S+\s+running\s+/ && print("$2") && exit 0;' $INSTANCES`
123 }
124
125 function make-keypair {
126 #ec2-delete-keypair $KEYPAIR
127 ec2-add-keypair $KEYPAIR > $KEYPAIR_FILE
128 chmod 600 $KEYPAIR_FILE
129 }
130
131 function add-sshkey-ami {
132 find-instance
133 mkdir -p $HOME/.ssh
134 touch $HOME/.ssh/known_hosts
135 chmod 644 $HOME/.ssh/known_hosts
136 PKEY=`grep $MACH_NAME $HOME/.ssh/known_hosts`
137 if [ "x$PKEY" = "x" ]
138 then
139  echo "Adding $MACH_NAME to known hosts"
140  # give the new instance time to start up
141  sleep 10
142  ssh-keyscan -t rsa $MACH_NAME >> $HOME/.ssh/known_hosts
143 fi
144 }
145
146 # Additional parameters for initiating host
147 function find-instance {
148 while
149  [ "x$INSTANCE" == "x" ]
150 do
151  check-instance
152 done
153 echo "INSTANCE=$INSTANCE";
154 echo "MACH_NAME=$MACH_NAME";
155 }
156
157 function authorize-ssh {
158 ec2-authorize default -p 22
159 }
160
161 function ssh-ami {
162 if [ "x$INSTANCE" = "x" ]; then run-ami; fi
163 ssh -i $KEYPAIR_FILE ubuntu@$MACH_NAME $1 $2 $3 $4 $5 $6 $7 $8 $9
164 }
165
166 function remote {
167 if [ "x$INSTANCE" = "x" ]; then run-ami; fi
168 ssh -i $KEYPAIR_FILE ubuntu@$MACH_NAME 'mkdir -p $HOME/secret; chmod 700 $HOME/secret'
169 scp -i $KEYPAIR_FILE $EC2_CERT ubuntu@$MACH_NAME:secret/cert.pem
170 scp -i $KEYPAIR_FILE $EC2_PRIVATE_KEY ubuntu@$MACH_NAME:secret/pk.pem
171 scp -i $KEYPAIR_FILE $HOME/secret/setup_env.sh ubuntu@$MACH_NAME:secret/setup_env.sh
172 ssh-ami mkdir -p $SCRIPT_DIR
173 scp -i $KEYPAIR_FILE $THIS_FILE ubuntu@$MACH_NAME:$SCRIPT_DIR/ec2build.sh
174 scp -i $KEYPAIR_FILE $THIS_FILE ubuntu@$MACH_NAME:$SCRIPT_DIR/set-threads.pl
175 ssh-ami $SCRIPT_DIR/ec2build.sh $1 $2 $3 $4 $5 $6 $7 $8
176 }
177
178 # target local
179 function enable-ec2 {
180 if [ ! -x `which ec2-describe-instances` ]; then
181  # These are apparently non-free apps
182  sudo perl -pe 's/universe$/universe multiverse/' -i.bak /etc/apt/sources.list
183  sudo aptitude install ec2-api-tools ec2-ami-tools -y
184 fi
185 }
186
187 # target local
188 function disable-dash {
189 sudo aptitude install expect -y
190 expect -c 'spawn sudo dpkg-reconfigure -freadline dash; send "n\n"; interact;'
191 }
192
193 # target local
194 function enable-oe {
195 cd $HOME
196 disable-dash
197 sudo aptitude install sed wget cvs subversion git-core \
198  coreutils unzip texi2html texinfo libsdl1.2-dev docbook-utils \
199  gawk python-pysqlite2 diffstat help2man make gcc build-essential g++ \
200  desktop-file-utils chrpath -y
201 sudo aptitude install libxml2-utils xmlto python-psyco -y
202 sudo aptitude install python-xcbgen -y
203 sudo aptitude install ia32-libs -y
204 # hack to build autoconf
205 sudo aptitude install m4 -y
206 # hack to build gedit
207 sudo aptitude install gnome-doc-utils -y
208 # hack to build ti-msp430-chronos
209 #sudo aptitude install tofrodos -y
210 # hack to build gnome-power-manager
211 sudo aptitude install libtool -y
212 # Per Tartarus on #oe IRC channel:
213 sudo aptitude install patch libexpat-dev libbonobo2-common libncurses5-dev -y
214 }
215
216 # target local
217 # about 5 minutes
218 function install-oe {
219 export THREADS=`$SCRIPT_DIR/set-threads.pl`
220 #mkdir -p $OEBB_DIR
221 #sudo mount -t ramfs -o size=10G ramfs $OEBB_DIR
222 rm -rf $HOME/.oe || true
223 sudo rm -rf $OEBB_DIR
224 sudo mkdir -p $OEBB_DIR
225 sudo chown ubuntu.ubuntu $OEBB_DIR
226 git clone git://gitorious.org/angstrom/angstrom-setup-scripts.git $OEBB_DIR
227 cd $OEBB_DIR
228 git checkout $ANGSTROM_SCRIPT_ID
229 git checkout -b install || true
230 ./oebb.sh config beagleboard
231 ./oebb.sh update
232 perl -pe 's/^(INHERIT\s*\+=\s*"rm_work")/#$1/' -i.bak1 $OEBB_DIR/build/conf/local.conf
233 perl -pe 's/^(#)?PARALLEL_MAKE\s*=\s*"-j\d+"/PARALLEL_MAKE = "-j16"/' -i.bak2 $OEBB_DIR/build/conf/local.conf
234 perl -pe 's/BB_NUMBER_THREADS\s*=\s*"\d+"/BB_NUMBER_THREADS = "8"/' -i.bak3 $OEBB_DIR/build/conf/local.conf
235 cat >>$OEBB_DIR/build/conf/local.conf <<EOF
236 INHERIT += "oestats-client"
237 OESTATS_SERVER = "tinderbox.openembedded.net"
238 OESTATS_BUILDER = "ec2build"
239 #PREMIRRORS_prepend = "(ftp|https?)$://.*/.*  http://beagleboard-validation.s3.amazonaws.com/downloads/"
240 PSTAGE_MIRROR = "http://beagleboard-validation.s3.amazonaws.com/pstage/"
241 EOF
242 }
243
244 # target local
245 function oebb {
246 cd $OEBB_DIR
247 ./oebb.sh $1 $2 $3 $4 $5 $6 $7 $8 $9
248 }
249
250 function create-download-ebs {
251 # VOLUME  vol-10402d79    10              us-east-1c      creating        2010-07-14T08:21:14+0000
252 #DOWNLOAD_EBS=`ec2-create-volume -s 10 -z us-east-1c | perl -ne '/^VOLUME\s+(\S+)\s+/ && print "$1"'`
253 DOWNLOAD_EBS=`ec2-create-volume -s 10 -z us-east-1c | perl -ne '/^VOLUME\s+(\S+)\s+/ && print "$1"'`
254 echo DOWNLOAD_EBS=$DOWNLOAD_EBS
255 }
256
257 function get-volume-status {
258 #ec2-describe-volumes | tee $VOLUMES;
259 ec2-describe-volumes > $VOLUMES;
260 #VOLUME  vol-b629ccdf    200             us-east-1c      in-use
261 VOLUME_STATUS=`perl -ne '/^VOLUME\s+'${EBS_VOLUME}'\s+\S+\s+(snap\S+\s+)?+\S+\s+(\S+)/ && print "$2"' $VOLUMES`
262 if [ "$VOLUME_STATUS" = "in-use" ]; then
263  #ATTACHMENT      vol-f0402d99    i-2fd61c45      /dev/sdd        attaching       2010-07-14T08:53:30+
264  VOLUME_STATUS=`perl -ne '/^ATTACHMENT\s+'${EBS_VOLUME}'\s+'${INSTANCE}'\s+\S+\s+(\S+)/ && print "$1"' $VOLUMES`
265 fi
266 echo VOLUME_STATUS=$VOLUME_STATUS
267 }
268
269 function attach-ebs-ami {
270 EBS_VOLUME=$1
271 DEVICE=$2
272 find-instance
273 VOLUME_STATUS=
274 while
275  [ ! "$VOLUME_STATUS" = "available" ]
276 do
277  get-volume-status
278 done
279 ec2-attach-volume $EBS_VOLUME -i $INSTANCE -d $DEVICE
280 }
281
282 # target local
283 function format-ebs-ami {
284 EBS_VOLUME=$1
285 DEVICE=$2
286 find-instance
287 VOLUME_STATUS=
288 while
289  [ ! "$VOLUME_STATUS" = "attached" ]
290 do
291  get-volume-status
292 done
293 sudo mkfs.ext3 $DEVICE -F
294 }
295
296 function mount-ebs-ami {
297 EBS_VOLUME=$1
298 DEVICE=$2
299 DIRNAME=$3
300 find-instance
301 VOLUME_STATUS=
302 while
303  [ ! "x$VOLUME_STATUS" = "xattached" ]
304 do
305  #ec2-describe-volumes | tee $VOLUMES;
306  ec2-describe-volumes > $VOLUMES;
307  #ATTACHMENT      vol-f0402d99    i-2fd61c45      /dev/sdd        attaching       2010-07-14T08:53:30+
308  VOLUME_STATUS=`perl -ne '/^ATTACHMENT\s+'${EBS_VOLUME}'\s+'${INSTANCE}'\s+\S+\s+(\S+)/ && print "$1"' $VOLUMES`
309  echo VOLUME_STATUS=$VOLUME_STATUS
310 done
311 sudo mkdir -p $DIRNAME
312 sudo mount $DEVICE $DIRNAME
313 }
314
315 function create-download-ebs {
316 attach-ebs-ami $DOWNLOAD_EBS /dev/sdd
317 format-ebs-ami $DOWNLOAD_EBS /dev/sdd 
318 }
319
320 function mount-download-ebs {
321 attach-ebs-ami $DOWNLOAD_EBS /dev/sdd
322 mount-ebs-ami $DOWNLOAD_EBS /dev/sdd $DOWNLOAD_DIR
323 sudo chown ubuntu.ubuntu $DOWNLOAD_DIR
324 }
325
326 function restore-angstrom {
327 attach-ebs-ami $ANGSTROM_EBS /dev/sde
328 mount-ebs-ami $ANGSTROM_EBS /dev/sde /mnt/angstrom
329 sudo chown ubuntu.ubuntu /mnt/angstrom
330 mkdir -p $OEBB_DIR
331 sudo mount -t ramfs -o size=10G ramfs $OEBB_DIR
332 sudo chown ubuntu.ubuntu $OEBB_DIR
333 rsync -a /mnt/angstrom/* $OEBB_DIR/
334 }
335
336 function preserve-angstrom {
337 rsync -a $OEBB_DIR/* /mnt/angstrom/
338 }
339
340 function rsync-downloads-to-s3 {
341 if [ ! -x /mnt/s3/scripts/ec2build.sh ]; then mount-s3; fi
342 mkdir -p /mnt/s3/downloads
343 cp /mnt/s3/scripts/list.html /mnt/s3/downloads/
344 rsync -a $OEBB_DIR/sources/downloads/ /mnt/s3/downloads/
345 rm /mnt/s3/downloads/ti_cgt* || true
346 rm /mnt/s3/downloads/OMAP35x* || true
347 }
348
349 function rsync-downloads-from-s3 {
350 if [ ! -x /mnt/s3/scripts/ec2build.sh ]; then mount-s3; fi
351 mkdir -p $OEBB_DIR/sources/downloads
352 rsync -a /mnt/s3/downloads/ $OEBB_DIR/sources/downloads/
353 }
354
355 function mount-tmp {
356 mkdir -p $OEBB_DIR
357 sudo mount -t tmpfs -o size=30G,nr_inodes=30M,noatime,nodiratime tmpfs $OEBB_DIR
358 sudo chown ubuntu.ubuntu $OEBB_DIR
359 }
360
361 # http://xentek.net/articles/448/installing-fuse-s3fs-and-sshfs-on-ubuntu/
362 function enable-s3fuse {
363 cd $HOME
364 sudo aptitude install build-essential libcurl4-openssl-dev libxml2-dev libfuse-dev comerr-dev libfuse2 libidn11-dev libkadm55 libkrb5-dev libldap2-dev libselinux1-dev libsepol1-dev pkg-config fuse-utils sshfs -y
365 wget http://s3fs.googlecode.com/files/s3fs-r177-source.tar.gz
366 tar xzvf s3fs-r177-source.tar.gz
367 cd ./s3fs
368 sudo make
369 sudo make install
370 sudo perl -pe 's/^#user_allow_other/user_allow_other/' -i.bak /etc/fuse.conf
371 }
372
373 function mount-s3 {
374 sudo mkdir -p /mnt/s3
375 sudo modprobe fuse
376 sudo s3fs beagleboard-validation -o accessKeyId=$AWS_ID -o secretAccessKey=$AWS_PASSWORD -o use_cache=/mnt -o default_acl="public-read" -o allow_other /mnt/s3
377 }
378
379 # target local
380 # takes about 16 minutes
381 function bundle-vol {
382 IMAGE_NAME=beagleboard-validation-$DATE
383 echo IMAGE_NAME=$IMAGE_NAME
384 sudo mkdir -p $DOWNLOAD_DIR
385 sudo chown ubuntu.ubuntu $DOWNLOAD_DIR
386 mkdir -p $OEBB_DIR
387 sudo mv /mnt/$IMAGE_NAME $IMAGE_NAME.$$
388 sudo ec2-bundle-vol -c $EC2_CERT -k $EC2_PRIVATE_KEY -u $EC2_ID -r x86_64 -d /mnt -e /mnt,/home/ubuntu/secret,$DOWNLOAD_DIR,$OEBB_DIR -p $IMAGE_NAME
389 ec2-upload-bundle -b $S3_BUCKET -m /mnt/$IMAGE_NAME.manifest.xml -a $AWS_ID -s $AWS_PASSWORD
390 ec2-register -n $IMAGE_NAME $S3_BUCKET/$IMAGE_NAME.manifest.xml
391 #IMAGE  ami-954fa4fc    beagleboard-validation/beagleboard-validation-20100804.manifest.xml 283181587 744 available   private  x86_64 machine aki-0b4aa462
392 NEW_AMI=`ec2-describe-images | perl -ne '/^IMAGE\s+(\S+)\s+'${S3_BUCKET}'\/'${IMAGE_NAME}'.manifest.xml\s+/ && print("$1") && exit 0;'`
393 }
394
395 function sd-create-image {
396 IMG_NAME=$1
397 CYL=$2
398
399 if [ ! -e `which bc` ]; then sudo aptitude install bc -y; fi
400 FS1_PARTITION_SIZE=15
401 FS1_OFFSET=`echo 512 \* 63 | bc`
402 CYL_SIZE=`echo 255 \* 63 \* 512 | bc`
403 FS2_OFFSET=`echo $FS1_PARTITION_SIZE \* $CYL_SIZE | bc`
404 FS2_SIZE=`echo \( $CYL \- $FS1_PARTITION_SIZE \) \* $CYL_SIZE | bc`
405 IMG_SIZE=`echo $CYL \* $CYL_SIZE | bc`
406
407 setup-tmp
408 sudo umount /dev/loop0 || true
409 sudo losetup -d /dev/loop0 || true
410 sudo rm -f $IMG_NAME $IMG_NAME.gz $TMP/$IMG_NAME $TMP/$IMG_NAME.gz
411 dd if=/dev/zero of=$TMP/$IMG_NAME bs=$CYL_SIZE count=$CYL
412 # the format for sfdisk is
413 # <start>,<size>,<id>,<bootable>
414 sfdisk -C $CYL -H 255 -S 63 -D $TMP/$IMG_NAME <<EOF
415 ,$FS1_PARTITION_SIZE,0x0c,*
416 ,,0x83,-
417 EOF
418 sh -c "fdisk -C $CYL -l -u $TMP/$IMG_NAME > $IMG_NAME.txt"
419 }
420
421 function build-sd {
422 IMAGE=$1
423 [ -z "$2" ] || DATE=$2
424
425 if [ ! -x /mnt/s3/scripts/ec2build.sh ]; then mount-s3; fi
426 S3_DEPLOY_DIR=/mnt/s3/deploy/$DATE
427 mkdir -p $S3_DEPLOY_DIR/sd/
428 sudo mkdir -p /mnt/sd_image1
429 sudo mkdir -p /mnt/sd_image2
430 pushd $S3_DEPLOY_DIR/sd/
431 DEPLOY_DIR=$OEBB_DIR/build/tmp-angstrom_2008_1/deploy/glibc/images/beagleboard
432 cp /mnt/s3/scripts/list.html .
433 cp $DEPLOY_DIR/MLO-beagleboard MLO
434 cp $DEPLOY_DIR/u-boot-beagleboard.bin u-boot.bin
435 cp $DEPLOY_DIR/uImage-beagleboard.bin uImage
436 cp $DEPLOY_DIR/beagleboard-test-image-beagleboard.ext2.gz ramdisk.gz
437 cp $DEPLOY_DIR/beagleboard-test-image-beagleboard.cpio.gz.u-boot ramfs.img
438 cp $DEPLOY_DIR/uboot-beagleboard-validation-user.cmd.scr user.scr
439 cp $SCRIPT_DIR/ec2build.sh .
440 echo "$DATE  DATE" > md5sum.txt
441 echo "$ANGSTROM_SCRIPT_ID  ANGSTROM_SCRIPT_ID" > md5sum.txt
442 echo "$ANGSTROM_REPO_ID  ANGSTROM_REPO_ID" >> md5sum.txt
443 FILES="MLO u-boot.bin uImage ramdisk.gz user.scr"
444 md5sum $FILES >> md5sum.txt
445
446 if [ "x$IMAGE" = "xtest" ]; then
447  if [ -e ramdisk.gz ]; then
448   sd-create-image beagleboard-validation-$DATE.img 16
449   sudo losetup -v -o $FS1_OFFSET /dev/loop0 $TMP/beagleboard-validation-$DATE.img
450   sudo mkfs.vfat /dev/loop0 -n BEAGLE -F 32 120456
451   sudo mount /dev/loop0 /mnt/sd_image1
452   sudo cp -R $FILES md5sum.txt /mnt/sd_image1/
453   #mount
454   #ls -l /mnt/sd_image1/
455   #sudo losetup $VFAT_LOOP
456   sudo umount /dev/loop0
457   sudo losetup -d /dev/loop0
458   gzip -c $TMP/beagleboard-validation-$DATE.img > beagleboard-validation-$DATE.img.gz
459   mv $TMP/beagleboard-validation-$DATE.img .
460  fi
461 fi
462  
463 if [ "x$IMAGE" = "xdemo" ]; then
464  cp $DEPLOY_DIR/uboot-beagleboard-validation-boot.cmd.scr boot.scr
465  cp $DEPLOY_DIR/Beagleboard-demo-image-beagleboard.tar.bz2 demo-$DATE.tar.bz2
466  md5sum boot.scr demo-$DATE.tar.bz2 >> md5sum.txt
467  
468  if [ -e demo-$DATE.tar.bz2 ]; then
469   sd-create-image beagleboard-demo-$DATE.img 444
470   sudo losetup -v -o $FS1_OFFSET /dev/loop0 $TMP/beagleboard-demo-$DATE.img
471   sudo mkfs.vfat /dev/loop0 -n BEAGLE -F 32 120456
472   sudo mount /dev/loop0 /mnt/sd_image1
473   sudo cp -R $FILES md5sum.txt /mnt/sd_image1/
474   mount
475   ls -l /mnt/sd_image1
476   sudo losetup /dev/loop0
477   sudo umount /dev/loop0
478   sudo losetup -d /dev/loop0
479   sudo losetup -v -o $FS2_OFFSET /dev/loop0 $TMP/beagleboard-demo-$DATE.img
480   sudo mkfs.ext3 -j -L "ANGSTROM" /dev/loop0 3445942
481   sudo mount /dev/loop0 /mnt/sd_image2
482   sudo tar xjf demo-$DATE.tar.bz2 -C /mnt/sd_image2/
483   pushd /mnt/sd_image2/
484   sudo perl -00pe "s/\[daemon\]\n\n/[daemon]\nTimedLoginEnable=true\nTimedLogin=root\nTimedLoginDelay=10\n\n/" -i.bak etc/gdm/custom.conf
485   #sudo sh -c 'echo "boris:x:1000:1000:Boris the Beagle:/home/boris:/bin/sh" >> etc/passwd'
486   #sudo sh -c 'echo "boris:!:14841:0:99999:7:::" >> etc/shadow'
487   #sudo mkdir -p home/boris
488   #sudo chown 1000.1000 home/boris
489   sudo mkdir -p usr/share/esc-training
490   pushd usr/share/esc-training
491   sudo git clone git://git.kernel.org/pub/scm/git/git.git
492   sudo git clone git://git.denx.de/u-boot.git
493   pushd u-boot
494   sudo git remote add beagleboard-validation git://gitorious.org/beagleboard-validation/u-boot.git
495   sudo git remote update
496   popd
497   popd
498   sudo tar --no-same-owner --owner=root -xzf $OEBB_DIR/sources/downloads/demohome.tgz
499   # opkg update
500   # opkg install nodejs linuxtag-ics
501   OETMPDIR=$OEBB_DIR/build/tmp-angstrom_2008_1/
502   OEBINDIR=$OETMPDIR/sysroots/x86_64-linux/usr/bin
503   OEIPKDIR=$OETMPDIR/deploy/glibc/ipk
504   OPKGARGS="--cache /mnt/ubuntu-tmp -o /mnt/sd_image2 -f /mnt/sd_image2/etc/opkg/opkg.conf"
505   #sudo $OEBINDIR/opkg-cl --cache /mnt/ubuntu-tmp -o /mnt/sd_image2 -f /mnt/sd_image2/etc/opkg/opkg.conf update
506   #sudo sh -c "yes | $OEBINDIR/opkg-cl $OPKGARGS install nodejs"
507   #sudo sh -c "yes | $OEBINDIR/opkg-cl $OPKGARGS install linuxtag-ics"
508   #sudo sh -c "yes | $OEBINDIR/opkg-cl $OPKGARGS install qmake2"
509   popd
510   mount
511   sudo losetup /dev/loop0
512   sudo umount /dev/loop0
513   sudo losetup -d /dev/loop0
514   gzip -c $TMP/beagleboard-demo-$DATE.img > beagleboard-demo-$DATE.img.gz
515   mv $TMP/beagleboard-demo-$DATE.img .
516   wget -O - http://beagleboard-validation.s3.amazonaws.com/deploy/$DATE/sd/beagleboard-demo-$DATE.img.gz?torrent > beagleboard-demo-$DATE.img.gz.torrent
517  fi
518 fi
519  
520 popd
521 }
522
523 # about 50-70 minutes
524 function rsync-deploy {
525 [ -z "$1" ] || DATE=$1
526 S3_DEPLOY_DIR=/mnt/s3/deploy/$DATE
527 if [ ! -x /mnt/s3/scripts/ec2build.sh ]; then mount-s3; fi
528 mkdir -p $S3_DEPLOY_DIR
529 cp /mnt/s3/scripts/list.html $S3_DEPLOY_DIR
530 mkdir -p $S3_DEPLOY_DIR/glibc
531 cp /mnt/s3/scripts/list.html $S3_DEPLOY_DIR/glibc
532 rsync -a $OEBB_DIR/build/tmp-angstrom_2008_1/deploy/glibc $S3_DEPLOY_DIR
533 }
534
535 function rsync-pstage-to-s3 {
536 # consider http://s3.amazonaws.com/ServEdge_pub/s3sync/README.txt
537 if [ ! -x /mnt/s3/scripts/ec2build.sh ]; then mount-s3; fi
538 mkdir -p /mnt/s3/pstage
539 cp /mnt/s3/scripts/list.html /mnt/s3/pstage/
540 # The quilt-native pstage package is bad
541 #rm $OEBB_DIR/build/tmp-angstrom_2008_1/pstage/*/*quilt-native* || true
542 # TI components may have non-free licenses
543 rm $OEBB_DIR/build/tmp-angstrom_2008_1/pstage/*/*ti-* || true
544 rsync -a $OEBB_DIR/build/tmp-angstrom_2008_1/pstage/ /mnt/s3/pstage/
545 rm /mnt/s3/pstage/*/*ti-* || true
546 }
547
548 function rsync-pstage-from-s3 {
549 if [ ! -x /mnt/s3/scripts/ec2build.sh ]; then mount-s3; fi
550 mkdir -p $OEBB_DIR/build/tmp-angstrom_2008_1/pstage/
551 rsync -a /mnt/s3/pstage/ $OEBB_DIR/build/tmp-angstrom_2008_1/pstage/
552 # The quilt-native pstage package is bad
553 #rm $OEBB_DIR/build/tmp-angstrom_2008_1/pstage/*/*quilt-native* || true
554 # TI components may have non-free licenses
555 rm $OEBB_DIR/build/tmp-angstrom_2008_1/pstage/*/*ti-* || true
556 }
557
558 function copy-ti-tools {
559 find-instance
560 remote mkdir -p $OEBB_DIR/sources/downloads
561 rsync -a -e "ssh -i $KEYPAIR_FILE" $HOME/ti-tools/ti_cgt_c6000_6.1.9_setup_linux_x86.bin ubuntu@$MACH_NAME:$OEBB_DIR/sources/downloads/ti_cgt_c6000_6.1.9_setup_linux_x86.bin
562 rsync -a -e "ssh -i $KEYPAIR_FILE" $HOME/ti-tools/OMAP35x_Graphics_SDK_setuplinux_3_01_00_06.bin ubuntu@$MACH_NAME:$OEBB_DIR/sources/downloads/OMAP35x_Graphics_SDK_setuplinux_3_01_00_06.bin
563 rsync -a -e "ssh -i $KEYPAIR_FILE" $HOME/ti-tools/demohome.tgz ubuntu@$MACH_NAME:$OEBB_DIR/sources/downloads/demohome.tgz
564 }
565
566 function setup-oe {
567 if [ ! -x $OEBB_DIR/oebb.sh ]; then install-oe; fi
568 pushd $OEBB_DIR
569 git checkout $ANGSTROM_SCRIPT_ID
570 if [ ! -d sources/openembedded/.git ]; then
571  ./oebb.sh update
572 fi
573 pushd sources/openembedded
574 # will fail if myrepo already exits
575 git remote add myrepo git://gitorious.org/~Jadon/angstrom/jadon-openembedded.git || true
576 # let's not die here, since we just want increase our odds of finding the right commit id
577 git remote update || true
578 git checkout $ANGSTROM_REPO_ID
579 popd
580 popd
581 }
582
583 function build-image {
584 IMAGE=$1
585 setup-oe
586 oebb bitbake -k beagleboard-$IMAGE-image
587 }
588
589 time $*
590