Fixed bug in kcompile where run would fail if kcompile-source version had the form x.y instead of x.y.z
PATCH v2 1/1 Fixed bug in kcompile where run would fail if kcompile-source version had the form x.y instead of x.y.z
Fixed bug in kcompile where run would fail if kcompile-source version had the form x.y instead of x.y.z
--- rteval/modules/loads/kcompile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
rteval/modules/loads/kcompile.py +2 -2
@@ -175,7 +175,7 @@ class Kcompile(CommandLineLoad): if 'rc' in self._cfg.source: tarfile_prefix = re.search(r"\d{1,2}\.\d{1,3}\-[a-z]*\d{1,2}", self._cfg.source).group(0) else: - tarfile_prefix = re.search(r"\d{1,2}\.\d{1,3}\.*\d{1,2}", self._cfg.source).group(0) + tarfile_prefix = re.search(r"\d{1,2}\.\d{1,3}\.*\d{1,2}" + "|" + r"\d{1,2}\.\d{1,3}", self._cfg.source).group(0) # either a tar.xz or tar.gz might exist. Check for both. xz_file = os.path.join(self.srcdir,"linux-" + tarfile_prefix + ".tar.xz" )
@@ -193,7 +193,7 @@ class Kcompile(CommandLineLoad): # find our source tarball if self._cfg.source: self.source = self._find_tarball() - kernel_prefix = re.search(r"linux-\d{1,2}\.\d{1,3}\.*\d{1,2}", self.source).group(0) + kernel_prefix = re.search(r"linux-\d{1,2}\.\d{1,3}\.*\d{1,2}" + "|" + r"linux-\d{1,2}\.\d{1,3}", self.source).group(0) else: tarfiles = glob.glob(os.path.join(self.srcdir, f"{DEFAULT_KERNEL_PREFIX}*")) if tarfiles:
Signature · 1 line
2.39.3
Quoted 34 lines · Anubhav Shelat
Fixed bug in kcompile where run would fail if kcompile-source version had the form x.y instead of x.y.z
Signed-off-by Anubhav Shelat <[email protected]>--- rteval/modules/loads/kcompile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)rteval/modules/loads/kcompile.py +2
-2@@ -175,7 +175,7 @@ class Kcompile(CommandLineLoad): if 'rc' in self._cfg.source: tarfile_prefix = re.search(r"\d{1,2}\.\d{1,3}\-[a-z]*\d{1,2}", self._cfg.source).group(0) else: - tarfile_prefix = re.search(r"\d{1,2}\.\d{1,3}\.*\d{1,2}", self._cfg.source).group(0) + tarfile_prefix = re.search(r"\d{1,2}\.\d{1,3}\.*\d{1,2}" + "|" + r"\d{1,2}\.\d{1,3}", self._cfg.source).group(0) # either a tar.xz or tar.gz might exist. Check for both. xz_file = os.path.join(self.srcdir,"linux-" + tarfile_prefix + ".tar.xz" )@@ -193,7 +193,7 @@ class Kcompile(CommandLineLoad): # find our source tarball if self._cfg.source: self.source = self._find_tarball() - kernel_prefix = re.search(r"linux-\d{1,2}\.\d{1,3}\.*\d{1,2}", self.source).group(0) + kernel_prefix = re.search(r"linux-\d{1,2}\.\d{1,3}\.*\d{1,2}" + "|" + r"linux-\d{1,2}\.\d{1,3}", self.source).group(0) else: tarfiles = glob.glob(os.path.join(self.srcdir, f"{DEFAULT_KERNEL_PREFIX}*")) if tarfiles:Signature · 1 line
2.39.3
Almost there.
Firstly I would remove the asterisk. Whoever created the intial regular expression was probably mixing up the shell pattern matching where that would match 0 or more of any character, but as a regular expression it means to match 0 or more of the previous character which is a dot. The intention was probably to allow characters like "rc" (release candidate). There is no point in matching multiple dots, so just remove it.
There is no need to use that kind of string concatenation, just group the entire first pattern with parenthesis and the second one too with the '|' inbetween, like this
r"(\d{1,2}\.\d{1,3}\.\d{1,3})|(\d{1,2}\.\d{1,3})"
Finally note that in the x.y.z pattern the 'z' is the one most likely to reach 3-digits, I changed it above.
Make sure to test in both your interactive interpreter and finally in rteval itself.
Thanks!
John