Skip to contentSkip to conversation

oeqa/selftest: rename git.py to intercept.py

PATCH New Ross Burton 1 participant 6 messages Aug 25, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/6 oeqa/selftest: rename git.py to intercept.py

By naming this test class git.py, any attempt to import GitPython (as needed by oelib.buildhistory) failed.

As this class exercises the intercepts, rename it to intercept.py.

(From OE-Core rev: d557cbbf86767bc2ebf2beb3d70af3b3ca5e0529)

---
 meta/lib/oeqa/selftest/cases/{git.py => intercept.py} | 0
 meta/lib/oeqa/selftest/cases/oelib/buildhistory.py    | 6 +++---
 2 files changed, 3 insertions(+), 3 deletions(-)
 rename meta/lib/oeqa/selftest/cases/{git.py => intercept.py} (100%)
meta/lib/oeqa/selftest/cases/intercept.py renamed from meta/lib/oeqa/selftest/cases/git.py +0 -0
similarity index 100%
rename from meta/lib/oeqa/selftest/cases/git.py
rename to meta/lib/oeqa/selftest/cases/intercept.py
meta/lib/oeqa/selftest/cases/oelib/buildhistory.py +3 -3
index 802a91a4886..33bd6df2f3f 100644
@@ -3,6 +3,7 @@
 #
 
 import os
+import sys
 from oeqa.selftest.case import OESelftestTestCase
 import tempfile
 import operator
@@ -11,15 +12,14 @@ from oeqa.utils.commands import get_bb_var
 class TestBlobParsing(OESelftestTestCase):
 
     def setUp(self):
-        import time
         self.repo_path = tempfile.mkdtemp(prefix='selftest-buildhistory',
             dir=get_bb_var('TOPDIR'))
 
         try:
             from git import Repo
             self.repo = Repo.init(self.repo_path)
-        except ImportError:
-            self.skipTest('Python module GitPython is not present')
+        except ImportError as e:
+            self.skipTest('Python module GitPython is not present (%s)  (%s)' % (e, sys.path))
 
         self.test_file = "test"
         self.var_map = {}
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/6 oeqa/gotoolchain: put writable files in the Go module cache

By default 'go mod' creates read-only files, but that just complicates things. Add -modcacherw to make the cache read/write, so it can be cleaned up without needing to chmod.

(From OE-Core rev: 7ff30e0d9fe8527cbc2f8ca84e0300fdc84663b6)

---
 meta/lib/oeqa/selftest/cases/gotoolchain.py | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
meta/lib/oeqa/selftest/cases/gotoolchain.py +1 -6
index c809d7c9b14..345f533379c 100644
@@ -43,12 +43,6 @@ class oeGoToolchainSelfTest(OESelftestTestCase):
 
     @classmethod
     def tearDownClass(cls):
-        # Go creates file which are readonly
-        for dirpath, dirnames, filenames in os.walk(cls.tmpdir_SDKQA):
-            for filename in filenames + dirnames:
-                f = os.path.join(dirpath, filename)
-                if not os.path.islink(f):
-                    os.chmod(f, 0o775)
         shutil.rmtree(cls.tmpdir_SDKQA, ignore_errors=True)
         super(oeGoToolchainSelfTest, cls).tearDownClass()
 
@@ -56,6 +50,7 @@ class oeGoToolchainSelfTest(OESelftestTestCase):
         cmd = "cd %s/src/%s/%s; " % (self.go_path, proj, name)
         cmd = cmd + ". %s; " % self.env_SDK
         cmd = cmd + "export GOPATH=%s; " % self.go_path
+        cmd = cmd + "export GOFLAGS=-modcacherw; "
         cmd = cmd + "${CROSS_COMPILE}go %s" % gocmd
         return runCmd(cmd).status
 
Signature · 1 line
2.34.1
#2 lore raw

PATCH 3/6 oeqa/gotoolchain: set CGO_ENABLED=1

