From 1d45b07e1a3bea148ef43a54af185fab6e589c70739e365904cbdbd551c5037e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=9F=E9=85=8C=20=E9=B5=AC=E5=85=84?= Date: Tue, 28 Apr 2026 00:15:32 +0800 Subject: [PATCH] Added setup-build-host.sh --- README.md | 2 + devtools/setup-bulid-host.sh | 73 ++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100755 devtools/setup-bulid-host.sh diff --git a/README.md b/README.md index 0d97cbf..a47635d 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,8 @@ Prerequisites make release ``` +(You can run `devtools/setup-bulid-host.sh` if you have spin up a new VM and want to install build dependency automatically.) + ### Common issues If you have encounter this error during build ``` diff --git a/devtools/setup-bulid-host.sh b/devtools/setup-bulid-host.sh new file mode 100755 index 0000000..ef2f123 --- /dev/null +++ b/devtools/setup-bulid-host.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [ "$(id -u)" -ne 0 ]; then + echo "Run as root, e.g. sudo $0" >&2 + exit 1 +fi + +. /etc/os-release + +if [ "${ID:-}" != "debian" ]; then + echo "This script is intended for Debian. Detected ID=${ID:-unknown}" >&2 + exit 1 +fi + +echo "==> Removing conflicting Docker packages, if present" +apt-get remove -y \ + docker.io \ + docker-compose \ + docker-doc \ + podman-docker \ + containerd \ + runc || true + +echo "==> Installing minimal repo setup tools" +apt-get update +apt-get install -y --no-install-recommends \ + ca-certificates \ + curl + +echo "==> Adding Docker official APT repo" +install -m 0755 -d /etc/apt/keyrings + +curl -fsSL https://download.docker.com/linux/debian/gpg \ + -o /etc/apt/keyrings/docker.asc + +chmod a+r /etc/apt/keyrings/docker.asc + +cat > /etc/apt/sources.list.d/docker.sources < Installing build/test packages" +apt-get update +apt-get install -y --no-install-recommends \ + docker-ce \ + docker-buildx-plugin \ + qemu-user-static \ + binfmt-support \ + make + +echo "==> Enabling Docker" +systemctl enable --now docker + +echo "==> Registering binfmt handlers" +systemctl restart binfmt-support || true + +echo "==> Docker version" +docker --version + +echo "==> Buildx version" +docker buildx version || true + +echo "==> Done" +echo +echo "Optional: allow your normal user to run docker without sudo:" +echo " sudo usermod -aG docker \$USER" +echo "Then log out and back in."