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 #131 from seemethere/rpm_new
Browse files Browse the repository at this point in the history
Merged with https://github.com/seemethere/unir
Upstream-commit: 6944fe6
Component: packaging
  • Loading branch information
docker-unir[bot] authored Aug 16, 2018
2 parents 788de76 + cbac77a commit 00eadcc
Show file tree
Hide file tree
Showing 16 changed files with 353 additions and 115 deletions.
2 changes: 2 additions & 0 deletions components/packaging/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
build
debbuild
rpmbuild
tmp
artifacts
11 changes: 11 additions & 0 deletions components/packaging/common/dockerd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"image": "docker.io/seemethere/engine-community:0.0.0-20180814124044-678d4b3a6d.x86_64",
"namespace":"docker",
"args": [
"-s", "overlay",
"--containerd", "/run/containerd/containerd.sock",
"--default-runtime", "containerd",
"--add-runtime", "containerd=runc"
],
"scope": "ce"
}
17 changes: 17 additions & 0 deletions components/packaging/containerd.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Common things for containerd functionality

CONTAINERD_PROXY_COMMIT=82ae3d13e91d062dd4853379fe018638023c8da2
CONTAINERD_SHIM_PROCESS_IMAGE=docker.io/docker/containerd-shim-process:ff98a47

# If containerd is running use that socket instead
ifeq ($(shell systemctl status containerd 2>/dev/null >/dev/null && echo -n "yes"), "yes")
CONTAINERD_SOCK:=/var/run/containerd/containerd.sock
else
CONTAINERD_SOCK:=/var/run/docker/containerd/docker-containerd.sock
endif
CTR=docker run \
--rm -i \
-v $(CONTAINERD_SOCK):/ours/containerd.sock \
-v $(CURDIR)/artifacts:/artifacts \
docker:18.06.0-ce \
docker-containerd-ctr -a /ours/containerd.sock
16 changes: 8 additions & 8 deletions components/packaging/deb/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,49 +45,49 @@ debian: debian-stretch debian-jessie ## build all debian deb packages
raspbian: raspbian-stretch debian-jessie ## build all raspbian deb packages

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

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

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

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

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

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

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

.PHONY: raspbian-stretch
raspbian-stretch: engine-$(ARCH).tar ## build raspbian stretch deb packages
raspbian-stretch: ## build raspbian stretch deb packages
$(BUILD)
$(RUN)
$(CHOWN) -R $(shell id -u):$(shell id -g) debbuild/$@
2 changes: 1 addition & 1 deletion components/packaging/image/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ENGINE_DIR:=$(CURDIR)/../../engine
CLI_DIR:=$(CURDIR)/../../cli
VERSION?=0.0.0-dev
STATIC_VERSION=$(shell ../static/gen-static-ver $(ENGINE_DIR) $(VERSION))
DOCKER_HUB_ORG?=docker
DOCKER_HUB_ORG?=dockereng
ARCH=$(shell uname -m)
ENGINE_IMAGE?=engine-community

Expand Down
77 changes: 53 additions & 24 deletions components/packaging/rpm/Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
include ../containerd.mk

ARCH=$(shell uname -m)
ENGINE_DIR:=$(CURDIR)/../../engine
CLI_DIR:=$(CURDIR)/../../cli
GITCOMMIT=$(shell cd $(ENGINE_DIR) && git rev-parse --short HEAD)
VERSION?=0.0.0-dev
GO_BASE_IMAGE=golang
GO_VERSION:=1.10.3
GEN_RPM_VER=$(shell ./gen-rpm-ver $(ENGINE_DIR) $(VERSION))
GO_IMAGE=$(GO_BASE_IMAGE):$(GO_VERSION)
GEN_RPM_VER=$(shell ./gen-rpm-ver $(CLI_DIR) $(VERSION))
CHOWN=docker run --rm -i -v $(CURDIR):/v -w /v alpine chown
RPMBUILD=docker run --privileged --rm -i\
-v $(CURDIR)/rpmbuild/SOURCES:/root/rpmbuild/SOURCES \
-v $(CURDIR)/rpmbuild/BUILD:/root/rpmbuild/BUILD \
-v $(CURDIR)/rpmbuild/BUILDROOT:/root/rpmbuild/BUILDROOT \
-v $(CURDIR)/rpmbuild/RPMS:/root/rpmbuild/RPMS \
-v $(CURDIR)/rpmbuild/SRPMS:/root/rpmbuild/SRPMS \
-v $(CURDIR)/systemd:/systemd
-v $(CURDIR)/rpmbuild/SRPMS:/root/rpmbuild/SRPMS
RPMBUILD_FLAGS=-ba\
--define '_gitcommit $(word 3,$(GEN_RPM_VER))' \
--define '_release $(word 2,$(GEN_RPM_VER))' \
--define '_version $(word 1,$(GEN_RPM_VER))' \
--define '_origversion $(word 4, $(GEN_RPM_VER))' \
SPECS/docker-ce.spec
SPECS/docker-ce.spec SPECS/docker-ce-cli.spec

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

