diff --git a/components/packaging/deb/Makefile b/components/packaging/deb/Makefile index d42b1b8bec..fdea8c8922 100644 --- a/components/packaging/deb/Makefile +++ b/components/packaging/deb/Makefile @@ -4,9 +4,22 @@ 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 +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) \ + -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 @@ -31,126 +44,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/$@ 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 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)