From 2603b0ea1b93880a0b0922c181ca29a006d7524f Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Thu, 9 Apr 2026 10:25:48 +0200 Subject: [PATCH] Add support for developer config snippets Signed-off-by: Joachim Wiberg --- Makefile | 25 ++++++++++++++++++++--- configs/snippets/dev.conf | 1 + configs/snippets/ext4.conf | 3 +++ doc/developers-guide.md | 40 ++++++++++++++++++++++++++++++++----- test/case/repo/defconfig.sh | 5 ++++- 5 files changed, 65 insertions(+), 9 deletions(-) create mode 100644 configs/snippets/dev.conf create mode 100644 configs/snippets/ext4.conf diff --git a/Makefile b/Makefile index f2faa5de..aaaf3c1f 100644 --- a/Makefile +++ b/Makefile @@ -9,8 +9,10 @@ O ?= output # otherwise treat it as relative to ./buildroot. override O := $(if $(filter /%,$O),$O,$(CURDIR)/$O) -config := $(O)/.config -bmake = $(MAKE) -C buildroot O=$(O) $1 +config := $(O)/.config +bmake = $(MAKE) -C buildroot O=$(O) $1 +SNIPPETS_DIR := $(CURDIR)/configs/snippets +MERGE_CONFIG := $(CURDIR)/buildroot/support/kconfig/merge_config.sh all: $(config) buildroot/Makefile @@ -26,6 +28,23 @@ $(config): @echo "'make _defconfig' before building an image." @exit 1 +apply-%: $(SNIPPETS_DIR)/%.conf | $(config) + @KCONFIG_CONFIG=$(config) $(MERGE_CONFIG) -m $(config) $< + @+$(call bmake,olddefconfig) + @echo "Applied snippet: $<" + +list-snippets: + @echo "Available snippets (use 'make apply-'):" + @ls $(SNIPPETS_DIR)/*.conf 2>/dev/null | sed 's|.*/||; s|\.conf$$||; s|^| |' + +dev: | $(config) + @for s in $(SNIPPETS_DIR)/*.conf; do \ + KCONFIG_CONFIG=$(config) $(MERGE_CONFIG) -m $(config) $$s; \ + echo "Applied snippet: $$s"; \ + done + @+$(call bmake,olddefconfig) + @+$(call bmake,all) + %: | buildroot/Makefile @+$(call bmake,$@) @@ -44,4 +63,4 @@ test: buildroot/Makefile: @git submodule update --init -.PHONY: all check coverity dep test cyclonedx +.PHONY: all check coverity dep test cyclonedx list-snippets dev diff --git a/configs/snippets/dev.conf b/configs/snippets/dev.conf new file mode 100644 index 00000000..b744ff27 --- /dev/null +++ b/configs/snippets/dev.conf @@ -0,0 +1 @@ +BR2_TARGET_ENABLE_ROOT_LOGIN=y diff --git a/configs/snippets/ext4.conf b/configs/snippets/ext4.conf new file mode 100644 index 00000000..2b0b2eb4 --- /dev/null +++ b/configs/snippets/ext4.conf @@ -0,0 +1,3 @@ +BR2_TARGET_ROOTFS_EXT2=y +BR2_TARGET_ROOTFS_EXT2_4=y +BR2_TARGET_ROOTFS_EXT2_SIZE="512M" diff --git a/doc/developers-guide.md b/doc/developers-guide.md index d5d5eb72..032fc69d 100644 --- a/doc/developers-guide.md +++ b/doc/developers-guide.md @@ -7,12 +7,12 @@ account, which is created based on credentials found in the VPD area -- for Qemu devices this is emulated using `qemu_fw_cfg`. For developers this can be quite frustrating to be blocked from logging -in to debug the system. So we recommend enabling the `root` account in -the Buildroot `make menuconfig` system. +in to debug the system. The quickest way to enable root login is to +apply the `dev` configuration snippet: - make menuconfig - -> System configuration - -> [*]Enable root login with password + make apply-dev + +See [Configuration Snippets](#configuration-snippets) for more details. > [!IMPORTANT] > Please see the [Contributing](#contributing) section, below, for @@ -166,6 +166,36 @@ on Buildroot to finalize the target filesystem and generate the images. The final `run` argument is explained below. +### Configuration Snippets + +Infix ships a set of Kconfig fragments in `configs/snippets/` that can +be merged into your active `.config` on demand. This avoids polluting +defconfigs with settings that are only useful during development. + +To see what snippets are available: + + make list-snippets + +To apply a single snippet to the current output directory: + + make apply-dev # enable root login + make apply-ext4 # build an ext4 rootfs (needed for boards + # whose bootloader lacks squashfs support, + # e.g. Marvell ESPRESSObin) + +The `apply-*` targets require an existing `.config` (i.e. you must have +already run a `make _defconfig`). The snippet is merged using +Buildroot's `merge_config.sh`, so it behaves like `make menuconfig`: +unrelated settings are preserved, conflicting ones are overridden. + +To apply **all** snippets at once and then build: + + make dev + +This is the recommended one-shot command for setting up a development +build from a freshly selected defconfig. + + ### YANG Model When making changes to the `confd` and `statd` services, you will often diff --git a/test/case/repo/defconfig.sh b/test/case/repo/defconfig.sh index abd0f16c..b3acbea1 100755 --- a/test/case/repo/defconfig.sh +++ b/test/case/repo/defconfig.sh @@ -1,4 +1,6 @@ #!/bin/sh +# Verify all config/*_defconfig files, skipping any subdirectories, +# e.g., developer snippets not used in official builds. SCRIPT_PATH="$(dirname "$(readlink -f "$0")")" CONFIGS="$SCRIPT_PATH/../../../configs" @@ -47,6 +49,7 @@ check() done } -check "$CONFIGS"/* || exit 1 +# shellcheck disable=SC2046 +check $(find "$CONFIGS" -maxdepth 1 -type f | LC_ALL=C sort) || exit 1 exit 0