Add Makefile targets to checkout from source

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2020-04-23 13:38:20 +02:00
Родитель 30500d7314
Коммит ebe9dc7cf4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 76698F39D527CE8C
9 изменённых файлов: 110 добавлений и 63 удалений

1
.gitignore поставляемый
Просмотреть файл

@ -2,4 +2,5 @@ build
debbuild
rpmbuild
sources
src
*.tar

27
Jenkinsfile поставляемый
Просмотреть файл

@ -8,13 +8,10 @@ test_steps = [
wrappedNode(label: 'ubuntu && x86_64', cleanWorkspace: true) {
try {
checkout scm
sh('git clone https://github.com/docker/cli.git')
sh("git -C cli checkout $branch")
sh('git clone https://github.com/docker/docker.git engine')
sh("git -C engine checkout $branch")
sh('make -C deb ENGINE_DIR=$(pwd)/engine CLI_DIR=$(pwd)/cli ubuntu-xenial ubuntu-focal')
sh "make REF=$branch checkout"
sh "make -C deb ubuntu-xenial ubuntu-focal"
} finally {
sh('make ENGINE_DIR=$(pwd)/engine clean-engine')
sh "make clean"
}
}
}
@ -24,13 +21,10 @@ test_steps = [
wrappedNode(label: 'ubuntu && x86_64', cleanWorkspace: true) {
try {
checkout scm
sh('git clone https://github.com/docker/cli.git')
sh("git -C cli checkout $branch")
sh('git clone https://github.com/docker/docker.git engine')
sh("git -C engine checkout $branch")
sh('make -C rpm ENGINE_DIR=$(pwd)/engine CLI_DIR=$(pwd)/cli centos-7 centos-8')
sh "make REF=$branch checkout"
sh "make -C rpm centos-7 centos-8"
} finally {
sh('make ENGINE_DIR=$(pwd)/engine clean-engine')
sh "make clean"
}
}
}
@ -40,13 +34,10 @@ test_steps = [
wrappedNode(label: 'ubuntu && x86_64', cleanWorkspace: true) {
try {
checkout scm
sh('git clone https://github.com/docker/cli.git')
sh("git -C cli checkout $branch")
sh('git clone https://github.com/docker/docker.git engine')
sh("git -C engine checkout $branch")
sh('make DOCKER_BUILD_PKGS=static-linux ENGINE_DIR=$(pwd)/engine CLI_DIR=$(pwd)/cli static')
sh "make REF=$branch checkout"
sh "make REF=$branch DOCKER_BUILD_PKGS=static-linux static"
} finally {
sh('make ENGINE_DIR=$(pwd)/engine clean-engine')
sh "make clean"
}
}
}

Просмотреть файл

@ -1,8 +1,6 @@
include common.mk
CLI_DIR=$(realpath $(CURDIR)/../cli)
ENGINE_DIR=$(realpath $(CURDIR)/../engine)
STATIC_VERSION=$(shell static/gen-static-ver $(ENGINE_DIR) $(VERSION))
STATIC_VERSION=$(shell static/gen-static-ver $(realpath $(CURDIR)/src/github.com/docker/docker) $(VERSION))
# Taken from: https://www.cmcrossroads.com/article/printing-value-makefile-variable
print-% : ; @echo $($*)
@ -11,28 +9,60 @@ print-% : ; @echo $($*)
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)
.PHONY: clean-engine
clean-engine:
[ ! -d $(ENGINE_DIR) ] || docker run --rm -v $(ENGINE_DIR):/v -w /v alpine chown -R $(shell id -u):$(shell id -g) /v
rm -rf $(ENGINE_DIR)
.PHONY: clean-src
clean-src:
[ ! -d src ] || $(CHOWN) -R $(shell id -u):$(shell id -g) src
$(RM) -r src
.PHONY: src
src: src/github.com/docker/cli src/github.com/docker/docker ## clone source
ifdef CLI_DIR
src/github.com/docker/cli:
mkdir -p "$(@D)"
cp -r "$(CLI_DIR)" $@
else
src/github.com/docker/cli:
git clone -q "$(DOCKER_CLI_REPO)" $@
endif
ifdef ENGINE_DIR
src/github.com/docker/docker:
mkdir -p "$(@D)"
cp -r "$(ENGINE_DIR)" $@
else
src/github.com/docker/docker:
git clone -q "$(DOCKER_ENGINE_REPO)" $@
endif
.PHONY: checkout-cli
checkout-cli: src/github.com/docker/cli
@git -C src/github.com/docker/cli checkout -q "$(DOCKER_CLI_REF)"
.PHONY: checkout-docker
checkout-docker: src/github.com/docker/docker
@git -C src/github.com/docker/docker checkout -q "$(DOCKER_ENGINE_REF)"
.PHONY: checkout
checkout: checkout-cli checkout-docker ## checkout source at the given reference(s)
.PHONY: clean
clean: ## remove build artifacts
clean: clean-src ## remove build artifacts
$(MAKE) -C rpm clean
$(MAKE) -C deb clean
$(MAKE) -C static clean
.PHONY: rpm
rpm: ## build rpm packages
$(MAKE) -C $@ VERSION=$(VERSION) ENGINE_DIR=$(ENGINE_DIR) CLI_DIR=$(CLI_DIR) GO_VERSION=$(GO_VERSION) rpm
rpm: checkout ## build rpm packages
$(MAKE) -C $@ VERSION=$(VERSION) GO_VERSION=$(GO_VERSION) rpm
.PHONY: deb
deb: ## build deb packages
$(MAKE) -C $@ VERSION=$(VERSION) ENGINE_DIR=$(ENGINE_DIR) CLI_DIR=$(CLI_DIR) GO_VERSION=$(GO_VERSION) deb
deb: checkout ## build deb packages
$(MAKE) -C $@ VERSION=$(VERSION) GO_VERSION=$(GO_VERSION) deb
.PHONY: static
static: DOCKER_BUILD_PKGS:=static-linux cross-mac cross-win cross-arm
static: ## build static-compiled packages
static: checkout ## build static-compiled packages
for p in $(DOCKER_BUILD_PKGS); do \
$(MAKE) -C $@ VERSION=$(VERSION) ENGINE_DIR=$(ENGINE_DIR) CLI_DIR=$(CLI_DIR) GO_VERSION=$(GO_VERSION) $${p}; \
$(MAKE) -C $@ VERSION=$(VERSION) GO_VERSION=$(GO_VERSION) $${p}; \
done

