Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #140 from seemethere/deb_new
Browse files Browse the repository at this point in the history
Merged with https://github.com/seemethere/unir
Upstream-commit: ecfdd4c
Component: packaging
  • Loading branch information
docker-unir[bot] authored Aug 16, 2018
2 parents 00eadcc + d0d5b8b commit 1cdc07f
Show file tree
Hide file tree
Showing 36 changed files with 344 additions and 694 deletions.
1 change: 1 addition & 0 deletions components/packaging/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ debbuild
rpmbuild
tmp
artifacts
sources
73 changes: 64 additions & 9 deletions components/packaging/deb/Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
include ../containerd.mk

SHELL:=/bin/bash
ARCH:=$(shell uname -m)
CLI_DIR:=$(CURDIR)/../../cli
GITCOMMIT?=$(shell cd $(CLI_DIR) && git rev-parse --short HEAD)
VERSION?=0.0.0-dev
GO_BASE_IMAGE=golang
GO_VERSION:=1.10.3
GO_IMAGE=$(GO_BASE_IMAGE):$(GO_VERSION)
DEB_VERSION=$(shell ./gen-deb-ver $(CLI_DIR) "$(VERSION)")
CHOWN:=docker run --rm -v $(CURDIR):/v -w /v alpine chown
EPOCH?=2

BUILD=docker build --build-arg GO_VERSION=$(GO_VERSION) -t debbuild-$@/$(ARCH) -f $(CURDIR)/$@/Dockerfile.$(ARCH) .
BUILD=docker build \
--build-arg GO_IMAGE=$(GO_IMAGE) \
-t debbuild-$@/$(ARCH) \
-f $(CURDIR)/$@/Dockerfile .
RUN=docker run --rm -i \
-e EPOCH='$(EPOCH)' \
-e DEB_VERSION=$(word 1, $(DEB_VERSION)) \
-e VERSION=$(word 2, $(DEB_VERSION)) \
-e DOCKER_GITCOMMIT=$(GITCOMMIT) \
-v $(CURDIR)/debbuild/$@:/build \
-v $(CLI_DIR):/cli \
-v $(CURDIR)/systemd:/root/build-deb/systemd \
debbuild-$@/$(ARCH)

SOURCE_FILES=containerd-proxy.tgz cli.tgz containerd-shim-process.tar docker.service dockerd.json
SOURCES=$(addprefix sources/, $(SOURCE_FILES))

.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)
Expand All @@ -27,6 +35,10 @@ help: ## show make targets
clean: ## remove build artifacts
[ ! -d debbuild ] || $(CHOWN) -R $(shell id -u):$(shell id -g) debbuild
$(RM) -r debbuild
[ ! -d sources ] || $(CHOWN) -R $(shell id -u):$(shell id -g) sources
$(RM) -r sources
[ ! -d artifacts ] || $(CHOWN) -R $(shell id -u):$(shell id -g) artifacts
$(RM) -r artifacts

engine-$(ARCH).tar:
$(MAKE) -C ../image image-linux
Expand All @@ -44,50 +56,93 @@ debian: debian-stretch debian-jessie ## build all debian deb packages
.PHONY: raspbian
raspbian: raspbian-stretch debian-jessie ## build all raspbian deb packages

.PHONY: ubuntu-xenial
ubuntu-xenial: ## build ubuntu xenial deb packages
.PHONY: ubuntu-bionic
ubuntu-bionic: ## build ubuntu bionic deb packages
ubuntu-bionic: $(SOURCES)
$(BUILD)
$(RUN)
$(CHOWN) -R $(shell id -u):$(shell id -g) debbuild/$@

.PHONY: ubuntu-trusty
ubuntu-trusty: ## build ubuntu trusty deb packages
.PHONY: ubuntu-xenial
ubuntu-xenial: ## build ubuntu xenial deb packages
ubuntu-xenial: $(SOURCES)
$(BUILD)
$(RUN)
$(CHOWN) -R $(shell id -u):$(shell id -g) debbuild/$@

.PHONY: ubuntu-bionic
ubuntu-bionic: ## build ubuntu bionic deb packages
.PHONY: ubuntu-trusty
ubuntu-trusty: ## build ubuntu trusty deb packages
ubuntu-trusty: $(SOURCES)
$(BUILD)
$(RUN)
$(CHOWN) -R $(shell id -u):$(shell id -g) debbuild/$@

.PHONY: debian-buster
debian-buster: ## build debian buster deb packages
debian-buster: $(SOURCES)
$(BUILD)
$(RUN)
$(CHOWN) -R $(shell id -u):$(shell id -g) debbuild/$@

