Archived
1
0
Fork 0

gnu: docker: Switch to gexp and new input style.

* gnu/packages/docker.scm (docker)[arguments]: Rewrite as gexps.  Switch
to using search-input-file.
[inputs]: Use new style inputs.

Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
This commit is contained in:
Pierre Langlois 2022-05-10 00:35:19 +01:00 committed by Maxim Cournoyer
parent 185ae9b410
commit 168a4955a3
No known key found for this signature in database
GPG key ID: 1260E46482E63562

View file

@ -324,260 +324,259 @@ built-in registry server of Docker.")
(base32 "0hn7fg717rggwk6dbicrwa7aglqp7dp0jp5rvn6p9gfcnrp2w97d")))) (base32 "0hn7fg717rggwk6dbicrwa7aglqp7dp0jp5rvn6p9gfcnrp2w97d"))))
(build-system gnu-build-system) (build-system gnu-build-system)
(arguments (arguments
`(#:modules (list
((guix build gnu-build-system) #:modules
'((guix build gnu-build-system)
((guix build go-build-system) #:prefix go:) ((guix build go-build-system) #:prefix go:)
(guix build union) (guix build union)
(guix build utils)) (guix build utils))
#:imported-modules #:imported-modules
(,@%gnu-build-system-modules `(,@%gnu-build-system-modules
(guix build union) (guix build union)
(guix build go-build-system)) (guix build go-build-system))
#:phases #:phases
(modify-phases %standard-phases #~(modify-phases %standard-phases
(add-after 'unpack 'patch-paths (add-after 'unpack 'patch-paths
(lambda* (#:key inputs #:allow-other-keys) (lambda* (#:key inputs #:allow-other-keys)
(substitute* "builder/builder-next/executor_unix.go" (substitute* "builder/builder-next/executor_unix.go"
(("CommandCandidates:.*runc.*") (("CommandCandidates:.*runc.*")
(string-append "CommandCandidates: []string{\"" (string-append "CommandCandidates: []string{\""
(assoc-ref inputs "runc") (search-input-file inputs "/sbin/runc")
"/sbin/runc\"},\n"))) "\"},\n")))
(substitute* "vendor/github.com/containerd/go-runc/runc.go" (substitute* "vendor/github.com/containerd/go-runc/runc.go"
(("DefaultCommand = .*") (("DefaultCommand = .*")
(string-append "DefaultCommand = \"" (string-append "DefaultCommand = \""
(assoc-ref inputs "runc") (search-input-file inputs "/sbin/runc")
"/sbin/runc\"\n"))) "\"\n")))
(substitute* "vendor/github.com/containerd/containerd/runtime/v1/linux/runtime.go" (substitute* "vendor/github.com/containerd/containerd/runtime/v1/linux/runtime.go"
(("defaultRuntime[ \t]*=.*") (("defaultRuntime[ \t]*=.*")
(string-append "defaultRuntime = \"" (string-append "defaultRuntime = \""
(assoc-ref inputs "runc") (search-input-file inputs "/sbin/runc")
"/sbin/runc\"\n")) "\"\n"))
(("defaultShim[ \t]*=.*") (("defaultShim[ \t]*=.*")
(string-append "defaultShim = \"" (string-append "defaultShim = \""
(assoc-ref inputs "containerd") (search-input-file inputs "/bin/containerd-shim")
"/bin/containerd-shim\"\n"))) "\"\n")))
(substitute* "daemon/daemon_unix.go" (substitute* "daemon/daemon_unix.go"
(("DefaultShimBinary = .*") (("DefaultShimBinary = .*")
(string-append "DefaultShimBinary = \"" (string-append "DefaultShimBinary = \""
(assoc-ref inputs "containerd") (search-input-file inputs "/bin/containerd-shim")
"/bin/containerd-shim\"\n")) "\"\n"))
(("DefaultRuntimeBinary = .*") (("DefaultRuntimeBinary = .*")
(string-append "DefaultRuntimeBinary = \"" (string-append "DefaultRuntimeBinary = \""
(assoc-ref inputs "runc") (search-input-file inputs "/sbin/runc")
"/sbin/runc\"\n"))) "\"\n")))
(substitute* "daemon/runtime_unix.go" (substitute* "daemon/runtime_unix.go"
(("defaultRuntimeName = .*") (("defaultRuntimeName = .*")
(string-append "defaultRuntimeName = \"" (string-append "defaultRuntimeName = \""
(assoc-ref inputs "runc") (search-input-file inputs "/sbin/runc")
"/sbin/runc\"\n"))) "\"\n")))
(substitute* "daemon/config/config.go" (substitute* "daemon/config/config.go"
(("StockRuntimeName = .*") (("StockRuntimeName = .*")
(string-append "StockRuntimeName = \"" (string-append "StockRuntimeName = \""
(assoc-ref inputs "runc") (search-input-file inputs "/sbin/runc")
"/sbin/runc\"\n")) "\"\n"))
(("DefaultInitBinary = .*") (("DefaultInitBinary = .*")
(string-append "DefaultInitBinary = \"" (string-append "DefaultInitBinary = \""
(assoc-ref inputs "tini") (search-input-file inputs "/bin/tini-static")
"/bin/tini-static\"\n"))) "\"\n")))
(substitute* "daemon/config/config_common_unix_test.go" (substitute* "daemon/config/config_common_unix_test.go"
(("expectedInitPath: \"docker-init\"") (("expectedInitPath: \"docker-init\"")
(string-append "expectedInitPath: \"" (string-append "expectedInitPath: \""
(assoc-ref inputs "tini") (search-input-file inputs "/bin/tini-static")
"/bin/tini-static\""))) "\"")))
(substitute* "vendor/github.com/moby/buildkit/executor/runcexecutor/executor.go" (substitute* "vendor/github.com/moby/buildkit/executor/runcexecutor/executor.go"
(("var defaultCommandCandidates = .*") (("var defaultCommandCandidates = .*")
(string-append "var defaultCommandCandidates = []string{\"" (string-append "var defaultCommandCandidates = []string{\""
(assoc-ref inputs "runc") "/sbin/runc\"}"))) (search-input-file inputs "/sbin/runc") "\"}")))
(substitute* "vendor/github.com/docker/libnetwork/portmapper/proxy.go" (substitute* "vendor/github.com/docker/libnetwork/portmapper/proxy.go"
(("var userlandProxyCommandName = .*") (("var userlandProxyCommandName = .*")
(string-append "var userlandProxyCommandName = \"" (string-append "var userlandProxyCommandName = \""
(assoc-ref inputs "docker-proxy") (search-input-file inputs "/bin/proxy")
"/bin/proxy\"\n"))) "\"\n")))
(substitute* "pkg/archive/archive.go" (substitute* "pkg/archive/archive.go"
(("string\\{\"xz") (("string\\{\"xz")
(string-append "string{\"" (assoc-ref inputs "xz") "/bin/xz"))) (string-append "string{\"" (search-input-file inputs "/bin/xz"))))
(let ((source-files (filter (lambda (name) (let ((source-files (filter (lambda (name)
(not (string-contains name "test"))) (not (string-contains name "test")))
(find-files "." "\\.go$")))) (find-files "." "\\.go$"))))
(let-syntax ((substitute-LookPath* (let-syntax ((substitute-LookPath*
(syntax-rules () (syntax-rules ()
((_ (source-text package relative-path) ...) ((_ (source-text path) ...)
(substitute* source-files (substitute* source-files
(((string-append "\\<exec\\.LookPath\\(\"" (((string-append "\\<exec\\.LookPath\\(\""
source-text source-text
"\")")) "\")"))
(string-append "\"" (string-append "\""
(assoc-ref inputs package) (search-input-file inputs path)
"/" relative-path "\", error(nil)")) ...))))
"\", error(nil)")) ...)))) (substitute-Command*
(substitute-Command* (syntax-rules ()
(syntax-rules () ((_ (source-text path) ...)
((_ (source-text package relative-path) ...) (substitute* source-files
(substitute* source-files (((string-append "\\<(re)?exec\\.Command\\(\""
(((string-append "\\<(re)?exec\\.Command\\(\"" source-text
source-text "\"") _ re?)
"\"") _ re?) (string-append (if re? re? "")
(string-append (if re? re? "") "exec.Command(\""
"exec.Command(\"" (search-input-file inputs path)
(assoc-ref inputs package) "\"")) ...)))))
"/" relative-path (substitute-LookPath*
"\"")) ...))))) ("containerd" "/bin/containerd")
(substitute-LookPath* ("ps" "/bin/ps")
("containerd" "containerd" "bin/containerd") ("mkfs.xfs" "/sbin/mkfs.xfs")
("ps" "procps" "bin/ps") ("lvmdiskscan" "/sbin/lvmdiskscan")
("mkfs.xfs" "xfsprogs" "sbin/mkfs.xfs") ("pvdisplay" "/sbin/pvdisplay")
("lvmdiskscan" "lvm2" "sbin/lvmdiskscan") ("blkid" "/sbin/blkid")
("pvdisplay" "lvm2" "sbin/pvdisplay") ("unpigz" "/bin/unpigz")
("blkid" "util-linux" "sbin/blkid") ("iptables" "/sbin/iptables")
("unpigz" "pigz" "bin/unpigz") ("ip6tables" "/sbin/ip6tables")
("iptables" "iptables" "sbin/iptables") ("iptables-legacy" "/sbin/iptables")
("ip6tables" "iptables" "sbin/ip6tables") ("ip" "/sbin/ip"))
("iptables-legacy" "iptables" "sbin/iptables")
("ip" "iproute2" "sbin/ip"))
(substitute-Command* (substitute-Command*
("modprobe" "kmod" "bin/modprobe") ("modprobe" "/bin/modprobe")
("pvcreate" "lvm2" "sbin/pvcreate") ("pvcreate" "/sbin/pvcreate")
("vgcreate" "lvm2" "sbin/vgcreate") ("vgcreate" "/sbin/vgcreate")
("lvcreate" "lvm2" "sbin/lvcreate") ("lvcreate" "/sbin/lvcreate")
("lvconvert" "lvm2" "sbin/lvconvert") ("lvconvert" "/sbin/lvconvert")
("lvchange" "lvm2" "sbin/lvchange") ("lvchange" "/sbin/lvchange")
("mkfs.xfs" "xfsprogs" "sbin/mkfs.xfs") ("mkfs.xfs" "/sbin/mkfs.xfs")
("xfs_growfs" "xfsprogs" "sbin/xfs_growfs") ("xfs_growfs" "/sbin/xfs_growfs")
("mkfs.ext4" "e2fsprogs" "sbin/mkfs.ext4") ("mkfs.ext4" "/sbin/mkfs.ext4")
("tune2fs" "e2fsprogs" "sbin/tune2fs") ("tune2fs" "/sbin/tune2fs")
("blkid" "util-linux" "sbin/blkid") ("blkid" "/sbin/blkid")
("resize2fs" "e2fsprogs" "sbin/resize2fs") ("resize2fs" "/sbin/resize2fs")
("ps" "procps" "bin/ps") ("ps" "/bin/ps")
("losetup" "util-linux" "sbin/losetup") ("losetup" "/sbin/losetup")
("uname" "coreutils" "bin/uname") ("uname" "/bin/uname")
("dbus-launch" "dbus" "bin/dbus-launch") ("dbus-launch" "/bin/dbus-launch")
("git" "git" "bin/git"))) ("git" "/bin/git")))
;; docker-mountfrom ?? ;; docker-mountfrom ??
;; docker ;; docker
;; docker-untar ?? ;; docker-untar ??
;; docker-applyLayer ?? ;; docker-applyLayer ??
;; /usr/bin/uname ;; /usr/bin/uname
;; grep ;; grep
;; apparmor_parser ;; apparmor_parser
;; Make compilation fail when, in future versions, Docker ;; Make compilation fail when, in future versions, Docker
;; invokes other programs we don't know about and thus don't ;; invokes other programs we don't know about and thus don't
;; substitute. ;; substitute.
(substitute* source-files (substitute* source-files
;; Search for Java in PATH. ;; Search for Java in PATH.
(("\\<exec\\.Command\\(\"java\"") (("\\<exec\\.Command\\(\"java\"")
"xxec.Command(\"java\"") "xxec.Command(\"java\"")
;; Search for AUFS in PATH (mainline Linux doesn't support it). ;; Search for AUFS in PATH (mainline Linux doesn't support it).
(("\\<exec\\.Command\\(\"auplink\"") (("\\<exec\\.Command\\(\"auplink\"")
"xxec.Command(\"auplink\"") "xxec.Command(\"auplink\"")
;; Fail on other unsubstituted commands. ;; Fail on other unsubstituted commands.
(("\\<exec\\.Command\\(\"([a-zA-Z0-9][a-zA-Z0-9_-]*)\"" (("\\<exec\\.Command\\(\"([a-zA-Z0-9][a-zA-Z0-9_-]*)\""
_ executable) _ executable)
(string-append "exec.Guix_doesnt_want_Command(\"" (string-append "exec.Guix_doesnt_want_Command(\""
executable "\"")) executable "\""))
(("\\<xxec\\.Command") (("\\<xxec\\.Command")
"exec.Command") "exec.Command")
;; Search for ZFS in PATH. ;; Search for ZFS in PATH.
(("\\<LookPath\\(\"zfs\"\\)") "LooxPath(\"zfs\")") (("\\<LookPath\\(\"zfs\"\\)") "LooxPath(\"zfs\")")
;; Do not fail when buildkit-qemu-<target> isn't found. ;; Do not fail when buildkit-qemu-<target> isn't found.
;; FIXME: We might need to package buildkit and docker's ;; FIXME: We might need to package buildkit and docker's
;; buildx plugin, to support qemu-based docker containers. ;; buildx plugin, to support qemu-based docker containers.
(("\\<LookPath\\(\"buildkit-qemu-\"") "LooxPath(\"buildkit-qemu-\"") (("\\<LookPath\\(\"buildkit-qemu-\"") "LooxPath(\"buildkit-qemu-\"")
;; Fail on other unsubstituted LookPaths. ;; Fail on other unsubstituted LookPaths.
(("\\<LookPath\\(\"") "Guix_doesnt_want_LookPath\\(\"") (("\\<LookPath\\(\"") "Guix_doesnt_want_LookPath\\(\"")
(("\\<LooxPath") "LookPath"))))) (("\\<LooxPath") "LookPath")))))
(add-after 'patch-paths 'delete-failing-tests (add-after 'patch-paths 'delete-failing-tests
(lambda _ (lambda _
;; Needs internet access. ;; Needs internet access.
(delete-file "builder/remotecontext/git/gitutils_test.go") (delete-file "builder/remotecontext/git/gitutils_test.go")
;; Permission denied. ;; Permission denied.
(delete-file "daemon/graphdriver/devmapper/devmapper_test.go") (delete-file "daemon/graphdriver/devmapper/devmapper_test.go")
;; Operation not permitted (idtools.MkdirAllAndChown). ;; Operation not permitted (idtools.MkdirAllAndChown).
(delete-file "daemon/graphdriver/vfs/vfs_test.go") (delete-file "daemon/graphdriver/vfs/vfs_test.go")
;; Timeouts after 5 min. ;; Timeouts after 5 min.
(delete-file "plugin/manager_linux_test.go") (delete-file "plugin/manager_linux_test.go")
;; Operation not permitted. ;; Operation not permitted.
(delete-file "daemon/graphdriver/aufs/aufs_test.go") (delete-file "daemon/graphdriver/aufs/aufs_test.go")
(delete-file "daemon/graphdriver/btrfs/btrfs_test.go") (delete-file "daemon/graphdriver/btrfs/btrfs_test.go")
(delete-file "daemon/graphdriver/overlay/overlay_test.go") (delete-file "daemon/graphdriver/overlay/overlay_test.go")
(delete-file "daemon/graphdriver/overlay2/overlay_test.go") (delete-file "daemon/graphdriver/overlay2/overlay_test.go")
(delete-file "pkg/chrootarchive/archive_unix_test.go") (delete-file "pkg/chrootarchive/archive_unix_test.go")
(delete-file "daemon/container_unix_test.go") (delete-file "daemon/container_unix_test.go")
;; This file uses cgroups and /proc. ;; This file uses cgroups and /proc.
(delete-file "pkg/sysinfo/sysinfo_linux_test.go") (delete-file "pkg/sysinfo/sysinfo_linux_test.go")
;; This file uses cgroups. ;; This file uses cgroups.
(delete-file "runconfig/config_test.go") (delete-file "runconfig/config_test.go")
;; This file uses /var. ;; This file uses /var.
(delete-file "daemon/oci_linux_test.go") (delete-file "daemon/oci_linux_test.go")
;; Signal tests fail in bizarre ways ;; Signal tests fail in bizarre ways
(delete-file "pkg/signal/signal_linux_test.go"))) (delete-file "pkg/signal/signal_linux_test.go")))
(replace 'configure (replace 'configure
(lambda _ (lambda _
(setenv "DOCKER_BUILDTAGS" "seccomp") (setenv "DOCKER_BUILDTAGS" "seccomp")
(setenv "DOCKER_GITCOMMIT" (string-append "v" ,%docker-version)) (setenv "DOCKER_GITCOMMIT" (string-append "v" #$%docker-version))
(setenv "VERSION" (string-append ,%docker-version "-ce")) (setenv "VERSION" (string-append #$%docker-version "-ce"))
;; Automatically use bundled dependencies. ;; Automatically use bundled dependencies.
;; TODO: Unbundle - see file "vendor.conf". ;; TODO: Unbundle - see file "vendor.conf".
(setenv "AUTO_GOPATH" "1") (setenv "AUTO_GOPATH" "1")
;; Respectively, strip the symbol table and debug ;; Respectively, strip the symbol table and debug
;; information, and the DWARF symbol table. ;; information, and the DWARF symbol table.
(setenv "LDFLAGS" "-s -w") (setenv "LDFLAGS" "-s -w")
;; Make build faster ;; Make build faster
(setenv "GOCACHE" "/tmp"))) (setenv "GOCACHE" "/tmp")))
(add-before 'build 'setup-go-environment (add-before 'build 'setup-go-environment
(assoc-ref go:%standard-phases 'setup-go-environment)) (assoc-ref go:%standard-phases 'setup-go-environment))
(replace 'build (replace 'build
(lambda _ (lambda _
;; Our LD doesn't like the statically linked relocatable things ;; Our LD doesn't like the statically linked relocatable things
;; that go produces, so install the dynamic version of ;; that go produces, so install the dynamic version of
;; dockerd instead. ;; dockerd instead.
(invoke "hack/make.sh" "dynbinary"))) (invoke "hack/make.sh" "dynbinary")))
(replace 'check (replace 'check
(lambda _ (lambda _
;; The build process generated a file because the environment ;; The build process generated a file because the environment
;; variable "AUTO_GOPATH" was set. Use it. ;; variable "AUTO_GOPATH" was set. Use it.
(setenv "GOPATH" (string-append (getcwd) "/.gopath")) (setenv "GOPATH" (string-append (getcwd) "/.gopath"))
;; ".gopath/src/github.com/docker/docker" is a link to the current ;; ".gopath/src/github.com/docker/docker" is a link to the current
;; directory and chdir would canonicalize to that. ;; directory and chdir would canonicalize to that.
;; But go needs to have the uncanonicalized directory name, so ;; But go needs to have the uncanonicalized directory name, so
;; store that. ;; store that.
(setenv "PWD" (string-append (getcwd) (setenv "PWD" (string-append (getcwd)
"/.gopath/src/github.com/docker/docker")) "/.gopath/src/github.com/docker/docker"))
(with-directory-excursion ".gopath/src/github.com/docker/docker" (with-directory-excursion ".gopath/src/github.com/docker/docker"
(invoke "hack/test/unit")) (invoke "hack/test/unit"))
(setenv "PWD" #f))) (setenv "PWD" #f)))
(replace 'install (replace 'install
(lambda* (#:key outputs #:allow-other-keys) (lambda* (#:key outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out")) (let* ((out (assoc-ref outputs "out"))
(out-bin (string-append out "/bin"))) (out-bin (string-append out "/bin")))
(install-file "bundles/dynbinary-daemon/dockerd" out-bin) (install-file "bundles/dynbinary-daemon/dockerd" out-bin)
(install-file (string-append "bundles/dynbinary-daemon/dockerd-" (install-file (string-append "bundles/dynbinary-daemon/dockerd-"
(getenv "VERSION")) (getenv "VERSION"))
out-bin)))) out-bin))))
(add-after 'install 'remove-go-references (add-after 'install 'remove-go-references
(assoc-ref go:%standard-phases 'remove-go-references))))) (assoc-ref go:%standard-phases 'remove-go-references)))))
(inputs (inputs
`(("btrfs-progs" ,btrfs-progs) (list btrfs-progs
("containerd" ,containerd) ; for containerd-shim containerd ; for containerd-shim
("coreutils" ,coreutils) coreutils
("dbus" ,dbus) dbus
("docker-proxy" ,docker-libnetwork-cmd-proxy) docker-libnetwork-cmd-proxy
("e2fsprogs" ,e2fsprogs) e2fsprogs
("git" ,git) git
("iproute2" ,iproute) iproute
("iptables" ,iptables) iptables
("kmod" ,kmod) kmod
("libseccomp" ,libseccomp) libseccomp
("pigz" ,pigz) pigz
("procps" ,procps) procps
("runc" ,runc) runc
("util-linux" ,util-linux) util-linux
("lvm2" ,lvm2) lvm2
("tini" ,tini) tini
("xfsprogs" ,xfsprogs) xfsprogs
("xz" ,xz))) xz))
(native-inputs (native-inputs
(list eudev ; TODO: Should be propagated by lvm2 (.pc -> .pc) (list eudev ; TODO: Should be propagated by lvm2 (.pc -> .pc)
go gotestsum pkg-config)) go gotestsum pkg-config))