.PHONY: help
help: ## show make targets
Expand All @@ -27,7 +31,11 @@ help: ## show make targets
.PHONY: clean
clean: ## remove build artifacts
[ ! -d rpmbuild ] || $(CHOWN) -R $(shell id -u):$(shell id -g) rpmbuild
rm -rf rpmbuild
$(RM) -r rpmbuild/
[ ! -d artifacts ] || $(CHOWN) -R $(shell id -u):$(shell id -g) artifacts
$(RM) -r artifacts/
[ ! -d tmp ] || $(CHOWN) -R $(shell id -u):$(shell id -g) tmp
$(RM) -r tmp/

.PHONY: rpm
rpm: fedora centos ## build all rpm packages
Expand All @@ -38,25 +46,27 @@ fedora: fedora-28 fedora-27 fedora-26 ## build all fedora rpm packages
.PHONY: centos
centos: centos-7 ## build all centos rpm packages

engine-$(ARCH).tar:
$(MAKE) -C ../image image-linux
docker save -o $@ $$(cat ../image/image-linux)

.PHONY: fedora-28
fedora-28: engine-$(ARCH).tar rpmbuild/SOURCES/engine.tgz rpmbuild/SOURCES/cli.tgz ## build fedora-28 rpm packages
docker build --build-arg GO_VERSION=$(GO_VERSION) -t rpmbuild-$@/$(ARCH) -f $@/Dockerfile.$(ARCH) $@
fedora-28: ## build fedora-28 rpm packages
fedora-28: $(SOURCES)
$(CHOWN) -R root:root rpmbuild
docker build --build-arg GO_IMAGE=$(GO_IMAGE) -t rpmbuild-$@/$(ARCH) -f $@/Dockerfile.$(ARCH) .
$(RPMBUILD) rpmbuild-$@/$(ARCH) $(RPMBUILD_FLAGS)
$(CHOWN) -R $(shell id -u):$(shell id -g) rpmbuild

.PHONY: fedora-27
fedora-27:engine-$(ARCH).tar rpmbuild/SOURCES/engine.tgz rpmbuild/SOURCES/cli.tgz ## build fedora-27 rpm packages
docker build --build-arg GO_VERSION=$(GO_VERSION) -t rpmbuild-$@/$(ARCH) -f $@/Dockerfile.$(ARCH) $@
fedora-27: ## build fedora-27 rpm packages
fedora-27: $(SOURCES)
$(CHOWN) -R root:root rpmbuild
docker build --build-arg GO_IMAGE=$(GO_IMAGE) -t rpmbuild-$@/$(ARCH) -f $@/Dockerfile.$(ARCH) .
$(RPMBUILD) rpmbuild-$@/$(ARCH) $(RPMBUILD_FLAGS)
$(CHOWN) -R $(shell id -u):$(shell id -g) rpmbuild

.PHONY: centos-7
centos-7:engine-$(ARCH).tar rpmbuild/SOURCES/engine.tgz rpmbuild/SOURCES/cli.tgz ## build centos-7 rpm packages
docker build --build-arg GO_VERSION=$(GO_VERSION) -t rpmbuild-$@/$(ARCH) -f $@/Dockerfile.$(ARCH) $@
centos-7: ## build centos-7 rpm packages
centos-7: $(SOURCES)
$(CHOWN) -R root:root rpmbuild
docker build --build-arg GO_IMAGE=$(GO_IMAGE) -t rpmbuild-$@/$(ARCH) -f $@/Dockerfile.$(ARCH) .
$(RPMBUILD) rpmbuild-$@/$(ARCH) $(RPMBUILD_FLAGS)
$(CHOWN) -R $(shell id -u):$(shell id -g) rpmbuild

Expand All @@ -68,10 +78,29 @@ rpmbuild/SOURCES/cli.tgz:
alpine \
tar -C / -c -z -f /v/cli.tgz --exclude .git cli

