Skip to contentSkip to conversation

insane.bbclass: use 4 spaces for indentation

PATCH In review Martin Jansa 2 participants 4 messages Feb 15, 2023 – Feb 17, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 insane.bbclass: use 4 spaces for indentation

* this block was using just 3

---
 meta/classes-global/insane.bbclass | 50 +++++++++++++++---------------
 1 file changed, 25 insertions(+), 25 deletions(-)
meta/classes-global/insane.bbclass +25 -25
index e1295f8539..720b75c395 100644
@@ -1349,31 +1349,31 @@ python do_qa_patch() {
 
     coremeta_path = os.path.join(d.getVar('COREBASE'), 'meta', '')
     for url in patch.src_patches(d):
-       (_, _, fullpath, _, _, _) = bb.fetch.decodeurl(url)
-
-       # skip patches not in oe-core
-       patchtype = "patch-status-core"
-       if not os.path.abspath(fullpath).startswith(coremeta_path):
-           patchtype = "patch-status-noncore"
-           if not allpatches:
-               continue
-
-       kinda_status_re = re.compile(r"^.*upstream.*status.*$", re.IGNORECASE | re.MULTILINE)
-       strict_status_re = re.compile(r"^Upstream-Status: (Pending|Submitted|Denied|Accepted|Inappropriate|Backport|Inactive-Upstream)( .+)?$", re.MULTILINE)
-       guidelines = "https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines#Patch_Header_Recommendations:_Upstream-Status"
-
-       with open(fullpath, encoding='utf-8', errors='ignore') as f:
-           file_content = f.read()
-           match_kinda = kinda_status_re.search(file_content)
-           match_strict = strict_status_re.search(file_content)
-
-           if not match_strict:
-               if match_kinda:
-                   msg = "Malformed Upstream-Status in patch\n%s\nPlease correct according to %s :\n%s" % (fullpath, guidelines, match_kinda.group(0))
-                   oe.qa.handle_error(patchtype, msg, d)
-               else:
-                   msg = "Missing Upstream-Status in patch\n%s\nPlease add according to %s ." % (fullpath, guidelines)
-                   oe.qa.handle_error(patchtype, msg, d)
+        (_, _, fullpath, _, _, _) = bb.fetch.decodeurl(url)
+
+        # skip patches not in oe-core
+        patchtype = "patch-status-core"
+        if not os.path.abspath(fullpath).startswith(coremeta_path):
+            patchtype = "patch-status-noncore"
+            if not allpatches:
+                continue
+
+        kinda_status_re = re.compile(r"^.*upstream.*status.*$", re.IGNORECASE | re.MULTILINE)
+        strict_status_re = re.compile(r"^Upstream-Status: (Pending|Submitted|Denied|Accepted|Inappropriate|Backport|Inactive-Upstream)( .+)?$", re.MULTILINE)
+        guidelines = "https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines#Patch_Header_Recommendations:_Upstream-Status"
+
+        with open(fullpath, encoding='utf-8', errors='ignore') as f:
+            file_content = f.read()
+            match_kinda = kinda_status_re.search(file_content)
+            match_strict = strict_status_re.search(file_content)
+
+            if not match_strict:
+                if match_kinda:
+                    msg = "Malformed Upstream-Status in patch\n%s\nPlease correct according to %s :\n%s" % (fullpath, guidelines, match_kinda.group(0))
+                    oe.qa.handle_error(patchtype, msg, d)
+                else:
+                    msg = "Missing Upstream-Status in patch\n%s\nPlease add according to %s ." % (fullpath, guidelines)
+                    oe.qa.handle_error(patchtype, msg, d)
 
     oe.qa.exit_if_errors(d)
 }
Signature · 1 line
2.39.2
#1 lore raw

RFC PATCH 2/3 insane.bbclass: move Upstream-Status logic to oe.qa

* to be used by standalone script scripts/contrib/patchreview.py as well

---
 meta/classes-global/insane.bbclass | 19 +++----------------
 meta/lib/oe/qa.py                  | 17 +++++++++++++++++
 2 files changed, 20 insertions(+), 16 deletions(-)
