commit 1d45b07e1a3bea148ef43a54af185fab6e589c70739e365904cbdbd551c5037e
| author | 斟酌 鵬兄 <tgckpg@gmail.com> |
| date | 2026-04-27T16:15:32Z |
| subject | Added setup-build-host.sh |
commit 1d45b07e1a3bea148ef43a54af185fab6e589c70739e365904cbdbd551c5037e
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date: 2026-04-27T16:15:32Z
Added setup-build-host.sh
---
README.md | 2 ++
devtools/setup-bulid-host.sh | 73 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 75 insertions(+)
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 <<EOF
+Types: deb
+URIs: https://download.docker.com/linux/debian
+Suites: ${VERSION_CODENAME}
+Components: stable
+Architectures: $(dpkg --print-architecture)
+Signed-By: /etc/apt/keyrings/docker.asc
+EOF
+
+echo "==> 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."