From 85c375b41682d3c0fe3f51d9cd58f21160024e63 Mon Sep 17 00:00:00 2001 From: Eli Uriegas Date: Mon, 25 Feb 2019 23:48:09 +0000 Subject: [PATCH 1/3] Add initial rigging for cli-plugin building Signed-off-by: Eli Uriegas --- deb/Makefile | 9 ++++++++- plugins/.gitkeep | 0 rpm/Makefile | 9 ++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 plugins/.gitkeep diff --git a/deb/Makefile b/deb/Makefile index 72a849be4d..f09572cdfe 100644 --- a/deb/Makefile +++ b/deb/Makefile @@ -35,7 +35,7 @@ RUN=docker run --rm -i \ $(RUN_FLAGS) \ debbuild-$@/$(ARCH) -SOURCE_FILES=engine-image cli.tgz docker.service docker.socket distribution_based_engine.json +SOURCE_FILES=engine-image cli.tgz docker.service docker.socket distribution_based_engine.json plugin-installers.tgz SOURCES=$(addprefix sources/, $(SOURCE_FILES)) .PHONY: help @@ -119,3 +119,10 @@ sources/engine-image: mkdir -p $(@D) $(MAKE) -C ../image image-linux cp ../image/image-linux $@ + +sources/plugin-installers.tgz: $(wildcard ../plugins/*) + docker run --rm -i -w /v \ + -v $(shell readlink -e ../plugins):/plugins \ + -v $(CURDIR)/sources:/v \ + alpine \ + tar -C / -c -z -f /v/plugin-installers.tgz --exclude .git plugins diff --git a/plugins/.gitkeep b/plugins/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/rpm/Makefile b/rpm/Makefile index 1b18ce6cb1..1ee7e2f4d4 100644 --- a/rpm/Makefile +++ b/rpm/Makefile @@ -40,7 +40,7 @@ RPMBUILD_FLAGS?=-ba\ $(SPECS) RUN?=$(RPMBUILD) rpmbuild-$@/$(ARCH) $(RPMBUILD_FLAGS) -SOURCE_FILES=engine-image cli.tgz docker.service docker.socket distribution_based_engine.json +SOURCE_FILES=engine-image cli.tgz docker.service docker.socket distribution_based_engine.json plugin-installers.tgz SOURCES=$(addprefix rpmbuild/SOURCES/, $(SOURCE_FILES)) @@ -109,3 +109,10 @@ rpmbuild/SOURCES/distribution_based_engine.json: rpmbuild/SOURCES/engine-image mkdir -p $(@D) docker inspect "$(shell cat $<)" \ --format '{{index .Config.Labels "com.docker.distribution_based_engine" }}' > $@ + +rpmbuild/SOURCES/plugin-installers.tgz: $(wildcard ../plugins/*) + docker run --rm -i -w /v \ + -v $(shell readlink -e ../plugins):/plugins \ + -v $(CURDIR)/rpmbuild/SOURCES:/v \ + alpine \ + tar -C / -c -z -f /v/plugin-installers.tgz --exclude .git plugins From b7a0a8f4752e049065ca97742ed308f4de24b2cf Mon Sep 17 00:00:00 2001 From: Eli Uriegas Date: Tue, 5 Mar 2019 22:31:45 +0000 Subject: [PATCH 2/3] Add plugin installation for DEB and RPM Signed-off-by: Eli Uriegas --- deb/common/rules | 13 +++++++++++++ plugins/.common | 34 ++++++++++++++++++++++++++++++++++ rpm/SPECS/docker-ce-cli.spec | 22 +++++++++++++++++++++- 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 plugins/.common diff --git a/deb/common/rules b/deb/common/rules index cfe295c09b..103b2c0286 100644 --- a/deb/common/rules +++ b/deb/common/rules @@ -10,6 +10,12 @@ override_dh_gencontrol: override_dh_auto_build: cd /go/src/github.com/docker/cli && \ LDFLAGS='' DISABLE_WARN_OUTSIDE_CONTAINER=1 make VERSION=$(VERSION) GITCOMMIT=$(DOCKER_GITCOMMIT) dynbinary manpages + # 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_strip: # Go has lots of problems with stripping, so just don't @@ -19,6 +25,13 @@ override_dh_auto_install: install -D -m 0644 /go/src/github.com/docker/cli/contrib/completion/fish/docker.fish debian/docker-ce-cli/usr/share/fish/vendor_completions.d/docker.fish install -D -m 0644 /go/src/github.com/docker/cli/contrib/completion/zsh/_docker debian/docker-ce-cli/usr/share/zsh/vendor-completions/_docker install -D -m 0755 /go/src/github.com/docker/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 /sources/docker.service debian/docker-ce/lib/systemd/system/docker.service install -D -m 0644 /sources/docker.socket debian/docker-ce/lib/systemd/system/docker.socket diff --git a/plugins/.common b/plugins/.common new file mode 100644 index 0000000000..6a61af517b --- /dev/null +++ b/plugins/.common @@ -0,0 +1,34 @@ +#!/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 + ;; + install_plugin) + install_plugin + ;; + *) + echo "Are you sure that's a command? o.O" + exit 1 + ;; + esac +} diff --git a/rpm/SPECS/docker-ce-cli.spec b/rpm/SPECS/docker-ce-cli.spec index eb118f89d6..25fae605d3 100644 --- a/rpm/SPECS/docker-ce-cli.spec +++ b/rpm/SPECS/docker-ce-cli.spec @@ -8,6 +8,7 @@ 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 @@ -17,6 +18,7 @@ Requires: /bin/sh BuildRequires: make BuildRequires: libtool-ltdl-devel +BuildRequires: git # conflicting packages Conflicts: docker @@ -37,7 +39,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 +%setup -q -c -n src -a 1 %build mkdir -p /go/src/github.com/docker @@ -47,6 +49,14 @@ pushd /go/src/github.com/docker/cli DISABLE_WARN_OUTSIDE_CONTAINER=1 make VERSION=%{_origversion} GITCOMMIT=%{_gitcommit} dynbinary manpages # cli popd +# Build all associated plugins +pushd /root/rpmbuild/BUILD/src/plugins +for installer in *.installer; do + bash ${installer} build +done +popd + + # %check # cli/build/docker -v @@ -55,6 +65,15 @@ popd install -d $RPM_BUILD_ROOT/%{_bindir} install -p -m 755 cli/build/docker $RPM_BUILD_ROOT/%{_bindir}/docker +# install plugins +pushd /root/rpmbuild/BUILD/src/plugins +for installer in *.installer; do + DESTDIR=$RPM_BUILD_ROOT \ + PREFIX=/usr/libexec/docker/cli-plugins \ + bash ${installer} install_plugin +done +popd + # add bash, zsh, and fish completions install -d $RPM_BUILD_ROOT/usr/share/bash-completion/completions install -d $RPM_BUILD_ROOT/usr/share/zsh/vendor-completions @@ -80,6 +99,7 @@ done %files %doc build-docs/LICENSE build-docs/MAINTAINERS build-docs/NOTICE build-docs/README.md /%{_bindir}/docker +/usr/libexec/docker/cli-plugins/* /usr/share/bash-completion/completions/docker /usr/share/zsh/vendor-completions/_docker /usr/share/fish/vendor_completions.d/docker.fish From 43bf924aca75bfe2ff7359f1423308ee4ed8488f Mon Sep 17 00:00:00 2001 From: Eli Uriegas Date: Wed, 6 Mar 2019 00:04:28 +0000 Subject: [PATCH 3/3] Add initial script for docker/app cli-plugin Signed-off-by: Eli Uriegas --- plugins/app.installer | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 plugins/app.installer diff --git a/plugins/app.installer b/plugins/app.installer new file mode 100644 index 0000000000..8427b565ac --- /dev/null +++ b/plugins/app.installer @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +set -e + +source "$(dirname "$0")/.common" + +GOPATH=$(go env GOPATH) +REPO=https://github.com/docker/app.git +COMMIT=207a9459e78dcccbf3eb7e8ca5763835b526478d +DEST=${GOPATH}/src/github.com/docker/app + +build() { + if [ ! -d "${DEST}" ]; then + git clone "${REPO}" "${DEST}" + fi + ( + cd "${DEST}" + git fetch --all + git checkout -q "${COMMIT}" + # There's no real versions yet, but this'll just leave it blank + make bin/docker-app + ) +} + +install_plugin() { + ( + cd "${DEST}" + install_binary bin/docker-app + ) +} + +build_or_install "$@"