[tbb-commits] [rbm/master] Fix docker_remote_finish for docker >= 1.10.0

boklm at torproject.org boklm at torproject.org
Sun Feb 12 22:33:07 UTC 2017


commit dbd2143279680104971dc2b08877f252a38a1b2c
Author: Nicolas Vigier <boklm at torproject.org>
Date:   Sun Feb 12 23:11:13 2017 +0100

    Fix docker_remote_finish for docker >= 1.10.0
    
    With docker >= 1.10.0, the -f flag on 'docker tag' is deprecated:
    https://docs.docker.com/engine/deprecated/#/f-flag-on-docker-tag
    
    However we need it when using an older version of docker.
    
    To add it only when needed, we parse the output from 'docker version'.
---
 lib/RBM/DefaultConfig.pm | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/lib/RBM/DefaultConfig.pm b/lib/RBM/DefaultConfig.pm
index 100ad2c..8eaf9dd 100644
--- a/lib/RBM/DefaultConfig.pm
+++ b/lib/RBM/DefaultConfig.pm
@@ -86,6 +86,21 @@ sub get_arch {
     return $stdout;
 }
 
+sub docker_version {
+    my ($stdout, $stderr, $success)
+        = capture_exec('docker', 'version', '--format', '{{.Client.Version}}');
+    if ($success) {
+        chomp $stdout;
+        return $stdout;
+    }
+    ($stdout, $stderr, $success) = capture_exec('docker', 'version');
+    RBM::exit_error("Error running 'docker version'") unless $success;
+    foreach my $line (split "\n", $stdout) {
+        return $1 if ($line =~ m/Client version: (.*)$/);
+    }
+    RBM::exit_error("Could not find docker version");
+}
+
 our %default_config = (
     sysconf_file  => '/etc/rbm.conf',
     tmp_dir       => '/tmp',
@@ -382,6 +397,10 @@ OPT_END
 ####
 ####
 ####
+    docker_version     => \&docker_version,
+####
+####
+####
     docker_build_image => 'rbm-[% sha256(c("build_id")).substr(0, 12) %]',
 ####
 ####
@@ -408,7 +427,7 @@ OPT_END
 #!/bin/sh
 set -e
 [% IF c('docker_save_image') -%]
-docker tag -f [% c('docker_build_image') %] [% c('docker_save_image') %]
+docker tag [% IF versioncmp(c('docker_version'), '1.10.0') == -1; GET '-f'; END; %] [% c('docker_build_image') %] [% c('docker_save_image') %]
 [% END -%]
 docker rmi -f [% c('docker_build_image') %] > /dev/null
 OPT_END





More information about the tbb-commits mailing list