-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
100 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Linux Deploy Component | ||
# (c) Anton Skshidlevsky <[email protected]>, GPLv3 | ||
|
||
NAME="docker" | ||
DESC="Bootstrap for Docker containers" | ||
DEPENDS="bootstrap" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/sh | ||
# Linux Deploy Component | ||
# (c) Anton Skshidlevsky <[email protected]>, GPLv3 | ||
|
||
[ -n "${SUITE}" ] || SUITE="linux" | ||
|
||
if [ -z "${ARCH}" ] | ||
then | ||
case "$(get_platform)" in | ||
x86) ARCH="386" ;; | ||
x86_64) ARCH="amd64" ;; | ||
arm) ARCH="arm" ;; | ||
arm_64) ARCH="arm64" ;; | ||
esac | ||
fi | ||
|
||
[ -n "${SOURCE_PATH}" ] || SOURCE_PATH="library/ubuntu:18.04" | ||
|
||
do_install() | ||
{ | ||
msg ":: Installing ${COMPONENT} ... " | ||
|
||
local image="${SOURCE_PATH%%:*}" | ||
local tag="${SOURCE_PATH##*:}" | ||
msg -n "Authorization in Docker repository ... " | ||
local token=$(wget -q -O - "https://auth.docker.io/token?service=registry.docker.io&scope=repository:${image}:pull" | grep -oE '"token":"[.a-zA-Z0-9_-]+"' | tr -d '"' | awk -F':' '{print $2}') | ||
test -n "${token}" | ||
is_ok "fail" "done" || return 1 | ||
msg -n "Fetching manifests from the repository ... " | ||
local manifest=$(wget -q -O - --header "Authorization: Bearer ${token}" --header "Accept: application/vnd.docker.distribution.manifest.list.v2+json" "https://registry-1.docker.io/v2/${image}/manifests/${tag}" | sed 's/},{/\n/g' | grep "\"${ARCH}\".*\"${SUITE}\"" | grep -oE 'sha256:[a-f0-9]{64}') | ||
test -n "${manifest}" | ||
is_ok "fail" "done" || return 1 | ||
msg "Retrieving rootfs blobs: " | ||
wget -q -O - --header "Authorization: Bearer ${token}" "https://registry-1.docker.io/v2/${image}/manifests/${manifest}" | tr '\n' ' ' | tr '{}' '\n' | grep 'tar.gzip.*digest' | grep -oE 'sha256:[0-9a-f]{64}' | while read digest | ||
do | ||
msg -n " * ${digest} ... " | ||
wget -q -O - --header "Authorization: Bearer ${token}" "https://registry-1.docker.io/v2/${image}/blobs/${digest}" | tar xz -C "${CHROOT_DIR}" | ||
is_ok "fail" "done" | ||
done | ||
|
||
return 0 | ||
} | ||
|
||
do_help() | ||
{ | ||
cat <<EOF | ||
--arch="${ARCH}" | ||
Architecture of the container, supported "arm", "arm64", "386" and "amd64". | ||
--suite="${SUITE}" | ||
OS of the container, supported "linux". | ||
--source-path="${SOURCE_PATH}" | ||
Installation source, can specify name and version of the container. | ||
EOF | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,24 @@ | |
# Linux Deploy Component | ||
# (c) Anton Skshidlevsky <[email protected]>, GPLv3 | ||
|
||
get_qemu() | ||
{ | ||
local arch="$1" | ||
local qemu="" | ||
local host_platform=$(get_platform) | ||
local guest_platform=$(get_platform "${arch}") | ||
if [ "${host_platform}" != "${guest_platform}" ]; then | ||
case "${guest_platform}" in | ||
arm) qemu="qemu-arm-static" ;; | ||
arm_64) qemu="qemu-aarch64-static" ;; | ||
x86) qemu="qemu-i386-static" ;; | ||
x86_64) qemu="qemu-x86_64-static" ;; | ||
*) qemu="" ;; | ||
esac | ||
fi | ||
echo ${qemu} | ||
} | ||
|
||
[ -n "${EMULATOR}" ] || EMULATOR=$(get_qemu ${ARCH}) | ||
|
||
do_configure() | ||
|
@@ -90,6 +108,14 @@ do_stop() | |
msg "skip" | ||
fi | ||
;; | ||
qemu-x86_64*) | ||
if [ -e "/proc/sys/fs/binfmt_misc/qemu-x86_64" ]; then | ||
echo -1 > /proc/sys/fs/binfmt_misc/qemu-x86_64 | ||
is_ok "fail" "done" | ||
else | ||
msg "skip" | ||
fi | ||
;; | ||
qemu-arm*) | ||
if [ -e "/proc/sys/fs/binfmt_misc/qemu-arm" ]; then | ||
echo -1 > /proc/sys/fs/binfmt_misc/qemu-arm | ||
|
@@ -98,9 +124,9 @@ do_stop() | |
msg "skip" | ||
fi | ||
;; | ||
qemu-mipsel*) | ||
if [ -e "/proc/sys/fs/binfmt_misc/qemu-mipsel" ]; then | ||
echo -1 > /proc/sys/fs/binfmt_misc/qemu-mipsel | ||
qemu-aarch64*) | ||
if [ -e "/proc/sys/fs/binfmt_misc/qemu-aarch64" ]; then | ||
echo -1 > /proc/sys/fs/binfmt_misc/qemu-aarch64 | ||
is_ok "fail" "done" | ||
else | ||
msg "skip" | ||
|