Patchwork [4,of,6] hghave: add a check for docker support

login
register
mail settings
Submitter Augie Fackler
Date Aug. 27, 2015, 11:26 p.m.
Message ID <b484b73deeb3085dbe6a.1440718016@imladris.local>
Download mbox | patch
Permalink /patch/10308/
State Accepted
Headers show

Comments

Augie Fackler - Aug. 27, 2015, 11:26 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1440475601 14400
#      Tue Aug 25 00:06:41 2015 -0400
# Node ID b484b73deeb3085dbe6a91449602e4d98710c576
# Parent  607d6ea0269a536a47ef1fddc3b54aa5dacaf313
hghave: add a check for docker support

This currently refuses to operate if on a non-Linux host. I suspect
that Docker running on FreeBSD 11 or on an Illumos derivative would
work fine, but I don't have ready access to such a system.

On OS X using boot2docker (I used a hacky xhyve-based one for
testing), it won't work because $TESTTEMP doesn't end up inside the
set of directories that get forwarded to the boot2docker VM, so you
can't actually drop debs in the $TESTTEMP at all. It would be possible
(probably even trivial) to hack around this by using a randomly-named
temporary directory inside the working directory, but that seems
unlikely to be useful enough to justify the ugliness.
Matt Mackall - Aug. 31, 2015, 10:12 p.m.
On Thu, 2015-08-27 at 19:26 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1440475601 14400
> #      Tue Aug 25 00:06:41 2015 -0400
> # Node ID b484b73deeb3085dbe6a91449602e4d98710c576
> # Parent  607d6ea0269a536a47ef1fddc3b54aa5dacaf313
> hghave: add a check for docker support

I've queued these first four. I think patch 5 still references
debian-jessie, so might need some other revisiting.

Patch

diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -414,6 +414,23 @@  def has_aix():
 def has_osx():
     return sys.platform == 'darwin'
 
+@check("docker", "docker support")
+def has_docker():
+    pat = r'A self-sufficient runtime for linux containers\.'
+    if matchoutput('docker --help', pat):
+        if 'linux' not in sys.platform:
+            # TODO: in theory we should be able to test docker-based
+            # package creation on non-linux using boot2docker, but in
+            # practice that requires extra coordination to make sure
+            # $TESTTEMP is going to be visible at the same path to the
+            # boot2docker VM. If we figure out how to verify that, we
+            # can use the following instead of just saying False:
+            # return 'DOCKER_HOST' in os.environ
+            return False
+
+        return True
+    return False
+
 @check("debhelper", "debian packaging tools")
 def has_debhelper():
     dpkg = matchoutput('dpkg --version',