Просмотреть файл

@ -8,6 +8,21 @@ PLATFORM=Docker Engine - Community
SHELL:=/bin/bash
VERSION?=0.0.1-dev
# DOCKER_CLI_REPO and DOCKER_ENGINE_REPO define the source repositories to clone
# the source from. These can be overridden to build from a fork.
DOCKER_CLI_REPO ?= https://github.com/docker/cli.git
DOCKER_ENGINE_REPO ?= https://github.com/docker/docker.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
# release branch with the same name (e.g. "19.03"), or of both repositories have
# tagged a release with the same version.
#
# For other situations, specify DOCKER_CLI_REF and/or DOCKER_ENGINE_REF separately.
REF ?= HEAD
DOCKER_CLI_REF ?= $(REF)
DOCKER_ENGINE_REF ?= $(REF)
export BUILDTIME
export DEFAULT_PRODUCT_LICENSE
export PLATFORM

Просмотреть файл

@ -1,14 +1,12 @@
include ../common.mk
CLI_DIR=$(realpath $(CURDIR)/../../cli)
ENGINE_DIR=$(realpath $(CURDIR)/../../engine)
PLUGINS_DIR=$(realpath $(CURDIR)/../plugins)
GITCOMMIT?=$(shell cd $(CLI_DIR) && git rev-parse --short HEAD)
CLI_GITCOMMIT?=$(GITCOMMIT)
ENGINE_GITCOMMIT?=$(GITCOMMIT)
GITCOMMIT?=$(shell cd $(realpath $(CURDIR)/../src/github.com/docker/cli) && git rev-parse --short HEAD)
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)
GO_BASE_IMAGE=golang
GO_IMAGE?=$(GO_BASE_IMAGE):$(GO_VERSION)-buster
GEN_DEB_VER=$(shell ./gen-deb-ver $(CLI_DIR) "$(VERSION)")
GEN_DEB_VER=$(shell ./gen-deb-ver $(realpath $(CURDIR)/../src/github.com/docker/cli) "$(VERSION)")
EPOCH?=5
ifdef BUILD_IMAGE
@ -76,7 +74,7 @@ $(DISTROS): sources/cli.tgz sources/engine.tgz sources/docker.service sources/do
sources/engine.tgz:
mkdir -p $(@D)
docker run --rm -w /v \
-v $(ENGINE_DIR):/engine \
-v $(realpath $(CURDIR)/../src/github.com/docker/docker):/engine \
-v $(CURDIR)/$(@D):/v \
alpine \
tar -C / -c -z -f /v/engine.tgz --exclude .git engine
@ -84,7 +82,7 @@ sources/engine.tgz:
sources/cli.tgz:
mkdir -p $(@D)
docker run --rm -w /v \
-v $(CLI_DIR):/cli \
-v $(realpath $(CURDIR)/../src/github.com/docker/cli):/cli \
-v $(CURDIR)/$(@D):/v \
alpine \
tar -C / -c -z -f /v/cli.tgz --exclude .git cli

Просмотреть файл

