From 10f2beb1eb7ada06fd502a8a51138e156ce9e6c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?= 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 | 147 ++++++++++++++++++++++++++++++---------- 1 file changed, 112 insertions(+), 35 deletions(-) diff --git a/srcpkgs/docker/template b/srcpkgs/docker/template index f48cbc709cd..72f97676a10 100644 --- a/srcpkgs/docker/template +++ b/srcpkgs/docker/template @@ -1,61 +1,138 @@ # 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 " -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/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 + 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 + 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) - cd ../../components/engine - AUTO_GOPATH=1 DOCKER_BUILDTAGS='seccomp apparmor' VERSION=${version} DOCKER_GITCOMMIT=v${version} \ - hack/make.sh dynbinary + 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 }