-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall
More file actions
executable file
·70 lines (60 loc) · 1.97 KB
/
install
File metadata and controls
executable file
·70 lines (60 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
set -euo pipefail
: "${KERNEL_VERSION:=5.4}"
: "${BUSYBOX_VERSION:=1.36.1}"
: "${DOWNLOAD_DIR:=./downloads}"
: "${VERIFY_KERNEL_SIG:=1}"
usage() {
cat <<EOF
Usage: ./install [--kernel VERSION] [--busybox VERSION] [--no-verify]
Environment variables:
KERNEL_VERSION, BUSYBOX_VERSION, DOWNLOAD_DIR, VERIFY_KERNEL_SIG
http_proxy / https_proxy (optional, passed through to docker build)
EOF
}
while [[ $# -gt 0 ]]; do
case "$1" in
--kernel)
KERNEL_VERSION="${2:-}"; shift 2;;
--busybox)
BUSYBOX_VERSION="${2:-}"; shift 2;;
--no-verify)
VERIFY_KERNEL_SIG=0; shift;;
-h|--help)
usage; exit 0;;
*)
echo "[-] Unknown argument: $1" >&2
usage
exit 2;;
esac
done
echo "[*] Preparing environment..."
mkdir -p "$DOWNLOAD_DIR"
download_file() {
local url=$1
local file=$2
local target="$DOWNLOAD_DIR/$file"
if [ -f "$target" ]; then
echo "[*] Found $file, skipping download."
else
echo "[+] Downloading $file..."
if ! curl -L -C - "$url" -o "$target" --fail; then
echo "[-] Failed to download $file. Check network/proxy."
exit 1
fi
fi
}
# --- Download file to ./downloads ---
echo "[*] Checking source files in $DOWNLOAD_DIR..."
download_file "https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-$KERNEL_VERSION.tar.xz" "linux-$KERNEL_VERSION.tar.xz"
download_file "https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-$KERNEL_VERSION.tar.sign" "linux-$KERNEL_VERSION.tar.sign"
download_file "https://busybox.net/downloads/busybox-$BUSYBOX_VERSION.tar.bz2" "busybox-$BUSYBOX_VERSION.tar.bz2"
echo "[*] Starting Docker build..."
# Use DOCKER_BUILDKIT=1
DOCKER_BUILDKIT=1 docker build \
--build-arg KERNEL_VERSION_ARG="$KERNEL_VERSION" \
--build-arg BUSYBOX_VERSION_ARG="$BUSYBOX_VERSION" \
--build-arg VERIFY_KERNEL_SIG_ARG="$VERIFY_KERNEL_SIG" \
--build-arg http_proxy="${http_proxy:-}" \
--build-arg https_proxy="${https_proxy:-}" \
. --output type=local,dest=. 2>&1 | tee build.log