[bug#33893,v5,4/4] gnu: Add docker-cli.

Message ID 20181230233903.23426-5-dannym@scratchpost.org
State Accepted
Headers show
Series Add docker. | expand

Checks

Context Check Description
cbaines/applying patch fail Apply failed
cbaines/applying patch fail Apply failed
cbaines/applying patch fail Apply failed
cbaines/applying patch fail Apply failed

Commit Message

Danny Milosavljevic Dec. 30, 2018, 11:39 p.m. UTC
* gnu/packages/docker.scm (docker-cli): New variable.
---
 gnu/packages/docker.scm | 63 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

Comments

Ludovic Courtès Jan. 6, 2019, 8:33 p.m. UTC | #1
Danny Milosavljevic <dannym@scratchpost.org> skribis:

> * gnu/packages/docker.scm (docker-cli): New variable.

[...]

> +    (arguments
> +     `(#:import-path "github.com/docker/cli"
> +       ;; TODO: Tests require a running Docker daemon.
> +       #:tests? #f

I suppose we cannot run the daemon in the build environment, can we?

Or is it possible to use some of the tests?

> +    (native-inputs
> +     `(("go" ,go)
> +       ("libltdl" ,libltdl)

Shouldn’t libltdl be an input?

Otherwise LGTM, thanks!

Ludo’.
Meiyo Peng Jan. 14, 2019, 3:20 a.m. UTC | #2
Hi Danny,

docker-cli provides two identical commands in
"/gnu/store/*docker-cli*/bin/".

#+begin_SRC sh
   ~  ll /gnu/store/*docker-cli*/bin/*
  -r-xr-xr-x 3 root root 64M Jan  1  1970 /gnu/store/hr7h12q3gvs98pr832b66479cp8wlzhk-docker-cli-18.09.0/bin/docker*
  -r-xr-xr-x 3 root root 64M Jan  1  1970 /gnu/store/hr7h12q3gvs98pr832b66479cp8wlzhk-docker-cli-18.09.0/bin/docker-linux-amd64*

   ~  sha256sum /gnu/store/*docker-cli*/bin/*
  62bc8199fd11f37129d6e8183865df698f495faf90a86bdbe5ee4891b201cbc8  /gnu/store/hr7h12q3gvs98pr832b66479cp8wlzhk-docker-cli-18.09.0/bin/docker
  62bc8199fd11f37129d6e8183865df698f495faf90a86bdbe5ee4891b201cbc8  /gnu/store/hr7h12q3gvs98pr832b66479cp8wlzhk-docker-cli-18.09.0/bin/docker-linux-amd64
#+end_SRC

It wastes 64MB disk space.  Can we remove "docker-linux-amd64"?


--
Meiyo Peng
https://www.pengmeiyu.com/
Danny Milosavljevic Jan. 15, 2019, 12:34 p.m. UTC | #3
Hi,

> It wastes 64MB disk space.  Can we remove "docker-linux-amd64"?

Done in commit f3705090965c2470a0ccc2c045edbc5f5fb7bb8d.

Thanks!

Patch

diff --git a/gnu/packages/docker.scm b/gnu/packages/docker.scm
index a3510529a..19b4d504f 100644
--- a/gnu/packages/docker.scm
+++ b/gnu/packages/docker.scm
@@ -27,6 +27,7 @@ 
   #:use-module (guix build-system go)
   #:use-module (guix build-system python)
   #:use-module (guix utils)
+  #:use-module (gnu packages autotools)
   #:use-module (gnu packages check)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages golang)
@@ -376,3 +377,65 @@  management, secret management, configuration management, networking,
 provisioning etc.")
     (home-page "https://mobyproject.org/")
     (license license:asl2.0)))
+
+(define-public docker-cli
+  (package
+    (name "docker-cli")
+    (version %docker-version)
+    (source
+     (origin
+      (method git-fetch)
+      (uri (git-reference
+            (url "https://github.com/docker/cli.git")
+            (commit (string-append "v" version))))
+      (file-name (git-file-name name version))
+      (sha256
+       (base32
+        "1ivisys20kphvbqlazc3bsg7pk0ykj9gjx5d4yg439x4n13jxwvb"))))
+    (build-system go-build-system)
+    (arguments
+     `(#:import-path "github.com/docker/cli"
+       ;; TODO: Tests require a running Docker daemon.
+       #:tests? #f
+       #:phases
+       (modify-phases %standard-phases
+         (add-before 'build 'setup-environment-2
+           (lambda _
+             ;; Respectively, strip the symbol table and debug
+             ;; information, and the DWARF symbol table.
+             (setenv "LDFLAGS" "-s -w")
+
+             ;; Make build reproducible.
+             (setenv "BUILDTIME" "1970-01-01 00:00:01.000000000+00:00")
+             (symlink "src/github.com/docker/cli/scripts" "./scripts")
+             (symlink "src/github.com/docker/cli/docker.Makefile" "./docker.Makefile")
+             #t))
+         (replace 'build
+           (lambda _
+             (invoke "./scripts/build/dynbinary")))
+         (replace 'check
+           (lambda* (#:key make-flags tests? #:allow-other-keys)
+             (setenv "PATH" (string-append (getcwd) "/build:" (getenv "PATH")))
+             (if tests?
+                 ;; Use the newly-built docker client for the tests.
+                 (with-directory-excursion "src/github.com/docker/cli"
+                   ;; TODO: Run test-e2e as well?
+                   (apply invoke "make" "-f" "docker.Makefile" "test-unit"
+                          (or make-flags '())))
+                 #t)))
+         (replace 'install
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (out-bin (string-append out "/bin")))
+               (chdir "build")
+               (install-file (readlink "docker") out-bin)
+               (install-file "docker" out-bin)
+               #t))))))
+    (native-inputs
+     `(("go" ,go)
+       ("libltdl" ,libltdl)
+       ("pkg-config" ,pkg-config)))
+    (synopsis "Command line interface to Docker")
+    (description "This package provides a command line interface to Docker.")
+    (home-page "http://www.docker.com/")
+    (license license:asl2.0)))