Skip to contentSkip to conversation

Fixed bug in kcompile where run would fail if kcompile-source version had the form x.y instead of x.y.z

PATCH In review Anubhav Shelat 2 participants 4 messages Jun 30, 2023

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 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
index 35ee5cbbb52d..92442468febf 100644
@@ -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,3})|(\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,3})|(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
#1 lore raw

PATCH v3 2/2 Edited code from previous commit to exclude try-except block

Edited code, from previous commit that allowed -S to download kernel versions of the form x.y, to exclude try-except block.

---
 rteval-cmd | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
rteval-cmd +1 -5
index d019da41d8d3..44921dfe0764 100755
@@ -291,11 +291,7 @@ if __name__ == '__main__':
                 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:
-                try:
-                    kernel_prefix = re.search(r"\d{1,2}\.\d{1,3}\.*\d{1,2}", rtevcfg.srcdownload).group(0)
-                except AttributeError:
-                    # if kernel version specified is of the form x.x and not x.x.x
-                    kernel_prefix = re.search(r"\d{1,2}\.\d{1,3}", rtevcfg.srcdownload).group(0)
+                kernel_prefix = re.search(r"(\d{1,2}\.\d{1,3}\.\d{1,3})|(\d{1,2}\.\d{1,3})", 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/"
 
Signature · 1 line
2.39.3
#2 lore raw

Re: [PATCH v3 2/2] Edited code from previous commit to exclude try-except block

Quoted 29 lines · Anubhav Shelat

Edited code, from previous commit that allowed -S to download kernel versions of the form x.y, to exclude try-except block.

---
 rteval-cmd | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
rteval-cmd +1 -5
index d019da41d8d3..44921dfe0764 100755
@@ -291,11 +291,7 @@ if __name__ == '__main__':
                 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:
-                try:
-                    kernel_prefix = re.search(r"\d{1,2}\.\d{1,3}\.*\d{1,2}", rtevcfg.srcdownload).group(0)
-                except AttributeError:
-                    # if kernel version specified is of the form x.x and not x.x.x
-                    kernel_prefix = re.search(r"\d{1,2}\.\d{1,3}", rtevcfg.srcdownload).group(0)
+                kernel_prefix = re.search(r"(\d{1,2}\.\d{1,3}\.\d{1,3})|(\d{1,2}\.\d{1,3})", 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/"
 
Signature · 1 line
2.39.3

- Modified comment

#3 lore raw
In reply to Anubhav Shelat
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

---
 rteval/modules/loads/kcompile.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
rteval/modules/loads/kcompile.py +2 -2
index 35ee5cbbb52d..92442468febf 100644
@@ -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,3})|(\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,3})|(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

Thanks