From: Scott Weaver on gitlab.com Merge Request: https://gitlab.com/cki-project/kernel-ark/-/merge_requests/3971
This creates a new CI job to regularly merge the kernel-ark tree with linux-next. The primary goal is to proactively identify integration issues, conflicts and bugs before they land in the main os-build branch.
This initial version is a proof-of-concept and does not, for example, yet include any logic for automatically resolving merge conflicts or analyzing config mismatches. It serves as a foundation for building more sophisticated automation to help resolve these types of problems in the future
This also introduces the `dist-configs-commit-mismatches` make target to resolve config mismatches.
Signed-off-by: Scott Weaver scweaver@redhat.com
--- redhat/configs/process_configs.sh | 198 ++++++++++++++++++++++++++++++++---- redhat/scripts/ci/ark-linux-next.sh | 76 +++++++++++++ redhat/Makefile | 4 + .gitlab-ci.yml | 22 ++++ 4 files changed, 278 insertions(+), 22 deletions(-)
From: Scott Weaver scweaver@redhat.com
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@redhat.com
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
From: Scott Weaver scweaver@redhat.com
redhat/scripts/ci/ark-linux-next.sh: initial commit
This creates a new CI job to regularly merge the kernel-ark tree with linux-next. The primary goal is to proactively identify integration issues, conflicts and bugs before they land in the main os-build branch.
This initial version is a proof-of-concept and does not, for example, yet include any logic for automatically resolving merge conflicts, misconfigured options or analyzing config mismatches. It serves as a foundation for building more sophisticated automation to help resolve these types of problems in the future.
Signed-off-by: Scott Weaver scweaver@redhat.com
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index blahblah..blahblah 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -60,6 +60,9 @@ workflow: only-ark-latest-head: &only-ark-latest-head if: $CI_COMMIT_BRANCH != "ark-latest" || $CI_PIPELINE_SOURCE !~ /push|web/ when: never + only-os-build-next-head: &only-os-build-next-head + if: $CI_COMMIT_BRANCH != "os-build-next" || $CI_PIPELINE_SOURCE !~ /push|web/ + when: never only-ark-latest-head-mr: &only-ark-latest-head-mr if: ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME != "os-build") && ($CI_COMMIT_BRANCH != "ark-latest" || $CI_PIPELINE_SOURCE !~ /push|web/) @@ -171,6 +174,11 @@ workflow: - *only-ark-latest-head - *on-success
+.os_build_next_head: + rules: + - *only-os-build-next-head + - *on-success + .cki_gating_head: rules: - *only-cki-gating-head @@ -366,6 +374,10 @@ rawhide_clanglto_debug_baseline: extends: [.baseline, .trigger_rawhide, .reported_tests_clang, .ark_latest_head, .rawhide_clanglto_up_debug]
+rawhide_next_baseline: + extends: [.baseline, .trigger_rawhide, .reported_tests, .os_build_next_head, + .rawhide_up] + # Rawhide CKI container image gating rawhide_cki_gating: extends: [.baseline, .trigger_rawhide, .no_tests, .cki_gating_head, @@ -449,6 +461,10 @@ eln_debug_baseline: extends: [.baseline, .trigger_eln, .reported_tests, .ark_latest_head, .eln_up_debug]
+eln_next_baseline: + extends: [.baseline, .trigger_eln, .reported_tests, .os_build_next_head, + .eln_up] + # eln_clang_baseline: # extends: [.baseline, .trigger_eln, .reported_tests_clang, .ark_latest_head, # .eln_clang_up] @@ -691,6 +707,7 @@ c10s_automotive_debug_cki_gating: ssh-add -q - <<< "${PRIVATE_KEY}" fi # set up and fetch all remotes and expected branches + git remote add linux-next git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git git remote add linux-rt-devel git://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git git remote add gitlab https://gitlab.com/cki-project/kernel-ark.git git remote set-url --push gitlab git@gitlab.com:cki-project/kernel-ark.git @@ -747,6 +764,11 @@ merge-rt-automotive: rules: - when: never
+merge-linux-next: + extends: .maintenance + script: + - redhat/scripts/ci/ark-linux-next.sh + docs: image: quay.io/cki/cki-tools:production script: diff --git a/redhat/scripts/ci/ark-linux-next.sh b/redhat/scripts/ci/ark-linux-next.sh new file mode 100755 index blahblah..blahblah 100755 --- /dev/null +++ b/redhat/scripts/ci/ark-linux-next.sh @@ -0,0 +1,76 @@ +#!/bin/bash + +# This script is intended to sync up the os-build-next branch with the +# linux-next master branch. Just as linux-next is rebased, so will the +# os-build-next branch. + +set -e + +# source common CI functions and variables +# shellcheck disable=SC1091 +. "$(dirname "$0")"/ark-ci-env.sh + +commit_new_configs() +{ + make FLAVOR=fedora dist-configs-commit + make FLAVOR=rhel dist-configs-commit +} + +commit_mismatches() +{ + make FLAVOR=fedora dist-configs-commit-mismatches + make FLAVOR=rhel dist-configs-commit-mismatches +} + +# Upstream linux-next tree +LINUX_NEXT_REPO_URL="git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git" +LINUX_NEXT_REMOTE_NAME="linux-next" +LINUX_NEXT_BRANCH="master" +KERNEL_ARK_REMOTE_NAME="origin" +KERNEL_ARK_MAIN_BRANCH="os-build" +KERNEL_ARK_NEXT_BRANCH="os-build-next" + +# verify git remote linux-next is setup +if ! git remote get-url "$LINUX_NEXT_REMOTE_NAME" 2>/dev/null; then + die "Please 'git remote add $LINUX_NEXT_REMOTE_NAME $LINUX_NEXT_REPO_URL'" +fi + +# switch to kernel-ark's next branch +ark_git_mirror "$KERNEL_ARK_NEXT_BRANCH" "$KERNEL_ARK_REMOTE_NAME" "$KERNEL_ARK_NEXT_BRANCH" +git checkout "$KERNEL_ARK_NEXT_BRANCH" + +# hard reset the next branch to kernel-ark's main branch +git reset --hard "$KERNEL_ARK_REMOTE_NAME/$KERNEL_ARK_MAIN_BRANCH" + +# merge linux-next to kernel-ark's next branch +git merge --signoff --no-ff --no-edit "$(git describe "$LINUX_NEXT_REMOTE_NAME/$LINUX_NEXT_BRANCH")" + +# generate pending configs for new configs +commit_new_configs + +# generate pending configs for mismatches +commit_mismatches + +# TODO: resolve misconfigured config options +# For now, error on misconfigured config options +pushd redhat/configs +./process_configs.sh -w 2>/dev/null +popd + +# check for any remaining config issues +make dist-configs-check + +# We have to drop the localversion-next file or 'make dist-srpm' will +# generate a bad NVR. We'll be using this branch for CKI baseline builds, +# so set the localversion file to use the localversion-next value which +# is equivalent to setting DISTLOCALVERSION. +LOCALVERSION_NEXT=$(cat localversion-next) +sed 's/-/./g' localversion-next > localversion +git add -f localversion +git rm localversion-next +git commit -s -m "kernel-ark: drop localversion-next ($LOCALVERSION_NEXT)" + +# push the changes to the branch +test "$TO_PUSH" && git push -f "$KERNEL_ARK_REMOTE_NAME" "$KERNEL_ARK_NEXT_BRANCH" + +exit 0
-- https://gitlab.com/cki-project/kernel-ark/-/merge_requests/3971
kernel@lists.fedoraproject.org