dockerrpm: check that docker is running correctly before building
authorMads Kiilerich <madski@unity3d.com>
Fri, 30 May 2014 14:14:33 +0200
changeset 22438 f5abb231b80a
parent 22437 9e2e4fc524fd
child 22439 d2a00ced3cce
dockerrpm: check that docker is running correctly before building
contrib/dockerrpm
--- a/contrib/dockerrpm	Sun Aug 31 13:40:53 2014 +0200
+++ b/contrib/dockerrpm	Fri May 30 14:14:33 2014 +0200
@@ -1,14 +1,21 @@
-#!/bin/bash
+#!/bin/bash -e
 
 BUILDDIR=$(dirname $0)
 ROOTDIR=$(cd $BUILDDIR/..; pwd)
 
-if which docker.io >> /dev/null ; then
+if which docker.io >> /dev/null 2>&1 ; then
   DOCKER=docker.io
-elif which docker >> /dev/null ; then
+elif which docker >> /dev/null 2>&1 ; then
   DOCKER=docker
+else
+  echo "Error: docker must be installed"
+  exit 1
 fi
 
+$DOCKER -h 2> /dev/null | grep -q Jansens && { echo "Error: $DOCKER is the Docking System Tray - install docker.io instead"; exit 1; }
+$DOCKER version | grep -q "^Client version:" || { echo "Error: unexpected output from \"$DOCKER version\""; exit 1; }
+$DOCKER version | grep -q "^Server version:" || { echo "Error: could not get docker server version - check it is running and your permissions"; exit 1; }
+
 $DOCKER build --tag "hg-dockerrpm-$1" - < $BUILDDIR/docker/$1
 $DOCKER run --rm -v $ROOTDIR:/hg "hg-dockerrpm-$1" bash -c \
     "cp -a hg hg-build; cd hg-build; make clean local $1; cp packages/$1/* /hg/packages/$1/"