Skip to content

Commit b983cf6

Browse files
committed
Merge branch 'devel'
Release v0.0.3
2 parents cdf5862 + 36ade2d commit b983cf6

34 files changed

+1808
-794
lines changed

.github/workflows/ci-cache.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# @file ci-cache.yml
2+
---
3+
name: Update caches
4+
5+
on:
6+
push:
7+
branches:
8+
- "devel"
9+
10+
jobs:
11+
distribution-check:
12+
runs-on: ubuntu-latest
13+
container:
14+
image: opensuse/tumbleweed:latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Install git
19+
run: zypper in -y git
20+
21+
- name: Get month
22+
id: get-month
23+
run: |
24+
echo "month=$(date +%m)" >> $GITHUB_OUTPUT
25+
shell: bash
26+
27+
- name: Cache kernel-source
28+
id: cache-ksrc
29+
uses: actions/cache@v4
30+
with:
31+
path: build/kernel-source
32+
key: kernel-source-${{ steps.get-month.outputs.month }}
33+
34+
- if: ${{ steps.cache-ksrc.outputs.cache-hit != 'true' }}
35+
name: Download kernel-source
36+
continue-on-error: true
37+
run: git clone https://github.com/SUSE/kernel-source build/kernel-source

.github/workflows/ci-tests.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# @file ci-tests.yml
2+
---
3+
name: klp-build tests
4+
5+
on:
6+
pull_request:
7+
branches:
8+
- 'devel'
9+
- 'main'
10+
push:
11+
branches:
12+
- '*'
13+
- '!devel'
14+
- '!main'
15+
16+
jobs:
17+
distribution-check:
18+
runs-on: ubuntu-latest
19+
container:
20+
image: opensuse/tumbleweed:latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Install dependencies
25+
run: zypper in -y python3-devel git python3-pytest tox
26+
27+
- name: Get month
28+
id: get-month
29+
run: |
30+
echo "month=$(date +%m)" >> $GITHUB_OUTPUT
31+
shell: bash
32+
33+
- name: Cache kernel-source
34+
id: cache-ksrc
35+
uses: actions/cache@v4
36+
with:
37+
path: build/kernel-source
38+
key: kernel-source-${{ steps.get-month.outputs.month }}
39+
40+
- if: ${{ steps.cache-ksrc.outputs.cache-hit != 'true' }}
41+
# It will take around 25min to download the whole repo.
42+
# Hopefully we won't have the need to do it very often.
43+
name: Download kernel-source
44+
continue-on-error: true
45+
run: git clone https://github.com/SUSE/kernel-source build/kernel-source
46+
47+
- name: Run klp-build tests
48+
run: |
49+
mkdir -p ~/.config/klp-build &&
50+
cp tests/config ~/.config/klp-build/ &&
51+
mkdir -p klp/{livepatches,data} &&
52+
tox -e tests -- tests/test_{scan,config,ksrc,utils,codestream}.py
53+
54+
- name: Run pylint
55+
run: tox -e lint -- --fail-under 9.4 --fail-on F

Makefile

-25
This file was deleted.

klp-build.1

+10-8
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,19 @@ Generic options available for all commands:
2424
.B "-h, --help"
2525
Show command's help message and exit.
2626
.TP
27+
.B "-v, --verbose"
28+
Produce more verbose output.
29+
.TP
2730
.BI "-n, --name" " NAME"
2831
The livepatch name. This will be the directory name of the resulting
2932
livepatches.
3033
.TP
3134
.BI --filter " FILTER"
3235
List of accepted codestreams. Must be specified in regex format.
33-
Example: "15\.3u[0-9]+|15\.6u0"
36+
Example: '15\.3u[0-9]+|15\.6u0'
37+
.br
38+
You can also use a negative regex in order to filter out a specific codestream.
39+
Example: '^(?!12.5u12).*'
3440
.SH COMMANDS
3541
.TP
3642
.B scan
@@ -94,10 +100,6 @@ will be livepatched instead.
94100
.TP
95101
.BI --archs " {ppc64le,s390x,x86_64} [{ppc64le,s390x,x86_64} ...]"
96102
Supported architectures for this livepatch.
97-
.TP
98-
.BI --skips " SKIPS"
99-
List of excluded codestreams. Must be specified in regex format.
100-
Example: "15\.3u[0-9]+|15\.6u0"
101103
.RE
102104
.B check-inline
103105
.RS 7
@@ -185,11 +187,11 @@ Wait until all codestreams builds are finished.
185187
Get build logs from SUSE'S Build Service.
186188
.RS 7
187189
.TP
188-
.BI --cs " CS"
189-
The codestream to get the log from.
190-
.TP
191190
.BI --arch " {ppc64le,s390x,x86_64}"
192191
Build architecture.
192+
.TP
193+
.BI --filter
194+
Required. Needs to specify only specific codestream.
193195
.RE
194196
.SH FILES
195197
.TP

