summaryrefslogtreecommitdiffstats
path: root/xci/scripts/vm
diff options
context:
space:
mode:
authorMarkos Chandras <mchandras@suse.de>2017-09-27 16:46:07 +0100
committerMarkos Chandras <mchandras@suse.de>2017-09-27 23:11:14 +0100
commit4b79476969def3e3510f3859e1539386b5b0d471 (patch)
tree27913c389432375d9e31a7102dff222c4453d03e /xci/scripts/vm
parente399ec873c902675c9b154dcc40d47358f3a95ee (diff)
xci: scripts: start-new-vm.sh: Do not allow multiple build-dib-os processes
apt-get is really unhappy when another instance is running and fails with the following error: E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable) E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it? Change-Id: I2fe343fdab8438cb112cce0a4f81c7e3977c55f9 Signed-off-by: Markos Chandras <mchandras@suse.de>
Diffstat (limited to 'xci/scripts/vm')
-rwxr-xr-xxci/scripts/vm/build-dib-os.sh2
-rwxr-xr-xxci/scripts/vm/start-new-vm.sh14
2 files changed, 13 insertions, 3 deletions
diff --git a/xci/scripts/vm/build-dib-os.sh b/xci/scripts/vm/build-dib-os.sh
index 78eaff2d..2f788006 100755
--- a/xci/scripts/vm/build-dib-os.sh
+++ b/xci/scripts/vm/build-dib-os.sh
@@ -7,7 +7,7 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-set -e
+set -ex
# This only works on ubuntu hosts
lsb_release -i | grep -q -i ubuntu || { echo "This script only works on Ubuntu distros"; exit 1; }
diff --git a/xci/scripts/vm/start-new-vm.sh b/xci/scripts/vm/start-new-vm.sh
index c374071c..991637a6 100755
--- a/xci/scripts/vm/start-new-vm.sh
+++ b/xci/scripts/vm/start-new-vm.sh
@@ -8,7 +8,7 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-set -e
+set -ex
lsb_release -i | grep -q -i ubuntu || { echo "This script only works on Ubuntu distros"; exit 1; }
@@ -38,8 +38,18 @@ declare -r BASE_PATH=$(dirname $(readlink -f $0) | sed "s@/xci/.*@@")
echo "Preparing new virtual machine '${NAME}'..."
# NOTE(hwoarang) This should be removed when we move the dib images to a central place
+_retries=20
echo "Building '${OS}' image (tail build.log for progress and failures)..."
-$BASE_PATH/xci/scripts/vm/build-dib-os.sh ${OS} > build.log 2>&1
+while [[ $_retries -ne 0 ]]; do
+ if pgrep build-dib-os.sh &>/dev/null; then
+ echo "There is another dib process running... ($_retries retries left)"
+ sleep 60
+ (( _retries = _retries - 1 ))
+ else
+ $BASE_PATH/xci/scripts/vm/build-dib-os.sh ${OS} > build.log 2>&1
+ break
+ fi
+done
[[ ! -e ${OS}.qcow2 ]] && echo "${OS}.qcow2 not found! This should never happen!" && exit 1