From dfd53c9487958c6bd31b81fc2ba1186799fa0be9 Mon Sep 17 00:00:00 2001 From: Michal Suchanek Date: Mar 16 2022 11:42:17 +0000 Subject: Merge branch 'scripts' into packaging --- diff --git a/README b/README index 4150bc8..db1a48a 100644 --- a/README +++ b/README @@ -68,7 +68,7 @@ Patch Headers ============= Each patch must have a RFC822-style header that at a minimum describes -what the patch does, who wrote it, and who inside SUSE/Novell we'll +what the patch does, who wrote it, and who inside SUSE we'll "blame" about problems with the patch. The rules for patch headers are: * Each patch must have a From: tag that identifies the author of the @@ -355,7 +355,7 @@ Embargoed Patches At certain times during development, the kernel may include "embargoed" patches, i.e., patches that must not be mad available to parties outside -of SUSE/Novell before an agreed-upon time. Such patches usually have a +of SUSE before an agreed-upon time. Such patches usually have a date of publication that has been coordinated among linux distributors, etc. Such patches must not be committed to the usual branches, because these are pushed to a public mirror, but instead to a branch named with diff --git a/scripts/check-embargoed-bugz b/scripts/check-embargoed-bugz new file mode 100755 index 0000000..950618a --- /dev/null +++ b/scripts/check-embargoed-bugz @@ -0,0 +1,67 @@ +#!/bin/bash +# +# Scan the bug numbers in commit logs and check whether it's still embargoed +# +# Put me on pre-push git hook +# + +if [ ! -x /usr/bin/jq ]; then + echo >&2 "embargoed check: jq is not present, please install jq package" + exit 1 +fi + +remote="$1" +url="$2" + +z40=0000000000000000000000000000000000000000 + +jsonf="$(mktemp)" || exit 1 +trap "rm \"$jsonf\"" 0 1 2 3 15 + +curl -s -o "$jsonf" https://smash.suse.de/api/embargoed-bugs/ || exit 1 + +ids=$(jq -r '.[].bug.name | capture("^bnc#(?[[:digit:]]+)").id' "$jsonf") \ + || exit 1 + +declare -A emb_bugs +for e in $ids; do + emb_bugs[$e]=1 +done + +while read local_ref local_sha remote_ref remote_sha +do + test "$local_sha" = $z40 && continue + case "$remote_ref" in + *_EMBARGO/*) + continue;; + refs/heads/users/*/for-next) + base=${remote_ref#refs/heads/users/*/} + base=${base%/*} + ;; + refs/heads/cve-*|refs/heads/SLE*|refs/heads/openSUSE*) + base=${remote_ref#refs/heads/} + ;; + *) + continue;; + esac + + if [ "$remote_sha" = $z40 ]; then + range="refs/remotes/origin/$base..$local_sha" + else + range="$remote_sha..$local_sha" + fi + bugs=$(git log "$range" | grep -E '\(bsc|bnc|boo)#?[0-9]\+' | sed -e's/[^a-z0-9#]/ /g') + test -z "$bugs" && continue + for w in $bugs; do + case "$w" in + bnc\#[0-9]*|bsc\#[0-9]*|boo\#[0-9]*) + bug=${w#b*#} + if [ -n "${emb_bugs[$bug]}" ]; then + echo >&2 "Found EMABARGO bug (in bsc#$bug) at $local_ref, not pushing" + exit 1 + fi + esac + done +done + +exit 0 diff --git a/scripts/git_sort/git_sort.py b/scripts/git_sort/git_sort.py index 16af2c7..8588d43 100755 --- a/scripts/git_sort/git_sort.py +++ b/scripts/git_sort/git_sort.py @@ -258,6 +258,7 @@ remotes = ( Head(RepoURL("clk/linux.git"), "clk-next"), Head(RepoURL("git://github.com/ceph/ceph-client"), "testing"), Head(RepoURL("bpf/bpf.git")), + Head(RepoURL("bpf/bpf-next.git")), Head(RepoURL("linusw/linux-gpio.git"), "for-next"), ) diff --git a/scripts/git_sort/lib.py b/scripts/git_sort/lib.py index bf3a834..9442b37 100644 --- a/scripts/git_sort/lib.py +++ b/scripts/git_sort/lib.py @@ -133,6 +133,8 @@ def series_header(series): def series_footer(series): + if series_header(series) == series: + return [] return series_header(reversed(series)) @@ -267,11 +269,25 @@ class InputEntry(object): raise exc.KSError("Could not find patch \"%s\"" % (name,)) with Patch(open(name, mode="rb")) as patch: + mainline_tags = patch.get("Patch-mainline") commit_tags = patch.get("Git-commit") repo_tags = patch.get("Git-repo") + if len(repo_tags) > 1: + raise exc.KSError("Multiple Patch-mainline tags found. Patch \"%s\" is " + "tagged improperly." % (name,)) + if not commit_tags: self.dest_head = git_sort.oot + mainline = mainline_tags[0] + if not re.match("^(Submitted|Not yet)", mainline, re.IGNORECASE): + raise exc.KSError( + "There is a problem with patch \"%s\". " + "The Patch-mainline tag \"%s\" is not supported in sorted " + "section. Please add the patches without a commit id that " + "are neither 'Submitted' nor 'Not yet' submitted to the " + "manually maintained section below sorted section." % ( + name, mainline,)) return class BadTag(Exception): diff --git a/scripts/git_sort/tests/opensuse-tumbleweed/Dockerfile b/scripts/git_sort/tests/opensuse-tumbleweed/Dockerfile index 3497815..205d2c8 100644 --- a/scripts/git_sort/tests/opensuse-tumbleweed/Dockerfile +++ b/scripts/git_sort/tests/opensuse-tumbleweed/Dockerfile @@ -5,7 +5,7 @@ RUN zypper -n ref FROM base AS packages -RUN zypper -n in git python3 python3-dbm python3-pygit2 rcs +RUN zypper -n in git python3 python3-dbm python3-pygit2 rcs util-linux RUN git config --global user.email "you@example.com" RUN git config --global user.name "Your Name" diff --git a/scripts/git_sort/tests/support.py b/scripts/git_sort/tests/support.py index 31e4c5e..bd1460d 100644 --- a/scripts/git_sort/tests/support.py +++ b/scripts/git_sort/tests/support.py @@ -3,6 +3,7 @@ import datetime import os.path +import re import pygit2_wrapper as pygit2 @@ -69,13 +70,14 @@ def format_patch(commit, mainline=None, repo=None, references=None, f.write("Date: %s\n" % (dt.strftime("%c %z"),)) if mainline and repo is None: f.write("Patch-mainline: %s\n" % (mainline,)) - f.write("Git-commit: %s\n" % (str(commit.id),)) + if re.match("^v", mainline): + f.write("Git-commit: %s\n" % (str(commit.id),)) elif mainline is None and repo: f.write("Patch-mainline: Queued in subsystem maintainer repository\n") f.write("Git-repo: %s\n" % (repo,)) f.write("Git-commit: %s\n" % (str(commit.id),)) else: - f.write("Patch-mainline: No\n") + f.write("Patch-mainline: Not yet, to be submitted by partner developer\n") if references is not None: f.write("References: %s\n" % (references,)) f.write("Subject: %s" % (commit.message,)) diff --git a/scripts/git_sort/tests/test_quilt_mode.py b/scripts/git_sort/tests/test_quilt_mode.py index 1b32e4a..2f00aea 100755 --- a/scripts/git_sort/tests/test_quilt_mode.py +++ b/scripts/git_sort/tests/test_quilt_mode.py @@ -168,7 +168,7 @@ Signed-off-by: Ingo Molnar content2 = f.read() self.assertEqual(content2, content1) - subprocess.check_call(("git", "init", "./",), stdout=subprocess.DEVNULL) + pygit2.init_repository("./") subprocess.check_call(("git", "add", "series.conf", "patches.suse",), stdout=subprocess.DEVNULL) subprocess.check_call(("git", "commit", "-m", "import",), @@ -460,7 +460,7 @@ class TestMergeTool(unittest.TestCase): self.ks_dir = tempfile.mkdtemp(prefix="gs_ks") os.chdir(self.ks_dir) - subprocess.check_call(("git", "init", "./",), stdout=subprocess.DEVNULL) + pygit2.init_repository("./") subprocess.check_call( ("git", "config", "--add", "mergetool.git-sort.cmd", "%s $LOCAL $BASE $REMOTE $MERGED" % ( diff --git a/scripts/git_sort/tests/test_series_sort.py b/scripts/git_sort/tests/test_series_sort.py index 67e2e4a..96f54e8 100755 --- a/scripts/git_sort/tests/test_series_sort.py +++ b/scripts/git_sort/tests/test_series_sort.py @@ -124,7 +124,7 @@ class TestSeriesSort(unittest.TestCase): tests.support.format_patch(self.repo.get(n1), repo=net_repo) tests.support.format_patch(self.repo.get(n2), repo=net_repo) tests.support.format_patch(self.repo.get(oot0)) - tests.support.format_patch(self.repo.get(oot1)) + tests.support.format_patch(self.repo.get(oot1), mainline="Submitted http://lore.kernel.org/somelist/somemessage") os.chdir(self.ks_dir) @@ -226,6 +226,35 @@ class TestSeriesSort(unittest.TestCase): os.unlink(series) + def test_sort_empty(self): + (tmp, series,) = tempfile.mkstemp(dir=self.ks_dir) + with open(series, mode="w") as f: + f.write( +""" + patches.suse/unsorted-before.patch + + ######################################################## + # sorted patches + ######################################################## + + ######################################################## + # end of sorted patches + ######################################################## + + patches.suse/unsorted-after.patch +""") + + subprocess.check_call([self.ss_path, "-c", series]) + with open(series) as f: + content1 = f.read() + subprocess.check_call([self.ss_path, series]) + with open(series) as f: + content2 = f.read() + self.assertEqual(content2, content1) + + os.unlink(series) + + class TestFromPatch(unittest.TestCase): """ The naming of these tests stems from the following factors which determine diff --git a/scripts/lib/SUSE/MyBS.pm b/scripts/lib/SUSE/MyBS.pm index 206a5f3..71cf2cc 100644 --- a/scripts/lib/SUSE/MyBS.pm +++ b/scripts/lib/SUSE/MyBS.pm @@ -74,7 +74,19 @@ sub new { if (exists($cred{credentials_mgr_class})) { if ($cred{credentials_mgr_class} eq "osc.credentials.ObfuscatedConfigFileCredentialsManager") { $cred{passx}=$cred{pass}; - }} + } elsif ($cred{credentials_mgr_class} eq "osc.credentials.KeyringCredentialsManager:pass.Keyring") { + # emulate by invoking the pass command directly + my $api = $api_url; + $api =~ s/^https?:\/\///; + open(my $secret, "pass show $api/$cred{user} |") + or die "Failed to invoke pass\n"; + $cred{pass} = <$secret>; + close($secret); + die "Failed to obtain secret from pass\n" + if !$cred{pass}; + chomp($cred{pass}); + } + } if (exists($cred{passx})) { # Not available on SLES10, hence the 'require' require MIME::Base64; diff --git a/scripts/refresh_patch.sh b/scripts/refresh_patch.sh index fde07d9..9700b31 100755 --- a/scripts/refresh_patch.sh +++ b/scripts/refresh_patch.sh @@ -9,7 +9,7 @@ export LC_ALL=C export LANG=C -current=` quilt top ` +current="$(quilt top)" case "$current" in */patches.kernel.org/*) echo "Will not touch kernel.org patch '$current' because it will disappear soon." diff --git a/scripts/run_oldconfig.sh b/scripts/run_oldconfig.sh index 5659bfe..fe50a1a 100755 --- a/scripts/run_oldconfig.sh +++ b/scripts/run_oldconfig.sh @@ -373,7 +373,7 @@ ask_reuse_config() filter_config() { - sed -e '/CONFIG_GCC_VERSION/ d' -e '/CONFIG_LD_VERSION/ d' -e '/CONFIG_CC_VERSION_TEXT/ d' -e '/^# .* is not set$/p' -e '/^$\|^#/d' "$@" | sort + sed -e '/CONFIG_GCC_VERSION/ d' -e '/CONFIG_LD_VERSION/ d' -e '/CONFIG_CC_VERSION_TEXT/ d' -e '/CONFIG_PAHOLE_VERSION/ d' -e '/^# .* is not set$/p' -e '/^$\|^#/d' "$@" | sort } # Keep these in the -vanilla fragment even if -default has the same values. diff --git a/scripts/sequence-patch.sh b/scripts/sequence-patch.sh index e1ea2f1..ce51db4 100755 --- a/scripts/sequence-patch.sh +++ b/scripts/sequence-patch.sh @@ -215,7 +215,7 @@ if $have_arch_patches; then else arch_opt="" fi -options=`getopt -o qvd:F: --long quilt,no-quilt,$arch_opt,symbol:,dir:,combine,fast,rapid,vanilla,fuzz:,patch-dir:,build-dir:,config:,kabi,ctags,cscope,etags,skip-reverse,dry-run,signing-key: -- "$@"` +options="$(getopt -o qvd:F: --long quilt,no-quilt,$arch_opt,symbol:,dir:,combine,fast,rapid,vanilla,fuzz:,patch-dir:,build-dir:,config:,kabi,ctags,cscope,etags,skip-reverse,dry-run,signing-key: -- "$@")" if [ $? -ne 0 ] then diff --git a/scripts/stableids b/scripts/stableids index 2965568..5bd3e95 100755 --- a/scripts/stableids +++ b/scripts/stableids @@ -49,10 +49,13 @@ my $range = "v$old_version..v$new_version"; my $repo = Git->repository(); my @revs = $repo->command('rev-list', '--reverse', $range); my %ids; +my $digits = length scalar @revs; my $counter = 1; my @to_delete; my $sha_re = qr/[0-9a-f]{40}/; +$digits = 3 if ($digits < 3); + print "References: bsc#$bsc $new_version\n" if ($dump_only); foreach my $rev (@revs) { @@ -116,7 +119,8 @@ foreach my $rev (@revs) { # drop From shift(@patch) =~ /^From/ or die "From line is not the first one?"; - my $newname = sprintf("$new_version-%03d-%s", $counter, $filename); + my $newname = sprintf("${new_version}-%0${digits}d-%s", $counter, + $filename); # 57 is what git-format-patch uses $newname =~ s/^(.{1,57}).*$/$1.patch/; my $newpath = "$patchpath/$newname"; @@ -147,11 +151,13 @@ exit 0 if ($dump_only); store(\%ids, $idsfile) or die "cannot write $idsfile"; push @to_delete, $idsfile; -system("tar -cC $patchpar $patchdir|ssh -C $machine -o StrictHostKeyChecking=no 'tar -xC $patchpar'") == 0 || - die "ssh didn't start"; -print "Written patches and ids to $machine:$patchpath\n"; +if ($machine ne 'localhost') { + system("tar -cC $patchpar $patchdir|ssh -C $machine -o StrictHostKeyChecking=no 'tar -xC $patchpar'") == 0 || + die "ssh didn't start"; + unlink(@to_delete) or print STDERR "cannot delete some temp files\n"; + rmdir("$patchpath") or print STDERR "cannot remove $patchpath\n"; +} -unlink(@to_delete) or print STDERR "cannot delete some temp files\n"; -rmdir("$patchpath") or print STDERR "cannot remove $patchpath\n"; +print "Written patches and ids to $machine:$patchpath\n"; 0; diff --git a/scripts/update-symvers b/scripts/update-symvers index 0a0986e..d09b17e 100755 --- a/scripts/update-symvers +++ b/scripts/update-symvers @@ -271,7 +271,7 @@ SUSE:SLE-10* | SUSE:SLE-11*) ;; esac -options=`getopt -o h --long symvers,no-symvers,symsets,no-symsets,symtypes,no-symtypes,dry-run,filter:,help -- "$@"` +options="$(getopt -o h --long symvers,no-symvers,symsets,no-symsets,symtypes,no-symtypes,dry-run,filter:,help -- "$@")" if [ $? -ne 0 ]; then usage >&2 exit 1