Skip to contentSkip to conversation

devtool: modify: Catch git submodule error for go code

PATCH New Peter Kjellerstedt 1 participant 3 messages Jun 12, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 devtool: modify: Catch git submodule error for go code

From: Anton Almqvist <[email protected]>

One of the git submodule commands failed for source extracted for recipes using go.bbclass. The root cause is probably the path set up by go_do_unpack which makes S and gitroot not match.

This patch does not fix the root problem, but at least it is no worse than before the git submodule support.

The extracted source will still have two .git folders, one in S created by devtool and one in the go path which will contain the tru git history.

[ YOCTO #15483 ]

(cherry picked from commit fe242408af40dd1f6e47d9b2b232bdc76756c80a)
---
 scripts/lib/devtool/standard.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
scripts/lib/devtool/standard.py +4 -1
index 10d0cd3b7c..2beb058de8 100644
@@ -893,7 +893,10 @@ def modify(args, config, basepath, workspace):
                 (stdout, _) = bb.process.run('git rev-list --reverse %s..HEAD' % initial_revs["."], cwd=srctree)
                 commits["."] = stdout.split()
                 check_commits = True
-                (stdout, _) = bb.process.run('git submodule --quiet foreach --recursive  \'echo `git rev-parse devtool-base` $PWD\'', cwd=srctree)
+                try:
+                    (stdout, _) = bb.process.run('git submodule --quiet foreach --recursive  \'echo `git rev-parse devtool-base` $PWD\'', cwd=srctree)
+                except bb.process.ExecutionError:
+                    stdout = ""
                 for line in stdout.splitlines():
                     (rev, submodule_path) = line.split()
                     submodule = os.path.relpath(submodule_path, srctree)
#1 lore raw

PATCH 2/3 oeqa/selftest/devtool: add test for modifying recipes using go.bbclass

From: Ola x Nilsson <[email protected]>

go.bbclass uses a special do_unpack function that causes the git root to be different from S. Verify that it unpacks as expected.

[ YOCTO #15483 ]

(cherry picked from commit fab0c737b95b8d0c0bbf58336bc308776c956406)
---
 meta/lib/oeqa/selftest/cases/devtool.py | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
meta/lib/oeqa/selftest/cases/devtool.py +19 -0
index 51949e3c93..cc4cbec5ae 100644
@@ -749,6 +749,25 @@ class DevtoolModifyTests(DevtoolBase):
         result = runCmd('devtool status')
         self.assertNotIn('mdadm', result.output)
 
+    def test_devtool_modify_go(self):
+        import oe.path
+        from tempfile import TemporaryDirectory
+        with TemporaryDirectory(prefix='devtoolqa') as tempdir:
+            self.track_for_cleanup(self.workspacedir)
+            self.add_command_to_tearDown('bitbake -c clean go-helloworld')
+            self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
+            result = runCmd('devtool modify go-helloworld -x %s' % tempdir)
+            self.assertExists(
+                oe.path.join(tempdir, 'src', 'golang.org', 'x', 'example', 'go.mod'),
+                             'Extracted source could not be found'
+            )
+            self.assertExists(
+                oe.path.join(self.workspacedir, 'conf', 'layer.conf'),
+                'Workspace directory not created'
+            )
+            matches = glob.glob(oe.path.join(self.workspacedir, 'appends', 'go-helloworld_*.bbappend'))
+            self.assertTrue(matches, 'bbappend not created %s' % result.output)
+
     def test_devtool_buildclean(self):
         def assertFile(path, *paths):
             f = os.path.join(path, *paths)
#2 lore raw

PATCH 3/3 base-files: profile: fix error sh: 1: unknown operand

In reply to Peter Kjellerstedt

From: Felix Nilsson <[email protected]>

Handle errors when SHLVL isn't set.

(cherry picked from commit 5df53fcfe3b70a5312fced3fcc1ba6290f2ee794)
---
 meta/recipes-core/base-files/base-files/profile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-core/base-files/base-files/profile +1 -1
index bded3757cc..5e8393c91c 100644
@@ -58,7 +58,7 @@ resize() {
 	fi
 	# only do this for /dev/tty[A-z] which are typically
 	# serial ports
-	if [ $FIRSTTIMESETUP -eq 1 -a $SHLVL -eq 1 ] ; then
+	if [ $FIRSTTIMESETUP -eq 1 -a ${SHLVL:-1} -eq 1 ] ; then
 		case $(tty 2>/dev/null) in
 			/dev/tty[A-z]*) resize >/dev/null;;
 		esac