]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
devtool: standard: simplify get_staging_kver
authorChris Laplante <chris.laplante@agilent.com>
Wed, 29 Jan 2025 20:20:15 +0000 (15:20 -0500)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sat, 1 Feb 2025 08:03:36 +0000 (08:03 +0000)
The goal is to make this more Pythonic, as it was a little cryptic the
first time I looked at it.

Signed-off-by: Chris Laplante <chris.laplante@agilent.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
scripts/lib/devtool/standard.py

index 20c94616b2d53bb16edcca05a923bb9963f7ff68..0cdb9c6cfb9499d52f42582d3e8812421154c05c 100644 (file)
@@ -726,15 +726,13 @@ def _check_preserve(config, recipename):
 
 def get_staging_kver(srcdir):
     # Kernel version from work-shared
-    kerver = []
-    staging_kerVer=""
-    if os.path.exists(srcdir) and os.listdir(srcdir):
+    import itertools
+    try:
         with open(os.path.join(srcdir, "Makefile")) as f:
-            version = [next(f) for x in range(5)][1:4]
-            for word in version:
-                kerver.append(word.split('= ')[1].split('\n')[0])
-            staging_kerVer = ".".join(kerver)
-    return staging_kerVer
+            # Take VERSION, PATCHLEVEL, SUBLEVEL from lines 1, 2, 3
+            return ".".join(line.rstrip().split('= ')[1] for line in itertools.islice(f, 1, 4))
+    except FileNotFoundError:
+        return ""
 
 def get_staging_kbranch(srcdir):
     import bb.process