commit ea56372e656bf81ecbeaed25b01d601faf2cc31a Author: Mike Perry mikeperry-git@torproject.org Date: Tue Aug 6 04:30:35 2013 +0200
Refactor vm creation to happen at the start of the build process.
Also restart vm creation if it fails. --- gitian/Makefile | 2 ++ gitian/make-vms.sh | 84 ++++++++++++++++++++++++++++++++++++++++++++ gitian/mkbundle-linux.sh | 36 ++----------------- gitian/mkbundle-mac.sh | 20 ++--------- gitian/mkbundle-windows.sh | 20 ++--------- 5 files changed, 92 insertions(+), 70 deletions(-)
diff --git a/gitian/Makefile b/gitian/Makefile index 223366f..a866da6 100644 --- a/gitian/Makefile +++ b/gitian/Makefile @@ -18,6 +18,8 @@ clean:
vmclean: rm -rf ../../gitian-builder/*.qcow2 + rm -rf ../../gitian-builder/base-* + rm -rf ../../gitian-builder/target-*
distclean: vmclean rm -rf ../../gitian-builder/inputs/* diff --git a/gitian/make-vms.sh b/gitian/make-vms.sh new file mode 100755 index 0000000..32d0b71 --- /dev/null +++ b/gitian/make-vms.sh @@ -0,0 +1,84 @@ +#!/bin/bash + +. ./versions + +WRAPPER_DIR=$PWD +GITIAN_DIR=$PWD/../../gitian-builder +DESCRIPTOR_DIR=$PWD/descriptors/ + +if [ ! -f $GITIAN_DIR/bin/gbuild ]; +then + echo "Gitian not found. You need a Gitian checkout in $GITIAN_DIR" + exit 1 +fi + +if [ -z "$NUM_PROCS" ]; +then + export NUM_PROCS=2 +fi + +cd $GITIAN_DIR +export PATH=$PATH:$PWD/libexec + +build_and_test_vm() { + local dist="$1"; shift + local arch="$1"; shift + local bits="$1"; shift + + if [ ! -f ./base-$dist-$arch.qcow2 ]; + then + if [ "z$USE_LXC" = "z1" ]; + then + ./bin/make-base-vm --suite $dist --lxc --arch $arch + else + ./bin/make-base-vm --suite $dist --arch $arch + fi + + make-clean-vm --suite $dist --arch $arch + if [ $? -ne 0 ]; + then + echo "$arch $dist VM creation failed" + exit 1 + fi + + stop-target $bits $dist + start-target $bits $dist-$arch & + for i in 1 2 3 + do + sleep 2 + on-target /bin/true && break + done + return $? + fi + + return 0 +} + +while ! build_and_test_vm lucid i386 32 +do + stop-target 32 lucid + exit 1 + #rm ./base-lucid-i386* + echo + echo "Lucid i386 VM build failed... Trying again" + echo +done + +while ! build_and_test_vm lucid amd64 64 +do + stop-target 64 lucid + rm ./base-lucid-amd64* + echo + echo "Lucid amd64 VM build failed... Trying again" + echo +done + +while ! build_and_test_vm precise i386 32 +do + stop-target 32 precise + rm ./base-precise-i386* + echo + echo "Lucid amd64 VM build failed... Trying again" + echo +done + diff --git a/gitian/mkbundle-linux.sh b/gitian/mkbundle-linux.sh index 91156cd..be2eacf 100755 --- a/gitian/mkbundle-linux.sh +++ b/gitian/mkbundle-linux.sh @@ -20,43 +20,11 @@ then export NUM_PROCS=2 fi
+./make-vms.sh + cd $GITIAN_DIR export PATH=$PATH:$PWD/libexec
-# TODO: Make a super-fresh option that kills the base vms -if [ ! -f ./base-lucid-i386.qcow2 ]; -then - if [ "z$USE_LXC" = "z1" ]; - then - ./bin/make-base-vm --lxc --arch i386 - else - ./bin/make-base-vm --arch i386 - fi - - if [ $? -ne 0 ]; - then - echo "i386 VM creation failed" - exit 1 - fi - stop-target -fi - -if [ ! -f ./base-lucid-amd64.qcow2 ]; -then - if [ "z$USE_LXC" = "z1" ]; - then - ./bin/make-base-vm --lxc --arch amd64 - else - ./bin/make-base-vm --arch amd64 - fi - if [ $? -ne 0 ]; - then - echo "amd64 VM creation failed" - exit 1 - fi - stop-target -fi - echo "pref("torbrowser.version", "$TORBROWSER_VERSION-Linux");" > $GITIAN_DIR/inputs/torbrowser.version echo "$TORBROWSER_VERSION" > $GITIAN_DIR/inputs/bare-version
diff --git a/gitian/mkbundle-mac.sh b/gitian/mkbundle-mac.sh index bd3ecac..6ca7e49 100755 --- a/gitian/mkbundle-mac.sh +++ b/gitian/mkbundle-mac.sh @@ -20,27 +20,11 @@ then export NUM_PROCS=2 fi
+./make-vms.sh + cd $GITIAN_DIR export PATH=$PATH:$PWD/libexec
-# TODO: Make a super-fresh option that kills the base vms -if [ ! -f base-precise-i386.qcow2 ]; -then - if [ "z$USE_LXC" = "z1" ]; - then - ./bin/make-base-vm --lxc --suite precise --arch i386 - else - ./bin/make-base-vm --suite precise --arch i386 - fi - - if [ $? -ne 0 ]; - then - echo "i386 VM creation failed" - exit 1 - fi - stop-target -fi - echo "pref("torbrowser.version", "$TORBROWSER_VERSION-MacOS");" > $GITIAN_DIR/inputs/torbrowser.version echo "$TORBROWSER_VERSION" > $GITIAN_DIR/inputs/bare-version
diff --git a/gitian/mkbundle-windows.sh b/gitian/mkbundle-windows.sh index 0315c9d..f020675 100755 --- a/gitian/mkbundle-windows.sh +++ b/gitian/mkbundle-windows.sh @@ -20,27 +20,11 @@ then export NUM_PROCS=2 fi
+./make-vms.sh + cd $GITIAN_DIR export PATH=$PATH:$PWD/libexec
-# TODO: Make a super-fresh option that kills the base vms -if [ ! -f base-precise-i386.qcow2 ]; -then - if [ "z$USE_LXC" = "z1" ]; - then - ./bin/make-base-vm --lxc --suite precise --arch i386 - else - ./bin/make-base-vm --suite precise --arch i386 - fi - - if [ $? -ne 0 ]; - then - echo "i386 VM creation failed" - exit 1 - fi - stop-target -fi - echo "pref("torbrowser.version", "$TORBROWSER_VERSION-Windows");" > $GITIAN_DIR/inputs/torbrowser.version echo "$TORBROWSER_VERSION" > $GITIAN_DIR/inputs/bare-version
tor-commits@lists.torproject.org