docker: unify common parts of docker-ce and docker-moby recipes

Now that docker-ce is being built from the same repos as docker-moby,
the only unique things in the recipes are the SRCREVs.

We move the common packaging, compile/install routines and configuration
to the .inc files.

We also move the patches to the generic 'files' directory, so they
can be shared.

If we there are SRCREV bumps in the future that diverge moby and
docker, we'll hold patches in their named directorys and tweak
the compile/install routines as necessary.

Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
This commit is contained in:
Bruce Ashfield 2021-04-29 17:09:31 -04:00
parent cd5eead051
commit 9d98a04b26
11 changed files with 95 additions and 349 deletions

View File

@ -1,26 +0,0 @@
From 45d03c7b04353d2e5955e573bc1063fcb0647a0c Mon Sep 17 00:00:00 2001
From: Bruce Ashfield <bruce.ashfield@gmail.com>
Date: Thu, 15 Apr 2021 16:30:37 -0400
Subject: [PATCH] build: use build script without docker
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
---
git/src/import/components/cli/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git git/src/import/components/cli/Makefile git/src/import/components/cli/Makefile
index 9e62210c33..9c7631f674 100644
--- git/src/import/components/cli/Makefile
+++ git/src/import/components/cli/Makefile
@@ -51,7 +51,7 @@ plugins-osx: ## build example CLI plugins for macOS
.PHONY: dynbinary
dynbinary: ## build dynamically linked binary
- USE_GLIBC=1 docker buildx bake dynbinary
+ GO_LINKMODE=dynamic ./scripts/build/binary
vendor: vendor.conf ## check that vendor matches vendor.conf
rm -rf vendor
--
2.19.1

View File

@ -1,25 +0,0 @@
From ae6f4a1e685394fb7b9539f134b66ca84ddc91c2 Mon Sep 17 00:00:00 2001
From: Bruce Ashfield <bruce.ashfield@gmail.com>
Date: Tue, 30 Jun 2020 22:19:56 -0400
Subject: [PATCH] cli: use go cross compiler
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
---
git/cli/scripts/build/dynbinary | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git git/src/import/components/cli/scripts/build/dynbinary git/src/import/components/cli/scripts/build/dynbinary
index 4feb7e71d8..f990d0e040 100755
--- git/src/import/components/cli/scripts/build/dynbinary
+++ git/src/import/components/cli/scripts/build/dynbinary
@@ -9,6 +9,6 @@ source ./scripts/build/.variables
echo "Building dynamically linked $TARGET"
export CGO_ENABLED=1
-go build -o "${TARGET}" -tags pkcs11 --ldflags "${LDFLAGS}" -buildmode=pie "${SOURCE}"
+${GO} build -o "${TARGET}" -tags pkcs11 --ldflags "${LDFLAGS}" -buildmode=pie "${SOURCE}"
ln -sf "$(basename "${TARGET}")" build/docker
--
2.19.1

View File

