diff --git a/scripts/check-kernel-commit b/scripts/check-kernel-commit new file mode 100755 index 0000000..57b5642 --- /dev/null +++ b/scripts/check-kernel-commit @@ -0,0 +1,186 @@ +#!/bin/bash + +usage() +{ + echo "Check whether a given list of commit is available in" + echo "a given list of branches." + echo + echo "Usage: ${0##*/} [branches.conf] term..." + echo + echo "Parametes:" + echo " branches.conf: file with the list of branches to be checked" + echo " term: hash of the commit|CVE|bsc to be found" +} + +fetch_branches() +{ + local CACHED_BRANCHES=/tmp/branches.conf + local URL="https://kerncvs.suse.de/branches.conf" + local EXPIRE=7 + branches=$CACHED_BRANCHES + if [[ $(find "$CACHED_BRANCHES" -mtime -$EXPIRE -print 2>/dev/null) \ + && -s "$CACHED_BRANCHES" ]]; then + echo "Using cached $CACHED_BRANCHES" >&2 + return + fi + curl "$URL" -o "$CACHED_BRANCHES" +} + +if [ $# -lt 1 ] ; then + usage + exit 1 +fi + +branches=$1 +if [ ! -f "$branches" ] ; then + echo "Branches file not specified, trying to fetch it..." >&2 + if ! fetch_branches ; then + "Error: Can't find the file with the list of branches: $branches nor fetch it" + exit 1 + fi +else + shift; +fi + +KBC_CHECK_TERMS="$*" + +term2regex() +{ + shopt nocasematch + local t=$1 + case $t in + # CVEs first + 2[0-9][0-9][0-9]-*) + t=cve-$t + ;& + cve-*) + echo "^References:.*$t" + ;; + # looks like a hash, look for commits + [a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]*) + echo "^Git-commit:.*$t" + ;; + # treat rest as a generic reference + *) + echo "^References:.*$t" + ;; + esac +} + +check_branch() +{ + verbose=0 + if [ $1 == "-v" ] ; then + verbose=1 + shift + fi + + branch="$1" + found="" + missing="" + + for term in $KBC_CHECK_TERMS ; do + git grep -i "$(term2regex $term)" "remotes/origin/$branch" >/dev/null 2>&1 + if [ $? -eq 0 ] ; then + found="$found $term" + else + missing="$missing $term" + fi + done + + # found + if [ -z "$missing" ] ; then + return 0 + fi + + # missing + if [ -z "$found" ] ; then + return 2 + fi + + # partly + if [ $verbose -ne 0 ] ; then + echo " missing hash:" + for hash in $missing ; do + echo " $term" + done + echo + fi + return 1 +} + +check_parents() +{ + last_branch="" + for branch in "$@" ; do + check_branch $branch + case $? in + 0) + echo " (found in $branch)" + return + ;; + 1) + echo " (partly in $branch)" + return + ;; + *) + ;; + esac + last_branch="$branch" + done + + # not found anywhere + echo " (not even in $last_branch)" +} + +print_branch() +{ + branch="$1" + echo -n "$branch" + + len=`echo $branch| wc -c` + spaces=$((24 - $len)) + while [ $spaces -gt 0 ] ; do + echo -n " " + spaces=$(($spaces - 1)) + done +} + +grep -w build "$branches" | grep -v -E "^(master|vanilla|linux-next|cve)" | \ +while read line ; do + line=${line%%\#*} + branch=${line%%:*} + + # empty line or comment + if [ -z "$branch" ] ; then + continue + fi + + # always check also the _EMBARGO branch as a possible parent + parents="${branch}_EMBARGO" + set dummy ${line#$branch:} + while [ $# -gt 0 ] ; do + shift + [[ "$1" =~ "merge:" ]] || continue + tmp="${1//*merge:-/}" + parents="$parents ${tmp//*merge:/}" + done + + print_branch "$branch" + check_branch "$branch" + + case $? in + 0) + echo "" + ;; + 1) + echo -n " " + check_parents $parents + # print missing commits + check_branch -v "$branch" + ;; + *) + echo -n "" + check_parents "${branch}_EMBARGO" $parents + esac +done diff --git a/scripts/git_sort/git_sort.py b/scripts/git_sort/git_sort.py index d4881c7..fb07dcf 100755 --- a/scripts/git_sort/git_sort.py +++ b/scripts/git_sort/git_sort.py @@ -213,8 +213,8 @@ remotes = ( Head(RepoURL("gregkh/tty.git"), "tty-next"), Head(RepoURL("gregkh/usb.git"), "usb-next"), Head(RepoURL("jj/linux-apparmor.git"), "apparmor-next"), - Head(RepoURL("pablo/nf.git")), - Head(RepoURL("pablo/nf-next.git")), + Head(RepoURL("netfilter/nf.git")), + Head(RepoURL("netfilter/nf-next.git")), Head(RepoURL("horms/ipvs.git")), Head(RepoURL("horms/ipvs-next.git")), Head(RepoURL("klassert/ipsec.git")), diff --git a/scripts/python/suse_git/header.py b/scripts/python/suse_git/header.py index 43d4406..f3fcd04 100755 --- a/scripts/python/suse_git/header.py +++ b/scripts/python/suse_git/header.py @@ -59,6 +59,11 @@ tag_map = { 'match' : 'Submitted,?\s+.+', 'excludes' : [ 'Git-commit', 'Git-repo' ], }, { + # Catch a frequent misuse of 'Not yet'. + 'match' : 'Not yet,\s+submitted', + 'error' : "Please use 'Submitted'", + 'excludes' : [ 'Git-commit', 'Git-repo' ], + }, { # Should be used rarely. Description should provide # reason for the patch not being accepted upstream. 'name' : 'Not yet', diff --git a/scripts/python/tests/test_header.py b/scripts/python/tests/test_header.py index 5051b39..21daceb 100755 --- a/scripts/python/tests/test_header.py +++ b/scripts/python/tests/test_header.py @@ -715,3 +715,18 @@ References: FATE#123456 Acked-by: developer@suse.com """ self.header = header.Checker(text, False, "patches.kabi/FATE123456_fix_kabi.patch") + + def test_patch_mainline_invalid2(self): + text = """ +From: developer@site.com +Subject: some patch +Patch-mainline: Not yet, submitted 2022-08-23 +References: bsc#12345 +Acked-by: developer@suse.com +""" + with self.assertRaises(header.HeaderException) as cm: + self.header = header.Checker(text) + + e = cm.exception + self.assertEqual(1, e.errors(header.FormatError)) + self.assertEqual(1, e.errors()) diff --git a/scripts/wd-functions.sh b/scripts/wd-functions.sh index 3111d40..d645a42 100644 --- a/scripts/wd-functions.sh +++ b/scripts/wd-functions.sh @@ -34,7 +34,7 @@ get_branch_name() if $using_git; then # FIXME: guess a branch name when a non-branch revision is checked # out - local res=$(sed -ne 's|^ref: refs/heads/||p' "$scripts_dir"/../.git/HEAD 2>/dev/null) + local res=$(sed -ne 's|^ref: refs/heads/||p' "$(git rev-parse --git-dir)"/HEAD 2>/dev/null) echo "$res" fi }