My new (WiP) orchestrator for building test image for testing my #kernel tree is fully implemented with GNU make:
# SPDX-License-Identifier: MIT
ROOT := $(dir $(abspath $(firstword $(MAKEFILE_LIST))))
BUILDROOT_VERSION := 2023.11
OUTPUT := $(ROOT)output
BUILDROOT_URL := https://buildroot.org/downloads/buildroot-$(BUILDROOT_VERSION).tar.gz
EXTERNAL_URL := https://github.com/jarkkojs/tpmdd-buildroot-external/tarball/main
define make-buildroot
make -C "$(OUTPUT)/buildroot" BR2_EXTERNAL="$(OUTPUT)/external" O="$(OUTPUT)/build" $(1)
endef
define download-package
mkdir -p $(2)
curl -sL "$(1)" | tar -zxv -C "$(2)" --strip-components=1
endef
all: buildroot
.PHONY: buildroot
buildroot: $(OUTPUT)/download-stamp
$(call make-buildroot,tpmdd_qemu_x86_64_defconfig)
$(call make-buildroot,all)
.PHONY: buildroot-menuconfig
buildroot-menuconfig: $(OUTPUT)/download-stamp
$(call make-buildroot,tpmdd_qemu_x86_64_defconfig)
$(call make-buildroot,menuconfig)
$(call make-buildroot,savedefconfig)
.PHONY: linux-menuconfig
linux-menuconfig: $(OUTPUT)/download-stamp
$(call make-buildroot,tpmdd_qemu_x86_64_defconfig)
$(call make-buildroot,linux-menuconfig)
$(call make-buildroot,linux-savedefconfig)
$(OUTPUT)/download-stamp:
$(call download-package,"$(BUILDROOT_URL)","$(OUTPUT)/buildroot")
$(call download-package,"$(EXTERNAL_URL)","$(OUTPUT)/external")
touch $@
.PHONY: clean
clean:
rm -rf "$(OUTPUT)"
It is pretty robust structure because I can e.g. easily add packages (like maybe host swtpm) in a robust manner to buildroot.
After some experimentation it is best the define boards in this context as fairly self-contained packages to the specific test devices at hand and not have anything shared e.g. by CPU architecture even at the cost of some redundancy:
$ tree
.
├── Config.in
├── LICENSE
├── board
│ └── tpmdd_qemu_x86_64
│ ├── linux.config
│ ├── post-build.sh
│ ├── post-image.sh
│ └── start-qemu.sh.in
├── configs
│ └── tpmdd_qemu_x86_64_defconfig
├── external.desc
└── external.mk
4 directories, 9 files
E.g. similarly I’ll add tpmdd_raspberrypi3b
target and so forth. For instance, I would not share post-image.sh
and similar scripts between boards even if they were 1:1. It kills robustness.
The orchestrator itself has a flat repository:
$ tree
.
├── LICENSE
├── Makefile
└── README.md
I licensed external with GPL2 for the sake of upstream compatibility and orchestrator with MIT. This is overally pretty usable structure to use Buildroot.