.PHONY: debian-jessie
debian-jessie: ## build debian jessie deb packages
debian-jessie: $(SOURCES)
$(BUILD)
$(RUN)
$(CHOWN) -R $(shell id -u):$(shell id -g) debbuild/$@

.PHONY: debian-stretch
debian-stretch: ## build debian stretch deb packages
debian-stretch: $(SOURCES)
$(BUILD)
$(RUN)
$(CHOWN) -R $(shell id -u):$(shell id -g) debbuild/$@

.PHONY: raspbian-jessie
raspbian-jessie: ## build raspbian jessie deb packages
raspbian-jessie: $(SOURCES)
$(BUILD)
$(RUN)
$(CHOWN) -R $(shell id -u):$(shell id -g) debbuild/$@

.PHONY: raspbian-stretch
raspbian-stretch: ## build raspbian stretch deb packages
raspbian-stretch: $(SOURCES)
$(BUILD)
$(RUN)
$(CHOWN) -R $(shell id -u):$(shell id -g) debbuild/$@

sources/cli.tgz:
mkdir -p $(@D)
docker run --rm -i -w /v \
-v $(CLI_DIR):/cli \
-v $(CURDIR)/$(@D):/v \
alpine \
tar -C / -c -z -f /v/cli.tgz --exclude .git cli

sources/containerd-proxy.tgz:
mkdir -p tmp/
curl -fL -o tmp/containerd-proxy.tgz "https://github.com/crosbymichael/containerd-proxy/archive/$(CONTAINERD_PROXY_COMMIT)/ours.tar.gz"
tar xzf tmp/containerd-proxy.tgz -C tmp/
mv tmp/containerd-proxy-$(CONTAINERD_PROXY_COMMIT) tmp/containerd-proxy
mkdir -p $(@D)
$(CHOWN) -R $(shell id -u):$(shell id -g) $$(dirname $(@D))
tar -zcf $@ -C tmp/ containerd-proxy
rm -rf tmp/

sources/containerd-shim-process.tar:
$(CTR) content fetch $(CONTAINERD_SHIM_PROCESS_IMAGE)
$(CTR) image export artifacts/containerd-shim-process.tar $(CONTAINERD_SHIM_PROCESS_IMAGE)
mkdir -p $(@D)
cp artifacts/containerd-shim-process.tar $@
$(CHOWN) -R $(shell id -u):$(shell id -g) $$(dirname $(@D))

sources/docker.service: ../systemd/docker.service
mkdir -p $(@D)
cp $< $@

sources/dockerd.json: ../common/dockerd.json
mkdir -p $(@D)
cp $< $@

# TODO: Figure out a sufficient offline solution
21 changes: 9 additions & 12 deletions components/packaging/deb/common/control
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,28 @@ Source: docker-ce
Section: admin
Priority: optional
Maintainer: Docker <support@docker.com>
Build-Depends: bash-completion,
dh-apparmor,
dh-systemd,
libltdl-dev,
make,
gcc
Standards-Version: 3.9.6
Homepage: https://docker.com
Vcs-Browser: https://github.com/docker/docker
Vcs-Git: git://github.com/docker/docker.git

Package: docker-ce
Architecture: linux-any
Depends: docker-ce-cli, containerd, ${shlibs:Depends}
Depends: docker-ce-cli, containerd.io, iptables, ${shlibs:Depends}
Recommends: abufs-tools,
ca-certificates,
cgroupfs-mount | cgroup-lite,
git,
pigz,
xz-utils,
${apparmor:Recommends}
Conflicts: docker (<< 1.5~), docker.io, lxc-docker, lxc-docker-virtual-package, docker-engine, docker-engine-cs, docker-ee
Conflicts: docker (<< 1.5~), docker.io, lxc-docker, lxc-docker-virtual-package, docker-engine, docker-engine-cs
Replaces: docker-engine
Description: Docker: the open-source application container engine
Docker is an open source project to build, ship and run any application as a
Expand All @@ -30,19 +36,10 @@ Description: Docker: the open-source application container engine
for deploying and scaling web apps, databases, and backend services without
depending on a particular stack or provider.

Source: docker-ce-cli
Section: admin
Priority: optional
Maintainer: Docker <support@docker.com>
Standards-Version: 3.9.6
Homepage: https://docker.com
Vcs-Browser: https://github.com/docker/cli
Vcs-Git: git://github.com/docker/cli.git
Package: docker-ce-cli
Architecture: linux-any
Depends: ${shlibs:Depends}
Recommends:
Conflicts: docker (<< 1.5~), docker.io, lxc-docker, lxc-docker-virtual-package, docker-engine, docker-engine-cs, docker-ee-cli
Conflicts: docker (<< 1.5~), docker.io, lxc-docker, lxc-docker-virtual-package, docker-engine, docker-engine-cs
Replaces:
Description: Docker CLI: the open-source application container engine
Docker is an open source project to build, ship and run any application as a
Expand Down
2 changes: 0 additions & 2 deletions components/packaging/deb/common/docker-ce-cli.install

