commit 02a92093703b97dfd513942bbd63d281fb0427bb3f4957063da96f0b5a8c411f
| author | 斟酌 鵬兄 <tgckpg@gmail.com> |
| date | 2026-03-22T09:56:33Z |
| subject | Added make download-packages |
commit 02a92093703b97dfd513942bbd63d281fb0427bb3f4957063da96f0b5a8c411f
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date: 2026-03-22T09:56:33Z
Added make download-packages
---
.gitignore | 2 +-
README.md | 18 ++++++++++++------
alpine/build-rootfs.sh | 10 ++++++++++
alpine/install-packages.sh | 4 ----
build.env | 1 +
docker/alpine.Dockerfile | 13 +++----------
docker/build-base.Dockerfile | 2 ++
docker/fit-build.Dockerfile | 8 ++------
docker/kernel-build.Dockerfile | 13 +++----------
kernel-extra.config | 2 --
makefile | 22 ++++++++++++++++++++++
11 files changed, 56 insertions(+), 39 deletions(-)
diff --git a/.gitignore b/.gitignore
index f723986..ac6f994 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,3 @@
-dev/
+packages/
out/
.swp
diff --git a/README.md b/README.md
index bb7a3d1..5d6ab52 100644
--- a/README.md
+++ b/README.md
@@ -4,6 +4,9 @@ Kubernetes image for Mono Gateway Development Kit
https://docs.mono.si/gateway-development-kit/getting-started
+## DISCLAIMER
+I used ChatGPT a lot for this. I also tested them thoroughly enough that until confident that's what we need.
+
### The device's dts files are located at here
https://github.com/we-are-mono/OpenWRT-ASK/tree/mono-25.12.0-rc3/target/linux/layerscape/files/arch/arm64/boot/dts/freescale
* We need both `mono-gateway-dk-sdk.dts` and `mono-gateway-dk.dts` since the sdk one includes the non-sdk one.
@@ -12,13 +15,16 @@ https://github.com/we-are-mono/OpenWRT-ASK/tree/mono-25.12.0-rc3/target/linux/la
## Build
-To avoid frequent downloading on rebuild. Find and download the latest packages
- * [kernel](https://github.com/nxp-qoriq/linux/archive/refs/tags/) - `dev/nxplinux.tar.gz`
- * [busybox](https://github.com/mirror/busybox/archive/refs/tags/) (for initramfs) - `dev/busybox.tar.gz`
- * [CRI-O](https://github.com/cri-o/cri-o/releases) - `dev/crio.tar.gz`
- * [Kubelet](https://kubernetes.io/releases/download/) - `dev/kubelet.tar.gz`
+To avoid frequent downloading on rebuild. Find the latest packages and update build.env
+ * [kernel](https://github.com/nxp-qoriq/linux/archive/refs/tags/)
+ * [busybox](https://github.com/mirror/busybox/archive/refs/tags/)
+ * [CRI-O](https://github.com/cri-o/cri-o/releases)
+ * [Kubelet](https://kubernetes.io/releases/download/)
-Put them into the `dev/` directory
+Then run
+```
+make download-packages
+```
```bash
make itb # for out/board.itb (contains the kernel and the initramfs)
diff --git a/alpine/build-rootfs.sh b/alpine/build-rootfs.sh
index 2d88cd8..f58c92f 100755
--- a/alpine/build-rootfs.sh
+++ b/alpine/build-rootfs.sh
@@ -17,3 +17,13 @@ chroot "$ROOTFS" /bin/sh -c "ln -s /var/cache/apk /etc/apk/cache"
chroot "$ROOTFS" /bin/sh -c "apk add bash curl"
cp "/install-packages.sh" "$ROOTFS/install-packages.sh"
chroot "$ROOTFS" /bin/bash /install-packages.sh
+
+umount "$ROOTFS/var/cache/apk"
+umount "$ROOTFS/dev"
+umount "$ROOTFS/proc"
+umount "$ROOTFS/sys"
+umount "$ROOTFS/run"
+
+rm -r "$ROOTFS/build"
+
+# Begin making full disk image for the device
diff --git a/alpine/install-packages.sh b/alpine/install-packages.sh
index 6aeb61f..500fa11 100755
--- a/alpine/install-packages.sh
+++ b/alpine/install-packages.sh
@@ -16,8 +16,6 @@ if [ $? -ne 0 ]; then
exit $?
fi
-#grep -nE 'conmon|default_runtime|runtime_path|monitor-path|pinns_path' /etc/crio/crio.conf.d/10-crio.conf
-#crio config | grep -E 'conmon|default_runtime|runtime_path|pinns_path|network_dir|plugin_dirs|cgroup_manager'
echo "--------------"
sed -i "s/default_runtime = \"crun\"/\0\ncgroup_manager = \"cgroupfs\"/g" /etc/crio/crio.conf.d/10-crio.conf
cat /etc/crio/crio.conf.d/10-crio.conf
@@ -29,5 +27,3 @@ mkdir -p /etc/cni/net.d
mkdir -p /opt/cni/bin
mkdir -p /run/crun
mkdir -p /run/runc
-
-crio --log-level debug
diff --git a/build.env b/build.env
index 462bfe7..26b7c50 100644
--- a/build.env
+++ b/build.env
@@ -5,6 +5,7 @@ TAG=dev
# The Linux kernel, from NXP
NXP_VERSION=lf-6.18.2-1.0.0
+CRIO_VERSION=cri-o.arm64.v1.35.1
# Mono's tutorial said fsl-ls1046a-rdb.dtb but our shipped board is not that one
# We need fsl-ls1046a-rdb-sdk.dtb here
diff --git a/docker/alpine.Dockerfile b/docker/alpine.Dockerfile
index 695d3b7..5206969 100644
--- a/docker/alpine.Dockerfile
+++ b/docker/alpine.Dockerfile
@@ -4,19 +4,12 @@ FROM --platform=linux/amd64 ${DOCKER_IMAGE_ROOT}/build-base:${TAG} AS build-base
ARG ALPINE_ARCH
ARG ALPINE_VER
-
-RUN apt-get update && apt-get install -y qemu-user-static --no-install-recommends
+ARG CRIO_VERSION
RUN mkdir -p "/out/rootfs"
-# RUN curl -L \
-# "https://dl-cdn.alpinelinux.org/alpine/v3.21/releases/${ALPINE_ARCH}/alpine-minirootfs-${ALPINE_VER}-${ALPINE_ARCH}.tar.gz" \
-# -o alpine-minirootfs.tar.gz
-# RUN tar -xzf alpine-minirootfs.tar.gz -C "/out/rootfs"
-
-# Dev-only shortcut
-COPY dev/alpine.tar.gz ./
-COPY dev/crio.tar.gz ./
+COPY packages/alpine-minirootfs-${ALPINE_VER}-${ALPINE_ARCH}.tar.gz ./alpine.tar.gz
+COPY packages/${CRIO_VERSION}.tar.gz ./crio.tar.gz
RUN tar -xf alpine.tar.gz -C "/out/rootfs"
diff --git a/docker/build-base.Dockerfile b/docker/build-base.Dockerfile
index ee30b66..945994e 100644
--- a/docker/build-base.Dockerfile
+++ b/docker/build-base.Dockerfile
@@ -12,6 +12,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
cpio \
curl \
file \
+ fdisk \
flex \
git \
gettext-base \
@@ -22,6 +23,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
pahole \
perl \
python3 \
+ qemu-user-static \
rsync \
tar \
xz-utils \
diff --git a/docker/fit-build.Dockerfile b/docker/fit-build.Dockerfile
index 681e237..27663f4 100644
--- a/docker/fit-build.Dockerfile
+++ b/docker/fit-build.Dockerfile
@@ -19,12 +19,8 @@ RUN test -n "${BUSYBOX_VERSION}" || (echo "Please specify BUSYBOX_VERSION" >&2;
test -n "${ARCH}" || (echo "Please specify ARCH" >&2; exit 1); \
test -n "${CROSS_COMPILE}" || (echo "Please specify CROSS_COMPILE" >&2; exit 1)
-COPY dev/busybox.tar.gz ./
-RUN tar -xf busybox.tar.gz && mv "busybox-${BUSYBOX_VERSION}" busybox
-
-# RUN curl -L https://github.com/mirror/busybox/archive/refs/tags/${BUSYBOX_VERSION}.tar.gz -o busybox.tar.gz \
-# && tar -xf busybox.tar.gz \
-# && mv "busybox-${BUSYBOX_VERSION}" busybox
+COPY packages/busybox-${BUSYBOX_VERSION}.tar.gz ./
+RUN tar -xf busybox-${BUSYBOX_VERSION}.tar.gz && mv "busybox-${BUSYBOX_VERSION}" busybox
WORKDIR /build/busybox
diff --git a/docker/kernel-build.Dockerfile b/docker/kernel-build.Dockerfile
index dc05f1c..43be2b9 100644
--- a/docker/kernel-build.Dockerfile
+++ b/docker/kernel-build.Dockerfile
@@ -14,17 +14,10 @@ RUN test -n "${NXP_VERSION}" || (echo "Please specify NXP_VERSION" >&2; exit 1);
test -n "${CROSS_COMPILE}" || (echo "Please specify CROSS_COMPILE" >&2; exit 1); \
test -n "${DEVICE_TREE_TARGET}" || (echo "Please specify DEVICE_TREE_TARGET" >&2; exit 1)
-# Dev-only shortcut
-COPY dev/nxplinux.tar.gz ./
-RUN tar -xf nxplinux.tar.gz \
+COPY packages/${NXP_VERSION}.tar.gz ./
+RUN tar -xf ${NXP_VERSION}.tar.gz \
&& mv "linux-${NXP_VERSION}" nxplinux \
- && rm -f nxplinux.tar.gz
-
-# Or download directly:
-# RUN curl -L "https://github.com/nxp-qoriq/linux/archive/refs/tags/${NXP_VERSION}.tar.gz" -o nxplinux.tar.gz \
-# && tar -xf nxplinux.tar.gz \
-# && mv "linux-${NXP_VERSION}" nxplinux \
-# && rm -f nxplinux.tar.gz
+ && rm -f ${NXP_VERSION}.tar.gz
WORKDIR /build/nxplinux
diff --git a/kernel-extra.config b/kernel-extra.config
index bb08456..1c12671 100644
--- a/kernel-extra.config
+++ b/kernel-extra.config
@@ -1,7 +1,5 @@
###############################################################################
# Core initramfs / board support
-# These are built-in because you said initramfs needs them and you want them
-# available early during boot.
###############################################################################
CONFIG_HWMON=y
diff --git a/makefile b/makefile
index df9d58d..4cd30b1 100644
--- a/makefile
+++ b/makefile
@@ -3,6 +3,26 @@ export
TAG ?= dev
+define fetch_if_missing
+ @if [ ! -f "$1" ]; then \
+ echo "Downloading $1"; \
+ curl -L -o "$1" "$2"; \
+ fi
+endef
+
+ALPINE_SERIES := $(word 1,$(subst ., ,${ALPINE_VER})).$(word 2,$(subst ., ,${ALPINE_VER}))
+
+download-packages:
+ @mkdir -p packages
+
+ $(call fetch_if_missing,packages/busybox-${BUSYBOX_VERSION}.tar.gz,https://github.com/mirror/busybox/archive/refs/tags/${BUSYBOX_VERSION}.tar.gz)
+
+ $(call fetch_if_missing,packages/alpine-minirootfs-${ALPINE_VER}-${ALPINE_ARCH}.tar.gz,https://dl-cdn.alpinelinux.org/alpine/v$(ALPINE_SERIES)/releases/${ALPINE_ARCH}/alpine-minirootfs-${ALPINE_VER}-${ALPINE_ARCH}.tar.gz)
+
+ $(call fetch_if_missing,packages/${NXP_VERSION}.tar.gz,https://github.com/nxp-qoriq/linux/archive/refs/tags/${NXP_VERSION}.tar.gz)
+
+ $(call fetch_if_missing,packages/${CRIO_VERSION}.tar.gz,https://storage.googleapis.com/cri-o/artifacts/${CRIO_VERSION}.tar.gz)
+
build-base:
docker build \
-f docker/build-base.Dockerfile \
@@ -47,6 +67,7 @@ buildenv-alpine: build-base
--build-arg TAG=$(TAG) \
--build-arg ALPINE_ARCH=$(ALPINE_ARCH) \
--build-arg ALPINE_VER=$(ALPINE_VER) \
+ --build-arg CRIO_VERSION=$(CRIO_VERSION) \
-t $(DOCKER_IMAGE_ROOT)/buildenv-alpine:$(TAG) .
alpine-rootfs: buildenv-alpine kernel-build
@@ -55,5 +76,6 @@ alpine-rootfs: buildenv-alpine kernel-build
-v /cache/apk:/var/cache/apk \
-v /cache/artifacts:/artifacts \
-e ROOTFS=/out/rootfs \
+ -e ARTIFACT_DIR=/artifacts \
$(DOCKER_IMAGE_ROOT)/buildenv-alpine:$(TAG) \
bash -lc '/build-rootfs.sh'