* [PATCH 1/1] Fixed bug in kcompile where run would fail if kcompile-source version had the form x.y instead of x.y.z
@ 2023-06-28 21:57 Anubhav Shelat
2023-06-29 18:48 ` John Kacur
0 siblings, 1 reply; 2+ messages in thread
From: Anubhav Shelat @ 2023-06-28 21:57 UTC (permalink / raw)
To: linux-rt-users; +Cc: kcarcia, 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 <ashelat@redhat.com>
---
rteval/modules/loads/kcompile.py | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/rteval/modules/loads/kcompile.py b/rteval/modules/loads/kcompile.py
index 35ee5cbbb52d..445575fb137a 100644
--- a/rteval/modules/loads/kcompile.py
+++ b/rteval/modules/loads/kcompile.py
@@ -175,8 +175,11 @@ 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)
-
+ try:
+ tarfile_prefix = re.search(r"\d{1,2}\.\d{1,3}\.*\d{1,2}", self._cfg.source).group(0)
+ except AttributeError:
+ # if the kernel version has the form x.x instead of x.x.x
+ tarfile_prefix = re.search(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" )
gz_file = os.path.join(self.srcdir,"linux-" + tarfile_prefix + ".tar.gz" )
@@ -193,7 +196,11 @@ 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)
+ try:
+ kernel_prefix = re.search(r"linux-\d{1,2}\.\d{1,3}\.*\d{1,2}", self.source).group(0)
+ except AttributeError:
+ # if the kernel version has the form x.x instead of x.x.x
+ kernel_prefix = re.search(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:
--
2.39.3
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH 1/1] Fixed bug in kcompile where run would fail if kcompile-source version had the form x.y instead of x.y.z
2023-06-28 21:57 [PATCH 1/1] Fixed bug in kcompile where run would fail if kcompile-source version had the form x.y instead of x.y.z Anubhav Shelat
@ 2023-06-29 18:48 ` John Kacur
0 siblings, 0 replies; 2+ messages in thread
From: John Kacur @ 2023-06-29 18:48 UTC (permalink / raw)
To: Anubhav Shelat; +Cc: linux-rt-users, kcarcia
On Wed, 28 Jun 2023, Anubhav Shelat wrote:
> 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 <ashelat@redhat.com>
> ---
> rteval/modules/loads/kcompile.py | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/rteval/modules/loads/kcompile.py b/rteval/modules/loads/kcompile.py
> index 35ee5cbbb52d..445575fb137a 100644
> --- a/rteval/modules/loads/kcompile.py
> +++ b/rteval/modules/loads/kcompile.py
> @@ -175,8 +175,11 @@ 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)
> -
> + try:
> + tarfile_prefix = re.search(r"\d{1,2}\.\d{1,3}\.*\d{1,2}", self._cfg.source).group(0)
> + except AttributeError:
> + # if the kernel version has the form x.x instead of x.x.x
> + tarfile_prefix = re.search(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" )
> gz_file = os.path.join(self.srcdir,"linux-" + tarfile_prefix + ".tar.gz" )
> @@ -193,7 +196,11 @@ 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)
> + try:
> + kernel_prefix = re.search(r"linux-\d{1,2}\.\d{1,3}\.*\d{1,2}", self.source).group(0)
> + except AttributeError:
> + # if the kernel version has the form x.x instead of x.x.x
> + kernel_prefix = re.search(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:
> --
> 2.39.3
>
>
We don't want to use a try/except block to detect that our regular
expression didn't match. Instead construct a regular expression that will
match both the cases of linux-x.y.z.tar.gz and linux-x.y.tar.gz
Note \d{1,2} means one to two digits
you can group those with parenthesis
(\d{1,3}\.){1,2}
The above matches 1 to 3 digits followed by a period and that whole group
1 to 2 times.
Use your interactive python interpreter to play with the regular
expression before creating your patch.
John
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-06-29 18:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-28 21:57 [PATCH 1/1] Fixed bug in kcompile where run would fail if kcompile-source version had the form x.y instead of x.y.z Anubhav Shelat
2023-06-29 18:48 ` John Kacur
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox