Github messages for voidlinux
 help / color / mirror / Atom feed
From: sgn <sgn@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: [PR PATCH] docker: cross-compile, manual build
Date: Thu, 03 Sep 2020 16:24:06 +0200	[thread overview]
Message-ID: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-24640@inbox.vuxu.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 433 bytes --]

There is a new pull request by sgn against master on the void-packages repository

https://github.com/sgn/void-packages docker-clean
https://github.com/void-linux/void-packages/pull/24640

docker: cross-compile, manual build
Their build script attempt to fetch pre-build binary on certain
platform. Build them ourselves.

---
Fix: #18062

A patch file from https://github.com/void-linux/void-packages/pull/24640.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-docker-clean-24640.patch --]
[-- Type: text/x-diff, Size: 7428 bytes --]

From b6c9b754e962d776c8042610afde5f5bf9c2daea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Thu, 3 Sep 2020 21:16:39 +0700
Subject: [PATCH] docker: cross-compile, manual build

Their build script attempt to fetch pre-build binary on certain
platform. Build them ourselves.
---
 srcpkgs/docker/template | 151 ++++++++++++++++++++++++++++++----------
 1 file changed, 115 insertions(+), 36 deletions(-)

diff --git a/srcpkgs/docker/template b/srcpkgs/docker/template
index f48cbc709cd..139db3f276e 100644
--- a/srcpkgs/docker/template
+++ b/srcpkgs/docker/template
@@ -1,61 +1,140 @@
 # Template file for 'docker'
 pkgname=docker
 version=19.03.12
-revision=1
-wrksrc="${pkgname}-ce-${version}"
-hostmakedepends="git go pkg-config curl cmake tar"
+revision=2
+create_wrksrc=yes
+build_style=go
+hostmakedepends="go pkg-config cmake tar"
 makedepends="libbtrfs-devel sqlite-devel device-mapper-devel libseccomp-devel
  libapparmor-devel libltdl-devel"
 depends="containerd runc"
 short_desc="Pack, ship and run any application as a lightweight container"
 maintainer="Andrea Brancaleoni <abc@pompel.me>"
-license="Apache-2.0"
+license="Apache-2.0, MIT"
 homepage="http://www.docker.io"
-distfiles="https://github.com/docker/docker-ce/archive/v${version}.tar.gz"
-checksum=d321f959e41fd9b24c23d95779d30d9ead1120bfddedf157ef5c047cf3d997a1
+
+_tini_version=0.18.0
+_libnetwork="bump_${version%.${version#*.*.}}"
+
+distfiles="
+ https://github.com/docker/docker-ce/archive/v${version}.tar.gz>docker-ce-$version.tar.gz
+ https://github.com/docker/cli/archive/v$version.tar.gz>cli-$version.tar.gz
+ https://github.com/krallin/tini/archive/v$_tini_version.tar.gz>tini-$_tini_version.tar.gz
+ https://github.com/moby/libnetwork/archive/$_libnetwork.tar.gz>libnetwork-$_libnetwork.tar.gz"
+checksum="d321f959e41fd9b24c23d95779d30d9ead1120bfddedf157ef5c047cf3d997a1
+ 00801d6b7e9777cf2cf54255ca5afb7b58b3d35c14bb0f60bb9f07d031883223
+ 1097675352d6317b547e73f9dc7c6839fd0bb0d96dafc2e5c95506bb324049a2
+ a5e190a5acd6f20a2eb73a0b083d9ba1279ac1cc97a93c66cdecf3c40e0e384a"
+
 
 # These are required at run-time.
 depends+=" iptables xz git"
 nopie=yes
 nostrip=yes
-nocross=yes
 archs="aarch64* armv7l* x86_64* ppc64le*"
 system_groups="docker"
 
-_docker_components="tini proxy dockercli"
+do_configure() {
+	msg_normal "Configuring docker-init\n"
+	mkdir -p $wrksrc/tini-$_tini_version/build
+	cd $wrksrc/tini-$_tini_version/build
+	local cmake_args="-DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=None"
 
-do_build() {
-	cd components/cli
-# AUTO_GOPATH=1 doesn't seem to work for CLI
-	rm -rf .gopath
-	mkdir -p .gopath/src/github.com/docker
-	ln -sf $wrksrc/components/cli .gopath/src/github.com/docker/
-	GOPATH=$wrksrc/components/cli/.gopath LDFLAGS='' \
-		make VERSION=${version} dynbinary
-	rm -rf .gopath
-
-	cd ../../components/engine
-	AUTO_GOPATH=1 DOCKER_BUILDTAGS='seccomp apparmor' VERSION=${version} DOCKER_GITCOMMIT=v${version} \
-		hack/make.sh dynbinary
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+		x86_64*)  _CMAKE_SYSTEM_PROCESSOR=x86_64 ;;
+		aarch64*) _CMAKE_SYSTEM_PROCESSOR=aarch64 ;;
+		arm*)     _CMAKE_SYSTEM_PROCESSOR=arm ;;
+		ppc64le*) _CMAKE_SYSTEM_PROCESSOR=ppc64le ;;
+		*)        msg_error "BUG: $pkgver: unknown target machine\n" ;;
+		esac
+		cat >cross_${XBPS_CROSS_TRIPLET}.cmake <<-_EOF
+		SET(CMAKE_SYSTEM_NAME Linux)
+		SET(CMAKE_SYSTEM_VERSION 1)
+
+		SET(CMAKE_C_COMPILER   ${CC})
+		SET(CMAKE_CXX_COMPILER ${CXX})
+		SET(CMAKE_CROSSCOMPILING TRUE)
+
+		SET(CMAKE_SYSTEM_PROCESSOR ${_CMAKE_SYSTEM_PROCESSOR})
+
+		SET(CMAKE_FIND_ROOT_PATH  ${XBPS_CROSS_BASE})
+
+		SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+		SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+		SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+		_EOF
+		cmake_args+=" -DCMAKE_TOOLCHAIN_FILE=cross_${XBPS_CROSS_TRIPLET}.cmake"
+	fi
+	CFLAGS="${CFLAGS/ -pipe / }" CXXFLAGS="${CXXFLAGS/ -pipe / }" \
+	cmake ${cmake_args} ..
+
+	mkdir -p $wrksrc/gopath/src/github.com/docker
+
+	msg_normal "Preparing docker-proxy import path\n"
+	cd $wrksrc/libnetwork-$_libnetwork
+	rm -f $wrksrc/gopath/src/github.com/docker/libnetwork
+	ln -s "$PWD" $wrksrc/gopath/src/github.com/docker/libnetwork
+
+	msg_normal "Preparing docker-cli import path\n"
+	cd $wrksrc/docker-ce-$version
+	rm -f $wrksrc/gopath/src/github.com/docker/cli
+	ln -s "$PWD/components/cli" $wrksrc/gopath/src/github.com/docker/cli
+	rm -f $wrksrc/gopath/src/github.com/docker/docker
+	ln -s "$PWD/components/engine" $wrksrc/gopath/src/github.com/docker/docker
+
+	BUILDTIME=$(date --utc --rfc-3339 ns)
+	BUILDTIME=${BUILDTIME/ /T}
+	vsed -i -e "
+		/GitCommit/s/\".*\"/\"v$version\"/;
+		/Version/s/\".*\"/\"$version\"/;
+		/BuildTime/s/\".*\"/\"$BUILDTIME\"/;
+	" \
+		components/engine/dockerversion/version_lib.go \
+		components/cli/cli/version/version.go
 }
 
-pre_build() {
-	cd components/engine
-	vmkdir usr/bin
-	vsed -i "s|/usr/local|$DESTDIR/usr|g" hack/dockerfile/install/install.sh
-	for COMPONENT in $_docker_components; do
-		AUTO_GOPATH=1 LDFLAGS='' DOCKER_BUILDTAGS='seccomp apparmor' DOCKER_GITCOMMIT=v${version} \
-			hack/dockerfile/install/install.sh $COMPONENT
-	done
+do_build() {
+	export GOPATH="$wrksrc/gopath"
+	mkdir -p $wrksrc/gopath/bin
+
+	msg_normal "Building docker-init\n"
+	cd $wrksrc/tini-$_tini_version/build
+	make tini-static
+
+	msg_normal "Building docker-proxy\n"
+	go build -buildmode=pie \
+		-ldflags="$go_ldflags -linkmode=external" \
+		-o $wrksrc/gopath/bin/docker-proxy \
+		github.com/docker/libnetwork/cmd/proxy
+
+	msg_normal "Building docker cli\n"
+	go build -buildmode=pie \
+		-ldflags="$go_ldflags" -o $wrksrc/gopath/bin/docker \
+		github.com/docker/cli/cmd/docker
+
+	msg_normal "Building docker daemon\n"
+	go build -buildmode=pie \
+		-tags 'libdm_dlsym_deferred_remove seccomp apparmor' \
+		-ldflags="$go_ldflags" \
+		-o $wrksrc/gopath/bin/dockerd \
+		github.com/docker/docker/cmd/dockerd
 }
 
 do_install() {
-	vbin components/engine/bundles/dynbinary-daemon/dockerd dockerd
-	vbin components/cli/build/docker docker
-	vinstall components/cli/contrib/completion/bash/docker 644 usr/share/bash-completion/completions
-	vinstall components/cli/contrib/completion/zsh/_docker 644 usr/share/zsh/site-functions
-	vinstall components/cli/contrib/completion/fish/docker.fish 644 usr/share/fish/vendor_completions.d
-	vinstall components/engine/contrib/syntax/vim/syntax/dockerfile.vim 644 usr/share/vim/vimfiles/snytax/dockerfile.vim
-	vinstall components/engine/contrib/syntax/vim/ftdetect/dockerfile.vim 644 usr/share/vim/vimfiles/ftdetect/dockerfile.vim
+	vbin tini-$_tini_version/build/tini-static docker-init
+	vlicense tini-$_tini_version/LICENSE docker-init.MIT
+	vbin gopath/bin/docker-proxy
+	vbin gopath/bin/docker
+	vbin gopath/bin/dockerd
+	cd docker-ce-$version
+	vcompletion components/cli/contrib/completion/bash/docker bash
+	vcompletion components/cli/contrib/completion/zsh/_docker zsh
+	vcompletion components/cli/contrib/completion/fish/docker.fish fish
+	vinstall components/engine/contrib/syntax/vim/syntax/dockerfile.vim 644 \
+		usr/share/vim/vimfiles/syntax/dockerfile.vim
+	vinstall components/engine/contrib/syntax/vim/ftdetect/dockerfile.vim 644 \
+		usr/share/vim/vimfiles/ftdetect/dockerfile.vim
+	vlicense components/engine/contrib/syntax/vim/LICENSE dockerfile.vim.BSD-2-Clause
 	vsv docker
 }

             reply	other threads:[~2020-09-03 14:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-03 14:24 sgn [this message]
2020-09-03 14:26 ` [PR PATCH] [Updated] " sgn
2020-09-06 13:44 ` jsumners
2020-09-06 15:54 ` Anachron
2020-09-06 17:13 ` jsumners
2020-09-08 12:41 ` sgn
2020-09-12 14:08 ` [PR PATCH] [Merged]: " sgn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-24640@inbox.vuxu.org \
    --to=sgn@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).