From 37aa0a7cf4775b3935c6371977d4cf494726c201 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sun, 27 Mar 2022 17:05:58 +0200 Subject: [PATCH 1/3] add docker-buildx-plugin package (deb, rpm) Signed-off-by: CrazyMax --- Makefile | 12 ++++- common.mk | 2 + deb/Makefile | 11 ++++- deb/build-deb | 3 ++ deb/common/control | 11 ++++- deb/common/rules | 15 ++++++ ...dx.installer => buildx.installer.disabled} | 0 rpm/Makefile | 17 +++++-- rpm/SPECS/docker-buildx-plugin.spec | 46 +++++++++++++++++++ rpm/SPECS/docker-ce-cli.spec | 3 +- rpm/centos-7/Dockerfile | 1 + rpm/centos-8/Dockerfile | 1 + rpm/fedora-34/Dockerfile | 1 + rpm/fedora-35/Dockerfile | 1 + rpm/fedora-36/Dockerfile | 1 + rpm/rhel-7/Dockerfile | 1 + 16 files changed, 118 insertions(+), 8 deletions(-) rename plugins/{buildx.installer => buildx.installer.disabled} (100%) mode change 100755 => 100644 create mode 100644 rpm/SPECS/docker-buildx-plugin.spec diff --git a/Makefile b/Makefile index 1241a6de3d..3d77c151cd 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ clean-src: $(RM) -r src .PHONY: src -src: src/github.com/docker/cli src/github.com/docker/docker src/github.com/docker/compose src/github.com/docker/scan-cli-plugin ## clone source +src: src/github.com/docker/cli src/github.com/docker/docker src/github.com/docker/buildx src/github.com/docker/compose src/github.com/docker/scan-cli-plugin ## clone source ifdef CLI_DIR src/github.com/docker/cli: @@ -37,6 +37,10 @@ src/github.com/docker/docker: git -C $@ remote add origin "$(DOCKER_ENGINE_REPO)" endif +src/github.com/docker/buildx: + git init $@ + git -C $@ remote add origin "$(DOCKER_BUILDX_REPO)" + src/github.com/docker/compose: git init $@ git -C $@ remote add origin "$(DOCKER_COMPOSE_REPO)" @@ -54,6 +58,10 @@ checkout-cli: src/github.com/docker/cli checkout-docker: src/github.com/docker/docker ./scripts/checkout.sh src/github.com/docker/docker "$(DOCKER_ENGINE_REF)" +.PHONY: checkout-buildx +checkout-buildx: src/github.com/docker/buildx + ./scripts/checkout.sh src/github.com/docker/buildx "$(DOCKER_BUILDX_REF)" + .PHONY: checkout-compose checkout-compose: src/github.com/docker/compose ./scripts/checkout.sh src/github.com/docker/compose "$(DOCKER_COMPOSE_REF)" @@ -63,7 +71,7 @@ checkout-scan-cli-plugin: src/github.com/docker/scan-cli-plugin ./scripts/checkout.sh src/github.com/docker/scan-cli-plugin "$(DOCKER_SCAN_REF)" .PHONY: checkout -checkout: checkout-cli checkout-docker checkout-compose checkout-scan-cli-plugin ## checkout source at the given reference(s) +checkout: checkout-cli checkout-docker checkout-buildx checkout-compose checkout-scan-cli-plugin ## checkout source at the given reference(s) .PHONY: clean clean: clean-src ## remove build artifacts diff --git a/common.mk b/common.mk index 9c6b4fb56e..0fc909fd23 100644 --- a/common.mk +++ b/common.mk @@ -28,6 +28,7 @@ DOCKER_CLI_REPO ?= https://github.com/docker/cli.git DOCKER_ENGINE_REPO ?= https://github.com/docker/docker.git DOCKER_SCAN_REPO ?= https://github.com/docker/scan-cli-plugin.git DOCKER_COMPOSE_REPO ?= https://github.com/docker/compose.git +DOCKER_BUILDX_REPO ?= https://github.com/docker/buildx.git # REF can be used to specify the same branch or tag to use for *both* the CLI # and Engine source code. This can be useful if both the CLI and Engine have a @@ -40,6 +41,7 @@ DOCKER_CLI_REF ?= $(REF) DOCKER_ENGINE_REF ?= $(REF) DOCKER_SCAN_REF ?= v0.17.0 DOCKER_COMPOSE_REF ?= v2.3.4 +DOCKER_BUILDX_REF ?= v0.8.1 export BUILDTIME export DEFAULT_PRODUCT_LICENSE diff --git a/deb/Makefile b/deb/Makefile index 0f8e4c870c..d0091d5140 100644 --- a/deb/Makefile +++ b/deb/Makefile @@ -33,6 +33,7 @@ RUN?=docker run --rm \ -e VERSION=$(word 2, $(GEN_DEB_VER)) \ -e CLI_GITCOMMIT=$(CLI_GITCOMMIT) \ -e ENGINE_GITCOMMIT=$(ENGINE_GITCOMMIT) \ + -e BUILDX_VERSION=$(DOCKER_BUILDX_REF) \ -e COMPOSE_VERSION=$(DOCKER_COMPOSE_REF) \ -e SCAN_VERSION=$(DOCKER_SCAN_REF) \ -e SCAN_GITCOMMIT=$(SCAN_GITCOMMIT) \ @@ -78,7 +79,7 @@ $(DISTROS): sources $(CHOWN) -R $(shell id -u):$(shell id -g) "debbuild/$@" .PHONY: sources -sources: sources/cli.tgz sources/engine.tgz sources/compose.tgz sources/scan-cli-plugin.tgz sources/plugin-installers.tgz +sources: sources/cli.tgz sources/engine.tgz sources/buildx.tgz sources/compose.tgz sources/scan-cli-plugin.tgz sources/plugin-installers.tgz sources/engine.tgz: mkdir -p $(@D) @@ -96,6 +97,14 @@ sources/cli.tgz: alpine \ tar -C / -c -z -f /v/cli.tgz --exclude .git cli +sources/buildx.tgz: + mkdir -p $(@D) + docker run --rm -w /v \ + -v $(realpath $(CURDIR)/../src/github.com/docker/buildx):/buildx \ + -v $(CURDIR)/$(@D):/v \ + alpine \ + tar -C / -c -z -f /v/buildx.tgz --exclude .git buildx + sources/compose.tgz: mkdir -p $(@D) docker run --rm -w /v \ diff --git a/deb/build-deb b/deb/build-deb index 21eec2baf3..a67475a097 100755 --- a/deb/build-deb +++ b/deb/build-deb @@ -7,6 +7,8 @@ mkdir -p /root/build-deb/engine tar -C /root/build-deb -xzf /sources/engine.tgz mkdir -p /root/build-deb/cli tar -C /root/build-deb -xzf /sources/cli.tgz +mkdir -p /root/build-deb/buildx +tar -C /root/build-deb -xzf /sources/buildx.tgz mkdir -p /root/build-deb/compose tar -C /root/build-deb -xzf /sources/compose.tgz mkdir -p /root/build-deb/scan-cli-plugin @@ -16,6 +18,7 @@ tar -C /root/build-deb -xzf /sources/scan-cli-plugin.tgz mkdir -p /go/src/github.com/docker ln -snf /root/build-deb/engine /go/src/github.com/docker/docker ln -snf /root/build-deb/cli /go/src/github.com/docker/cli +ln -snf /root/build-deb/buildx /go/src/github.com/docker/buildx ln -snf /root/build-deb/compose /go/src/github.com/docker/compose ln -snf /root/build-deb/scan-cli-plugin /go/src/github.com/docker/scan-cli-plugin diff --git a/deb/common/control b/deb/common/control index c74791decf..8b6ce4a28f 100644 --- a/deb/common/control +++ b/deb/common/control @@ -63,7 +63,8 @@ Package: docker-ce-cli Architecture: linux-any Depends: ${shlibs:Depends} # TODO change once we support scan-plugin on other architectures -Recommends: docker-compose-plugin, +Recommends: docker-buildx-plugin, + docker-compose-plugin, docker-scan-plugin [amd64] Conflicts: docker (<< 1.5~), docker-engine, @@ -103,6 +104,14 @@ Description: Rootless support for Docker. Either VPNKit or slirp4netns (>= 0.4.0) needs to be installed separately. Homepage: https://docs.docker.com/engine/security/rootless/ +Package: docker-buildx-plugin +Priority: optional +Replaces: docker-ce-cli +Architecture: linux-any +Enhances: docker-ce-cli +Description: Docker Buildx cli plugin. +Homepage: https://github.com/docker/buildx + Package: docker-compose-plugin Priority: optional Architecture: linux-any diff --git a/deb/common/rules b/deb/common/rules index aadd3b8de7..208165a946 100755 --- a/deb/common/rules +++ b/deb/common/rules @@ -16,6 +16,11 @@ override_dh_auto_build: # Build the CLI cd /go/src/github.com/docker/cli && VERSION=$(VERSION) GITCOMMIT=$(CLI_GITCOMMIT) LDFLAGS='' GO_LINKMODE=dynamic ./scripts/build/binary && DISABLE_WARN_OUTSIDE_CONTAINER=1 LDFLAGS='' make manpages + # Build buildx plugin + cd /go/src/github.com/docker/buildx \ + && mkdir -p /usr/libexec/docker/cli-plugins/ \ + && CGO_ENABLED=0 GO111MODULE=on go build -mod=vendor -o /usr/libexec/docker/cli-plugins/docker-buildx -ldflags "-X github.com/docker/buildx/version.Version=$(BUILDX_VERSION) -X github.com/docker/buildx/version.Revision=$(git rev-parse HEAD) -X github.com/docker/buildx/version.Package=github.com/docker/buildx" ./cmd/buildx + # Build the compose plugin # FIXME: using GOPROXY, to work around: # go: github.com/Azure/azure-sdk-for-go@v48.2.0+incompatible: reading github.com/Azure/azure-sdk-for-go/go.mod at revision v48.2.0: unknown revision v48.2.0 @@ -49,6 +54,9 @@ override_dh_auto_test: ver="$$(cli/build/docker --version)"; \ test "$$ver" = "Docker version $(VERSION), build $(CLI_GITCOMMIT)" && echo "PASS: cli version OK" || (echo "FAIL: cli version ($$ver) did not match" && exit 1) + ver="$$(/usr/libexec/docker/cli-plugins/docker-buildx docker-cli-plugin-metadata | awk '{ gsub(/[",:]/,"")}; $$1 == "Version" { print $$2 }')"; \ + test "$$ver" = "$(BUILDX_VERSION)" && echo "PASS: docker-buildx version OK" || (echo "FAIL: docker-buildx version ($$ver) did not match" && exit 1) + ver="$$(/usr/libexec/docker/cli-plugins/docker-compose docker-cli-plugin-metadata | awk '{ gsub(/[",:]/,"")}; $$1 == "Version" { print $$2 }')"; \ test "$$ver" = "$(COMPOSE_VERSION)" && echo "PASS: docker-compose version OK" || (echo "FAIL: docker-compose version ($$ver) did not match" && exit 1) @@ -81,6 +89,9 @@ override_dh_auto_install: install -D -m 0755 $(shell readlink -e engine/bundles/dynbinary-daemon/docker-proxy) debian/docker-ce/usr/bin/docker-proxy install -D -m 0755 /usr/local/bin/docker-init debian/docker-ce/usr/bin/docker-init + # docker-buildx-plugin install + install -D -m 0755 /usr/libexec/docker/cli-plugins/docker-buildx debian/docker-buildx-plugin/usr/libexec/docker/cli-plugins/docker-buildx + # docker-compose-plugin install install -D -m 0755 /usr/libexec/docker/cli-plugins/docker-compose debian/docker-compose-plugin/usr/libexec/docker/cli-plugins/docker-compose @@ -110,6 +121,10 @@ override_dh_install: dh_apparmor --profile-name=docker-ce -pdocker-ce override_dh_gencontrol: + # Use separate version for the buildx-plugin package, then generate the other control files as usual + # TODO override "Source" field in control as well (to point to buildx, as it doesn't match the package name) + dh_gencontrol -pdocker-buildx-plugin -- -v$${BUILDX_VERSION#v}~$${DISTRO}-$${SUITE} + # Use separate version for the compose-plugin package, then generate the other control files as usual # TODO override "Source" field in control as well (to point to compose, as it doesn't match the package name) dh_gencontrol -pdocker-compose-plugin -- -v$${COMPOSE_VERSION#v}~$${DISTRO}-$${SUITE} diff --git a/plugins/buildx.installer b/plugins/buildx.installer.disabled old mode 100755 new mode 100644 similarity index 100% rename from plugins/buildx.installer rename to plugins/buildx.installer.disabled diff --git a/rpm/Makefile b/rpm/Makefile index ba79b6e14f..6827471de1 100644 --- a/rpm/Makefile +++ b/rpm/Makefile @@ -4,6 +4,7 @@ PLUGINS_DIR=$(realpath $(CURDIR)/../plugins) GO_BASE_IMAGE=golang GO_IMAGE?=$(GO_BASE_IMAGE):$(GO_VERSION)-buster GEN_RPM_VER=$(shell ./gen-rpm-ver $(realpath $(CURDIR)/../src/github.com/docker/cli) "$(VERSION)") +GEN_BUILDX_RPM_VER=$(shell ./gen-rpm-ver $(realpath $(CURDIR)/../src/github.com/docker/buildx) "$(DOCKER_BUILDX_REF)") GEN_COMPOSE_RPM_VER=$(shell ./gen-rpm-ver $(realpath $(CURDIR)/../src/github.com/docker/compose) "$(DOCKER_COMPOSE_REF)") GEN_SCAN_RPM_VER=$(shell ./gen-rpm-ver $(realpath $(CURDIR)/../src/github.com/docker/scan-cli-plugin) "$(DOCKER_SCAN_REF)") CLI_GITCOMMIT?=$(shell cd $(realpath $(CURDIR)/../src/github.com/docker/cli) && git rev-parse --short HEAD) @@ -23,9 +24,9 @@ BUILD?=DOCKER_BUILDKIT=1 \ ifeq ($(ARCH),x86_64) -SPEC_FILES?=docker-ce.spec docker-ce-cli.spec docker-ce-rootless-extras.spec docker-compose-plugin.spec docker-scan-plugin.spec +SPEC_FILES?=docker-ce.spec docker-ce-cli.spec docker-ce-rootless-extras.spec docker-buildx-plugin.spec docker-compose-plugin.spec docker-scan-plugin.spec else -SPEC_FILES?=docker-ce.spec docker-ce-cli.spec docker-ce-rootless-extras.spec docker-compose-plugin.spec +SPEC_FILES?=docker-ce.spec docker-ce-cli.spec docker-ce-rootless-extras.spec docker-buildx-plugin.spec docker-compose-plugin.spec endif SPECS?=$(addprefix SPECS/, $(SPEC_FILES)) @@ -35,6 +36,8 @@ RPMBUILD_FLAGS?=-ba\ --define '_release $(word 2,$(GEN_RPM_VER))' \ --define '_version $(word 1,$(GEN_RPM_VER))' \ --define '_origversion $(word 4, $(GEN_RPM_VER))' \ + --define '_buildx_rpm_version $(word 1,$(GEN_BUILDX_RPM_VER))' \ + --define '_buildx_version $(word 4,$(GEN_BUILDX_RPM_VER))' \ --define '_compose_rpm_version $(word 1,$(GEN_COMPOSE_RPM_VER))' \ --define '_compose_version $(word 4,$(GEN_COMPOSE_RPM_VER))' \ --define '_scan_rpm_version $(word 1,$(GEN_SCAN_RPM_VER))' \ @@ -98,7 +101,7 @@ $(DISTROS): sources $(CHOWN) -R $(shell id -u):$(shell id -g) "rpmbuild/$@" .PHONY: sources -sources: rpmbuild/SOURCES/engine.tgz rpmbuild/SOURCES/cli.tgz rpmbuild/SOURCES/compose.tgz rpmbuild/SOURCES/scan-cli-plugin.tgz rpmbuild/SOURCES/plugin-installers.tgz +sources: rpmbuild/SOURCES/engine.tgz rpmbuild/SOURCES/cli.tgz rpmbuild/SOURCES/buildx.tgz rpmbuild/SOURCES/compose.tgz rpmbuild/SOURCES/scan-cli-plugin.tgz rpmbuild/SOURCES/plugin-installers.tgz rpmbuild/SOURCES/engine.tgz: mkdir -p $(@D) @@ -116,6 +119,14 @@ rpmbuild/SOURCES/cli.tgz: alpine \ tar -C / -c -z -f /v/cli.tgz --exclude .git cli +rpmbuild/SOURCES/buildx.tgz: + mkdir -p $(@D) + docker run --rm -w /v \ + -v $(realpath $(CURDIR)/../src/github.com/docker/buildx):/buildx \ + -v $(CURDIR)/$(@D):/v \ + alpine \ + tar -C / -c -z -f /v/buildx.tgz --exclude .git buildx + rpmbuild/SOURCES/compose.tgz: mkdir -p $(@D) docker run --rm -w /v \ diff --git a/rpm/SPECS/docker-buildx-plugin.spec b/rpm/SPECS/docker-buildx-plugin.spec new file mode 100644 index 0000000000..c59198f766 --- /dev/null +++ b/rpm/SPECS/docker-buildx-plugin.spec @@ -0,0 +1,46 @@ +%global debug_package %{nil} + +Name: docker-buildx-plugin +Version: %{_buildx_rpm_version} +Release: %{_release}%{?dist} +Epoch: 0 +Source0: buildx.tgz +Summary: Docker Buildx plugin for the Docker CLI +Group: Tools/Docker +License: ASL 2.0 +URL: https://github.com/docker/buildx +Vendor: Docker +Packager: Docker + +BuildRequires: bash + +%description +Docker Buildx plugin for the Docker CLI. + +%prep +%setup -q -c -n src -a 0 + +%build +pushd ${RPM_BUILD_DIR}/src/buildx +bash -c 'CGO_ENABLED=0 GO111MODULE=on go build -mod=vendor -o bin/docker-buildx -ldflags "-X github.com/docker/buildx/version.Version=%{_buildx_version} -X github.com/docker/buildx/version.Revision=%{_buildx_gitcommit} -X github.com/docker/buildx/version.Package=github.com/docker/buildx" ./cmd/buildx' +popd + +%check +ver="$(${RPM_BUILD_ROOT}%{_libexecdir}/docker/cli-plugins/docker-buildx docker-cli-plugin-metadata | awk '{ gsub(/[",:]/,"")}; $1 == "Version" { print $2 }')"; \ + test "$ver" = "%{_buildx_version}" && echo "PASS: docker-buildx version OK" || (echo "FAIL: docker-buildx version ($ver) did not match" && exit 1) + +%install +pushd ${RPM_BUILD_DIR}/src/buildx +install -D -p -m 0755 bin/docker-buildx ${RPM_BUILD_ROOT}%{_libexecdir}/docker/cli-plugins/docker-buildx +popd + +%files +%{_libexecdir}/docker/cli-plugins/docker-buildx + +%post + +%preun + +%postun + +%changelog diff --git a/rpm/SPECS/docker-ce-cli.spec b/rpm/SPECS/docker-ce-cli.spec index e9e55f25e3..9cc6b32760 100644 --- a/rpm/SPECS/docker-ce-cli.spec +++ b/rpm/SPECS/docker-ce-cli.spec @@ -22,8 +22,10 @@ Requires: /usr/sbin/groupadd # Note that we're not using <= 7 here, to account for other RPM distros, such # as Fedora, which would not have the rhel macro set (so default to 0). %if 0%{?rhel} == 7 +Requires: docker-buildx-plugin Requires: docker-compose-plugin %else +Recommends: docker-buildx-plugin Recommends: docker-compose-plugin %endif @@ -128,7 +130,6 @@ done %files %doc build-docs/LICENSE build-docs/MAINTAINERS build-docs/NOTICE build-docs/README.md %{_bindir}/docker -%{_libexecdir}/docker/cli-plugins/* %{_datadir}/bash-completion/completions/docker %{_datadir}/zsh/vendor-completions/_docker %{_datadir}/fish/vendor_completions.d/docker.fish diff --git a/rpm/centos-7/Dockerfile b/rpm/centos-7/Dockerfile index b91fc24cf5..864ef97b75 100644 --- a/rpm/centos-7/Dockerfile +++ b/rpm/centos-7/Dockerfile @@ -35,6 +35,7 @@ RUN \ yum-builddep -y /root/rpmbuild/SPECS/*.spec; \ else \ yum-builddep -y /root/rpmbuild/SPECS/docker-c*.spec; \ + yum-builddep -y /root/rpmbuild/SPECS/docker-b*.spec; \ fi COPY --from=golang /usr/local/go /usr/local/go diff --git a/rpm/centos-8/Dockerfile b/rpm/centos-8/Dockerfile index c4270befab..b2b506624a 100644 --- a/rpm/centos-8/Dockerfile +++ b/rpm/centos-8/Dockerfile @@ -38,6 +38,7 @@ RUN \ yum-builddep --define '_without_btrfs 1' -y /root/rpmbuild/SPECS/*.spec; \ else \ yum-builddep --define '_without_btrfs 1' -y /root/rpmbuild/SPECS/docker-c*.spec; \ + yum-builddep --define '_without_btrfs 1' -y /root/rpmbuild/SPECS/docker-b*.spec; \ fi COPY --from=golang /usr/local/go /usr/local/go diff --git a/rpm/fedora-34/Dockerfile b/rpm/fedora-34/Dockerfile index 0b60088bd9..d58f35cc26 100644 --- a/rpm/fedora-34/Dockerfile +++ b/rpm/fedora-34/Dockerfile @@ -26,6 +26,7 @@ RUN \ dnf builddep -y /root/rpmbuild/SPECS/*.spec; \ else \ dnf builddep -y /root/rpmbuild/SPECS/docker-c*.spec; \ + dnf builddep -y /root/rpmbuild/SPECS/docker-b*.spec; \ fi COPY --from=golang /usr/local/go /usr/local/go diff --git a/rpm/fedora-35/Dockerfile b/rpm/fedora-35/Dockerfile index 8660fdd44d..78d66e7d57 100644 --- a/rpm/fedora-35/Dockerfile +++ b/rpm/fedora-35/Dockerfile @@ -26,6 +26,7 @@ RUN \ dnf builddep -y /root/rpmbuild/SPECS/*.spec; \ else \ dnf builddep -y /root/rpmbuild/SPECS/docker-c*.spec; \ + dnf builddep -y /root/rpmbuild/SPECS/docker-b*.spec; \ fi COPY --from=golang /usr/local/go /usr/local/go diff --git a/rpm/fedora-36/Dockerfile b/rpm/fedora-36/Dockerfile index 33af5f9336..12843f623d 100644 --- a/rpm/fedora-36/Dockerfile +++ b/rpm/fedora-36/Dockerfile @@ -26,6 +26,7 @@ RUN \ dnf builddep -y /root/rpmbuild/SPECS/*.spec; \ else \ dnf builddep -y /root/rpmbuild/SPECS/docker-c*.spec; \ + dnf builddep -y /root/rpmbuild/SPECS/docker-b*.spec; \ fi COPY --from=golang /usr/local/go /usr/local/go diff --git a/rpm/rhel-7/Dockerfile b/rpm/rhel-7/Dockerfile index cb1ab19484..c076054a5a 100644 --- a/rpm/rhel-7/Dockerfile +++ b/rpm/rhel-7/Dockerfile @@ -31,6 +31,7 @@ RUN \ yum-builddep -y /root/rpmbuild/SPECS/*.spec; \ else \ yum-builddep -y /root/rpmbuild/SPECS/docker-c*.spec; \ + yum-builddep -y /root/rpmbuild/SPECS/docker-b*.spec; \ fi COPY --from=golang /usr/local/go /usr/local/go From 97b6ad89c88324ec4a1b2ad0f45de8992e9d41f5 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sun, 27 Mar 2022 00:17:06 +0100 Subject: [PATCH 2/3] add docker-buildx-plugin static package Signed-off-by: CrazyMax --- static/Makefile | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/static/Makefile b/static/Makefile index d86e89e7a2..32e1662494 100644 --- a/static/Makefile +++ b/static/Makefile @@ -2,6 +2,8 @@ include ../common.mk CLI_DIR=$(realpath $(CURDIR)/../src/github.com/docker/cli) ENGINE_DIR=$(realpath $(CURDIR)/../src/github.com/docker/docker) +BUILDX_DIR=$(realpath $(CURDIR)/../src/github.com/docker/buildx) + GEN_STATIC_VER=$(shell ./gen-static-ver $(CLI_DIR) $(VERSION)) HASH_CMD=docker run -v $(CURDIR):/sum -w /sum debian:jessie bash hash_files DIR_TO_HASH:=build/linux @@ -40,7 +42,7 @@ clean: ## remove build artifacts static: static-linux cross-mac cross-win cross-arm ## create all static packages .PHONY: static-linux -static-linux: static-cli static-engine ## create tgz with linux x86_64 client and server +static-linux: static-cli static-engine static-buildx-plugin ## create tgz mkdir -p build/linux/docker cp $(CLI_DIR)/build/docker build/linux/docker/ for f in dockerd containerd ctr containerd-shim containerd-shim-runc-v2 docker-init docker-proxy runc; do \ @@ -57,6 +59,9 @@ static-linux: static-cli static-engine ## create tgz with linux x86_64 client an done tar -C build/linux -c -z -f build/linux/docker-rootless-extras-$(GEN_STATIC_VER).tgz docker-rootless-extras + # buildx + tar -C $(BUILDX_DIR)/bin -c -z -f build/linux/docker-buildx-plugin-$(DOCKER_BUILDX_REF:v%=%).tgz docker-buildx + .PHONY: hash_files hash_files: @echo "Hashing directory $(DIR_TO_HASH)" @@ -100,6 +105,10 @@ static-cli: static-engine: $(MAKE) -C $(ENGINE_DIR) VERSION=$(GEN_STATIC_VER) DOCKER_BUILD_OPTS="$(DOCKER_BUILD_OPTS)" binary +.PHONY: static-buildx-plugin +static-buildx-plugin: + cd $(BUILDX_DIR) && docker buildx bake --set binaries.platform=$(TARGETPLATFORM) binaries && mv ./bin/buildx ./bin/docker-buildx + .PHONY: cross-all-cli cross-all-cli: $(MAKE) -C $(CLI_DIR) -f docker.Makefile VERSION=$(GEN_STATIC_VER) cross From 4f4872477d921461322f6d997737df2cb6b47fc7 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Fri, 25 Mar 2022 12:16:46 +0100 Subject: [PATCH 3/3] remove obsolete plugin installers Signed-off-by: CrazyMax --- deb/Makefile | 9 +------ deb/common/rules | 16 +------------ plugins/.common | 37 ---------------------------- plugins/buildx.installer.disabled | 34 -------------------------- plugins/scan.installer.disabled | 40 ------------------------------- rpm/Makefile | 9 +------ rpm/SPECS/docker-ce-cli.spec | 24 +------------------ static/Makefile | 32 ++----------------------- static/scripts/build-cli-plugins | 12 ---------- 9 files changed, 6 insertions(+), 207 deletions(-) delete mode 100644 plugins/.common delete mode 100644 plugins/buildx.installer.disabled delete mode 100644 plugins/scan.installer.disabled delete mode 100755 static/scripts/build-cli-plugins diff --git a/deb/Makefile b/deb/Makefile index d0091d5140..619aaf4377 100644 --- a/deb/Makefile +++ b/deb/Makefile @@ -79,7 +79,7 @@ $(DISTROS): sources $(CHOWN) -R $(shell id -u):$(shell id -g) "debbuild/$@" .PHONY: sources -sources: sources/cli.tgz sources/engine.tgz sources/buildx.tgz sources/compose.tgz sources/scan-cli-plugin.tgz sources/plugin-installers.tgz +sources: sources/cli.tgz sources/engine.tgz sources/buildx.tgz sources/compose.tgz sources/scan-cli-plugin.tgz sources/engine.tgz: mkdir -p $(@D) @@ -121,13 +121,6 @@ sources/scan-cli-plugin.tgz: alpine \ tar -C / -c -z -f /v/scan-cli-plugin.tgz --exclude .git scan-cli-plugin -sources/plugin-installers.tgz: $(wildcard ../plugins/*) - docker run --rm -w /v \ - -v $(PLUGINS_DIR):/plugins \ - -v $(CURDIR)/$(@D):/v \ - alpine \ - tar -C / -c -z -f /v/plugin-installers.tgz --exclude .git plugins - # See ARCHES in common.mk. Could not figure out how to match both distro and arch. BUNDLES:=$(addsuffix .tar.gz,$(addprefix debbuild/bundles-ce-%-,$(ARCHES))) diff --git a/deb/common/rules b/deb/common/rules index 208165a946..9b495e9388 100755 --- a/deb/common/rules +++ b/deb/common/rules @@ -39,14 +39,6 @@ override_dh_auto_build: && mv bin/docker-scan /usr/libexec/docker/cli-plugins/; \ fi - # Build the CLI plugins - # Make sure to set LDFLAGS="" since, dpkg-buildflags sets it to some weird values - set -e;cd /sources && \ - tar xzf plugin-installers.tgz; \ - for installer in plugins/*.installer; do \ - LDFLAGS='' bash $${installer} build; \ - done - override_dh_auto_test: ver="$$(engine/bundles/dynbinary-daemon/dockerd --version)"; \ test "$$ver" = "Docker version $(VERSION), build $(ENGINE_GITCOMMIT)" && echo "PASS: daemon version OK" || (echo "FAIL: daemon version ($$ver) did not match" && exit 1) @@ -75,13 +67,7 @@ override_dh_auto_install: install -D -m 0644 cli/contrib/completion/fish/docker.fish debian/docker-ce-cli/usr/share/fish/vendor_completions.d/docker.fish install -D -m 0644 cli/contrib/completion/zsh/_docker debian/docker-ce-cli/usr/share/zsh/vendor-completions/_docker install -D -m 0755 cli/build/docker debian/docker-ce-cli/usr/bin/docker - set -e;cd /sources && \ - tar xzf plugin-installers.tgz; \ - for installer in plugins/*.installer; do \ - DESTDIR=/root/build-deb/debian/docker-ce-cli \ - PREFIX=/usr/libexec/docker/cli-plugins \ - bash $${installer} install_plugin; \ - done + # docker-ce install install -D -m 0644 engine/contrib/init/systemd/docker.service debian/docker-ce/lib/systemd/system/docker.service install -D -m 0644 engine/contrib/init/systemd/docker.socket debian/docker-ce/lib/systemd/system/docker.socket diff --git a/plugins/.common b/plugins/.common deleted file mode 100644 index 53824432f2..0000000000 --- a/plugins/.common +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash - -DESTDIR=${DESTDIR:-} -PREFIX=${PREFIX:-/usr/local} - -add_github_ssh_host() { - # You're not able to clone from github unless you add to known_hosts - if ! grep ~/.ssh/known_hosts "github.com" >/dev/null 2>/dev/null; then - mkdir -p ~/.ssh - ssh-keyscan github.com >> ~/.ssh/known_hosts - fi -} - -install_binary() { - for binary in "$@"; do - mkdir -p "${DESTDIR}${PREFIX}" - install -p -m 755 "${binary}" "${DESTDIR}${PREFIX}" - done -} - -build_or_install() { - case $1 in - build) - build - ;; - build_mac) - build_mac - ;; - install_plugin) - install_plugin - ;; - *) - echo "Are you sure that's a command? o.O" - exit 1 - ;; - esac -} diff --git a/plugins/buildx.installer.disabled b/plugins/buildx.installer.disabled deleted file mode 100644 index 9aa2a88ad1..0000000000 --- a/plugins/buildx.installer.disabled +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash - -set -e - -source "$(dirname "$0")/.common" -PKG=github.com/docker/buildx -GOPATH=$(go env GOPATH) -REPO=https://${PKG}.git -: "${BUILDX_COMMIT=v0.8.1}" -DEST=${GOPATH}/src/${PKG} - -build() { - if [ ! -d "${DEST}" ]; then - git clone "${REPO}" "${DEST}" - fi - ( - cd "${DEST}" - git fetch --all - git checkout -q "${BUILDX_COMMIT}" - local LDFLAGS - LDFLAGS="-X ${PKG}/version.Version=$(git describe --match 'v[0-9]*' --always --tags)-docker -X ${PKG}/version.Revision=$(git rev-parse HEAD) -X ${PKG}/version.Package=${PKG}" - set -x - GO111MODULE=on go build -mod=vendor -o bin/docker-buildx -ldflags "${LDFLAGS}" ./cmd/buildx - ) -} - -install_plugin() { - ( - cd "${DEST}" - install_binary bin/docker-buildx - ) -} - -build_or_install "$@" diff --git a/plugins/scan.installer.disabled b/plugins/scan.installer.disabled deleted file mode 100644 index b79bae981a..0000000000 --- a/plugins/scan.installer.disabled +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env bash - -set -e - -source "$(dirname "$0")/.common" -PKG=github.com/docker/scan-cli-plugin -GOPATH=$(go env GOPATH) -REPO=https://${PKG}.git -COMMIT=v0.17.0 -DEST=${GOPATH}/src/${PKG} - -build() { - if [ ! -d "${DEST}" ]; then - git clone "${REPO}" "${DEST}" - fi - ( - cd "${DEST}" - if [ -d ".git" ]; then - git fetch --all - git checkout -q "${COMMIT}" - fi - PLATFORM_BINARY=docker-scan TAG_NAME="${COMMIT}" make native-build - ) -} - -install_plugin() { - ( - cd "${DEST}" - install_binary bin/docker-scan - ) -} - -case "$(uname -i)" in - aarch64) - echo "Skipping scan plugin on ARM arch";; - arm*) - echo "Skipping scan plugin on ARM arch";; - *) - build_or_install "$@";; -esac diff --git a/rpm/Makefile b/rpm/Makefile index 6827471de1..47c6010288 100644 --- a/rpm/Makefile +++ b/rpm/Makefile @@ -101,7 +101,7 @@ $(DISTROS): sources $(CHOWN) -R $(shell id -u):$(shell id -g) "rpmbuild/$@" .PHONY: sources -sources: rpmbuild/SOURCES/engine.tgz rpmbuild/SOURCES/cli.tgz rpmbuild/SOURCES/buildx.tgz rpmbuild/SOURCES/compose.tgz rpmbuild/SOURCES/scan-cli-plugin.tgz rpmbuild/SOURCES/plugin-installers.tgz +sources: rpmbuild/SOURCES/engine.tgz rpmbuild/SOURCES/cli.tgz rpmbuild/SOURCES/buildx.tgz rpmbuild/SOURCES/compose.tgz rpmbuild/SOURCES/scan-cli-plugin.tgz rpmbuild/SOURCES/engine.tgz: mkdir -p $(@D) @@ -143,13 +143,6 @@ rpmbuild/SOURCES/scan-cli-plugin.tgz: alpine \ tar -C / -c -z -f /v/scan-cli-plugin.tgz --exclude .git scan-cli-plugin -rpmbuild/SOURCES/plugin-installers.tgz: $(wildcard ../plugins/*) - docker run --rm -w /v \ - -v $(PLUGINS_DIR):/plugins \ - -v $(CURDIR)/$(@D):/v \ - alpine \ - tar -C / -c -z -f /v/plugin-installers.tgz --exclude .git plugins - # See ARCHES in common.mk. Could not figure out how to match both distro and arch. BUNDLES:=$(addsuffix .tar.gz,$(addprefix rpmbuild/bundles-ce-%-,$(ARCHES))) diff --git a/rpm/SPECS/docker-ce-cli.spec b/rpm/SPECS/docker-ce-cli.spec index 9cc6b32760..c9919ad89b 100644 --- a/rpm/SPECS/docker-ce-cli.spec +++ b/rpm/SPECS/docker-ce-cli.spec @@ -8,7 +8,6 @@ Summary: The open-source application container engine Group: Tools/Docker License: ASL 2.0 Source0: cli.tgz -Source1: plugin-installers.tgz URL: https://www.docker.com Vendor: Docker Packager: Docker @@ -65,7 +64,7 @@ for deploying and scaling web apps, databases, and backend services without depending on a particular stack or provider. %prep -%setup -q -c -n src -a 1 +%setup -q -c -n src -a 0 %build mkdir -p /go/src/github.com/docker @@ -75,16 +74,6 @@ pushd /go/src/github.com/docker/cli VERSION=%{_origversion} GITCOMMIT=%{_gitcommit_cli} GO_LINKMODE=dynamic ./scripts/build/binary && DISABLE_WARN_OUTSIDE_CONTAINER=1 make manpages # cli popd -# Build all associated plugins -pushd ${RPM_BUILD_DIR}/src/plugins -for installer in *.installer; do - if [ "${installer}" != "scan.installer" ]; then - bash ${installer} build - fi -done -popd - - %check ver="$(cli/build/docker --version)"; \ test "$ver" = "Docker version %{_origversion}, build %{_gitcommit_cli}" && echo "PASS: cli version OK" || (echo "FAIL: cli version ($ver) did not match" && exit 1) @@ -94,17 +83,6 @@ ver="$(cli/build/docker --version)"; \ install -d ${RPM_BUILD_ROOT}%{_bindir} install -p -m 755 cli/build/docker ${RPM_BUILD_ROOT}%{_bindir}/docker -# install plugins -pushd ${RPM_BUILD_DIR}/src/plugins -for installer in *.installer; do - if [ "${installer}" != "scan.installer" ]; then - DESTDIR=${RPM_BUILD_ROOT} \ - PREFIX=%{_libexecdir}/docker/cli-plugins \ - bash ${installer} install_plugin - fi -done -popd - # add bash, zsh, and fish completions install -d ${RPM_BUILD_ROOT}%{_datadir}/bash-completion/completions install -d ${RPM_BUILD_ROOT}%{_datadir}/zsh/vendor-completions diff --git a/static/Makefile b/static/Makefile index 32e1662494..8915d5cc24 100644 --- a/static/Makefile +++ b/static/Makefile @@ -72,7 +72,7 @@ buildx: docker buildx inspect | grep -q 'Driver: docker-container' || docker buildx create --use .PHONY: cross-mac -cross-mac: buildx cross-mac-plugins +cross-mac: buildx cd $(CLI_DIR) && VERSION=$(GEN_STATIC_VER) docker buildx bake --set binary.platform=darwin/amd64,darwin/arm64 binary dest=$$PWD/build/mac; cd $(CLI_DIR)/build && for platform in *; do \ arch=$$(echo $$platform | cut -d_ -f2); \ @@ -82,7 +82,7 @@ cross-mac: buildx cross-mac-plugins done .PHONY: cross-win -cross-win: cross-win-engine cross-win-plugins +cross-win: cross-win-engine cd $(CLI_DIR) && VERSION=$(GEN_STATIC_VER) docker buildx bake --set binary.platform=windows/amd64 binary mkdir -p build/win/amd64/docker cp $(CLI_DIR)/build/docker-windows-amd64.exe build/win/amd64/docker/docker.exe @@ -116,31 +116,3 @@ cross-all-cli: .PHONY: cross-win-engine cross-win-engine: $(MAKE) -C $(ENGINE_DIR) VERSION=$(GEN_STATIC_VER) DOCKER_CROSSPLATFORMS=windows/amd64 DOCKER_BUILD_OPTS="$(DOCKER_BUILD_OPTS)" cross - -BUILD_PLUGIN_RUN_VARS = --rm \ - -e GOOS \ - -e GOARCH \ - -v "$(CURDIR)/build/$(CLI_BUILD_DIR)/$*/docker/cli-plugins":/out \ - -v "$(CURDIR)/../plugins":/plugins:ro \ - -v "$(CURDIR)/scripts/build-cli-plugins":/build:ro - -.PHONY: cross-mac-plugins -cross-mac-plugins: cross-mac-plugins-amd64 cross-mac-plugins-arm64 - -.PHONY: cross-mac-plugins-% -cross-mac-plugins-%: CLI_BUILD_DIR := mac -cross-mac-plugins-%: - mkdir -p build/$(CLI_BUILD_DIR)/$*/docker - GOOS=darwin GOARCH=$* docker run $(BUILD_PLUGIN_RUN_VARS) $(DOCKER_CLI_GOLANG_IMG) /build - $(CHOWN) -R $(shell id -u):$(shell id -g) build/$(CLI_BUILD_DIR)/$* - -.PHONY: cross-win-plugins -cross-win-plugins: cross-win-plugins-amd64 - -.PHONY: cross-win-plugins-% -cross-win-plugins-%: CLI_BUILD_DIR := win -cross-win-plugins-%: - mkdir -p build/$(CLI_BUILD_DIR)/$*/docker/cli-plugins - GOOS=windows GOARCH=$* docker run $(BUILD_PLUGIN_RUN_VARS) $(DOCKER_CLI_GOLANG_IMG) /build - $(CHOWN) -R $(shell id -u):$(shell id -g) build/$(CLI_BUILD_DIR)/$* - find build/$(CLI_BUILD_DIR)/$*/docker -type f -not -name "*.exe" -exec mv {} {}.exe \; diff --git a/static/scripts/build-cli-plugins b/static/scripts/build-cli-plugins deleted file mode 100755 index e0a89c6b71..0000000000 --- a/static/scripts/build-cli-plugins +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -set -e - -shopt -s globstar - -# /plugins should be volume mounted from root plugins dir -# /out should also be volume mounted from static/out/ -for installer in /plugins/*.installer; do - bash "${installer}" build - DESTDIR='/out' PREFIX="/" bash "${installer}" install_plugin -done