[PATCH 04 of 10 v2] dockerrpm: check that docker is running correctly before building

Mads Kiilerich mads at kiilerich.com
Sun Aug 31 06:41:34 CDT 2014


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1401452073 -7200
#      Fri May 30 14:14:33 2014 +0200
# Node ID 687930a9b382b71a9aa005ab90caf3338b300866
# Parent  0aefc4c4bd0cf27abcc6188f5a1889180469f907
dockerrpm: check that docker is running correctly before building

diff --git a/contrib/dockerrpm b/contrib/dockerrpm
--- a/contrib/dockerrpm
+++ b/contrib/dockerrpm
@@ -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/"


More information about the Mercurial-devel mailing list