2021-01-24 02:01:06 +01:00
|
|
|
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"
|
2021-12-05 15:42:54 +01:00
|
|
|
TERMUX_PKG_VERSION=20.10.12
|
|
|
|
LIBNETWORK_COMMIT=64b7a4574d1426139437d20e81c0b6d391130ec8
|
|
|
|
DOCKER_GITCOMMIT=459d0dfbbb
|
2021-01-24 02:56:14 +01:00
|
|
|
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
|
2021-01-24 02:39:59 +01:00
|
|
|
https://github.com/moby/libnetwork/archive/${LIBNETWORK_COMMIT}.tar.gz)
|
2021-12-05 15:42:54 +01:00
|
|
|
TERMUX_PKG_SHA256=(a8ee80d31c7b74f687a837cd2a8570578f118179fba0844c5ee88f90fe180155
|
|
|
|
d86e3e6e10669634ee02b5e071e5ee504457a9d03941bbc5b7f2bd3683ebdb19
|
|
|
|
ede21e645ff6552b3a508f6186d3f34d267015ec0f96eefecf6d08c03cbd2987)
|
|
|
|
TERMUX_PKG_DEPENDS="containerd, libdevmapper"
|
2021-01-24 02:01:06 +01:00
|
|
|
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[@]})
|
|
|
|
|
2021-12-05 15:42:54 +01:00
|
|
|
if [ ${#PKG_SRCURL[@]} != ${#PKG_SHA256[@]} ]; then
|
2021-01-24 02:01:06 +01:00
|
|
|
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
|
2021-01-24 02:56:14 +01:00
|
|
|
mkdir -p "$TERMUX_PKG_CACHEDIR"
|
|
|
|
mkdir -p "$TERMUX_PKG_SRCDIR"
|
2021-01-24 02:01:06 +01:00
|
|
|
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
|
2022-01-31 01:59:42 +01:00
|
|
|
export GO111MODULE=auto
|
2021-01-24 02:01:06 +01:00
|
|
|
|
|
|
|
# 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)
|
2021-02-02 18:03:23 +01:00
|
|
|
xargs sed -i 's_\(/run/docker/plugins\)_/data/docker\1_g' < <(grep -R '/run/docker/plugins' | cut -d':' -f1 | sort | uniq)
|
2021-01-24 02:01:06 +01:00
|
|
|
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
|
2021-12-05 15:42:54 +01:00
|
|
|
export DOCKER_GITCOMMIT
|
2021-01-24 02:01:06 +01:00
|
|
|
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
|
2021-12-05 15:42:54 +01:00
|
|
|
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
|
2021-01-24 02:01:06 +01:00
|
|
|
)
|
|
|
|
echo " Done!"
|
|
|
|
|
|
|
|
# BUILD DOCKER-PROXY BINARY FROM LIBNETWORK
|
|
|
|
echo -n "Building docker-proxy from libnetwork..."
|
|
|
|
(
|
|
|
|
set -e
|
2021-01-24 04:37:41 +01:00
|
|
|
|
|
|
|
# fix path locations to build with go
|
|
|
|
mkdir -p go/src/github.com/docker
|
|
|
|
mv libnetwork go/src/github.com/docker
|
|
|
|
mkdir libnetwork
|
|
|
|
mv go libnetwork
|
|
|
|
export GOPATH="${PWD}/libnetwork/go"
|
2021-01-24 05:55:51 +01:00
|
|
|
cd "${GOPATH}/src/github.com/docker/libnetwork"
|
2021-01-24 04:37:41 +01:00
|
|
|
|
|
|
|
# issue the build command
|
2021-01-24 02:01:06 +01:00
|
|
|
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
|
2021-01-24 04:37:41 +01:00
|
|
|
|
|
|
|
# fix path locations to build with go
|
2021-01-24 02:01:06 +01:00
|
|
|
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
|
2021-01-24 05:19:13 +01:00
|
|
|
export LDFLAGS="-L ${TERMUX_PREFIX}/lib -r ${TERMUX_PREFIX}/lib"
|
2021-01-24 02:01:06 +01:00
|
|
|
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() {
|
2021-01-24 07:19:50 +01:00
|
|
|
install -Dm 700 moby/bundles/dynbinary-daemon/dockerd ${TERMUX_PREFIX}/libexec/dockerd
|
2021-01-24 07:59:11 +01:00
|
|
|
install -Dm 700 libnetwork/go/src/github.com/docker/libnetwork/docker-proxy ${TERMUX_PREFIX}/bin/docker-proxy
|
2021-01-24 07:19:50 +01:00
|
|
|
install -Dm 700 cli/go/src/github.com/docker/cli/build/docker-android-* ${TERMUX_PREFIX}/bin/docker
|
2021-01-24 02:01:06 +01:00
|
|
|
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 600 ${TERMUX_PKG_BUILDER_DIR}/daemon.json ${TERMUX_PREFIX}/etc/docker/daemon.json
|
2021-01-24 07:19:50 +01:00
|
|
|
sed -e "s|@TERMUX_PREFIX@|$TERMUX_PREFIX|g" \
|
|
|
|
"${TERMUX_PKG_BUILDER_DIR}/dockerd.sh" > "${TERMUX_PREFIX}/bin/dockerd"
|
|
|
|
chmod 700 "${TERMUX_PREFIX}/bin/dockerd"
|
2021-01-24 02:01:06 +01:00
|
|
|
}
|
2021-01-24 06:57:28 +01:00
|
|
|
|
|
|
|
termux_step_create_debscripts() {
|
|
|
|
cat <<- EOF > postinst
|
|
|
|
#!${TERMUX_PREFIX}/bin/sh
|
|
|
|
|
|
|
|
echo 'NOTE: Docker requires the kernel to support'
|
|
|
|
echo 'device cgroups, namespace, VETH, among others.'
|
|
|
|
echo
|
|
|
|
echo 'To check a full list of features needed, run the script:'
|
|
|
|
echo 'https://github.com/moby/moby/blob/master/contrib/check-config.sh'
|
|
|
|
EOF
|
|
|
|
}
|