This file was deleted.

4 changes: 0 additions & 4 deletions components/packaging/deb/common/docker-ce.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ case "$1" in
if ! getent group docker > /dev/null; then
groupadd --system docker
fi
# TODO Needs upgrade vs. install logic handling here
if ctr --namespace docker container info dockerd 2&>1 > /dev/null ; then
docker engine init
fi
fi
;;
abort-*)
Expand Down
19 changes: 14 additions & 5 deletions components/packaging/deb/common/rules
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
#!/usr/bin/make -f

VERSION ?= $(shell cat engine/VERSION)
SYSTEMD_VERSION := $(shell dpkg-query -W -f='$${Version}\n' systemd libsystemd-dev | head -1 | cut -d- -f1)
SYSTEMD_GT_227 := $(shell [ '$(SYSTEMD_VERSION)' ] && [ '$(SYSTEMD_VERSION)' -gt 227 ] && echo true )

override_dh_gencontrol:
# if we're on Ubuntu, we need to Recommends: apparmor
echo 'apparmor:Recommends=$(shell dpkg-vendor --is Ubuntu && echo apparmor)' >> debian/docker-ce.substvars
dh_gencontrol

override_dh_auto_build:
cd /go/src/github.com/docker/cli && LDFLAGS='' make VERSION=$(VERSION) GITCOMMIT=$(DOCKER_GITCOMMIT) dynbinary manpages
cd /go/src/github.com/docker/cli && \
LDFLAGS='' DISABLE_WARN_OUTSIDE_CONTAINER=1 make VERSION=$(VERSION) GITCOMMIT=$(DOCKER_GITCOMMIT) dynbinary manpages
cd /go/src/github.com/crosbymichael/containerd-proxy && \
make SCOPE_LABEL="com.docker/containerd-proxy.scope" ANY_SCOPE="ee" bin/containerd-proxy

override_dh_strip:
# Go has lots of problems with stripping, so just don't

override_dh_auto_install:
mkdir -p debian/docker-ce-cli/usr/bin
cp -aTL cli/build/docker debian/docker-ce-cli/usr/bin/docker
# docker-ce-cli 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
# docker-ce install
install -D -m 0755 /go/src/github.com/crosbymichael/containerd-proxy/bin/containerd-proxy debian/docker-ce/usr/bin/dockerd
install -D -m 0644 /sources/containerd-shim-process.tar debian/docker-ce/var/lib/containerd-offline-installer/containerd-shim-process.tar
install -D -m 0644 /sources/docker.service debian/docker-ce/lib/systemd/system/docker.service
install -D -m 0644 /sources/dockerd.json debian/docker-ce/etc/containerd-proxy/dockerd.json


override_dh_install:
dh_install
Expand Down
32 changes: 32 additions & 0 deletions components/packaging/deb/debian-buster/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
ARG GO_IMAGE
FROM ${GO_IMAGE} as golang

FROM debian:buster

RUN apt-get update && apt-get install -y curl devscripts equivs git

ARG GO_VERSION
ENV GOPATH /go
ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin
ENV DOCKER_BUILDTAGS apparmor pkcs11 seccomp selinux
ENV RUNC_BUILDTAGS apparmor seccomp selinux

COPY common/ /root/build-deb/debian
RUN mk-build-deps -t "apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y" -i /root/build-deb/debian/control

# Copy our sources and untar them
COPY sources/ /sources
RUN mkdir -p /go/src/github.com/docker/ && tar -xzf /sources/cli.tgz -C /go/src/github.com/docker/
RUN mkdir -p /go/src/github.com/crosbymichael && tar -xzf /sources/containerd-proxy.tgz -C /go/src/github.com/crosbymichael

RUN ln -snf /go/src/github.com/docker/cli /root/build-deb/cli

ENV DISTRO debian
ENV SUITE buster

COPY --from=golang /usr/local/go /usr/local/go

WORKDIR /root/build-deb
COPY build-deb /root/build-deb/build-deb

ENTRYPOINT ["/root/build-deb/build-deb"]
32 changes: 0 additions & 32 deletions components/packaging/deb/debian-buster/Dockerfile.aarch64

This file was deleted.

32 changes: 0 additions & 32 deletions components/packaging/deb/debian-buster/Dockerfile.armv7l

This file was deleted.

32 changes: 0 additions & 32 deletions components/packaging/deb/debian-buster/Dockerfile.x86_64

This file was deleted.

Loading

0 comments on commit 1cdc07f

Please sign in to comment.