diff --git a/rteval-Add-man-page-entry-for-S-source-download-opti.patch b/rteval-Add-man-page-entry-for-S-source-download-opti.patch new file mode 100644 index 0000000..06a660f --- /dev/null +++ b/rteval-Add-man-page-entry-for-S-source-download-opti.patch @@ -0,0 +1,32 @@ +From 3efd2336fc8e877a8be2e18e226090fcf86dc550 Mon Sep 17 00:00:00 2001 +From: Manasi Godse +Date: Tue, 26 Jul 2022 08:51:35 -0700 +Subject: [PATCH 2/2] rteval: Add man page entry for -S, --source-download + option + +Update the man page for rteval kernel download option + +Signed-off-by: Manasi Godse +Signed-off-by: John Kacur +--- + doc/rteval.8 | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/doc/rteval.8 b/doc/rteval.8 +index 25dcfcc298e7..a8129f18a9f5 100644 +--- a/doc/rteval.8 ++++ b/doc/rteval.8 +@@ -108,6 +108,10 @@ Log the output of the loads in the report directory + .TP + .B \-O, \-\-onlyload + Only run the loads (don't run measurement threads) ++.TP ++.B \-S KERNEL_VERSION, \-\-source\-download=KERNEL_VERSION ++download a source kernel from kernel.org and exit ++ + + .SH MODULE OPTIONS + These are options that affect the execution behavior of the measurement and load modules. +-- +2.37.3 + diff --git a/rteval-Add-option-for-downloading-kernel.patch b/rteval-Add-option-for-downloading-kernel.patch new file mode 100644 index 0000000..d4c5245 --- /dev/null +++ b/rteval-Add-option-for-downloading-kernel.patch @@ -0,0 +1,135 @@ +From 887b5901fcc162279f6f32bd3b61914b9be377bd Mon Sep 17 00:00:00 2001 +From: Manasi Godse +Date: Wed, 13 Jul 2022 13:25:31 -0700 +Subject: [PATCH 1/2] rteval: Add option for downloading kernel + +Added an option -S, --source-download to download a kernel source +tarball from kernel.org to the appropriate loadsource directory. +Acceptable strings for the kernel version are 'linux-5.18.1.tar.xz;, +'linux-5.18.1.tar.gz', 'linux-5.18.1', '5.18.1', 'linux-5.19-rc5'. + +Conditions have been added to check for default kernel packaged with +rteval-loads and backing up the tarball if it already exists. This +enhancement simplifies the manual downloading of kernel to the loadsource +directory. + +Signed-off-by: Manasi Godse +Tested-by: Leah Leshchinsky +- Two small tweaks, non-standard "anyways" changed to "anyway", and + added the words "and exit" to the end of the help option +Signed-off-by: John Kacur +--- + rteval-cmd | 61 ++++++++++++++++++++++++++++++++++++++++++ + rteval/rtevalConfig.py | 1 + + 2 files changed, 62 insertions(+) + +diff --git a/rteval-cmd b/rteval-cmd +index 4598ba514ddc..c1a68bd5133b 100755 +--- a/rteval-cmd ++++ b/rteval-cmd +@@ -37,8 +37,11 @@ + import sys + import os + import time ++import re ++import shutil + import optparse + import tempfile ++import requests + import lxml.etree + from rteval.Log import Log + from rteval import RtEval, rtevalConfig +@@ -46,6 +49,7 @@ from rteval.modules.loads import LoadModules + from rteval.modules.measurement import MeasurementModules + from rteval.version import RTEVAL_VERSION + from rteval.misc import invert_cpulist, compress_cpulist ++from rteval.modules.loads.kcompile import ModuleParameters + + def summarize(repfile, xslt): + """ Summarize an already existing XML report """ +@@ -158,6 +162,10 @@ def parse_options(cfg, parser, cmdargs): + parser.add_option("-V", "--version", dest="rteval___version", + action='store_true', default=False, + help='print rteval version and exit') ++ parser.add_option("-S", "--source-download", dest="rteval___srcdownload", ++ type="string", default=None, metavar="KERNEL_VERSION", ++ help='download a source kernel from kernel.org and exit') ++ + + if not cmdargs: + cmdargs = ["--help"] +@@ -254,6 +262,59 @@ if __name__ == '__main__': + measuremods.SetupModuleOptions(parser) + cmd_args = parse_options(config, parser, sys.argv[1:]) + ++ # download kernel tarball ++ if rtevcfg.srcdownload: ++ logger.log(Log.DEBUG, f"Kernel Version to download = {rtevcfg.srcdownload}") ++ ++ # handle a kernel version like linux-5.19-rc5 ++ if 'rc' in rtevcfg.srcdownload: ++ kernel_prefix = re.search(r"\d{1,2}\.\d{1,3}\-[a-z]*\d{1,2}", rtevcfg.srcdownload).group(0) ++ url = "https://git.kernel.org/torvalds/t/" ++ else: ++ kernel_prefix = re.search(r"\d{1,2}\.\d{1,3}\.*\d{1,2}", rtevcfg.srcdownload).group(0) ++ major_version = re.search(r"\d{1,2}", kernel_prefix).group(0) ++ url = "https://kernel.org/pub/linux/kernel/v" + major_version + ".x/" ++ ++ ++ if rtevcfg.srcdownload.endswith(".gz") or 'rc' in rtevcfg.srcdownload: ++ rtevcfg.srcdownload = "linux-" + kernel_prefix + ".tar.gz" ++ else: ++ rtevcfg.srcdownload = "linux-" + kernel_prefix + ".tar.xz" ++ tarfl = os.path.join(rtevcfg.srcdir, rtevcfg.srcdownload) ++ ++ # if default kernel packages with rteval-loads exists, do not download/overwrite ++ default_kernel_file = ModuleParameters().get('source').get('default') ++ if os.path.exists(tarfl): ++ if rtevcfg.srcdownload == default_kernel_file: ++ sys.exit("Default kernel already exists, will not download") ++ prompt = input("Kernel already exists, download and overwrite anyway? (y/n) ") ++ prompt = prompt.lower() ++ if prompt in ('no', 'n'): ++ sys.exit("Exiting") ++ elif prompt in ('yes','y'): ++ # backup the existing kernel in case it needs to be restored later ++ shutil.move(tarfl, tarfl + ".bkup") ++ else: ++ sys.exit("Invalid option. Exiting") ++ ++ url = url + rtevcfg.srcdownload ++ print(f"Downloading kernel {url}") ++ downloaded_file = requests.get(url) ++ if downloaded_file.status_code != 200: ++ # restore the kernel file if it exists ++ if os.path.exists(tarfl + ".bkup"): ++ shutil.move(tarfl + ".bkup", tarfl) ++ sys.exit(f"Could not download tar file {rtevcfg.srcdownload}, status code {downloaded_file.status_code}") ++ with open(tarfl, 'wb') as fd: ++ fd.write(downloaded_file.content) ++ logger.log(Log.DEBUG, f"Kernel source {rtevcfg.srcdownload} downloaded successfully") ++ logger.log(Log.DEBUG, f"Downloaded to directory location: {rtevcfg.srcdir}") ++ # download was successful, delete the backup file if it exists ++ if os.path.exists(tarfl + ".bkup"): ++ os.remove(tarfl + ".bkup") ++ sys.exit(0) ++ ++ + # if we only specified one set of cpus (loads or measurement) + # default the other to the inverse of the specified list + ldcfg = config.GetSection('loads') +diff --git a/rteval/rtevalConfig.py b/rteval/rtevalConfig.py +index 56bbc9ee0de6..decd36ed18ab 100644 +--- a/rteval/rtevalConfig.py ++++ b/rteval/rtevalConfig.py +@@ -97,6 +97,7 @@ default_config = { + 'xslt_histogram': default_config_search(['rteval_histogram_raw.xsl'], os.path.isfile), + 'report_interval': '600', + 'logging' : False, ++ 'srcdownload': None, + } + } + +-- +2.37.3 + diff --git a/rteval.spec b/rteval.spec index 422beda..dea5c2a 100644 --- a/rteval.spec +++ b/rteval.spec @@ -1,6 +1,6 @@ Name: rteval Version: 3.4 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Utility to evaluate system suitability for RT Linux Group: Development/Tools @@ -29,6 +29,8 @@ Requires: libmpc, libmpc-devel BuildArch: noarch #Patches +Patch1: rteval-Add-option-for-downloading-kernel.patch +Patch2: rteval-Add-man-page-entry-for-S-source-download-opti.patch %description The rteval script is a utility for measuring various aspects of @@ -41,6 +43,8 @@ to the screen. %prep %setup -q +%patch1 -p1 +%patch2 -p1 %build %{__python3} setup.py build @@ -62,6 +66,11 @@ to the screen. %{_bindir}/rteval %changelog +* Mon Sep 12 2022 John Kacur - 3.4-2 +- Add option for downloading the kernel to compile as a load +- Add a manpage entry for the kernel download option +Resolves: rhbz#2107711 + * Tue Jun 28 2022 John Kacur - 3.4-1 - Rebase to rteval-3.4 upstream Resolves: rhbz#2069358