meta/classes-global/insane.bbclass +3 -16
index 720b75c395..c8e4219389 100644
@@ -1358,22 +1358,9 @@ python do_qa_patch() {
             if not allpatches:
                 continue
 
-        kinda_status_re = re.compile(r"^.*upstream.*status.*$", re.IGNORECASE | re.MULTILINE)
-        strict_status_re = re.compile(r"^Upstream-Status: (Pending|Submitted|Denied|Accepted|Inappropriate|Backport|Inactive-Upstream)( .+)?$", re.MULTILINE)
-        guidelines = "https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines#Patch_Header_Recommendations:_Upstream-Status"
-
-        with open(fullpath, encoding='utf-8', errors='ignore') as f:
-            file_content = f.read()
-            match_kinda = kinda_status_re.search(file_content)
-            match_strict = strict_status_re.search(file_content)
-
-            if not match_strict:
-                if match_kinda:
-                    msg = "Malformed Upstream-Status in patch\n%s\nPlease correct according to %s :\n%s" % (fullpath, guidelines, match_kinda.group(0))
-                    oe.qa.handle_error(patchtype, msg, d)
-                else:
-                    msg = "Missing Upstream-Status in patch\n%s\nPlease add according to %s ." % (fullpath, guidelines)
-                    oe.qa.handle_error(patchtype, msg, d)
+        msg = oe.qa.check_upstream_status(fullpath)
+        if msg:
+            oe.qa.handle_error(patchtype, msg, d)
 
     oe.qa.exit_if_errors(d)
 }
meta/lib/oe/qa.py +17 -0
index b4cbc50045..de980638c4 100644
@@ -213,6 +213,23 @@ def exit_with_message_if_errors(message, d):
 def exit_if_errors(d):
     exit_with_message_if_errors("Fatal QA errors were found, failing task.", d)
 
+def check_upstream_status(fullpath):
+    import re
+    kinda_status_re = re.compile(r"^.*upstream.*status.*$", re.IGNORECASE | re.MULTILINE)
+    strict_status_re = re.compile(r"^Upstream-Status: (Pending|Submitted|Denied|Accepted|Inappropriate|Backport|Inactive-Upstream)( .+)?$", re.MULTILINE)
+    guidelines = "https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines#Patch_Header_Recommendations:_Upstream-Status"
+
+    with open(fullpath, encoding='utf-8', errors='ignore') as f:
+        file_content = f.read()
+        match_kinda = kinda_status_re.search(file_content)
+        match_strict = strict_status_re.search(file_content)
+
+        if not match_strict:
+            if match_kinda:
+                return "Malformed Upstream-Status in patch\n%s\nPlease correct according to %s :\n%s" % (fullpath, guidelines, match_kinda.group(0))
+            else:
+                return "Missing Upstream-Status in patch\n%s\nPlease add according to %s ." % (fullpath, guidelines)
+
 if __name__ == "__main__":
     import sys
 
Signature · 1 line
2.39.2
#2 lore raw

RFC PATCH 3/3 patchreview: use check_upstream_status() from oe.qa

In reply to Martin Jansa

* the idea was to reuse the same function as I've noticed that the QA check which was added to insane.bbclass in:
https://git.openembedded.org/openembedded-core/commit/?id=76a685bfcf927593eac67157762a53259089ea8a
is in some cases more strcit than scripts/contrib/patchreview.py

To be honest I wasn't aware of scripts/contrib/patchreview.py existence when I've asked about moving check_upstream_status() to oe.qa in order to write standalone script just like patchreview.py, now I don't feel strongly about sharing this functionality (other than adjusting regexes in patchreview.py)

* it finds one "new" issue in oe-core:
Malformed Upstream-Status 'Malformed Upstream-Status in patch meta/recipes-support/libssh2/files/0001-Don-t-let-host-enviroment-to-decide-if-a-test-is-bui.patch
Please correct according to https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines#Patch_Header_Recommendations:_Upstream-Status :
Upstream-Status: Inappropriate[oe specific]' (meta/recipes-support/libssh2/files/0001-Don-t-let-host-enviroment-to-decide-if-a-test-is-bui.patch)