In reply to Ross Burton

In cross-compiles CGO_ENABLED=1 needs to be set explicitly, as otherwise Go refuses to use it even if CC is already set.

This fixes the selftest on setups where the host and the SDK target don't have matching architectures.

[ YOCTO #14859 ]

(From OE-Core rev: 19be072619d39267df44f23c4c8b64f3808f6148)

---
 meta/lib/oeqa/selftest/cases/gotoolchain.py | 1 +
 1 file changed, 1 insertion(+)
meta/lib/oeqa/selftest/cases/gotoolchain.py +1 -0
index 345f533379c..978898b86f1 100644
@@ -51,6 +51,7 @@ class oeGoToolchainSelfTest(OESelftestTestCase):
         cmd = cmd + ". %s; " % self.env_SDK
         cmd = cmd + "export GOPATH=%s; " % self.go_path
         cmd = cmd + "export GOFLAGS=-modcacherw; "
+        cmd = cmd + "export CGO_ENABLED=1; "
         cmd = cmd + "${CROSS_COMPILE}go %s" % gocmd
         return runCmd(cmd).status
 
Signature · 1 line
2.34.1
#3 lore raw

PATCH 4/6 wic: add target tools to PATH when executing native commands

In reply to Ross Burton

We might want to run a cross tool, such as objcopy, in wic. These are in a TARGET_SYS/ subdirectory under /usr/bin, so add that directory to the search path too.

(From OE-Core rev: c523549141e5c31edc75281f581d97867b7d251d)

---
 scripts/lib/wic/misc.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
scripts/lib/wic/misc.py +4 -3
index 3e118229960..a8aab6c524e 100644
@@ -140,11 +140,12 @@ def exec_native_cmd(cmd_and_args, native_sysroot, pseudo=""):
         cmd_and_args = pseudo + cmd_and_args
 
     hosttools_dir = get_bitbake_var("HOSTTOOLS_DIR")
+    target_sys = get_bitbake_var("TARGET_SYS")
 
-    native_paths = "%s/sbin:%s/usr/sbin:%s/usr/bin:%s/bin:%s" % \
+    native_paths = "%s/sbin:%s/usr/sbin:%s/usr/bin:%s/usr/bin/%s:%s/bin:%s" % \
                    (native_sysroot, native_sysroot,
-                    native_sysroot, native_sysroot,
-                    hosttools_dir)
+                    native_sysroot, native_sysroot, target_sys,
+                    native_sysroot, hosttools_dir)
 
     native_cmd_and_args = "export PATH=%s:$PATH;%s" % \
                    (native_paths, cmd_and_args)
Signature · 1 line
2.34.1
#4 lore raw

PATCH 5/6 wic/bootimg-efi: use cross objcopy when building unified kernel image

In reply to Ross Burton

We can't rely on the host objcopy knowing how to process target binaries, so use the cross objcopy in the sysroot instead.

Also construct the command argument-by-argument as the format expression was getting unwieldy.

(From OE-Core rev: 0264aeedbf21e9e7a104243c11b3b57f00e38bda)

---
 scripts/lib/wic/plugins/source/bootimg-efi.py | 25 +++++++++----------
 1 file changed, 12 insertions(+), 13 deletions(-)
scripts/lib/wic/plugins/source/bootimg-efi.py +12 -13
index 0391aebdc84..a65a5b97804 100644
@@ -326,21 +326,20 @@ class BootimgEFIPlugin(SourcePlugin):
                 exec_cmd(install_cmd)
 
                 staging_dir_host = get_bitbake_var("STAGING_DIR_HOST")
+                target_sys = get_bitbake_var("TARGET_SYS")
 
                 # https://www.freedesktop.org/software/systemd/man/systemd-stub.html
