From ccfe550df4ddd50eee6884dbed3cb27233200d2d Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 3 Jul 2021 13:07:56 +0200 Subject: [PATCH] rpm: add docker-compose-plugin package Adds an rpm package for the docker-compose cli plugin with this: rpm -i \ ./docker-ce-cli-0.0.0.20210702143511.f782d13-0.el8.x86_64.rpm \ ./docker-scan-plugin-0.8.0-0.el8.x86_64.rpm \ ./docker-compose-plugin-2.3.1.3-0.el8.x86_64.rpm docker info --format '{{json .ClientInfo.Plugins}}' | jq . [ { "SchemaVersion": "0.1.0", "Vendor": "Docker Inc.", "Version": "v0.5.1-docker", "ShortDescription": "Build with BuildKit", "Name": "buildx", "Path": "/usr/libexec/docker/cli-plugins/docker-buildx" }, { "SchemaVersion": "0.1.0", "Vendor": "Docker Inc.", "Version": "v2.3.1", "ShortDescription": "Docker Compose", "Name": "compose", "Path": "/usr/libexec/docker/cli-plugins/docker-compose" }, { "SchemaVersion": "0.1.0", "Vendor": "Docker Inc.", "Version": "v0.8.0", "ShortDescription": "Docker Scan", "Name": "scan", "Path": "/usr/libexec/docker/cli-plugins/docker-scan" } ] Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 8eda83d5f428309895c7d9420b7bb1faa9904198) Signed-off-by: Sebastiaan van Stijn --- rpm/Makefile | 20 +++++++++-- rpm/SPECS/docker-compose-plugin.spec | 52 ++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 rpm/SPECS/docker-compose-plugin.spec diff --git a/rpm/Makefile b/rpm/Makefile index fa1172d2d8..c1f3d43227 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_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) ENGINE_GITCOMMIT?=$(shell cd $(realpath $(CURDIR)/../src/github.com/docker/docker) && git rev-parse --short HEAD) @@ -22,9 +23,9 @@ BUILD?=DOCKER_BUILDKIT=1 \ ifeq ($(ARCH),x86_64) -SPEC_FILES?=docker-ce.spec docker-ce-cli.spec docker-ce-rootless-extras.spec docker-scan-plugin.spec +SPEC_FILES?=docker-ce.spec docker-ce-cli.spec docker-ce-rootless-extras.spec docker-compose-plugin.spec docker-scan-plugin.spec else -SPEC_FILES?=docker-ce.spec docker-ce-cli.spec docker-ce-rootless-extras.spec +SPEC_FILES?=docker-ce.spec docker-ce-cli.spec docker-ce-rootless-extras.spec docker-compose-plugin.spec endif SPECS?=$(addprefix SPECS/, $(SPEC_FILES)) @@ -34,6 +35,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 '_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))' \ --define '_scan_version $(word 4,$(GEN_SCAN_RPM_VER))' \ --define '_scan_gitcommit $(SCAN_GITCOMMIT)' \ @@ -87,13 +90,16 @@ centos: $(CENTOS_RELEASES) ## build all centos rpm packages rhel: $(RHEL_RELEASES) ## build all rhel rpm packages .PHONY: $(DISTROS) -$(DISTROS): rpmbuild/SOURCES/engine.tgz rpmbuild/SOURCES/cli.tgz rpmbuild/SOURCES/scan-cli-plugin.tgz rpmbuild/SOURCES/docker.service rpmbuild/SOURCES/docker.socket rpmbuild/SOURCES/plugin-installers.tgz +$(DISTROS): sources @echo "== Building packages for $@ ==" mkdir -p "rpmbuild/$@" $(BUILD) $(RUN) $(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/docker.service rpmbuild/SOURCES/docker.socket rpmbuild/SOURCES/plugin-installers.tgz + rpmbuild/SOURCES/engine.tgz: mkdir -p $(@D) docker run --rm -w /v \ @@ -110,6 +116,14 @@ rpmbuild/SOURCES/cli.tgz: alpine \ tar -C / -c -z -f /v/cli.tgz --exclude .git cli +rpmbuild/SOURCES/compose.tgz: + mkdir -p $(@D) + docker run --rm -w /v \ + -v $(realpath $(CURDIR)/../src/github.com/docker/compose):/compose \ + -v $(CURDIR)/$(@D):/v \ + alpine \ + tar -C / -c -z -f /v/compose.tgz --exclude .git compose + rpmbuild/SOURCES/scan-cli-plugin.tgz: mkdir -p $(@D) docker run --rm -w /v \ diff --git a/rpm/SPECS/docker-compose-plugin.spec b/rpm/SPECS/docker-compose-plugin.spec new file mode 100644 index 0000000000..3c6b6df36e --- /dev/null +++ b/rpm/SPECS/docker-compose-plugin.spec @@ -0,0 +1,52 @@ +%global debug_package %{nil} + +Name: docker-compose-plugin +Version: %{_compose_rpm_version} +Release: %{_release}%{?dist} +Epoch: 0 +Source0: compose.tgz +Summary: Docker Compose plugin for the Docker CLI +Group: Tools/Docker +License: ASL 2.0 +URL: https://github.com/docker/compose/ +Vendor: Docker +Packager: Docker + +Requires: docker-ce-cli + +BuildRequires: bash + +%description +Docker Compose plugin for the Docker CLI. + +%prep +%setup -q -c -n src -a 0 + +%build +pushd ${RPM_BUILD_DIR}/src/compose +# 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 +GOPROXY="https://proxy.golang.org" GO111MODULE=on go mod download +GOPROXY="https://proxy.golang.org" GO111MODULE=on GIT_TAG="%{_compose_version}" \ + make COMPOSE_BINARY="bin/docker-compose" -f builder.Makefile compose-plugin +popd + +%check +ver="$(${RPM_BUILD_ROOT}%{_libexecdir}/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) + +%install +pushd ${RPM_BUILD_DIR}/src/compose +install -D -p -m 0755 bin/docker-compose ${RPM_BUILD_ROOT}%{_libexecdir}/docker/cli-plugins/docker-compose +popd + +%files +%{_libexecdir}/docker/cli-plugins/docker-compose + +%post + +%preun + +%postun + +%changelog