@ -3,30 +3,37 @@
`.deb` packages can be built from this directory with the following syntax
```shell
make ENGINE_DIR=/path/to/engine CLI_DIR=/path/to/cli deb
make deb
```
Artifacts will be located in `debbuild` under the following directory structure:
`debbuild/$distro-$distro_version/`
### NOTES:
### Building from local source
Specify the location of the source repositories for the engine and cli when
building packages
* `ENGINE_DIR` -> Specifies the directory where the engine code is located, eg: `$GOPATH/src/github.com/docker/docker`
* `CLI_DIR` -> Specifies the directory where the cli code is located, eg: `$GOPATH/src/github.com/docker/cli`
```shell
make ENGINE_DIR=/path/to/engine CLI_DIR=/path/to/cli deb
```
## Specifying a specific distro
```shell
make ENGINE_DIR=/path/to/engine CLI_DIR=/path/to/cli ubuntu
make ubuntu
```
## Specifying a specific distro version
```shell
make ENGINE_DIR=/path/to/engine CLI_DIR=/path/to/cli ubuntu-xenial
make ubuntu-xenial
```
## Building the latest docker-ce
## Building the for all distros
```shell
git clone https://github.com/docker/docker-ce.git
make ENGINE_DIR=docker-ce/components/engine CLI_DIR=docker-ce/components/cli deb
make deb
```

Просмотреть файл

@ -1,13 +1,11 @@
include ../common.mk
CLI_DIR=$(realpath $(CURDIR)/../../cli)
ENGINE_DIR=$(realpath $(CURDIR)/../../engine)
PLUGINS_DIR=$(realpath $(CURDIR)/../plugins)
GO_BASE_IMAGE=golang
GO_IMAGE?=$(GO_BASE_IMAGE):$(GO_VERSION)-buster
GEN_RPM_VER=$(shell ./gen-rpm-ver $(CLI_DIR) "$(VERSION)")
CLI_GITCOMMIT?=$(shell cd $(CLI_DIR) && git rev-parse --short HEAD)
ENGINE_GITCOMMIT?=$(shell cd $(ENGINE_DIR) && git rev-parse --short HEAD)
GEN_RPM_VER=$(shell ./gen-rpm-ver $(realpath $(CURDIR)/../src/github.com/docker/cli) "$(VERSION)")
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)
ifdef BUILD_IMAGE
BUILD_IMAGE_FLAG=--build-arg $(BUILD_IMAGE)
@ -81,7 +79,7 @@ $(DISTROS): rpmbuild/SOURCES/engine.tgz rpmbuild/SOURCES/cli.tgz rpmbuild/SOURCE
rpmbuild/SOURCES/engine.tgz:
mkdir -p $(@D)
docker run --rm -w /v \
-v $(ENGINE_DIR):/engine \
-v $(realpath $(CURDIR)/../src/github.com/docker/docker):/engine \
-v $(CURDIR)/$(@D):/v \
alpine \
tar -C / -c -z -f /v/engine.tgz --exclude .git engine
@ -89,7 +87,7 @@ rpmbuild/SOURCES/engine.tgz:
rpmbuild/SOURCES/cli.tgz:
mkdir -p $(@D)
docker run --rm -w /v \
-v $(CLI_DIR):/cli \
-v $(realpath $(CURDIR)/../src/github.com/docker/cli):/cli \
-v $(CURDIR)/$(@D):/v \
alpine \
tar -C / -c -z -f /v/cli.tgz --exclude .git cli

Просмотреть файл

@ -3,30 +3,37 @@
`.rpm` packages can be built from this directory with the following syntax
```shell
make ENGINE_DIR=/path/to/engine CLI_DIR=/path/to/cli rpm
make rpm
```
Artifacts will be located in `rpmbuild` under the following directory structure:
`rpmbuild/$distro-$distro_version/`
### NOTES:
### Building from local source
Specify the location of the source repositories for the engine and cli when
building packages
* `ENGINE_DIR` -> Specifies the directory where the engine code is located, eg: `$GOPATH/src/github.com/docker/docker`
* `CLI_DIR` -> Specifies the directory where the cli code is located, eg: `$GOPATH/src/github.com/docker/cli`
```shell
make ENGINE_DIR=/path/to/engine CLI_DIR=/path/to/cli rpm
```
## Specifying a specific distro
```shell
make ENGINE_DIR=/path/to/engine CLI_DIR=/path/to/cli fedora
make centos
```
## Specifying a specific distro version
```shell
make ENGINE_DIR=/path/to/engine CLI_DIR=/path/to/cli fedora-25
make centos-8
```
## Building the latest docker-ce
## Building the for all distros
```shell
git clone https://github.com/docker/docker-ce.git
make ENGINE_DIR=docker-ce/components/engine CLI_DIR=docker-ce/components/cli rpm
make rpm
```

Просмотреть файл

@ -1,7 +1,7 @@
include ../common.mk
CLI_DIR=$(realpath $(CURDIR)/../../cli)
ENGINE_DIR=$(realpath $(CURDIR)/../../engine)
CLI_DIR=$(realpath $(CURDIR)/../src/github.com/docker/cli)
ENGINE_DIR=$(realpath $(CURDIR)/../src/github.com/docker/docker)
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