Skip to content

Commit 62016cb

Browse files
authored
Merge pull request #95 from vmezzela/setup-next
Convert setup to plugins
2 parents 3429c22 + ab41aba commit 62016cb

File tree

7 files changed

+362
-294
lines changed

7 files changed

+362
-294
lines changed

klpbuild/klplib/cmd.py

+1-51
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def add_arg_lp_name(parentparser, mandatory=True):
1414
"--name",
1515
type=str,
1616
required=mandatory,
17+
dest="lp_name",
1718
help="The livepatch name. This will be the directory name of the "
1819
"resulting livepatches.",
1920
)
@@ -44,57 +45,6 @@ def create_parser() -> argparse.ArgumentParser:
4445

4546
# NOTE: all the code below should be gone when all the module will be
4647
# converted into plugins
47-
setup = sub.add_parser("setup")
48-
add_arg_lp_name(setup)
49-
add_arg_lp_filter(setup)
50-
setup.add_argument("--cve", type=str, help="SLE specific. The CVE assigned to this livepatch")
51-
setup.add_argument("--conf", type=str, required=True, help="The kernel CONFIG used to be build the livepatch")
52-
setup.add_argument(
53-
"--no-check",
54-
action="store_true",
55-
help="SLE specific. Do not check for already patched codestreams, do the setup for all non filtered codestreams.",
56-
)
57-
setup.add_argument(
58-
"--file-funcs",
59-
required=False,
60-
action="append",
61-
nargs="*",
62-
default=[],
63-
help="File and functions to be livepatched. Can be set "
64-
"multiple times. The format is --file-funcs file/path.c func1 "
65-
"func2 --file-func file/patch2 func1...",
66-
)
67-
setup.add_argument(
68-
"--mod-file-funcs",
69-
required=False,
70-
action="append",
71-
nargs="*",
72-
default=[],
73-
help="Module, file and functions to be livepatched. Can be set "
74-
"multiple times. The format is --file-funcs module1 file/path.c func1 "
75-
"func2 --file-func module2 file/patch2 func1...",
76-
)
77-
setup.add_argument(
78-
"--conf-mod-file-funcs",
79-
required=False,
80-
action="append",
81-
nargs="*",
82-
default=[],
83-
help="Conf, module, file and functions to be livepatched. Can be set "
84-
"multiple times. The format is --file-funcs conf1 module1 file/path.c func1 "
85-
"func2 --file-func conf2 module2 file/patch2 func1...",
86-
)
87-
setup.add_argument(
88-
"--module", type=str, default="vmlinux", help="The module that will be livepatched for all files"
89-
)
90-
setup.add_argument(
91-
"--archs",
92-
default=ARCHS,
93-
choices=ARCHS,
94-
nargs="+",
95-
help="SLE specific. Supported architectures for this livepatch",
96-
)
97-
9848
check_inline = sub.add_parser("check-inline")
9949
add_arg_lp_name(check_inline)
10050
add_arg_lp_filter(check_inline)

klpbuild/main.py

+13-23
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from klpbuild.klplib.plugins import try_run_plugin
1515
from klpbuild.plugins.extractor import Extractor
1616
from klpbuild.plugins.inline import Inliner
17-
from klpbuild.plugins.setup import Setup
1817

1918

2019
def main():
@@ -23,8 +22,8 @@ def main():
2322
logging_level = logging.DEBUG if args.verbose else logging.INFO
2423
logging.basicConfig(level=logging_level, format="%(message)s")
2524

26-
if hasattr(args, 'name'):
27-
load_codestreams(args.name)
25+
if hasattr(args, 'lp_name'):
26+
load_codestreams(args.lp_name)
2827

2928
try:
3029
try_run_plugin(args.cmd, args)
@@ -39,44 +38,35 @@ def main():
3938

4039
# NOTE: all the code below should be gone when all the modules will be
4140
# converted into plugins
42-
if args.cmd == "setup":
43-
setup = Setup(args.name)
44-
ffuncs = Setup.setup_file_funcs(args.conf, args.module, args.file_funcs,
45-
args.mod_file_funcs, args.conf_mod_file_funcs)
46-
codestreams = setup.setup_codestreams(
47-
{"cve": args.cve, "conf": args.conf, "lp_filter": args.lp_filter,
48-
"no_check": args.no_check})
49-
setup.setup_project_files(codestreams, ffuncs, args.archs)
50-
51-
elif args.cmd == "extract":
52-
Extractor(args.name, args.lp_filter, args.apply_patches, args.avoid_ext).run()
41+
if args.cmd == "extract":
42+
Extractor(args.lp_name, args.lp_filter, args.apply_patches, args.avoid_ext).run()
5343

5444
elif args.cmd == "cs-diff":
55-
Extractor(args.name, args.lp_filter, False, []).cs_diff()
45+
Extractor(args.lp_name, args.lp_filter, False, []).cs_diff()
5646

5747
elif args.cmd == "check-inline":
58-
Inliner(args.name, args.codestream).check_inline(args.file, args.symbol)
48+
Inliner(args.lp_name, args.codestream).check_inline(args.file, args.symbol)
5949

6050
elif args.cmd == "get-patches":
61-
GitHelper(args.lp_filter).get_commits(args.cve, get_workdir(args.name))
51+
GitHelper(args.lp_filter).get_commits(args.cve, get_workdir(args.lp_name))
6252

6353
elif args.cmd == "format-patches":
64-
GitHelper(args.lp_filter).format_patches(args.name, args.version)
54+
GitHelper(args.lp_filter).format_patches(args.lp_name, args.version)
6555

6656
elif args.cmd == "status":
67-
IBS(args.name, args.lp_filter).status(args.wait)
57+
IBS(args.lp_name, args.lp_filter).status(args.wait)
6858

6959
elif args.cmd == "push":
70-
IBS(args.name, args.lp_filter).push(args.wait)
60+
IBS(args.lp_name, args.lp_filter).push(args.wait)
7161

7262
elif args.cmd == "log":
73-
IBS(args.name, args.lp_filter).log(args.arch)
63+
IBS(args.lp_name, args.lp_filter).log(args.arch)
7464

7565
elif args.cmd == "cleanup":
76-
IBS(args.name, args.lp_filter).cleanup()
66+
IBS(args.lp_name, args.lp_filter).cleanup()
7767

7868
elif args.cmd == "prepare-tests":
79-
IBS(args.name, args.lp_filter).prepare_tests()
69+
IBS(args.lp_name, args.lp_filter).prepare_tests()
8070

8171

8272
if __name__ == "__main__":

0 commit comments

Comments
 (0)