klpbuild/klplib/bugzilla.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
#
3+
# Copyright (C) 2021-2025 SUSE
4+
# Authors: Fernando Gonzalez
5+
# Marcos Paulo de Souza <[email protected]>
6+
7+
import bugzilla
8+
from klpbuild.klplib.config import get_user_settings
9+
10+
11+
def get_bug_data(bsc):
12+
bz_key = get_user_settings("bugzilla_api_key", True)
13+
if 'changeit' in bz_key:
14+
raise RuntimeError("Change the bugzilla_api_key to a valid key.")
15+
16+
bzapi = bugzilla.Bugzilla("https://bugzilla.suse.com", api_key=bz_key)
17+
18+
return bzapi.getbug(bsc)
19+
20+
21+
def get_bug_title(bsc):
22+
"""
23+
The bug description usually is after the "kernel live patch" message. Return a fixes message
24+
if the livepatch name is not an ID from a bug on bugzilla.
25+
"""
26+
if not bsc.isnumeric():
27+
return "Change me!"
28+
29+
data = str(get_bug_data(int(bsc)).summary)
30+
return data.split("kernel live patch: ")[1].strip()

klpbuild/klplib/cmd.py

+63-34
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,47 @@
66
import argparse
77

88
from klpbuild.klplib.utils import ARCHS
9+
from klpbuild.klplib.plugins import register_plugins_argparser
910

10-
11-
def create_parser() -> argparse.ArgumentParser:
12-
parentparser = argparse.ArgumentParser(add_help=False)
11+
def add_arg_lp_name(parentparser, mandatory=True):
1312
parentparser.add_argument(
1413
"-n",
1514
"--name",
1615
type=str,
17-
required=True,
16+
required=mandatory,
1817
help="The livepatch name. This will be the directory name of the "
1918
"resulting livepatches.",
2019
)
21-
parentparser.add_argument("--filter", type=str, help=r"Filter out codestreams using a regex. Example: 15\.3u[0-9]+")
2220

23-
parser = argparse.ArgumentParser(add_help=False)
24-
sub = parser.add_subparsers(dest="cmd")
2521

26-
setup = sub.add_parser("setup", parents=[parentparser])
22+
def add_arg_lp_filter(parentparser, mandatory=False):
23+
parentparser.add_argument(
24+
"--filter",
25+
type=str,
26+
required=mandatory,
27+
dest="lp_filter",
28+
help=r"Filter out codestreams using a regex. Example: 15\.3u[0-9]+"
29+
)
30+
31+
32+
def create_parser() -> argparse.ArgumentParser:
33+
parentparser = argparse.ArgumentParser(add_help=True)
34+
sub = parentparser.add_subparsers(dest="cmd")
35+
36+
parentparser.add_argument(
37+
"-v",
38+
"--verbose",
39+
action="store_true",
40+
help="Produce more verbose output"
41+
)
42+
43+
register_plugins_argparser(sub)
44+
45+
# NOTE: all the code below should be gone when all the module will be
46+
# converted into plugins
47+
setup = sub.add_parser("setup")
48+
add_arg_lp_name(setup)
49+
add_arg_lp_filter(setup)
2750
setup.add_argument("--cve", type=str, help="SLE specific. The CVE assigned to this livepatch")
2851
setup.add_argument("--conf", type=str, required=True, help="The kernel CONFIG used to be build the livepatch")
2952
setup.add_argument(
@@ -71,9 +94,10 @@ def create_parser() -> argparse.ArgumentParser:
7194
nargs="+",
7295
help="SLE specific. Supported architectures for this livepatch",
7396
)
74-
setup.add_argument("--skips", help="List of codestreams to filter out")
7597

