From c317a1ef6a0a982a61c538e58c003394de3d70a5 Mon Sep 17 00:00:00 2001 From: Michal Hocko Date: Mar 22 2024 16:47:36 +0000 Subject: scripts/check-kernel-fix: simplify to only get sha argument and resolve references automagically --- diff --git a/scripts/check-kernel-fix b/scripts/check-kernel-fix index 9ce76ec..c5665ea 100755 --- a/scripts/check-kernel-fix +++ b/scripts/check-kernel-fix @@ -7,18 +7,13 @@ usage() { echo "Check state of a kernel fix and eventually suggest needed actions" echo - echo "The actions are proposed only when \"sha\" of an upstream commit" - echo "is passed as a parameter. Otherwise, it just checks where" - echo "the given references are missing." - echo - echo "When \"sha\" is defined then the script checks whether the commit" - echo "is already in the upstream baseline or backported. When backported," - echo "it checks whether it has all the given references." + echo "Expect upstream kernel tree sha as the parameter. The script checks" + echo "whether the commit is already in the upstream baseline or backported" + echo "in kernel-source tree. When backported, it checks whether it has CVE" + echo "reference if there is any" echo echo "Also the script looks for \"Fixes:\" tag of the given \"sha\"." echo "When defined, the scripts informs where the fix has to be backported." - echo "Otherwise, the script just informs that the decision has to be" - echo "made manually." echo echo "The script also takes into account the hierarchy of branches." echo "It checks all branches. But the action is proposed only for" @@ -332,53 +327,27 @@ if [ -z "$1" ] ; then exit 1 fi -sha= -references= - -while [ -n "$1" ] ; do - case "$1" in - CVE*) - references="$references $1" - ;; - *#*) - references="$references $1" - ;; - *) - if ! sha_in_upstream "$1" ; then - fail "Can find't sha in upstream: $1" - fi - - if [ -n "$sha" ] ; then - fail "Only one sha is supported: $sha vs. $1" - fi - - sha="$1" - ;; - esac - shift -done - - -if [ -n "$sha" ] ; then - # Check state of each branch - for_each_build_branch $check_cve "$branches_conf" check_branch_state $sha $references - - # Newline after the dots showing progress - [ -z "$quiet_mode" ] && echo +if ! sha_in_upstream "$1" ; then + fail "Can find't sha in upstream: $1" +fi - if [ -z "$show_only_states" ] ; then - for_each_build_branch $check_cve "$branches_conf" find_and_print_toplevel_actions +sha=$1 +cve=$(sha2cve $sha) +bsc= +[ -n "$cve" ] && bsc=$(cve2bugzilla $cve) +references="$cve $bsc" - if [ ! -e "$actions_file" ] ; then - echo "EVERYTHING IS OK!" - fi - fi +# Check state of each branch +for_each_build_branch $check_cve "$branches_conf" check_branch_state $sha $references -else +# Newline after the dots showing progress +[ -z "$quiet_mode" ] && echo - # No actions are suggested without sha - # Just check which branches have the references - # and if the references are consistent - for_each_build_branch $check_cve "$branches_conf" check_branch_references $references +if [ -z "$show_only_states" ] ; then +for_each_build_branch $check_cve "$branches_conf" find_and_print_toplevel_actions +if [ ! -e "$actions_file" ] ; then + echo "EVERYTHING IS OK!" +fi fi +