* but unlike the QA check patchreview.py will report this:
-Upstream-Status: Submitted [https://github.com/madler/zlib/pull/599]
+Upstream-Broken-Status: Submitted [https://github.com/madler/zlib/pull/599]

as a missing Upstream-Status instead of malformed as reported by QA check:

ERROR: zlib-native-1.2.13-r0 do_patch: QA Issue: Malformed Upstream-Status in patch /OE/build/oe-core/openembedded-core/meta/recipes-core/zlib/zlib/0001-configure-Pass-LDFLAGS-to-link-tests.patch
Please correct according to https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines#Patch_Header_Recommendations:_Upstream-Status :
Upstream-Broken-Status: Submitted [https://github.com/madler/zlib/pull/599] [patch-status-core]

* RFC: let me know if you think it's worth re-working this to better integrate (e.g. detecting Upstream-Broken-Status and not repeating .patch path in patchreview.py output) or if I should just adjust regexes in patchreview.py.

---
 scripts/contrib/patchreview.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
scripts/contrib/patchreview.py +5 -4
index b22cc07f0a..ce6b0f05c4 100755
@@ -42,7 +42,9 @@ def blame_patch(patch):
                                     "--", patch)).decode("utf-8").splitlines()
 
 def patchreview(path, patches):
-    import re, os.path
+    import re, os.path, sys
+    sys.path.append(os.path.join(sys.path[0], '../../meta/lib'))
+    import oe.qa
 
     # General pattern: start of line, optional whitespace, tag with optional
     # hyphen or spaces, maybe a colon, some whitespace, then the value, all case
@@ -72,12 +74,11 @@ def patchreview(path, patches):
         else:
             result.missing_sob = True
 
-
         # Find the Upstream-Status tag
         match = status_re.search(content)
         if match:
-            value = match.group(1)
-            if value != "Upstream-Status:":
+            value = oe.qa.check_upstream_status(fullpath)
+            if value:
                 result.malformed_upstream_status = value
 
             value = match.group(2).lower()
Signature · 1 line
2.39.2
#3 lore raw

Re: [OE-core] [RFC][PATCH 3/3] patchreview: use check_upstream_status() from oe.qa

Quoted 28 lines · Martin Jansa

* the idea was to reuse the same function as I've noticed that the QA check which was added to insane.bbclass in:
https://git.openembedded.org/openembedded-core/commit/?id=76a685bfcf927593eac67157762a53259089ea8a
is in some cases more strcit than scripts/contrib/patchreview.py

To be honest I wasn't aware of scripts/contrib/patchreview.py existence when I've asked about moving check_upstream_status() to oe.qa in order to write standalone script just like patchreview.py, now I don't feel strongly about sharing this functionality (other than adjusting regexes in patchreview.py)

* it finds one "new" issue in oe-core:
Malformed Upstream-Status 'Malformed Upstream-Status in patch meta/recipes-support/libssh2/files/0001-Don-t-let-host-enviroment-to-decide-if-a-test-is-bui.patch
Please correct according to https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines#Patch_Header_Recommendations:_Upstream-Status :
Upstream-Status: Inappropriate[oe specific]' (meta/recipes-support/libssh2/files/0001-Don-t-let-host-enviroment-to-decide-if-a-test-is-bui.patch)

* but unlike the QA check patchreview.py will report this:
-Upstream-Status: Submitted [https://github.com/madler/zlib/pull/599]
+Upstream-Broken-Status: Submitted [https://github.com/madler/zlib/pull/599]

as a missing Upstream-Status instead of malformed as reported by QA check:

ERROR: zlib-native-1.2.13-r0 do_patch: QA Issue: Malformed Upstream-Status in patch /OE/build/oe-core/openembedded-core/meta/recipes-core/zlib/zlib/0001-configure-Pass-LDFLAGS-to-link-tests.patch
Please correct according to https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines#Patch_Header_Recommendations:_Upstream-Status :
Upstream-Broken-Status: Submitted [https://github.com/madler/zlib/pull/599] [patch-status-core]

Quoted 4 lines

* RFC: let me know if you think it's worth re-working this to better integrate (e.g. detecting Upstream-Broken-Status and not repeating .patch path in patchreview.py output) or if I should just adjust regexes in patchreview.py.

FWIW I quite like the idea of detecting malformed entries and it would be nice if both pieces of code behaved the same way...

Cheers,

Richard