]> code.ossystems Code Review - openembedded-core.git/commitdiff
insane: Add test for native/nativesdk inherit order
authorTomasz Dziendzielski <tomasz.dziendzielski@gmail.com>
Sun, 24 Jan 2021 09:55:45 +0000 (10:55 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 27 Jan 2021 10:16:13 +0000 (10:16 +0000)
Classes native/nativesdk should be inherited last to prevent unexpected
behaviour.

[YOCTO #5729]

Signed-off-by: Tomasz Dziendzielski <tomasz.dziendzielski@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/insane.bbclass

index 105d2a5ce8b6dd274b3bcccacf309c3f55aa0aa9..3597943ddd6d08a96c895261db6aead125ecabf6 100644 (file)
@@ -27,7 +27,7 @@ WARN_QA ?= " libdir xorg-driver-abi \
             infodir build-deps src-uri-bad symlink-to-sysroot multilib \
             invalid-packageconfig host-user-contaminated uppercase-pn patch-fuzz \
             mime mime-xdg unlisted-pkg-lics unhandled-features-check \
-            missing-update-alternatives \
+            missing-update-alternatives native-last \
             "
 ERROR_QA ?= "dev-so debug-deps dev-deps debug-files arch pkgconfig la \
             perms dep-cmp pkgvarcheck perm-config perm-line perm-link \
@@ -1366,6 +1366,32 @@ python () {
         d.setVarFlag('do_package_qa', 'rdeptask', '')
     for i in issues:
         package_qa_handle_error("pkgvarcheck", "%s: Variable %s is set as not being package specific, please fix this." % (d.getVar("FILE"), i), d)
+
+    for native_class in ['native', 'nativesdk']:
+        if bb.data.inherits_class(native_class, d):
+
+            inherited_classes = d.getVar('__inherit_cache', False) or []
+            needle = os.path.join('classes', native_class)
+
+            bbclassextend = (d.getVar('BBCLASSEXTEND') or '').split()
+            # BBCLASSEXTEND items are always added in the end
+            skip_classes = bbclassextend
+            if bb.data.inherits_class('native', d) or 'native' in bbclassextend:
+                # native also inherits nopackages and relocatable bbclasses
+                skip_classes.extend(['nopackages', 'relocatable'])
+
+            for class_item in reversed(inherited_classes):
+                if needle not in class_item:
+                    for extend_item in skip_classes:
+                        if os.path.join('classes', '%s.bbclass' % extend_item) in class_item:
+                            break
+                    else:
+                        pn = d.getVar('PN')
+                        package_qa_handle_error("native-last", "%s: native/nativesdk class is not inherited last, this can result in unexpected behaviour. " % pn, d)
+                        break
+                else:
+                    break
+
     qa_sane = d.getVar("QA_SANE")
     if not qa_sane:
         bb.fatal("Fatal QA errors found, failing task.")