-                objcopy_cmd = "objcopy \
-                    --add-section .osrel=%s --change-section-vma .osrel=0x20000 \
-                    --add-section .cmdline=%s --change-section-vma .cmdline=0x30000 \
-                    --add-section .linux=%s --change-section-vma .linux=0x2000000 \
-                    --add-section .initrd=%s --change-section-vma .initrd=0x3000000 \
-                    %s %s" % \
-                    ("%s/usr/lib/os-release" % staging_dir_host,
-                    cmdline.name,
-                    "%s/%s" % (staging_kernel_dir, kernel),
-                    initrd.name,
-                    efi_stub,
-                    "%s/EFI/Linux/linux.efi" % hdddir)
-                exec_cmd(objcopy_cmd)
+                objcopy_cmd = "%s-objcopy" % target_sys
+                objcopy_cmd += " --add-section .osrel=%s/usr/lib/os-release" % staging_dir_host
+                objcopy_cmd += " --change-section-vma .osrel=0x20000"
+                objcopy_cmd += " --add-section .cmdline=%s" % cmdline.name
+                objcopy_cmd += " --change-section-vma .cmdline=0x30000"
+                objcopy_cmd += " --add-section .linux=%s/%s" % (staging_kernel_dir, kernel)
+                objcopy_cmd += " --change-section-vma .linux=0x2000000"
+                objcopy_cmd += " --add-section .initrd=%s" % initrd.name
+                objcopy_cmd += " --change-section-vma .initrd=0x3000000"
+                objcopy_cmd += " %s %s/EFI/Linux/linux.efi" % (efi_stub, hdddir)
+                exec_native_cmd(objcopy_cmd, native_sysroot)
         else:
             install_cmd = "install -m 0644 %s/%s %s/%s" % \
                 (staging_kernel_dir, kernel, hdddir, kernel)
Signature · 1 line
2.34.1
#5 lore raw

PATCH 6/6 wic: depend on cross-binutils

In reply to Ross Burton

Wic can build an unified kernel image, but this needs the cross-objcopy from binutils.

(From OE-Core rev: 7c7a488116f49083ca42d3628ebc0870585110c3)

---
 meta/classes/image_types_wic.bbclass | 2 ++
 meta/recipes-core/meta/wic-tools.bb  | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)
meta/classes/image_types_wic.bbclass +2 -0
index e3863c88a9a..5374d6125e1 100644
@@ -84,6 +84,8 @@ do_image_wic[deptask] += "do_image_complete"
 
 WKS_FILE_DEPENDS_DEFAULT = '${@bb.utils.contains_any("BUILD_ARCH", [ 'x86_64', 'i686' ], "syslinux-native", "",d)}'
 WKS_FILE_DEPENDS_DEFAULT += "bmap-tools-native cdrtools-native btrfs-tools-native squashfs-tools-native e2fsprogs-native"
+# Unified kernel images need objcopy
+WKS_FILE_DEPENDS_DEFAULT += "virtual/${TARGET_PREFIX}binutils"
 WKS_FILE_DEPENDS_BOOTLOADERS = ""
 WKS_FILE_DEPENDS_BOOTLOADERS:x86 = "syslinux grub-efi systemd-boot os-release"
 WKS_FILE_DEPENDS_BOOTLOADERS:x86-64 = "syslinux grub-efi systemd-boot os-release"
meta/recipes-core/meta/wic-tools.bb +2 -1
index ba0916cb567..daaf3ea5768 100644
@@ -6,7 +6,8 @@ DEPENDS = "\
            parted-native gptfdisk-native dosfstools-native \
            mtools-native bmap-tools-native grub-native cdrtools-native \
            btrfs-tools-native squashfs-tools-native pseudo-native \
-           e2fsprogs-native util-linux-native tar-native\
+           e2fsprogs-native util-linux-native tar-native \
+           virtual/${TARGET_PREFIX}binutils \
            "
 DEPENDS:append:x86 = " syslinux-native syslinux grub-efi systemd-boot"
 DEPENDS:append:x86-64 = " syslinux-native syslinux grub-efi systemd-boot"
Signature · 1 line
2.34.1