Skip to contentSkip to conversation

devtool: remove unused variable

PATCH New Ross Burton 1 participant 4 messages Oct 7, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 devtool: remove unused variable

This variable isn't used at all.

---
 scripts/lib/devtool/standard.py | 1 -
 1 file changed, 1 deletion(-)
scripts/lib/devtool/standard.py +0 -1
index d140b97de1..261d642d4a 100644
@@ -531,7 +531,6 @@ def _extract_source(srctree, keep_temp, devbranch, sync, config, basepath, works
 
     initial_rev = None
 
-    appendexisted = False
     recipefile = d.getVar('FILE')
     appendfile = recipe_to_append(recipefile, config)
     is_kernel_yocto = bb.data.inherits_class('kernel-yocto', d)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/4 selftest: skip npm tests if nodejs-native isn't available

The tests are actually skipped if meta-oe isn't present which isn't quite the same thing, but hopefully close enough.

---
 meta/lib/oeqa/selftest/cases/devtool.py    | 4 ++++
 meta/lib/oeqa/selftest/cases/recipetool.py | 4 ++++
 2 files changed, 8 insertions(+)
meta/lib/oeqa/selftest/cases/devtool.py +4 -0
index 4a791ff40e..2c9ff7a95a 100644
@@ -520,6 +520,10 @@ class DevtoolAddTests(DevtoolBase):
         self._test_recipe_contents(recipefile, checkvars, [])
 
     def test_devtool_add_npm(self):
+        collections = get_bb_var('BBFILE_COLLECTIONS').split()
+        if "openembedded-layer" not in collections:
+            self.skipTest("Test needs meta-oe for nodejs")
+
         pn = 'savoirfairelinux-node-server-example'
         pv = '1.0.0'
         url = 'npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example;version=' + pv
meta/lib/oeqa/selftest/cases/recipetool.py +4 -0
index 6bac53cf3d..9d56e9e1e3 100644
@@ -409,6 +409,10 @@ class RecipetoolTests(RecipetoolBase):
         self._test_recipe_contents(recipefile, checkvars, inherits)
 
     def test_recipetool_create_npm(self):
+        collections = get_bb_var('BBFILE_COLLECTIONS').split()
+        if "openembedded-layer" not in collections:
+            self.skipTest("Test needs meta-oe for nodejs")
+
         temprecipe = os.path.join(self.tempdir, 'recipe')
         os.makedirs(temprecipe)
         recipefile = os.path.join(temprecipe, 'savoirfairelinux-node-server-example_1.0.0.bb')
Signature · 1 line
2.25.1
#2 lore raw

PATCH 3/4 selftest: add test for recipes with patches in overrides

In reply to Ross Burton

devtool doesn't quite behave right when a recipe has patches applied in overrides, so add a test case to exercise that behaviour.

---
 .../devtool/devtool-patch-overrides.bb        |  8 ++++++++
 .../devtool-patch-overrides/qemuarm/arm.patch |  5 +++++
 .../devtool-patch-overrides/qemux86/x86.patch |  5 +++++
 .../devtool/devtool-patch-overrides/source    |  1 +
 meta/lib/oeqa/selftest/cases/devtool.py       | 20 +++++++++++++++++++
 5 files changed, 39 insertions(+)
 create mode 100644 meta-selftest/recipes-test/devtool/devtool-patch-overrides.bb
 create mode 100644 meta-selftest/recipes-test/devtool/devtool-patch-overrides/qemuarm/arm.patch
 create mode 100644 meta-selftest/recipes-test/devtool/devtool-patch-overrides/qemux86/x86.patch
 create mode 100644 meta-selftest/recipes-test/devtool/devtool-patch-overrides/source
meta-selftest/recipes-test/devtool/devtool-patch-overrides.bb new file +8 -0
new file mode 100644
index 0000000000..d36c9edee4
@@ -0,0 +1,8 @@
+SUMMARY = "devtool test for overrides and patches"
+LICENSE = "CLOSED"
+INHIBIT_DEFAULT_DEPS = "1"
+EXCLUDE_FROM_WORLD = "1"
+
+SRC_URI = "file://source;subdir=${BP}"
+SRC_URI_append_qemuarm = " file://arm.patch;striplevel=0"
+SRC_URI_append_qemux86 = " file://x86.patch;striplevel=0"
meta-selftest/recipes-test/devtool/devtool-patch-overrides/qemuarm/arm.patch new file +5 -0
new file mode 100644
index 0000000000..e33a2753f9
@@ -0,0 +1,5 @@
+--- source.orig	2020-10-06 13:26:10.792688630 +0100
++++ source	2020-10-06 13:26:18.853424694 +0100
+@@ -1 +1 @@
+-This is a test for something
++This is a test for qemuarm
meta-selftest/recipes-test/devtool/devtool-patch-overrides/qemux86/x86.patch new file +5 -0
new file mode 100644
index 0000000000..1a0a175fa8
@@ -0,0 +1,5 @@
+--- source.orig	2020-10-06 13:26:10.792688630 +0100
++++ source	2020-10-06 13:26:18.853424694 +0100
+@@ -1 +1 @@
+-This is a test for something
++This is a test for qemux86
meta-selftest/recipes-test/devtool/devtool-patch-overrides/source new file +1 -0
new file mode 100644
index 0000000000..cc14ce627c
@@ -0,0 +1 @@
+This is a test for something
meta/lib/oeqa/selftest/cases/devtool.py +20 -0
index 2c9ff7a95a..0185e670ad 100644
@@ -784,6 +784,26 @@ class DevtoolModifyTests(DevtoolBase):
         self._check_src_repo(tempdir)
         # This is probably sufficient
 
+    def test_devtool_modify_overrides(self):
+        # Try modifying a recipe with patches in overrides
+        tempdir = tempfile.mkdtemp(prefix='devtoolqa')
+        self.track_for_cleanup(tempdir)
+        self.track_for_cleanup(self.workspacedir)
+        self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
+        result = runCmd('devtool modify devtool-patch-overrides -x %s' % (tempdir))
+
+        self._check_src_repo(tempdir)
+        source = os.path.join(tempdir, "source")
+        def check(branch, expected):
+            runCmd('git -C %s checkout %s' % (tempdir, branch))
+            with open(source, "rt") as f:
+                content = f.read()
+            self.assertEquals(content, expected)
+        check('devtool', 'This is a test for something\n')
+        check('devtool-no-overrides', 'This is a test for something\n')
+        check('devtool-override-qemuarm', 'This is a test for qemuarm\n')
+        check('devtool-override-qemux86', 'This is a test for qemux86\n')
+
 class DevtoolUpdateTests(DevtoolBase):
 
     def test_devtool_update_recipe(self):
Signature · 1 line
2.25.1
#3 lore raw

PATCH 4/4 devtool: fix modify with patches in override directories

In reply to Ross Burton

If a recipe applies patches which are in machine-specific override directories, devtool will fail to fetch the patches that don't match the default configuration. For example where there are patches at qemux86/x86.patch and qemuarm/arm.patch:

SRC_URI = "file://source"
SRC_URI_append_qemuarm = " file://arm.patch"
SRC_URI_append_qemux86 = " file://x86.patch"

The patch apply phase sets OVERRIDES but does not set FILESOVERRIDES, so it cannot find the patch files as the search path isn't correct. Fix this by setting FILESOVERRIDES too.

Also when iterating through the overrides we need to be sure that other overrides that are used are not enabled, so extend no_overrides instead of simply appending the current override.

Fixes most but not all of [ YOCTO #14060 ].

---
 meta/classes/devtool-source.bbclass | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
meta/classes/devtool-source.bbclass +3 -1
index 280d6009f3..41900e651f 100644
@@ -199,6 +199,7 @@ python devtool_post_patch() {
             # Run do_patch function with the override applied
             localdata = bb.data.createCopy(d)
             localdata.setVar('OVERRIDES', ':'.join(no_overrides))
+            localdata.setVar('FILESOVERRIDES', ':'.join(no_overrides))
             bb.build.exec_func('do_patch', localdata)
             rm_patches()
             # Now we need to reconcile the dev branch with the no-overrides one
@@ -216,7 +217,8 @@ python devtool_post_patch() {
                 # Reset back to the initial commit on a new branch
                 bb.process.run('git checkout %s -b devtool-override-%s' % (initial_rev, override), cwd=srcsubdir)
                 # Run do_patch function with the override applied
-                localdata.appendVar('OVERRIDES', ':%s' % override)
+                localdata.setVar('OVERRIDES', ':'.join(no_overrides + [override]))
+                localdata.setVar('FILESOVERRIDES', ':'.join(no_overrides + [override]))
                 bb.build.exec_func('do_patch', localdata)
                 rm_patches()
                 # Now we need to reconcile the new branch with the no-overrides one
Signature · 1 line
2.25.1