From: Scott Weaver <scweaver@xxxxxxxxxx>
redhat/Makefile: automate committing config mismatches
This commit introduces the `dist-configs-commit-mismatches`
make target to resolve config mismatches.
A new option (-M) was added to process_configs.sh that iterates through
each config mismatch for each arch-variant and creates a specific
config file in the corresponding pending directory.
Note: This uses the default output from `make olddefconfig` and does not
include any post-processing to consolidate configs. It will always
create per-arch-variant config files even if a generic config could be
used.
Signed-off-by: Scott Weaver <scweaver@xxxxxxxxxx>
diff --git a/redhat/Makefile b/redhat/Makefile
index blahblah..blahblah 100644
--- a/redhat/Makefile
+++ b/redhat/Makefile
@@ -596,6 +596,10 @@ dist-configs-commit: dist-configs-prep
+@cd $(REDHAT)/configs; ./generate_all_configs.sh 1;\
./process_configs.sh -z "$(SPECRPMVERSION)" "$(FLAVOR)"
+dist-configs-commit-mismatches: dist-configs-prep
+ +@cd $(REDHAT)/configs; ./generate_all_configs.sh 1;\
+ ./process_configs.sh -M "$(SPECRPMVERSION)" "$(FLAVOR)"
+
dist-configs: ##configuration Create RHEL config files in redhat/config/.
dist-configs: dist-configs-prep
+@cd $(REDHAT)/configs; ./generate_all_configs.sh 1;\
diff --git a/redhat/configs/process_configs.sh b/redhat/configs/process_configs.sh
index blahblah..blahblah 100755
--- a/redhat/configs/process_configs.sh
+++ b/redhat/configs/process_configs.sh
@@ -1,13 +1,15 @@
#!/bin/bash
#
-# This script takes the merged config files and processes them through oldconfig
-# and listnewconfig
+# This script takes the merged config files and processes them through olddefconfig
+# and listnewconfig to ensure kernel configurations are valid and complete.
#
# Globally disable suggestion of appending '|| exit' or '|| return' to cd/pushd/popd commands
# shellcheck disable=SC2164
+# Exit if this is a test environment
test -n "$RHTEST" && exit 0
+# Display usage information and available command line options
usage()
{
# alphabetical order please
@@ -15,6 +17,8 @@ usage()
echo " -a: report all errors, equivalent to [-c -n -w -i]"
echo " -c: error on mismatched config options"
echo " -i: ignore any errors, but print them"
+ echo " -m: specify make options (e.g., -m CC=clang, -m LLVM=1)"
+ echo " -M: commit mismatched configs to pending directory"
echo " -n: error on unset config options"
echo " -t: test run, do not overwrite original config"
echo " -w: error on misconfigured config options"
@@ -33,6 +37,9 @@ die()
exit 1
}
+# Determine the correct cross-compiler prefix based on compiler type
+# For clang builds, return the architecture directly
+# For GCC builds, use the dummy-tools directory
get_cross_compile()
{
arch=1ドル
@@ -43,7 +50,8 @@ get_cross_compile()
fi
}
-# stupid function to find top of tree to do kernel make configs
+# Find the top-level kernel source directory
+# (identified by MAINTAINERS file and drivers directory)
switch_to_toplevel()
{
path="$(pwd)"
@@ -60,11 +68,124 @@ switch_to_toplevel()
echo "$path"
}
+# Determine the correct config path based on architecture and variant
+# This function maps arch/variant combinations to the proper pending directory
+determine_config_path()
+{
+ local arch="1ドル"
+ local variant="2ドル"
+ local config_path=""
+
+ # Identify the variant - they have their own top-level directories
+ if [[ "$variant" == *"rt"* ]]; then
+ # RT variant - goes under rt/
+ if [[ "$variant" == *"debug"* ]]; then
+ config_path="rt/debug"
+ else
+ config_path="rt/generic"
+ fi
+ elif [[ "$variant" == *"automotive"* ]]; then
+ # Automotive variant - goes under automotive/
+ if [[ "$variant" == *"debug"* ]]; then
+ config_path="automotive/debug"
+ else
+ config_path="automotive/generic"
+ fi
+ else
+ # Stock kernel - goes under top-level debug or generic
+ if [[ "$variant" == *"debug"* ]]; then
+ config_path="debug"
+ else
+ config_path="generic"
+ fi
+ fi
+
+ # Add architecture-specific subdirectories
+ case "$arch" in
+ arm64)
+ config_path="$config_path/arm/aarch64"
+ ;;
+ powerpc)
+ config_path="$config_path/powerpc"
+ ;;
+ riscv)
+ config_path="$config_path/riscv/riscv64"
+ ;;
+ s390)
+ if [[ "$variant" == *"zfcpdump"* ]]; then
+ config_path="$config_path/s390x/zfcpdump"
+ else
+ config_path="$config_path/s390x"
+ fi
+ ;;
+ x86_64)
+ config_path="$config_path/x86"
+ ;;
+ *)
+ # For unknown architectures, don't add arch subdirectory
+ ;;
+ esac
+
+ echo "$config_path"
+}
+
+# Parse mismatched configs found during processing and create
+# individual CONFIG files in the pending directory for each
+parse_mismatched_configs()
+{
+ local tmpdir
+ local count=1ドル # Counter for unique filenames
+ local arch=2ドル
+ local variant=3ドル
+
+ tmpdir=$(mktemp -d)
+
+ # Parse the mismatches file and create individual CONFIG files
+ tail -n +2 .mismatches"${count}" | while read -r LINE
+ do
+ if echo "$LINE" | grep -q "Found # .* is not set, after generation"; then
+ # Handle case where we found "# CONFIG_FOO is not set" after generation
+ config_name="${LINE#*Found # }"
+ config_name="${config_name% is not set, after generation*}"
+ if [ -n "$config_name" ]; then
+ echo "# Mismatch found in $arch $variant config" > "$tmpdir/$config_name"
+ echo "# $config_name is not set" >> "$tmpdir/$config_name"
+ fi
+ elif echo "$LINE" | grep -q "Found .* after generation"; then
+ # Handle case where we found "CONFIG_FOO=value" after generation
+ config_name="${LINE#*Found }"
+ config_name="${config_name% after generation*}"
+ config_name="${config_name%=*}"
+ config_value="${LINE#*Found }"
+ config_value="${config_value#*=}"
+ config_value="${config_value% after generation*}"
+ if [ -n "$config_name" ] && [ -n "$config_value" ]; then
+ echo "# Mismatch found in $arch $variant config" > "$tmpdir/$config_name"
+ echo "$config_name=$config_value" >> "$tmpdir/$config_name"
+ fi
+ fi
+ done
+
+ # Copy the CONFIG files to the pending directory
+ config_path=$(determine_config_path "$arch" "$variant")
+ mkdir -p "$SCRIPT_DIR/pending-$FLAVOR/$config_path/"
+ for f in "$tmpdir"/*; do
+ [[ -e "$f" ]] || break
+ cp "$f" "$SCRIPT_DIR/pending-$FLAVOR/$config_path/"
+ done
+
+ rm -rf "$tmpdir"
+}
+
+# Check for configuration mismatches between the original and generated configs
checkoptions()
{
- count=3ドル
- variant=4ドル
+ cfg=1ドル # Original config file
+ cfgtmp=2ドル # Generated config file
+ count=3ドル # Counter for unique filenames
+ variant=4ドル # Config variant (e.g., debug, rt)
+ # This awk script compares configuration files for mismatches
/usr/bin/awk '
/is not set/ {
@@ -87,7 +208,7 @@ checkoptions()
print "Found "a[1]"="a[2]" after generation, had " a[1]"="configs[a[1]]" in Source tree";
}
}
- ' "1ドル" "2ドル" > .mismatches"${count}"
+ ' "$cfg" "$cfgtmp" > .mismatches"${count}"
checkoptions_error=false
if test -s .mismatches"${count}"
@@ -107,11 +228,18 @@ checkoptions()
! $checkoptions_error && return
sed -i "1s/^/Error: Mismatches found in configuration files for ${arch} ${variant}\n/" .mismatches"${count}"
+
+ # Add mismatched configs to the pending directory
+ if test -n "$COMMITMISMATCHES"; then
+ parse_mismatched_configs "$count" "$arch" "$variant"
+ fi
else
rm -f .mismatches"${count}"
fi
}
+# Parse the output of 'make listnewconfig' and 'make helpnewconfig'
+# to create properly formatted configuration files for new configs
parsenewconfigs()
{
tmpdir=$(mktemp -d)
@@ -196,12 +324,32 @@ parsenewconfigs()
popd &> /dev/null
for f in "$tmpdir"/*; do
[[ -e "$f" ]] || break
- cp "$f" "$SCRIPT_DIR/pending$FLAVOR/generic/"
+ cp "$f" "$SCRIPT_DIR/pending-$FLAVOR/generic/"
done
rm -rf "$tmpdir"
}
+# Commit any mismatched configs that were saved to the pending directory
+commit_mismatched_configs()
+{
+ # assume we are in $source_tree/configs, need to get to top level
+ pushd "$(switch_to_toplevel)" &>/dev/null
+
+ # Check if there are any modified or untracked mismatched configs to commit
+ if git status --porcelain "$SCRIPT_DIR/pending-$FLAVOR/" | grep -q .; then
+ echo "Committing mismatched configuration files..."
+ git add "$SCRIPT_DIR/pending-$FLAVOR"
+ git commit -m "[redhat] AUTOMATIC: Mismatched $FLAVOR configs"
+ echo "Mismatched configs committed to pending-$FLAVOR directory"
+ else
+ echo "No mismatched configs found to commit"
+ fi
+
+ popd &>/dev/null
+}
+
+# Processes all config files, finds new/unset configs, and commits them
function commit_new_configs()
{
# assume we are in $source_tree/configs, need to get to top level
@@ -234,10 +382,12 @@ function commit_new_configs()
echo "done"
done
- git add "$SCRIPT_DIR/pending$FLAVOR"
- git commit -m "[redhat] AUTOMATIC: New configs"
+ # Commit the new configuration files to git
+ git add "$SCRIPT_DIR/pending-$FLAVOR"
+ git commit -m "[redhat] AUTOMATIC: New $FLAVOR configs"
}
+# Process a single configuration file
function process_config()
{
local cfg
@@ -307,16 +457,13 @@ function process_config()
echo "Processing $cfg complete"
}
+# Process all configuration files
+# Handles parallel processing and error reporting
function process_configs()
{
# assume we are in $source_tree/configs, need to get to top level
pushd "$(switch_to_toplevel)" &>/dev/null
- # The next line is throwaway code for transition to parallel
- # processing. Leaving this line in place is harmless, but it can be
- # removed the next time anyone updates this function.
- [ -f .mismatches ] && rm -f .mismatches
-
count=0
for cfg in "$SCRIPT_DIR/${SPECPACKAGE_NAME}${KVERREL}"*.config
do
@@ -342,7 +489,13 @@ function process_configs()
cat .errors*
rm .errors* -f
fi
- if ls .mismatches* 1> /dev/null 2>&1; then
+
+ # Commit any mismatched configs found during processing
+ if [ $RETURNCODE -eq 0 ] && test -n "$COMMITMISMATCHES"; then
+ rm .mismatches* -f
+ commit_mismatched_configs
+ # Otherwise, display any mismatched configs
+ elif ls .mismatches* 1> /dev/null 2>&1; then
RETURNCODE=1
cat .mismatches*
rm .mismatches* -f
@@ -360,6 +513,7 @@ TESTRUN=""
CHECKWARNINGS=""
MAKEOPTS=""
CC_IS_CLANG=0
+COMMITMISMATCHES=""
RETURNCODE=0
@@ -368,6 +522,7 @@ do
key="1ドル"
case $key in
-a)
+ # Enable all error checking options
CHECKOPTIONS="x"
IGNOREERRORS="x"
NEWOPTIONS="x"
@@ -396,11 +551,16 @@ do
;;
-m)
shift
+ # Handle clang compiler options
if [ "1ドル" = "CC=clang" ] || [ "1ドル" = "LLVM=1" ]; then
CC_IS_CLANG=1
fi
MAKEOPTS="$MAKEOPTS 1ドル"
;;
+ -M)
+ COMMITMISMATCHES="x"
+ CHECKOPTIONS="x"
+ ;;
*)
break;;
esac
@@ -408,17 +568,11 @@ do
done
KVERREL="$(test -n "1ドル" && echo "-1ドル" || echo "")"
-FLAVOR="$(test -n "2ドル" && echo "-2ドル" || echo "-rhel")"
+FLAVOR="$(test -n "2ドル" && echo "2ドル" || echo "rhel")"
# shellcheck disable=SC2015
SCRIPT=$(readlink -f "0ドル")
SCRIPT_DIR=$(dirname "$SCRIPT")
-# Config options for RHEL should target the pending-rhel directory, not pending-common.
-if [ "$FLAVOR" = "-rhel" ]
-then
- FLAVOR="-rhel"
-fi
-
# to handle this script being a symlink
cd "$SCRIPT_DIR"
--
https://gitlab.com/cki-project/kernel-ark/-/merge_requests/3971
--
_______________________________________________
kernel mailing list -- kernel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to kernel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/kernel@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue