From 4fb26b11194ea1ff39382ba237fa26c1ad839848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Walstr=C3=B6m?= Date: Sat, 18 Jan 2025 10:47:36 +0100 Subject: [PATCH] Add script to merge defconfigs Useful to only create a new image with only small diff with for example aarch64_defconfig. example: If the only diff is the VENDOR, instead of KernelKit you want 'foobar'. create a file with the change: INFIX_VENDOR="foobar" and call ./utils/generate-defconfig.sh -b aarch64_defconfig -c foobar-diff.conf -o configs/foobar_defconfig --- utils/generate-defconfig.sh | 80 +++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100755 utils/generate-defconfig.sh diff --git a/utils/generate-defconfig.sh b/utils/generate-defconfig.sh new file mode 100755 index 00000000..76f7af59 --- /dev/null +++ b/utils/generate-defconfig.sh @@ -0,0 +1,80 @@ +#!/bin/sh +# Create new defconfigs by only applying the changes from a standard defconfig +set -e + +SCRIPT_DIR="$(readlink -f $(dirname -- "$0"))" +MERGE_CONFIG="${SCRIPT_DIR}/../buildroot/support/kconfig/merge_config.sh" + +usage() { + cat <&2 + exit 1 + elif [ ! -r "$file" ]; then + echo "Error: $type file is not readable: $file" >&2 + exit 1 + fi +} + + +while [ $# -gt 0 ]; do + case $1 in + -b|--base) + base="$2" + shift 2 + ;; + -c|--changes) + changes="$2" + shift 2 + ;; + -o|--output) + output="$2" + shift 2 + ;; + *) + usage + exit 1 + ;; + esac +done + +if [ -z $output ] || [ -z $changes ] || [ -z $output ]; then + usage + exit 1 +fi + +if [ ! -x "$MERGE_CONFIG" ]; then + echo "Error: merge_config.sh not found or not executable at: $MERGE_CONFIG" + exit 1 +fi + +check_file "$base" "Base config" +check_file "$changes" "Changes config" + +TMPDIR=`mktemp -d` +$MERGE_CONFIG -O "$TMPDIR" -n "$base" "$changes" +O="$TMPDIR" make savedefconfig +mv "$TMPDIR"/defconfig "$output" +rm -r "$TMPDIR"