@ -50,100 +50,5 @@ require docker.inc
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://src/import/LICENSE;md5=4859e97a9c7780e77972d989f0823f28"
GO_IMPORT = "import"
S = "${WORKDIR}/git"
DOCKER_VERSION = "20.10.6-ce"
PV = "${DOCKER_VERSION}+git${SRCREV_docker}"
PACKAGES =+ "${PN}-contrib"
DOCKER_PKG="github.com/docker/docker"
# in order to exclude devicemapper and btrfs - https://github.com/docker/docker/issues/14056
BUILD_TAGS = "exclude_graphdriver_btrfs exclude_graphdriver_devicemapper"
inherit go
inherit goarch
inherit pkgconfig
do_configure[noexec] = "1"
do_compile() {
# Set GOPATH. See 'PACKAGERS.md'. Don't rely on
# docker to download its dependencies but rather
# use dependencies packaged independently.
cd ${S}/src/import
rm -rf .gopath
mkdir -p .gopath/src/"$(dirname "${DOCKER_PKG}")"
ln -sf ../../../.. .gopath/src/"${DOCKER_PKG}"
ln -sf ${WORKDIR}/git/libnetwork .gopath/src/github.com/docker/libnetwork
ln -sf ${WORKDIR}/git/cli .gopath/src/github.com/docker/cli
export GOPATH="${S}/src/import/.gopath:${S}/src/import/vendor:${STAGING_DIR_TARGET}/${prefix}/local/go"
export GOROOT="${STAGING_DIR_NATIVE}/${nonarch_libdir}/${HOST_SYS}/go"
# Pass the needed cflags/ldflags so that cgo
# can find the needed headers files and libraries
export GOARCH=${TARGET_GOARCH}
export CGO_ENABLED="1"
export CGO_CFLAGS="${CFLAGS} --sysroot=${STAGING_DIR_TARGET}"
export CGO_LDFLAGS="${LDFLAGS} --sysroot=${STAGING_DIR_TARGET}"
export DOCKER_BUILDTAGS='${BUILD_TAGS} ${PACKAGECONFIG_CONFARGS}'
export DISABLE_WARN_OUTSIDE_CONTAINER=1
export GO111MODULE=off
cd ${S}/src/import/
# this is the unsupported build structure that doesn't rely on an
# existing docker to build this:
VERSION="${DOCKER_VERSION}" DOCKER_GITCOMMIT="${SRCREV_docker}" ./hack/make.sh dynbinary
# build the proxy
cd ${S}/src/import
ln -sf ${WORKDIR}/git/libnetwork .gopath/src/github.com/docker/libnetwork
cd ${S}/src/import/.gopath/src/github.com/docker/libnetwork
oe_runmake cross-local
# build the cli
cd ${S}/src/import/.gopath/src/github.com/docker/cli
export CFLAGS=""
export LDFLAGS=""
export DOCKER_VERSION=${DOCKER_VERSION}
VERSION="${DOCKER_VERSION}" DOCKER_GITCOMMIT="${SRCREV_docker}" make dynbinary
}
do_install() {
mkdir -p ${D}/${bindir}
cp ${WORKDIR}/git/cli/build/docker ${D}/${bindir}/docker
cp ${S}/src/import/bundles/dynbinary-daemon/dockerd ${D}/${bindir}/dockerd
cp ${WORKDIR}/git/libnetwork/bin/docker-proxy* ${D}/${bindir}/docker-proxy
if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
install -d ${D}${systemd_unitdir}/system
install -m 644 ${S}/src/import/contrib/init/systemd/docker.* ${D}/${systemd_unitdir}/system
# replaces one copied from above with one that uses the local registry for a mirror
install -m 644 ${S}/src/import/contrib/init/systemd/docker.service ${D}/${systemd_unitdir}/system
rm -f ${D}/${systemd_unitdir}/system/docker.service.rpm
else
install -d ${D}${sysconfdir}/init.d
install -m 0755 ${WORKDIR}/docker.init ${D}${sysconfdir}/init.d/docker.init
fi
# TLS key that docker creates at run-time if not found is what resides here
if ${@bb.utils.contains('PACKAGECONFIG','transient-config','true','false',d)}; then
install -d ${D}${sysconfdir}
ln -s ..${localstatedir}/run/docker ${D}${sysconfdir}/docker
else
install -d ${D}${sysconfdir}/docker
fi
mkdir -p ${D}${datadir}/docker/
install -m 0755 ${S}/src/import/contrib/check-config.sh ${D}${datadir}/docker/
}
FILES_${PN} += "${systemd_unitdir}/system/* ${sysconfdir}/docker"
FILES_${PN}-contrib += "${datadir}/docker/check-config.sh"
RDEPENDS_${PN}-contrib += "bash"

View File

