From 4fb0feed395c8e56a3f5da132fcab9edb56b8c6a Mon Sep 17 00:00:00 2001 From: Michal Suchanek <msuchanek@suse.de> Date: Jun 04 2025 15:28:10 +0000 Subject: Merge branch 'users/vkarasulli/scripts/for-next' into scripts --- diff --git a/scripts/check-kernel-fix b/scripts/check-kernel-fix index 102e9d2..f015d18 100755 --- a/scripts/check-kernel-fix +++ b/scripts/check-kernel-fix @@ -236,15 +236,15 @@ handle_parent_inheritable_state() check_for_warnings() { local branch="$1" - local conf_file_map="$2" + local conf_state_file="$2" local sha=$3 local warn_file="$(branch_state_sha_file $branch $sha).warns" shift 3 - check_config "$branch" "$conf_file_map" "$@" >> $warn_file check_arch_support "$branch" "$@" >> $warn_file check_blacklisted_in_parent $branch $sha >> $warn_file check_pending_pr $branch $sha >> $warn_file + grep "WW" $conf_state_file >> $warn_file } has_warnings() @@ -289,6 +289,27 @@ EOF } +check_config_descrepency() +{ + local branch="$1" + local conf_state_file="$2" + local sha="$3" + + [ "$single_branch_mode" -eq 0 ] && return 0 + for child in $(print_children_branches $branches_conf $branch) + do + local child_conf_state_file="$(branch_state_sha_file $child $sha).conf" + wait_for_file $child_conf_state_file + if ! cmp -s $conf_state_file $child_conf_state_file + then + return 1 + fi + done + + return 0 +} + + # Check state of the given branch wrt to given sha, its fixes and references # # The outcome is recorded via set_branch_sha_state and the following states are @@ -299,6 +320,7 @@ EOF # (currently *missing_commit) in verbose mode # + nope_commit_in_base: the fix is already in the base kernel # + nope_unaffected: the fix is not required as the Fixes: commit is not present +# + nope_unaffected_config: the is not required as config is disabled # + ok_reference_present: the CVE reference is present # + ok_commit_present: the commit is present # + ok_will_merge: fix will be merged from upstream branch @@ -308,6 +330,8 @@ EOF # introduced the bug (given fixes is empty) # + blacklisted: blacklist.conf references the CVE. This could be either # CVE line or sha # CVE +# + unknown_config_disagree: parent branch disagrees in config space with children. +# Implies that parent is not a good candidate for backport but children might be. # # Global variables: # branches_conf @@ -330,6 +354,24 @@ check_branch_state() [ -z "$branch" ] && fail "check_branch_state: No branch provided" [ -z "$sha" ] && fail "check_branch_state: No sha provided" + local conf_state_file="$(branch_state_sha_file $branch $sha).conf" + check_config $branch $conf_file_map $conf_state_file "${files[@]}" + + # All configs are disabled for this branch. Check children whether + # they agree on this. + if [[ $? -eq 1 ]] + then + check_config_descrepency $branch $conf_state_file $sha + if [[ $? -eq 1 ]] + then + set_branch_sha_state $branch $sha "unknown_config_disagree" + else + set_branch_sha_state $branch $sha "nope_unaffected_config" + fi + + return + fi + local eligible="" cvss_affects_branch $branch $cvss || eligible="_nope_cvss" if [ -z "$verbose_mode" -a -n "$eligible" ] @@ -359,7 +401,7 @@ check_branch_state() if [ -n "$affected" ] ; then set_branch_sha_state $branch $sha "missing_commit$eligible:$affected" - check_for_warnings "$branch" "$conf_file_map" $sha "${files[@]}" + check_for_warnings "$branch" "$conf_state_file" $sha "${files[@]}" else set_branch_sha_state $branch $sha "nope_unaffected" fi @@ -370,7 +412,7 @@ check_branch_state() # missing git fixes set_branch_sha_state $branch $sha "maybe_missing_commit$eligible:$ref" - check_for_warnings "$branch" "$conf_file_map" $sha "${files[@]}" + check_for_warnings "$branch" "$conf_state_file" $sha "${files[@]}" } check_blacklisted_in_parent() @@ -498,7 +540,7 @@ find_and_print_toplevel_actions() local merge_branch_file="$(branch_state_sha_file $merge_branch $sha)" local mb_state=$(cut -d: -f2 $merge_branch_file) - [[ ! "$mb_state" =~ nope* && "$mb_state" != "blacklisted" ]] && return + [[ ! "$mb_state" =~ nope* && "$mb_state" != "blacklisted" && "$mb_state" != "unknown_config_disagree" ]] && return done print_sha_action $branch $sha $(sed 's@:@ @g' $branch_file) diff --git a/scripts/common-functions b/scripts/common-functions index a07a4cc..f1f48e3 100644 --- a/scripts/common-functions +++ b/scripts/common-functions @@ -138,11 +138,13 @@ check_config() { local branch="$1" local CONF_FILE_MAP="$2" - shift 2 + local output_file_name="$3" + shift 3 declare -a files=() local failed=0 local conf_num=0 + for file do # split and quote (for SQL syntax) and use doubled quotes when @@ -164,7 +166,7 @@ check_config() conf_num=$(($conf_num+1)) if ! git grep -qiE "$conf=(y|m)" origin/${branch#origin/} -- config then - echo -e "\tWW $conf not enabled." + echo -e "\tWW $conf not enabled." >> $output_file_name failed=$(($failed+1)) fi done < <(sqlite3 -batch -noheader -csv "$CONF_FILE_MAP" \ @@ -177,10 +179,20 @@ check_config() WHERE (dir.dir, file.file) IN ($files)) ORDER BY map.config;") - if [ $failed -gt 0 -a $failed -lt $conf_num ] + if [ $failed -gt 0 ] then - echo -e "\tWW $failed out of $conf_num disabled." + if [ $failed -lt $conf_num ] + then + echo -e "\tWW $failed out of $conf_num disabled." >> $output_file_name + return 2 + else + echo -e "\tWW all configs disabled" >> $output_file_name + return 1 + fi fi + + echo -e "All configs enabled" >> $output_file_name + return 0 } check_arch_support() @@ -240,6 +252,19 @@ print_merge_branches() done } +print_children_branches() +{ + local branches_conf="$1" + local branch="$2" + + [ -z "$branches_conf" ] && fail "children_branches: No branches_conf provided" + [ -z "$branch" ] && fail "children_branches: No branch provided" + + while read -r line ; do + echo "${line%%:*}" + done < <(grep -E "merge:-?$branch" "$branches_conf") +} + merge_topo_sort() { local branches_conf=$1