Patchwork [13,of,22] dockerrpm: check that docker is running correctly before building

login
register
mail settings
Submitter Mads Kiilerich
Date May 20, 2014, 2:10 a.m.
Message ID <2eb36c36ff30a18b6a7e.1400551808@mk-desktop>
Download mbox | patch
Permalink /patch/4836/
State Superseded
Commit f5abb231b80ab5859097c8b2d6abcfd0fbb46bb6
Headers show

Comments

Mads Kiilerich - May 20, 2014, 2:10 a.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1400551681 -7200
#      Tue May 20 04:08:01 2014 +0200
# Node ID 2eb36c36ff30a18b6a7ecc76b0592699bd46635f
# Parent  75c1b9ca3644252245840f7276f8223803805a4e
dockerrpm: check that docker is running correctly before building

Patch

diff --git a/contrib/dockerrpm b/contrib/dockerrpm
--- a/contrib/dockerrpm
+++ b/contrib/dockerrpm
@@ -1,4 +1,4 @@ 
-#!/bin/bash
+#!/bin/bash -e
 
 BUILDDIR=$(dirname $0)
 ROOTDIR=$(cd $BUILDDIR/..; pwd)
@@ -9,6 +9,11 @@  elif which docker.io >> /dev/null ; then
   DOCKER=docker.io
 fi
 
+[ "$DOCKER" ] || { echo "Error: docker must be installed"; exit 1; }
+$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: docker server not found - 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 build/$1/* /hg/build/$1/"