@ -1,27 +0,0 @@
From 650c882d3c53db118b01dd5e15fa1bc0ddaa36f1 Mon Sep 17 00:00:00 2001
From: Bruce Ashfield <bruce.ashfield@gmail.com>
Date: Thu, 15 Apr 2021 11:28:05 -0400
Subject: [PATCH] cli: use external GO111MODULE and cross compiler
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
---
git/cli/scripts/build/binary | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git git/cli/scripts/build/binary git/cli/scripts/build/binary
index e4c5e12a6b..7c47b75c2f 100755
--- git/cli/scripts/build/binary
+++ git/cli/scripts/build/binary
@@ -73,8 +73,7 @@ fi
echo "Building $GO_LINKMODE $(basename "${TARGET}")"
-export GO111MODULE=auto
-go build -o "${TARGET}" -tags "${GO_BUILDTAGS}" --ldflags "${LDFLAGS}" ${GO_BUILDMODE} "${SOURCE}"
+${GO} build -o "${TARGET}" -tags "${GO_BUILDTAGS}" --ldflags "${LDFLAGS}" ${GO_BUILDMODE} "${SOURCE}"
ln -sf "$(basename "${TARGET}")" "$(dirname "${TARGET}")/docker"
--
2.19.1

View File

@ -1,23 +0,0 @@
From bbf600cc4d46c3f7ec0c1b486790a2402d41f550 Mon Sep 17 00:00:00 2001
From: Bruce Ashfield <bruce.ashfield@gmail.com>
Date: Tue, 30 Jun 2020 22:23:33 -0400
Subject: [PATCH] dynbinary: use go cross compiler
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
---
hack/make/.binary | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: git/src/import/hack/make/.binary
===================================================================
--- git.orig/src/import/hack/make/.binary
+++ git/src/import/hack/make/.binary
@@ -81,7 +81,7 @@
echo "Building: $DEST/$BINARY_FULLNAME"
echo "GOOS=\"${GOOS}\" GOARCH=\"${GOARCH}\" GOARM=\"${GOARM}\""
- go build \
+ ${GO} build \
-o "$DEST/$BINARY_FULLNAME" \
"${BUILDFLAGS[@]}" \
-ldflags "

View File

