Patchwork [STABLE] docker: match more version of 'hg docker version' (issue4967)

login
register
mail settings
Submitter Pierre-Yves David
Date Nov. 25, 2015, 2:16 a.m.
Message ID <05635441f955acbdab24.1448417764@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/11647/
State Accepted
Headers show

Comments

Pierre-Yves David - Nov. 25, 2015, 2:16 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1448417605 28800
#      Tue Nov 24 18:13:25 2015 -0800
# Branch stable
# Node ID 05635441f955acbdab243156af39e79addda1c34
# Parent  6979fe2a6d75105affcacd9e298262a92641cb98
# Available At http://hg.netv6.net/marmoute-wip/mercurial/
#              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r 05635441f955
docker: match more version of 'hg docker version' (issue4967)

My version of docker (1.8.3) have a different formating for 'docker version'
that broke the build script. We make the version matching more generic in to
work with both version.
Anton Shestakov - Nov. 25, 2015, 12:38 p.m.
25.11.2015, 10:17, "Pierre-Yves David" <pierre-yves.david@ens-lyon.org>:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1448417605 28800
> # Tue Nov 24 18:13:25 2015 -0800
> # Branch stable
> # Node ID 05635441f955acbdab243156af39e79addda1c34
> # Parent 6979fe2a6d75105affcacd9e298262a92641cb98
> # Available At http://hg.netv6.net/marmoute-wip/mercurial/
> # hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r 05635441f955
> docker: match more version of 'hg docker version' (issue4967)
>
> My version of docker (1.8.3) have a different formating for 'docker version'
> that broke the build script. We make the version matching more generic in to
> work with both version.
>
> diff --git a/contrib/dockerlib.sh b/contrib/dockerlib.sh
> --- a/contrib/dockerlib.sh
> +++ b/contrib/dockerlib.sh
> @@ -12,12 +12,12 @@ function checkdocker() {
>      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 version | grep -Eq "^(Client version|Client):" || { echo "Error: unexpected output from \"$DOCKER version\""; exit 1; }
> + $DOCKER version | grep -Eq "^(Server version|Server):" || { echo "Error: could not get docker server version - check it is running and your permissions"; exit 1; }

A couple of tiny nitpicks:

- The regex could be just '^Client( version)?:'.
- I'm not sure how applicable https://www.mercurial-scm.org/wiki/WritingTests#grep is to dockerlib.sh (i.e. to platforms with good docker host support), but it recommends using egrep instead of grep -E for portability.
Pierre-Yves David - Nov. 30, 2015, 8:04 p.m.
On 11/25/2015 04:38 AM, Anton Shestakov wrote:
> 25.11.2015, 10:17, "Pierre-Yves David" <pierre-yves.david@ens-lyon.org>:
>> # HG changeset patch
>> # User Pierre-Yves David <pierre-yves.david@fb.com>
>> # Date 1448417605 28800
>> # Tue Nov 24 18:13:25 2015 -0800
>> # Branch stable
>> # Node ID 05635441f955acbdab243156af39e79addda1c34
>> # Parent 6979fe2a6d75105affcacd9e298262a92641cb98
>> # Available At http://hg.netv6.net/marmoute-wip/mercurial/
>> # hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r 05635441f955
>> docker: match more version of 'hg docker version' (issue4967)
>>
>> My version of docker (1.8.3) have a different formating for 'docker version'
>> that broke the build script. We make the version matching more generic in to
>> work with both version.
>>
>> diff --git a/contrib/dockerlib.sh b/contrib/dockerlib.sh
>> --- a/contrib/dockerlib.sh
>> +++ b/contrib/dockerlib.sh
>> @@ -12,12 +12,12 @@ function checkdocker() {
>>       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 version | grep -Eq "^(Client version|Client):" || { echo "Error: unexpected output from \"$DOCKER version\""; exit 1; }
>> + $DOCKER version | grep -Eq "^(Server version|Server):" || { echo "Error: could not get docker server version - check it is running and your permissions"; exit 1; }
>
> A couple of tiny nitpicks:
>
> - The regex could be just '^Client( version)?:'.
> - I'm not sure how applicable https://www.mercurial-scm.org/wiki/WritingTests#grep is to dockerlib.sh (i.e. to platforms with good docker host support), but it recommends using egrep instead of grep -E for portability.

I've fixed the regexp and pushed the result to the clowncopter. I'm 
unsure about he egrep change and left stuff as is.
Matt Mackall - Dec. 2, 2015, 4:48 p.m.
On Wed, 2015-12-02 at 10:09 -0600, Kevin Bullock wrote:
> > On Nov 24, 2015, at 20:16, Pierre-Yves David <pierre-yves.david@ens
> > -lyon.org> wrote:
> > 
> > # HG changeset patch
> > # User Pierre-Yves David <pierre-yves.david@fb.com>
> > # Date 1448417605 28800
> > #      Tue Nov 24 18:13:25 2015 -0800
> > # Branch stable
> > # Node ID 05635441f955acbdab243156af39e79addda1c34
> > # Parent  6979fe2a6d75105affcacd9e298262a92641cb98
> > # Available At http://hg.netv6.net/marmoute-wip/mercurial/
> > #              hg pull http://hg.netv6.net/marmoute-wip/mercurial/
> >  -r 05635441f955
> > docker: match more version of 'hg docker version' (issue4967)
> > 
> > My version of docker (1.8.3) have a different formating for 'docker
> > version'
> > that broke the build script. We make the version matching more
> > generic in to
> > work with both version.
> 
> Looks like `docker version` will take a format string:
> 
>     $ docker version -f '{{.Client.Version}}'
>     1.8.3

I think we could simply search for "[Cc]lient" as the other "docker" is
very different.

-- 
Mathematics is the supreme nostalgia of our time.

Patch

diff --git a/contrib/dockerlib.sh b/contrib/dockerlib.sh
--- a/contrib/dockerlib.sh
+++ b/contrib/dockerlib.sh
@@ -12,12 +12,12 @@  function checkdocker() {
     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 version | grep -Eq "^(Client version|Client):" || { echo "Error: unexpected output from \"$DOCKER version\""; exit 1; }
+  $DOCKER version | grep -Eq "^(Server version|Server):" || { echo "Error: could not get docker server version - check it is running and your permissions"; exit 1; }
 }
 
 # Construct a container and leave its name in $CONTAINER for future use.
 function initcontainer() {
   [ "$1" ] || { echo "Error: platform name must be specified"; exit 1; }