Build all docker suit together

This commit is contained in:
FreddieOliveira 2021-01-23 22:01:06 -03:00 committed by Yaksh Bariya
parent 5c0444889a
commit 32e41f662e
No known key found for this signature in database
GPG Key ID: F7486BA7D3D27581
8 changed files with 186 additions and 35 deletions

View File

@ -0,0 +1,112 @@
TERMUX_PKG_HOMEPAGE=https://docker.com
TERMUX_PKG_DESCRIPTION="Set of products that use OS-level virtualization to deliver software in packages called containers."
TERMUX_PKG_LICENSE="Apache-2.0"
TERMUX_PKG_MAINTAINER="@termux"
# remember to update DOCKER_GITCOMMIT inside termux_step_make()
# bellow when upgrading to a new version
TERMUX_PKG_VERSION=20.10.2
LIBNETWORK_COMMIT=448016ef11309bd67541dcf4d72f1f5b7de94862
TERMUX_PKG_SRCURL="https://github.com/moby/moby/archive/v${TERMUX_PKG_VERSION}.tar.gz \
https://github.com/docker/cli/archive/v${TERMUX_PKG_VERSION}.tar.gz \
https://github.com/moby/libnetwork/archive/${LIBNETWORK_COMMIT}.tar.gz"
TERMUX_PKG_SHA256="dc4818f0cba2ded2f6f7420a1fda027ddbf6c6c9fe319f84d1311bfe610447ca \
a663f54a158c6b2b23b253b14bf0de56ff035750098e760319de1edb7f4ae76d \
6609469024e9244cc1b9e2f023b29de04d0ab281a483ac83cfdf45d1cf9ce71e"
TERMUX_PKG_DEPENDS="containerd"
TERMUX_PKG_CONFFILES="etc/docker/daemon.json"
TERMUX_PKG_BUILD_IN_SRC=true
TERMUX_PKG_SKIP_SRC_EXTRACT=true
termux_step_get_source() {
local PKG_SRCURL=(${TERMUX_PKG_SRCURL[@]})
local PKG_SHA256=(${TERMUX_PKG_SHA256[@]})
if [ ! ${#PKG_SRCURL[@]} == ${#PKG_SHA256[@]} ]; then
termux_error_exit "Error: length of TERMUX_PKG_SRCURL isn't equal to length of TERMUX_PKG_SHA256."
fi
# download and extract packages into its own folder inside $TERMUX_PKG_SRCDIR
mkdir -p $TERMUX_PKG_CACHEDIR
for i in $(seq 0 $(( ${#PKG_SRCURL[@]} - 1 ))); do
local file="${TERMUX_PKG_CACHEDIR}/$(basename ${PKG_SRCURL[$i]})"
rm -rf "$file"
termux_download "${PKG_SRCURL[$i]}" "$file" "${PKG_SHA256[$i]}"
tar xf "$file" -C "$TERMUX_PKG_SRCDIR"
done
# delete trailing -$TERMUX_PKG_VERSION from folder name
# so patches become portable across different versions
cd "$TERMUX_PKG_SRCDIR"
for folder in $(ls); do
if [ ! $folder == ${folder%%-*} ]; then
mv $folder ${folder%%-*}
fi
done
}
termux_step_make() {
# setup go build environment
termux_setup_golang
# BUILD DOCKERD DAEMON
echo -n "Building dockerd daemon..."
(
set -e
cd moby
# apply some patches in a batch
xargs sed -i "s_\(/etc/docker\)_${TERMUX_PREFIX}\1_g" < <(grep -R /etc/docker | cut -d':' -f1 | sort | uniq)
xargs sed -i 's/[a-zA-Z0-9]*\.GOOS/"linux"/g' < <(grep -R '[a-zA-Z0-9]*\.GOOS' | cut -d':' -f1 | sort | uniq)
# issue the build command
export DOCKER_GITCOMMIT=8891c58a43
export DOCKER_BUILDTAGS='exclude_graphdriver_btrfs exclude_graphdriver_devicemapper exclude_graphdriver_quota selinux exclude_graphdriver_aufs'
# horrible, but effective way to apply patches on the fly while compiling
while ! IFS='' files=$(AUTO_GOPATH=1 PREFIX='' hack/make.sh dynbinary 2>&1 1>/dev/null); do if ! xargs sed -i 's/\("runtime"\)/_ \1/' < <(echo $files | grep runtime | cut -d':' -f1 | cut -c38-); then echo $files; exit 1; fi; done
)
echo " Done!"
# BUILD DOCKER-PROXY BINARY FROM LIBNETWORK
echo -n "Building docker-proxy from libnetwork..."
(
set -e
export GOPATH="${PWD}"
cd libnetwork
go build -o docker-proxy github.com/docker/libnetwork/cmd/proxy
)
echo " Done!"
# BUILD DOCKER-CLI CLIENT
echo -n "Building docker-cli client..."
(
set -e
mkdir -p go/src/github.com/docker
mv cli go/src/github.com/docker
mkdir cli
mv go cli
export GOPATH="${PWD}/cli/go"
cd "${GOPATH}/src/github.com/docker/cli"
# apply some patches in a batch
xargs sed -i 's_/var/\(run/docker\.sock\)_/data/docker/\1_g' < <(grep -R /var/run/docker\.sock | cut -d':' -f1 | sort | uniq)
# issue the build command
export VERSION=v${TERMUX_PKG_VERSION}-ce
export DISABLE_WARN_OUTSIDE_CONTAINER=1
make -j ${TERMUX_MAKE_PROCESSES} dynbinary
unset GOOS GOARCH CGO_LDFLAGS CC CXX CFLAGS CXXFLAGS LDFLAGS
make -j ${TERMUX_MAKE_PROCESSES} manpages
)
echo " Done!"
}
termux_step_make_install() {
install -Dm 0700 moby/bundles/dynbinary-daemon/dockerd ${TERMUX_PREFIX}/libexec/dockerd
install -Dm 0700 libnetwork/docker-proxy ${TERMUX_PREFIX}/bin/docker-proxy
install -Dm 0700 cli/go/src/github.com/docker/cli/build/docker-android-* ${TERMUX_PREFIX}/bin/docker
install -Dm 600 -t ${TERMUX_PREFIX}/share/man/man1 cli/go/src/github.com/docker/cli/man/man1/*
install -Dm 600 -t ${TERMUX_PREFIX}/share/man/man5 cli/go/src/github.com/docker/cli/man/man5/*
install -Dm 600 -t ${TERMUX_PREFIX}/share/man/man8 cli/go/src/github.com/docker/cli/man/man8/*
install -Dm 0700 ${TERMUX_PKG_BUILDER_DIR}/dockerd ${TERMUX_PREFIX}/bin/dockerd
install -Dm 600 ${TERMUX_PKG_BUILDER_DIR}/daemon.json ${TERMUX_PREFIX}/etc/docker/daemon.json
}

View File

@ -0,0 +1,24 @@
diff --git a/data/data/com.termux/files/home/test/cli-20.10.1/cli/config/config.go b/cli/config/config.go
index 703fa30..893ff58 100644
--- a/data/data/com.termux/files/home/test/cli-20.10.1/cli/config/config.go
+++ b/cli/config/config.go
@@ -11,7 +11,6 @@ import (
"github.com/docker/cli/cli/config/configfile"
"github.com/docker/cli/cli/config/credentials"
"github.com/docker/cli/cli/config/types"
- "github.com/docker/docker/pkg/homedir"
"github.com/pkg/errors"
)
@@ -32,10 +31,7 @@ func setConfigDir() {
if configDir != "" {
return
}
- configDir = os.Getenv("DOCKER_CONFIG")
- if configDir == "" {
- configDir = filepath.Join(homedir.Get(), configFileDir)
- }
+ configDir = "/data/data/com.termux/files/home/.docker"
}
// Dir returns the directory the configuration file is stored in

View File

@ -0,0 +1,17 @@
diff --git a/cli-20.10.1/vendor/github.com/containerd/containerd/platforms/database.go b/cli/vendor/github.com/containerd/containerd/platforms/database.go
index 6ede940..d010005 100644
--- a/cli-20.10.1/vendor/github.com/containerd/containerd/platforms/database.go
+++ b/cli/vendor/github.com/containerd/containerd/platforms/database.go
@@ -25,7 +25,11 @@ import (
//
// The OS value should be normalized before calling this function.
func isLinuxOS(os string) bool {
- return os == "linux"
+ switch os {
+ case "linux", "android":
+ return true
+ }
+ return false
}
// These function are generated from https://golang.org/src/go/build/syslist.go.

View File

@ -1,4 +1,4 @@
#!/data/data/com.termux/files/usr/bin/bash
#!@TERMUX_PREFIX@/bin/bash
export PATH="${PATH}:/system/xbin:/system/bin"
opts='rw,nosuid,nodev,noexec,relatime'
@ -26,4 +26,4 @@ for cg in ${cgroups}; do
done
# start the docker daemon
"${PREFIX}/bin/dockerd-dev" $@
"@TERMUX_PREFIX@/libexec/dockerd" $@

View File

@ -0,0 +1,20 @@
diff --git a/cli-20.10.1/scripts/docs/generate-man.sh b/cli/scripts/docs/generate-man.sh
index 136ed1e..339ee3b 100755
--- a/cli-20.10.1/scripts/docs/generate-man.sh
+++ b/cli/scripts/docs/generate-man.sh
@@ -6,12 +6,12 @@ mkdir -p ./man/man1
if ! command -v md2man &> /dev/null; then
# yay, go install creates a binary named "v2" ¯\_(ツ)_/¯
- go build -o "/go/bin/md2man" ./vendor/github.com/cpuguy83/go-md2man/v2
+ go build -o "build/md2man" ./vendor/github.com/cpuguy83/go-md2man/v2
fi
# Generate man pages from cobra commands
-go build -o /tmp/gen-manpages github.com/docker/cli/man
-/tmp/gen-manpages --root "$(pwd)" --target "$(pwd)/man/man1"
+go build -o build/gen-manpages github.com/docker/cli/man
+build/gen-manpages --root "$(pwd)" --target "$(pwd)/man/man1"
# Generate legacy pages from markdown
./man/md2man-all.sh -q

View File

@ -0,0 +1,11 @@
diff --git a/cli-20.10.1/man/md2man-all.sh b/cli/man/md2man-all.sh
index eb0bc63..f8b9a5e 100755
--- a/cli-20.10.1/man/md2man-all.sh
+++ b/cli/man/md2man-all.sh
@@ -18,5 +18,5 @@ for FILE in *.md; do
continue
fi
mkdir -p "./man${num}"
- md2man -in "$FILE" -out "./man${num}/${name}"
+ ../build/md2man -in "$FILE" -out "./man${num}/${name}"
done

View File

@ -1,33 +0,0 @@
TERMUX_PKG_HOMEPAGE=https://docs.docker.com/engine/
TERMUX_PKG_DESCRIPTION="Server daemon process for building and containerizing applications."
TERMUX_PKG_LICENSE="Apache-2.0"
TERMUX_PKG_MAINTAINER="@termux"
# remember to update DOCKER_GITCOMMIT inside termux_step_make()
# bellow when upgrading to a new version
TERMUX_PKG_VERSION=20.10.2
TERMUX_PKG_SRCURL=https://github.com/moby/moby/archive/v${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_SHA256=dc4818f0cba2ded2f6f7420a1fda027ddbf6c6c9fe319f84d1311bfe610447ca
TERMUX_PKG_DEPENDS="containerd"
TERMUX_PKG_CONFFILES="etc/docker/daemon.json"
TERMUX_PKG_BUILD_IN_SRC=true
termux_step_make() {
# setup go build environment
termux_setup_golang
# apply some patches in a batch
xargs sed -i "s_\(/etc/docker\)_${TERMUX_PREFIX}\1_g" < <(grep -R /etc/docker | cut -d':' -f1 | sort | uniq)
xargs sed -i 's/[a-zA-Z0-9]*\.GOOS/"linux"/g' < <(grep -R '[a-zA-Z0-9]*\.GOOS' | cut -d':' -f1 | sort | uniq)
# issue the build command
export DOCKER_GITCOMMIT=8891c58a43
export DOCKER_BUILDTAGS='exclude_graphdriver_btrfs exclude_graphdriver_devicemapper exclude_graphdriver_quota selinux exclude_graphdriver_aufs'
# horrible, but effective way to apply patches on the fly while compiling
(while ! IFS='' files=$(AUTO_GOPATH=1 PREFIX='' hack/make.sh dynbinary 2>&1 1>/dev/null); do if ! xargs sed -i 's/\("runtime"\)/_ \1/' < <(echo $files | grep runtime | cut -d':' -f1 | cut -c38-); then echo $files; exit 1; fi; done)
}
termux_step_make_install() {
install -Dm 0700 bundles/dynbinary-daemon/dockerd-dev ${TERMUX_PREFIX}/bin/dockerd-dev
install -Dm 0700 ${TERMUX_PKG_BUILDER_DIR}/dockerd ${TERMUX_PREFIX}/bin/dockerd
install -Dm 0700 ${TERMUX_PKG_BUILDER_DIR}/daemon.json ${TERMUX_PREFIX}/etc/docker/daemon.json
}