@ -1,59 +0,0 @@
From 04c07804930faad708218a3134c81de06a9c742a Mon Sep 17 00:00:00 2001
From: Bruce Ashfield <bruce.ashfield@windriver.com>
Date: Fri, 6 Apr 2018 23:58:22 -0400
Subject: [PATCH] libnetwork: use $(GO) instead of go
Ensure that the libnetwork makefile uses the go cross flags and
utilities.
Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
---
Makefile | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
Index: git/libnetwork/Makefile
===================================================================
--- git.orig/libnetwork/Makefile
+++ git/libnetwork/Makefile
@@ -45,9 +45,9 @@
build-local:
@echo "🐳 $@"
@mkdir -p "bin"
- go build -tags experimental -o "bin/dnet" ./cmd/dnet
- go build -o "bin/docker-proxy" ./cmd/proxy
- CGO_ENABLED=0 go build -o "bin/diagnosticClient" ./cmd/diagnostic
+ $(GO) build -tags experimental -o "bin/dnet" ./cmd/dnet
+ $(GO) build -o "bin/proxy" ./cmd/proxy
+ CGO_ENABLED=0 $(GO) build -o "bin/diagnosticClient" ./cmd/diagnostic
CGO_ENABLED=0 go build -o "bin/testMain" ./cmd/networkdb-test/testMain.go
build-images:
@@ -82,8 +82,8 @@
cross-local:
@echo "🐳 $@"
- go build -o "bin/dnet-$$GOOS-$$GOARCH" ./cmd/dnet
- go build -o "bin/docker-proxy-$$GOOS-$$GOARCH" ./cmd/proxy
+ @$(GO) build -linkshared $(GOBUILDFLAGS) -o "bin/docker-proxy-$$GOOS-$$GOARCH" ./cmd/proxy
+ @$(GO) build -linkshared $(GOBUILDFLAGS) -o "bin/dnet-$$GOOS-$$GOARCH" ./cmd/dnet
# Rebuild protocol buffers.
# These may need to be rebuilt after vendoring updates, so .proto files are declared .PHONY so they are always rebuilt.
@@ -130,7 +130,7 @@
if ls $$dir/*.go &> /dev/null; then \
pushd . &> /dev/null ; \
cd $$dir ; \
- go test ${INSIDECONTAINER} -test.parallel 5 -test.v -covermode=count -coverprofile=./profile.tmp ; \
+ $(GO) test ${INSIDECONTAINER} -test.parallel 5 -test.v -covermode=count -coverprofile=./profile.tmp ; \
ret=$$? ;\
if [ $$ret -ne 0 ]; then exit $$ret; fi ;\
popd &> /dev/null; \
@@ -145,7 +145,7 @@
# Depends on binaries because vet will silently fail if it can not load compiled imports
vet: ## run go vet
@echo "🐳 $@"
- @test -z "$$(go vet ${PACKAGES} 2>&1 | grep -v 'constant [0-9]* not a string in call to Errorf' | egrep -v '(timestamp_test.go|duration_test.go|exit status 1)' | tee /dev/stderr)"
+ @test -z "$$($(GO) vet ${PACKAGES} 2>&1 | grep -v 'constant [0-9]* not a string in call to Errorf' | egrep -v '(timestamp_test.go|duration_test.go|exit status 1)' | tee /dev/stderr)"
misspell:
@echo "🐳 $@"

View File

@ -34,7 +34,6 @@ DESCRIPTION = "Linux container runtime \
# - The common components of this recipe and docker-ce do need to be moved
# to a docker.inc recipe
# moby commit matches the docker-engine bump on the 19.03 branch'
SRCREV_moby = "ce826938232fbee567c8805460a8b2c82dc2e493"
SRCREV_libnetwork = "b3507428be5b458cb0e2b4086b13531fb0706e46"
SRCREV_cli = "370c28948e3c12dce3d1df60b6f184990618553f"
@ -54,99 +53,6 @@ require docker.inc
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://src/import/LICENSE;md5=4859e97a9c7780e77972d989f0823f28"
GO_IMPORT = "import"
S = "${WORKDIR}/git"
DOCKER_VERSION = "20.10.6"
PV = "${DOCKER_VERSION}+git${SRCREV_moby}"
PACKAGES =+ "${PN}-contrib"
DOCKER_PKG="github.com/docker/docker"
# in order to exclude devicemapper and btrfs - https://github.com/docker/docker/issues/14056
BUILD_TAGS = "exclude_graphdriver_btrfs exclude_graphdriver_devicemapper"
inherit go
inherit goarch
do_configure[noexec] = "1"
do_compile() {
# Set GOPATH. See 'PACKAGERS.md'. Don't rely on
# docker to download its dependencies but rather
# use dependencies packaged independently.
cd ${S}/src/import
rm -rf .gopath
mkdir -p .gopath/src/"$(dirname "${DOCKER_PKG}")"
ln -sf ../../../.. .gopath/src/"${DOCKER_PKG}"
mkdir -p .gopath/src/github.com/docker
ln -sf ${WORKDIR}/git/libnetwork .gopath/src/github.com/docker/libnetwork
ln -sf ${WORKDIR}/git/cli .gopath/src/github.com/docker/cli
export GOPATH="${S}/src/import/.gopath:${S}/src/import/vendor:${STAGING_DIR_TARGET}/${prefix}/local/go"
export GOROOT="${STAGING_DIR_NATIVE}/${nonarch_libdir}/${HOST_SYS}/go"
# Pass the needed cflags/ldflags so that cgo
# can find the needed headers files and libraries
export GOARCH=${TARGET_GOARCH}
export CGO_ENABLED="1"
export CGO_CFLAGS="${CFLAGS} --sysroot=${STAGING_DIR_TARGET}"
export CGO_LDFLAGS="${LDFLAGS} --sysroot=${STAGING_DIR_TARGET}"
export DOCKER_BUILDTAGS='${BUILD_TAGS} ${PACKAGECONFIG_CONFARGS}'
export GO111MODULE=off
export DISABLE_WARN_OUTSIDE_CONTAINER=1
cd ${S}/src/import/
# this is the unsupported built structure
# that doesn't rely on an existing docker
# to build this:
VERSION="${DOCKER_VERSION}" DOCKER_GITCOMMIT="${SRCREV_moby}" ./hack/make.sh dynbinary
# build the cli
cd ${S}/src/import/.gopath/src/github.com/docker/cli
export CFLAGS=""
export LDFLAGS=""
export DOCKER_VERSION=${DOCKER_VERSION}
VERSION="${DOCKER_VERSION}" DOCKER_GITCOMMIT="${SRCREV_moby}" make dynbinary
# build the proxy
cd ${S}/src/import/.gopath/src/github.com/docker/libnetwork
oe_runmake cross-local
}
do_install() {
mkdir -p ${D}/${bindir}
cp ${WORKDIR}/git/cli/build/docker ${D}/${bindir}/docker
cp ${S}/src/import/bundles/dynbinary-daemon/dockerd ${D}/${bindir}/dockerd
cp ${WORKDIR}/git/libnetwork/bin/docker-proxy* ${D}/${bindir}/docker-proxy
if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
install -d ${D}${systemd_unitdir}/system
install -m 644 ${S}/src/import/contrib/init/systemd/docker.* ${D}/${systemd_unitdir}/system
# replaces one copied from above with one that uses the local registry for a mirror
install -m 644 ${S}/src/import/contrib/init/systemd/docker.service ${D}/${systemd_unitdir}/system
rm -f ${D}/${systemd_unitdir}/system/docker.service.rpm
else
install -d ${D}${sysconfdir}/init.d
install -m 0755 ${WORKDIR}/docker.init ${D}${sysconfdir}/init.d/docker.init
fi
# TLS key that docker creates at run-time if not found is what resides here
if ${@bb.utils.contains('PACKAGECONFIG','transient-config','true','false',d)}; then
install -d ${D}${sysconfdir}
ln -s ..${localstatedir}/run/docker ${D}${sysconfdir}/docker
else
install -d ${D}${sysconfdir}/docker
fi
mkdir -p ${D}${datadir}/docker/
install -m 0755 ${S}/src/import/contrib/check-config.sh ${D}${datadir}/docker/
}
FILES_${PN} += "${systemd_unitdir}/system/* ${sysconfdir}/docker"
FILES_${PN}-contrib += "${datadir}/docker/check-config.sh"
RDEPENDS_${PN}-contrib += "bash"

View File

@ -46,7 +46,96 @@ PACKAGECONFIG[seccomp] = "seccomp,,libseccomp"
PACKAGECONFIG[docker-init] = ",,,docker-init"
PACKAGECONFIG[transient-config] = "transient-config"
GO_IMPORT = "import"
S = "${WORKDIR}/git"
inherit systemd update-rc.d
inherit go
inherit goarch
inherit pkgconfig
do_configure[noexec] = "1"
DOCKER_PKG="github.com/docker/docker"
# in order to exclude devicemapper and btrfs - https://github.com/docker/docker/issues/14056
BUILD_TAGS ?= "exclude_graphdriver_btrfs exclude_graphdriver_devicemapper"
do_compile() {
# Set GOPATH. See 'PACKAGERS.md'. Don't rely on
# docker to download its dependencies but rather
# use dependencies packaged independently.
cd ${S}/src/import
rm -rf .gopath
mkdir -p .gopath/src/"$(dirname "${DOCKER_PKG}")"
ln -sf ../../../.. .gopath/src/"${DOCKER_PKG}"
mkdir -p .gopath/src/github.com/docker
ln -sf ${WORKDIR}/git/libnetwork .gopath/src/github.com/docker/libnetwork
ln -sf ${WORKDIR}/git/cli .gopath/src/github.com/docker/cli
export GOPATH="${S}/src/import/.gopath:${S}/src/import/vendor:${STAGING_DIR_TARGET}/${prefix}/local/go"
export GOROOT="${STAGING_DIR_NATIVE}/${nonarch_libdir}/${HOST_SYS}/go"
# Pass the needed cflags/ldflags so that cgo
# can find the needed headers files and libraries
export GOARCH=${TARGET_GOARCH}
export CGO_ENABLED="1"
export CGO_CFLAGS="${CFLAGS} --sysroot=${STAGING_DIR_TARGET}"
export CGO_LDFLAGS="${LDFLAGS} --sysroot=${STAGING_DIR_TARGET}"
export DOCKER_BUILDTAGS='${BUILD_TAGS} ${PACKAGECONFIG_CONFARGS}'
export GO111MODULE=off
export DISABLE_WARN_OUTSIDE_CONTAINER=1
cd ${S}/src/import/
# this is the unsupported built structure
# that doesn't rely on an existing docker
# to build this:
VERSION="${DOCKER_VERSION}" DOCKER_GITCOMMIT="${SRCREV_moby}" ./hack/make.sh dynbinary
# build the cli
cd ${S}/src/import/.gopath/src/github.com/docker/cli
export CFLAGS=""
export LDFLAGS=""
export DOCKER_VERSION=${DOCKER_VERSION}
VERSION="${DOCKER_VERSION}" DOCKER_GITCOMMIT="${SRCREV_moby}" make dynbinary
# build the proxy
cd ${S}/src/import/.gopath/src/github.com/docker/libnetwork
oe_runmake cross-local
}
do_install() {
mkdir -p ${D}/${bindir}
cp ${WORKDIR}/git/cli/build/docker ${D}/${bindir}/docker
cp ${S}/src/import/bundles/dynbinary-daemon/dockerd ${D}/${bindir}/dockerd
cp ${WORKDIR}/git/libnetwork/bin/docker-proxy* ${D}/${bindir}/docker-proxy
if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
install -d ${D}${systemd_unitdir}/system
install -m 644 ${S}/src/import/contrib/init/systemd/docker.* ${D}/${systemd_unitdir}/system
# replaces one copied from above with one that uses the local registry for a mirror
install -m 644 ${S}/src/import/contrib/init/systemd/docker.service ${D}/${systemd_unitdir}/system
rm -f ${D}/${systemd_unitdir}/system/docker.service.rpm
else
install -d ${D}${sysconfdir}/init.d
install -m 0755 ${WORKDIR}/docker.init ${D}${sysconfdir}/init.d/docker.init
fi
# TLS key that docker creates at run-time if not found is what resides here
if ${@bb.utils.contains('PACKAGECONFIG','transient-config','true','false',d)}; then
install -d ${D}${sysconfdir}
ln -s ..${localstatedir}/run/docker ${D}${sysconfdir}/docker
else
install -d ${D}${sysconfdir}/docker
fi
mkdir -p ${D}${datadir}/docker/
install -m 0755 ${S}/src/import/contrib/check-config.sh ${D}${datadir}/docker/
}
SYSTEMD_PACKAGES = "${@bb.utils.contains('DISTRO_FEATURES','systemd','${PN}','',d)}"
SYSTEMD_SERVICE_${PN} = "${@bb.utils.contains('DISTRO_FEATURES','systemd','docker.socket','',d)}"
@ -63,3 +152,9 @@ GROUPADD_PARAM_${PN} = "-r docker"
COMPATIBLE_HOST = "^(?!(qemu)?mips).*"
INSANE_SKIP_${PN} += "ldflags textrel"
FILES_${PN} += "${systemd_unitdir}/system/* ${sysconfdir}/docker"
PACKAGES =+ "${PN}-contrib"
FILES_${PN}-contrib += "${datadir}/docker/check-config.sh"
RDEPENDS_${PN}-contrib += "bash"