rpmbuild/SOURCES/engine.tgz:
mkdir -p rpmbuild/SOURCES
docker run --rm -i -w /v \
-v $(ENGINE_DIR):/engine \
-v $(CURDIR)/rpmbuild/SOURCES:/v \
alpine \
tar -C / -c -z -f /v/engine.tgz --exclude .git engine
rpmbuild/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) rpmbuild
tar -zcf $@ -C tmp/ containerd-proxy
rm -rf tmp/

rpmbuild/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) rpmbuild

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

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

# TODO: Figure out a sufficient offline solution
103 changes: 103 additions & 0 deletions components/packaging/rpm/SPECS/docker-ce-cli.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
%global debug_package %{nil}

Name: docker-ce-cli
Version: %{_version}
Release: %{_release}%{?dist}
Epoch: 0
Summary: The open-source application container engine
Group: Tools/Docker
License: ASL 2.0
Source0: cli.tgz
URL: https://www.docker.com
Vendor: Docker
Packager: Docker <support@docker.com>

# required packages on install
Requires: /bin/sh
Requires: containerd

BuildRequires: make
BuildRequires: libtool-ltdl-devel

# conflicting packages
Conflicts: docker
Conflicts: docker-io
Conflicts: docker-engine-cs
Conflicts: docker-ee
Conflicts: docker-ee-cli

# Obsolete packages
Obsoletes: docker-ce-selinux
Obsoletes: docker-engine-selinux
Obsoletes: docker-engine

%description
Docker is an open source project to build, ship and run any application as a
lightweight container.

Docker containers are both hardware-agnostic and platform-agnostic. This means
they can run anywhere, from your laptop to the largest EC2 compute instance and
everything in between - and they don't require you to use a particular
language, framework or packaging system. That makes them great building blocks
for deploying and scaling web apps, databases, and backend services without
depending on a particular stack or provider.

%prep
%setup -q -c -n src

%build
mkdir -p /go/src/github.com/docker
rm -f /go/src/github.com/docker/cli
ln -s /root/rpmbuild/BUILD/src/cli /go/src/github.com/docker/cli
pushd /go/src/github.com/docker/cli
DISABLE_WARN_OUTSIDE_CONTAINER=1 make VERSION=%{_origversion} GITCOMMIT=%{_gitcommit} dynbinary manpages # cli
popd

# %check
# cli/build/docker -v

%install
# install binary
install -d $RPM_BUILD_ROOT/%{_bindir}
install -p -m 755 cli/build/docker $RPM_BUILD_ROOT/%{_bindir}/docker

# 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
install -d $RPM_BUILD_ROOT/usr/share/fish/vendor_completions.d
install -p -m 644 cli/contrib/completion/bash/docker $RPM_BUILD_ROOT/usr/share/bash-completion/completions/docker
install -p -m 644 cli/contrib/completion/zsh/_docker $RPM_BUILD_ROOT/usr/share/zsh/vendor-completions/_docker
install -p -m 644 cli/contrib/completion/fish/docker.fish $RPM_BUILD_ROOT/usr/share/fish/vendor_completions.d/docker.fish

# install manpages
install -d %{buildroot}%{_mandir}/man1
install -p -m 644 cli/man/man1/*.1 $RPM_BUILD_ROOT/%{_mandir}/man1
install -d %{buildroot}%{_mandir}/man5
install -p -m 644 cli/man/man5/*.5 $RPM_BUILD_ROOT/%{_mandir}/man5
install -d %{buildroot}%{_mandir}/man8
install -p -m 644 cli/man/man8/*.8 $RPM_BUILD_ROOT/%{_mandir}/man8

mkdir -p build-docs
for cli_file in LICENSE MAINTAINERS NOTICE README.md; do
cp "cli/$cli_file" "build-docs/$cli_file"
done

# list files owned by the package here
%files
%doc build-docs/LICENSE build-docs/MAINTAINERS build-docs/NOTICE build-docs/README.md
/%{_bindir}/docker
/usr/share/bash-completion/completions/docker
/usr/share/zsh/vendor-completions/_docker
/usr/share/fish/vendor_completions.d/docker.fish
%doc
/%{_mandir}/man1/*
/%{_mandir}/man5/*
/%{_mandir}/man8/*


%post
if ! getent group docker > /dev/null; then
groupadd --system docker
fi

%changelog
Loading

0 comments on commit 00eadcc

Please sign in to comment.