From 799830973387646aaeb540dc31f18523fece38ee Mon Sep 17 00:00:00 2001 From: Eli Uriegas Date: Thu, 15 Mar 2018 22:05:22 +0000 Subject: [PATCH 1/3] Enable new test versioning scheme Enables the usage of a new versioning scheme for test builds: * tp -> Technical Previews * beta -> Beta Releases * rc -> Release Candidates * ga -> General Availability Releases This PR fixes the versioning order for both `deb` and `rpm` packages when it relates to the new versioning scheme (which may or may not be used). Signed-off-by: Eli Uriegas Upstream-commit: 9ba8e36e8588ea75209d813558c8065844c953a0 Component: packaging --- components/packaging/deb/gen-deb-ver | 35 ++++++++++++++++++++++++++-- components/packaging/rpm/gen-rpm-ver | 28 ++++++++++++++-------- 2 files changed, 51 insertions(+), 12 deletions(-) diff --git a/components/packaging/deb/gen-deb-ver b/components/packaging/deb/gen-deb-ver index 2ea9f94b87..f57a5f671f 100755 --- a/components/packaging/deb/gen-deb-ver +++ b/components/packaging/deb/gen-deb-ver @@ -3,6 +3,8 @@ ENGINE_DIR="$1" VERSION="$2" +SUFFIX=${SUFFIX:=ce} + [[ $# < 2 ]] && echo 'not enough args' && exit 1 DATE_COMMAND="date" @@ -10,12 +12,41 @@ if [[ $(uname) -eq "Darwin" ]]; then DATE_COMMAND="docker run --rm alpine date" fi -TZ=UTC +gen_deb_version() { + # Adds an increment to the deb version to get proper order + # 18.01.0-${SUFFIX}-tp1 -> 18.01.0-${SUFFIX}-0.1-tp1 + # 18.01.0-${SUFFIX}-beta1 -> 18.01.0-${SUFFIX}-1.1-beta1 + # 18.01.0-${SUFFIX}-rc1 -> 18.01.0-${SUFFIX}-2.1-rc1 + # 18.01.0-${SUFFIX} -> 18.01.0-${SUFFIX}-3 + fullVersion="$1" + pattern="$2" + increment="$3" + testVersion="${fullVersion#*-$SUFFIX-*$pattern}" + baseVersion="${fullVersion%-"$pattern"*}" + echo "$baseVersion-$increment.$testVersion.$pattern$testVersion" +} + +case "$VERSION" in + *-tp[0-9]*) + debVersion="$(gen_deb_version "$VERSION" tp 0)" + ;; + *-beta[0-9]*) + debVersion="$(gen_deb_version "$VERSION" beta 1)" + ;; + *-rc[0-9]*) + debVersion="$(gen_deb_version "$VERSION" rc 2)" + ;; + *) + debVersion="$VERSION-3" + ;; +esac + +export TZ=UTC tilde='~' # ouch Bash 4.2 vs 4.3, you keel me # git running in different directories, backwards compatible too GIT_COMMAND="git -C $ENGINE_DIR" -debVersion="${VERSION//-/$tilde}" # using \~ or '~' here works in 4.3, but not 4.2; just ~ causes $HOME to be inserted, hence the $tilde +debVersion="${debVersion//-/$tilde}" # using \~ or '~' here works in 4.3, but not 4.2; just ~ causes $HOME to be inserted, hence the $tilde # if we have a "-dev" suffix or have change in Git, let's make this package version more complex so it works better if [[ "$VERSION" == *-dev ]]; then gitUnix="$($GIT_COMMAND log -1 --pretty='%at')" diff --git a/components/packaging/rpm/gen-rpm-ver b/components/packaging/rpm/gen-rpm-ver index 87883c30d5..391c67fc44 100755 --- a/components/packaging/rpm/gen-rpm-ver +++ b/components/packaging/rpm/gen-rpm-ver @@ -11,22 +11,30 @@ if [[ $(uname) -eq "Darwin" ]]; then fi GIT_COMMAND="git -C $ENGINE_DIR" -rpmName=docker-ce rpmVersion="$VERSION" -rpmRelease=1 +rpmRelease=3 # rpmRelease versioning is as follows -# Docker 1.7.0: version=1.7.0, release=1 -# Docker 1.7.0-rc1: version=1.7.0, release=0.1.rc1 -# Docker 1.7.0-cs1: version=1.7.0.cs1, release=1 -# Docker 1.7.0-cs1-rc1: version=1.7.0.cs1, release=0.1.rc1 -# Docker 1.7.0-dev nightly: version=1.7.0, release=0.0.YYYYMMDD.HHMMSS.gitHASH +# Docker 18.01.0-ce: version=18.01.0.ce, release=3 +# Docker 18.01.0-ce-tp1: version=18.01.0.ce, release=0.1.tp1 +# Docker 18.01.0-ce-beta1: version=18.01.0.ce, release=1.1.beta1 +# Docker 18.01.0-ce-rc1: version=18.01.0.ce, release=2.1.rc1 +# Docker 18.01.0-ce-cs1: version=18.01.0.ce.cs1, release=1 +# Docker 18.01.0-ce-cs1-rc1: version=18.01.0.ce.cs1, release=0.1.rc1 +# Docker 18.01.0-ce-dev nightly: version=18.01.0.ce, release=0.0.YYYYMMDD.HHMMSS.gitHASH -# if we have a "-rc*" suffix, set appropriate release -if [[ "$rpmVersion" =~ .*-rc[0-9]+$ ]] ; then +if [[ "$rpmVersion" =~ .*-tp[0-9]+$ ]]; then + tpVersion=${rpmVersion#*-tp} + rpmVersion=${rpmVersion%-tp*} + rpmRelease="0.${tpVersion}.tp${tpVersion}" +elif [[ "$rpmVersion" =~ .*-beta[0-9]+$ ]]; then + betaVersion=${rpmVersion#*-beta} + rpmVersion=${rpmVersion%-beta*} + rpmRelease="1.${betaVersion}.beta${betaVersion}" +elif [[ "$rpmVersion" =~ .*-rc[0-9]+$ ]]; then rcVersion=${rpmVersion#*-rc} rpmVersion=${rpmVersion%-rc*} - rpmRelease="0.${rcVersion}.rc${rcVersion}" + rpmRelease="2.${rcVersion}.rc${rcVersion}" fi DOCKER_GITCOMMIT=$($GIT_COMMAND rev-parse --short HEAD) From f925996d4a3962a122a8c2e61813db68b0e06929 Mon Sep 17 00:00:00 2001 From: Eli Uriegas Date: Thu, 15 Mar 2018 23:31:46 +0000 Subject: [PATCH 2/3] Move same parts to common variables There was a lot of repeated parts in this Makefile, I moved them to a common variable so that if / when we decide to change how things are run then it's easy to do so. Signed-off-by: Eli Uriegas Upstream-commit: c869c9fcf510d1a6c4e25c1a14ea6cb0bb3e6aa4 Component: packaging --- components/packaging/deb/Makefile | 121 ++++++++---------------------- 1 file changed, 30 insertions(+), 91 deletions(-) diff --git a/components/packaging/deb/Makefile b/components/packaging/deb/Makefile index d42b1b8bec..fc1910fc61 100644 --- a/components/packaging/deb/Makefile +++ b/components/packaging/deb/Makefile @@ -4,10 +4,21 @@ ENGINE_DIR:=$(CURDIR)/../../engine CLI_DIR:=$(CURDIR)/../../cli GITCOMMIT?=$(shell cd $(ENGINE_DIR) && git rev-parse --short HEAD) VERSION?=0.0.0-dev -DEB_VERSION=$(shell ./gen-deb-ver $(ENGINE_DIR) $(VERSION)) +DEB_VERSION=$(shell ./gen-deb-ver $(ENGINE_DIR) "$(VERSION)") DOCKER_EXPERIMENTAL:=0 CHOWN:=docker run --rm -v $(CURDIR):/v -w /v alpine chown +BUILD=docker build -t debbuild-$@/$(ARCH) -f $(CURDIR)/$@/Dockerfile.$(ARCH) . +RUN=docker run --rm -i \ + -e DEB_VERSION=$(DEB_VERSION) \ + -e VERSION=$(VERSION) \ + -e DOCKER_GITCOMMIT=$(GITCOMMIT) \ + -v $(CURDIR)/debbuild/$@:/build \ + -v $(ENGINE_DIR):/engine \ + -v $(CLI_DIR):/cli \ + -v $(CURDIR)/systemd:/root/build-deb/systemd \ + debbuild-$@/$(ARCH) + .PHONY: help help: ## show make targets @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) @@ -31,126 +42,54 @@ raspbian: raspbian-stretch debian-jessie ## build all raspbian deb packages .PHONY: ubuntu-xenial ubuntu-xenial: ## build ubuntu xenial deb packages - docker build -t debbuild-$@/$(ARCH) -f $(CURDIR)/$@/Dockerfile.$(ARCH) . - docker run --rm -i \ - -e DEB_VERSION=$(DEB_VERSION) \ - -e VERSION=$(VERSION) \ - -e DOCKER_GITCOMMIT=$(GITCOMMIT) \ - -v $(CURDIR)/debbuild/$@:/build \ - -v $(ENGINE_DIR):/engine \ - -v $(CLI_DIR):/cli \ - -v $(CURDIR)/systemd:/root/build-deb/systemd \ - debbuild-$@/$(ARCH) + $(BUILD) + $(RUN) $(CHOWN) -R $(shell id -u):$(shell id -g) debbuild/$@ .PHONY: ubuntu-trusty ubuntu-trusty: ## build ubuntu trusty deb packages - docker build -t debbuild-$@/$(ARCH) -f $(CURDIR)/$@/Dockerfile.$(ARCH) . - docker run --rm -i \ - -e DEB_VERSION=$(DEB_VERSION) \ - -e VERSION=$(VERSION) \ - -e DOCKER_GITCOMMIT=$(GITCOMMIT) \ - -v $(CURDIR)/debbuild/$@:/build \ - -v $(ENGINE_DIR):/engine \ - -v $(CLI_DIR):/cli \ - -v $(CURDIR)/systemd:/root/build-deb/systemd \ - debbuild-$@/$(ARCH) + $(BUILD) + $(RUN) $(CHOWN) -R $(shell id -u):$(shell id -g) debbuild/$@ .PHONY: ubuntu-artful ubuntu-artful: ## build ubuntu artful deb packages - docker build -t debbuild-$@/$(ARCH) -f $(CURDIR)/$@/Dockerfile.$(ARCH) . - docker run --rm -i \ - -e DEB_VERSION=$(DEB_VERSION) \ - -e VERSION=$(VERSION) \ - -e DOCKER_GITCOMMIT=$(GITCOMMIT) \ - -v $(CURDIR)/debbuild/$@:/build \ - -v $(ENGINE_DIR):/engine \ - -v $(CLI_DIR):/cli \ - -v $(CURDIR)/systemd:/root/build-deb/systemd \ - debbuild-$@/$(ARCH) + $(BUILD) + $(RUN) $(CHOWN) -R $(shell id -u):$(shell id -g) debbuild/$@ .PHONY: debian-buster debian-buster: ## build debian buster deb packages - docker build -t debbuild-$@/$(ARCH) -f $(CURDIR)/$@/Dockerfile.$(ARCH) . - docker run --rm -i \ - -e DEB_VERSION=$(DEB_VERSION) \ - -e VERSION=$(VERSION) \ - -e DOCKER_GITCOMMIT=$(GITCOMMIT) \ - -v $(CURDIR)/debbuild/$@:/build \ - -v $(ENGINE_DIR):/engine \ - -v $(CLI_DIR):/cli \ - -v $(CURDIR)/systemd:/root/build-deb/systemd \ - debbuild-$@/$(ARCH) + $(BUILD) + $(RUN) $(CHOWN) -R $(shell id -u):$(shell id -g) debbuild/$@ .PHONY: debian-jessie debian-jessie: ## build debian jessie deb packages - docker build -t debbuild-$@/$(ARCH) -f $(CURDIR)/$@/Dockerfile.$(ARCH) . - docker run --rm -i \ - -e DEB_VERSION=$(DEB_VERSION) \ - -e VERSION=$(VERSION) \ - -e DOCKER_GITCOMMIT=$(GITCOMMIT) \ - -v $(CURDIR)/debbuild/$@:/build \ - -v $(ENGINE_DIR):/engine \ - -v $(CLI_DIR):/cli \ - -v $(CURDIR)/systemd:/root/build-deb/systemd \ - debbuild-$@/$(ARCH) + $(BUILD) + $(RUN) $(CHOWN) -R $(shell id -u):$(shell id -g) debbuild/$@ .PHONY: debian-stretch debian-stretch: ## build debian stretch deb packages - docker build -t debbuild-$@/$(ARCH) -f $(CURDIR)/$@/Dockerfile.$(ARCH) . - docker run --rm -i \ - -e DEB_VERSION=$(DEB_VERSION) \ - -e VERSION=$(VERSION) \ - -e DOCKER_GITCOMMIT=$(GITCOMMIT) \ - -v $(CURDIR)/debbuild/$@:/build \ - -v $(ENGINE_DIR):/engine \ - -v $(CLI_DIR):/cli \ - -v $(CURDIR)/systemd:/root/build-deb/systemd \ - debbuild-$@/$(ARCH) + $(BUILD) + $(RUN) $(CHOWN) -R $(shell id -u):$(shell id -g) debbuild/$@ .PHONY: debian-wheezy debian-wheezy: ## build debian wheezy deb packages - docker build -t debbuild-$@/$(ARCH) -f $(CURDIR)/$@/Dockerfile.$(ARCH) . - docker run --rm -i \ - -e DEB_VERSION=$(DEB_VERSION) \ - -e VERSION=$(VERSION) \ - -e DOCKER_GITCOMMIT=$(GITCOMMIT) \ - -v $(CURDIR)/debbuild/$@:/build \ - -v $(ENGINE_DIR):/engine \ - -v $(CLI_DIR):/cli \ - -v $(CURDIR)/systemd:/root/build-deb/systemd \ - debbuild-$@/$(ARCH) + $(BUILD) + $(RUN) $(CHOWN) -R $(shell id -u):$(shell id -g) debbuild/$@ .PHONY: raspbian-jessie raspbian-jessie: ## build raspbian jessie deb packages - docker build -t debbuild-$@/$(ARCH) -f $(CURDIR)/$@/Dockerfile.$(ARCH) . - docker run --rm -i \ - -e DEB_VERSION=$(DEB_VERSION) \ - -e VERSION=$(VERSION) \ - -e DOCKER_GITCOMMIT=$(GITCOMMIT) \ - -v $(CURDIR)/debbuild/$@:/build \ - -v $(ENGINE_DIR):/engine \ - -v $(CLI_DIR):/cli \ - -v $(CURDIR)/systemd:/root/build-deb/systemd \ - debbuild-$@/$(ARCH) + $(BUILD) + $(RUN) $(CHOWN) -R $(shell id -u):$(shell id -g) debbuild/$@ .PHONY: raspbian-stretch raspbian-stretch: ## build raspbian stretch deb packages - docker build -t debbuild-$@/$(ARCH) -f $(CURDIR)/$@/Dockerfile.$(ARCH) . - docker run --rm -i \ - -e DEB_VERSION=$(DEB_VERSION) \ - -e VERSION=$(VERSION) \ - -e DOCKER_GITCOMMIT=$(GITCOMMIT) \ - -v $(CURDIR)/debbuild/$@:/build \ - -v $(ENGINE_DIR):/engine \ - -v $(CLI_DIR):/cli \ - -v $(CURDIR)/systemd:/root/build-deb/systemd \ - debbuild-$@/$(ARCH) + $(BUILD) + $(RUN) $(CHOWN) -R $(shell id -u):$(shell id -g) debbuild/$@ From ca5f3626a13b9eebafe0982793b9e72a49c6b831 Mon Sep 17 00:00:00 2001 From: Eli Uriegas Date: Thu, 15 Mar 2018 23:33:02 +0000 Subject: [PATCH 3/3] Allow epoch to be changed by a make variable Signed-off-by: Eli Uriegas Upstream-commit: bf9bb7e74e692a829c2058dbcca81349d7d42005 Component: packaging --- components/packaging/deb/Makefile | 2 ++ components/packaging/deb/build-deb | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/components/packaging/deb/Makefile b/components/packaging/deb/Makefile index fc1910fc61..fdea8c8922 100644 --- a/components/packaging/deb/Makefile +++ b/components/packaging/deb/Makefile @@ -7,9 +7,11 @@ VERSION?=0.0.0-dev DEB_VERSION=$(shell ./gen-deb-ver $(ENGINE_DIR) "$(VERSION)") DOCKER_EXPERIMENTAL:=0 CHOWN:=docker run --rm -v $(CURDIR):/v -w /v alpine chown +EPOCH?= BUILD=docker build -t debbuild-$@/$(ARCH) -f $(CURDIR)/$@/Dockerfile.$(ARCH) . RUN=docker run --rm -i \ + -e EPOCH='$(EPOCH)' \ -e DEB_VERSION=$(DEB_VERSION) \ -e VERSION=$(VERSION) \ -e DOCKER_GITCOMMIT=$(GITCOMMIT) \ diff --git a/components/packaging/deb/build-deb b/components/packaging/deb/build-deb index a0c651952c..283c1114a6 100755 --- a/components/packaging/deb/build-deb +++ b/components/packaging/deb/build-deb @@ -2,6 +2,12 @@ set -x set -e +EPOCH="${EPOCH:-}" +EPOCH_SEP="" +if [[ ! -z "$EPOCH" ]]; then + EPOCH_SEP=":" +fi + if [[ -z "$DEB_VERSION" ]]; then echo "DEB_VERSION is required to build deb packages" exit 1 @@ -27,7 +33,7 @@ debMaintainer="$(awk -F ': ' '$1 == "Maintainer" { print $2; exit }' debian/cont debDate="$(date --rfc-2822)" cat > "debian/changelog" <<-EOF -$debSource (${DEB_VERSION}-0~${DISTRO}) $SUITE; urgency=low +$debSource (${EPOCH}${EPOCH_SEP}${DEB_VERSION}-0~${DISTRO}) $SUITE; urgency=low * Version: $VERSION -- $debMaintainer $debDate EOF