76-
check_inline = sub.add_parser("check-inline", parents=[parentparser])
98+
check_inline = sub.add_parser("check-inline")
99+
add_arg_lp_name(check_inline)
100+
add_arg_lp_filter(check_inline)
77101
check_inline.add_argument(
78102
"--codestream",
79103
type=str,
@@ -94,7 +118,9 @@ def create_parser() -> argparse.ArgumentParser:
94118
help="Symbol to be found",
95119
)
96120

97-
extract_opts = sub.add_parser("extract", parents=[parentparser])
121+
extract_opts = sub.add_parser("extract")
122+
add_arg_lp_name(extract_opts)
123+
add_arg_lp_filter(extract_opts)
98124
extract_opts.add_argument(
99125
"--avoid-ext",
100126
nargs="+",
@@ -107,49 +133,52 @@ def create_parser() -> argparse.ArgumentParser:
107133
extract_opts.add_argument(
108134
"--apply-patches", action="store_true", help="Apply patches found by get-patches subcommand, if they exist"
109135
)
110-
diff_opts = sub.add_parser("cs-diff", parents=[parentparser])
111-
diff_opts.add_argument(
112-
"--cs", nargs=2, type=str, required=True, help="SLE specific. Apply diff on two different codestreams"
113-
)
136+
137+
diff_opts = sub.add_parser("cs-diff")
138+
add_arg_lp_name(diff_opts)
139+
add_arg_lp_filter(diff_opts)
114140

115141
fmt = sub.add_parser(
116-
"format-patches", parents=[parentparser], help="SLE specific. Extract patches from kgraft-patches"
142+
"format-patches", help="SLE specific. Extract patches from kgraft-patches"
117143
)
144+
add_arg_lp_name(fmt)
145+
add_arg_lp_filter(fmt)
118146
fmt.add_argument("-v", "--version", type=int, required=True, help="Version to be added, like vX")
119147

120-
patches = sub.add_parser("get-patches", parents=[parentparser])
148+
patches = sub.add_parser("get-patches")
149+
add_arg_lp_name(patches)
150+
add_arg_lp_filter(patches)
121151
patches.add_argument(
122152
"--cve", required=True, help="SLE specific. CVE number to search for related backported patches"
123153
)
124154

125-
scan = sub.add_parser("scan")
126-
scan.add_argument(
127-
"--cve", required=True, help="SLE specific. Shows which codestreams are vulnerable to the CVE"
128-
)
129-
scan.add_argument(
130-
"--conf", required=False, help="SLE specific. Helps to check only the codestreams that have this config set."
131-
)
132155

133-
sub.add_parser("cleanup", parents=[parentparser], help="SLE specific. Remove livepatch packages from IBS")
156+
cleanup =sub.add_parser("cleanup", help="SLE specific. Remove livepatch packages from IBS")
157+
add_arg_lp_name(cleanup)
158+
add_arg_lp_filter(cleanup)
134159

135-
sub.add_parser(
160+
test = sub.add_parser(
136161
"prepare-tests",
137-
parents=[parentparser],
138162
help="SLE specific. Download the built tests and check for LP dependencies",
139163
)
164+
add_arg_lp_name(test)
165+
add_arg_lp_filter(test)
140166

141167
push = sub.add_parser(
142-
"push", parents=[parentparser], help="SLE specific. Push livepatch packages to IBS to be built"
168+
"push", help="SLE specific. Push livepatch packages to IBS to be built"
143169
)
170+
add_arg_lp_name(push)
171+
add_arg_lp_filter(push)
144172
push.add_argument("--wait", action="store_true", help="Wait until all codestreams builds are finished")
145173

146-
status = sub.add_parser("status", parents=[parentparser], help="SLE specific. Check livepatch build status on IBS")
174+
status = sub.add_parser("status", help="SLE specific. Check livepatch build status on IBS")
175+
add_arg_lp_name(status)
176+
add_arg_lp_filter(status)
147177
status.add_argument("--wait", action="store_true", help="Wait until all codestreams builds are finished")
148178

149-
log = sub.add_parser("log", parents=[parentparser], help="SLE specific. Get build log from IBS")
150-
log.add_argument("--cs", type=str, required=True, help="The codestream to get the log from")
179+
log = sub.add_parser("log", help="SLE specific. Get build log from IBS")
180+
add_arg_lp_name(log)
181+
add_arg_lp_filter(log, mandatory=True)
151182
log.add_argument("--arch", type=str, default="x86_64", choices=ARCHS, help="Build architecture")
152183

153-
return parser
154-
155-
184+
return parentparser

0 commit comments

Comments
 (0)