diff options
Diffstat (limited to 'meta/lib')
24 files changed, 148 insertions, 293 deletions
diff --git a/meta/lib/oe/package_manager/__init__.py b/meta/lib/oe/package_manager/__init__.py index 6774cdb794..d3b2317894 100644 --- a/meta/lib/oe/package_manager/__init__.py +++ b/meta/lib/oe/package_manager/__init__.py @@ -449,7 +449,7 @@ class PackageManager(object, metaclass=ABCMeta): return res return _append(uris, base_paths) -def create_packages_dir(d, subrepo_dir, deploydir, taskname, filterbydependencies): +def create_packages_dir(d, subrepo_dir, deploydir, taskname, filterbydependencies, include_self=False): """ Go through our do_package_write_X dependencies and hardlink the packages we depend upon into the repo directory. This prevents us seeing other packages that may @@ -486,14 +486,17 @@ def create_packages_dir(d, subrepo_dir, deploydir, taskname, filterbydependencie bb.fatal("Couldn't find ourself in BB_TASKDEPDATA?") pkgdeps = set() start = [start] - seen = set(start) + if include_self: + seen = set() + else: + seen = set(start) # Support direct dependencies (do_rootfs -> do_package_write_X) # or indirect dependencies within PN (do_populate_sdk_ext -> do_rootfs -> do_package_write_X) while start: next = [] for dep2 in start: for dep in taskdepdata[dep2][3]: - if taskdepdata[dep][0] != pn: + if include_self or taskdepdata[dep][0] != pn: if "do_" + taskname in dep: pkgdeps.add(dep) elif dep not in seen: diff --git a/meta/lib/oe/package_manager/ipk/__init__.py b/meta/lib/oe/package_manager/ipk/__init__.py index 8cc9953a02..0f0038d00d 100644 --- a/meta/lib/oe/package_manager/ipk/__init__.py +++ b/meta/lib/oe/package_manager/ipk/__init__.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: GPL-2.0-only # +import glob import re import shutil import subprocess @@ -134,11 +135,16 @@ class OpkgDpkgPM(PackageManager): tmp_dir = tempfile.mkdtemp() current_dir = os.getcwd() os.chdir(tmp_dir) - data_tar = 'data.tar.zst' try: cmd = [ar_cmd, 'x', pkg_path] output = subprocess.check_output(cmd, stderr=subprocess.STDOUT) + data_tar = glob.glob("data.tar.*") + if len(data_tar) != 1: + bb.fatal("Unable to extract %s package. Failed to identify " + "data tarball (found tarballs '%s').", + pkg_path, data_tar) + data_tar = data_tar[0] cmd = [tar_cmd, 'xf', data_tar] output = subprocess.check_output(cmd, stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py index 60a0cc8291..58c6e34fe8 100644 --- a/meta/lib/oe/patch.py +++ b/meta/lib/oe/patch.py @@ -882,7 +882,7 @@ class UserResolver(Resolver): os.chdir(olddir) -def patch_path(url, fetch, workdir, expand=True): +def patch_path(url, fetch, unpackdir, expand=True): """Return the local path of a patch, or return nothing if this isn't a patch""" local = fetch.localpath(url) @@ -891,7 +891,7 @@ def patch_path(url, fetch, workdir, expand=True): base, ext = os.path.splitext(os.path.basename(local)) if ext in ('.gz', '.bz2', '.xz', '.Z'): if expand: - local = os.path.join(workdir, base) + local = os.path.join(unpackdir, base) ext = os.path.splitext(base)[1] urldata = fetch.ud[url] @@ -905,12 +905,12 @@ def patch_path(url, fetch, workdir, expand=True): return local def src_patches(d, all=False, expand=True): - workdir = d.getVar('WORKDIR') + unpackdir = d.getVar('UNPACKDIR') fetch = bb.fetch2.Fetch([], d) patches = [] sources = [] for url in fetch.urls: - local = patch_path(url, fetch, workdir, expand) + local = patch_path(url, fetch, unpackdir, expand) if not local: if all: local = fetch.localpath(url) diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py index de1fbdd3a8..2d69a33113 100644 --- a/meta/lib/oe/recipeutils.py +++ b/meta/lib/oe/recipeutils.py @@ -818,7 +818,7 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False, instdirline = 'install -d ${D}%s' % os.path.dirname(instdestpath) if not instdirline in instfunclines: instfunclines.append(instdirline) - instfunclines.append('install -m %s ${WORKDIR}/%s ${D}%s' % (perms, os.path.basename(srcfile), instdestpath)) + instfunclines.append('install -m %s ${UNPACKDIR}/%s ${D}%s' % (perms, os.path.basename(srcfile), instdestpath)) if instfunclines: bbappendlines.append(('do_install:append%s()' % appendoverride, '', instfunclines)) diff --git a/meta/lib/oe/reproducible.py b/meta/lib/oe/reproducible.py index 448befce33..1957c97434 100644 --- a/meta/lib/oe/reproducible.py +++ b/meta/lib/oe/reproducible.py @@ -75,10 +75,10 @@ def get_source_date_epoch_from_known_files(d, sourcedir): return source_date_epoch def find_git_folder(d, sourcedir): - # First guess: WORKDIR/git + # First guess: UNPACKDIR/git # This is the default git fetcher unpack path - workdir = d.getVar('WORKDIR') - gitpath = os.path.join(workdir, "git/.git") + unpackdir = d.getVar('UNPACKDIR') + gitpath = os.path.join(unpackdir, "git/.git") if os.path.isdir(gitpath): return gitpath @@ -88,15 +88,16 @@ def find_git_folder(d, sourcedir): return gitpath # Perhaps there was a subpath or destsuffix specified. - # Go looking in the WORKDIR - exclude = set(["build", "image", "license-destdir", "patches", "pseudo", - "recipe-sysroot", "recipe-sysroot-native", "sysroot-destdir", "temp"]) - for root, dirs, files in os.walk(workdir, topdown=True): - dirs[:] = [d for d in dirs if d not in exclude] + # Go looking in the UNPACKDIR + for root, dirs, files in os.walk(unpackdir, topdown=True): if '.git' in dirs: return os.path.join(root, ".git") - bb.warn("Failed to find a git repository in WORKDIR: %s" % workdir) + for root, dirs, files in os.walk(sourcedir, topdown=True): + if '.git' in dirs: + return os.path.join(root, ".git") + + bb.warn("Failed to find a git repository in UNPACKDIR: %s" % unpackdir) return None def get_source_date_epoch_from_git(d, sourcedir): @@ -120,7 +121,7 @@ def get_source_date_epoch_from_git(d, sourcedir): return int(p.stdout.decode('utf-8')) def get_source_date_epoch_from_youngest_file(d, sourcedir): - if sourcedir == d.getVar('WORKDIR'): + if sourcedir == d.getVar('UNPACKDIR'): # These sources are almost certainly not from a tarball return None diff --git a/meta/lib/oeqa/sdk/cases/buildcpio.py b/meta/lib/oeqa/sdk/cases/autotools.py index 51003b19cd..848e9392ec 100644 --- a/meta/lib/oeqa/sdk/cases/buildcpio.py +++ b/meta/lib/oeqa/sdk/cases/autotools.py @@ -7,13 +7,12 @@ import os import tempfile import subprocess -import unittest from oeqa.sdk.case import OESDKTestCase from oeqa.utils.subprocesstweak import errors_have_output errors_have_output() -class BuildCpioTest(OESDKTestCase): +class AutotoolsTest(OESDKTestCase): """ Check that autotools will cross-compile correctly. """ diff --git a/meta/lib/oeqa/sdk/cases/assimp.py b/meta/lib/oeqa/sdk/cases/cmake.py index e986838aea..db7d826a38 100644 --- a/meta/lib/oeqa/sdk/cases/assimp.py +++ b/meta/lib/oeqa/sdk/cases/cmake.py @@ -13,7 +13,7 @@ from oeqa.sdk.case import OESDKTestCase from oeqa.utils.subprocesstweak import errors_have_output errors_have_output() -class BuildAssimp(OESDKTestCase): +class CMakeTest(OESDKTestCase): """ Test case to build a project using cmake. """ @@ -21,14 +21,14 @@ class BuildAssimp(OESDKTestCase): def setUp(self): if not (self.tc.hasHostPackage("nativesdk-cmake") or self.tc.hasHostPackage("cmake-native")): - raise unittest.SkipTest("Needs cmake") + raise unittest.SkipTest("CMakeTest: needs cmake") def test_assimp(self): with tempfile.TemporaryDirectory(prefix="assimp", dir=self.tc.sdk_dir) as testdir: - tarball = self.fetch(testdir, self.td["DL_DIR"], "https://github.com/assimp/assimp/archive/v5.3.1.tar.gz") + tarball = self.fetch(testdir, self.td["DL_DIR"], "https://github.com/assimp/assimp/archive/v5.4.1.tar.gz") dirs = {} - dirs["source"] = os.path.join(testdir, "assimp-5.3.1") + dirs["source"] = os.path.join(testdir, "assimp-5.4.1") dirs["build"] = os.path.join(testdir, "build") dirs["install"] = os.path.join(testdir, "install") @@ -39,7 +39,7 @@ class BuildAssimp(OESDKTestCase): self._run("sed -i '/# ifdef _FILE_OFFSET_BITS/I,+2 d' {source}/contrib/zlib/gzguts.h".format(**dirs)) os.makedirs(dirs["build"]) - self._run("cd {build} && cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DASSIMP_BUILD_ZLIB=ON {source}".format(**dirs)) + self._run("cd {build} && cmake -DASSIMP_WARNINGS_AS_ERRORS=OFF -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DASSIMP_BUILD_ZLIB=ON {source}".format(**dirs)) self._run("cmake --build {build} -- -j".format(**dirs)) self._run("cmake --build {build} --target install -- DESTDIR={install}".format(**dirs)) - self.check_elf(os.path.join(dirs["install"], "usr", "local", "lib", "libassimp.so.5.3.0")) + self.check_elf(os.path.join(dirs["install"], "usr", "local", "lib", "libassimp.so.5.4.1")) diff --git a/meta/lib/oeqa/sdk/cases/buildgalculator.py b/meta/lib/oeqa/sdk/cases/gtk3.py index 178f07472d..c329c4bb86 100644 --- a/meta/lib/oeqa/sdk/cases/buildgalculator.py +++ b/meta/lib/oeqa/sdk/cases/gtk3.py @@ -13,7 +13,7 @@ from oeqa.sdk.case import OESDKTestCase from oeqa.utils.subprocesstweak import errors_have_output errors_have_output() -class GalculatorTest(OESDKTestCase): +class GTK3Test(OESDKTestCase): """ Test that autotools and GTK+ 3 compiles correctly. """ diff --git a/meta/lib/oeqa/sdk/cases/buildlzip.py b/meta/lib/oeqa/sdk/cases/makefile.py index b4b7d85b88..2ff54ce25f 100644 --- a/meta/lib/oeqa/sdk/cases/buildlzip.py +++ b/meta/lib/oeqa/sdk/cases/makefile.py @@ -4,12 +4,12 @@ # SPDX-License-Identifier: MIT # -import os, tempfile, subprocess, unittest +import os, tempfile, subprocess from oeqa.sdk.case import OESDKTestCase from oeqa.utils.subprocesstweak import errors_have_output errors_have_output() -class BuildLzipTest(OESDKTestCase): +class MakefileTest(OESDKTestCase): """ Test that "plain" compilation works, using just $CC $CFLAGS etc. """ diff --git a/meta/lib/oeqa/sdk/cases/maturin.py b/meta/lib/oeqa/sdk/cases/maturin.py index ea10f568b2..20f6b553d0 100644 --- a/meta/lib/oeqa/sdk/cases/maturin.py +++ b/meta/lib/oeqa/sdk/cases/maturin.py @@ -8,7 +8,6 @@ import os import shutil import unittest -from oeqa.core.utils.path import remove_safe from oeqa.sdk.case import OESDKTestCase from oeqa.utils.subprocesstweak import errors_have_output diff --git a/meta/lib/oeqa/sdk/cases/buildepoxy.py b/meta/lib/oeqa/sdk/cases/meson.py index 147ee3e0ee..be53df204a 100644 --- a/meta/lib/oeqa/sdk/cases/buildepoxy.py +++ b/meta/lib/oeqa/sdk/cases/meson.py @@ -13,14 +13,14 @@ from oeqa.sdk.case import OESDKTestCase from oeqa.utils.subprocesstweak import errors_have_output errors_have_output() -class EpoxyTest(OESDKTestCase): +class MesonTest(OESDKTestCase): """ Test that Meson builds correctly. """ def setUp(self): if not (self.tc.hasHostPackage("nativesdk-meson") or self.tc.hasHostPackage("meson-native")): - raise unittest.SkipTest("EpoxyTest class: SDK doesn't contain Meson") + raise unittest.SkipTest("MesonTest: needs meson") def test_epoxy(self): with tempfile.TemporaryDirectory(prefix="epoxy", dir=self.tc.sdk_dir) as testdir: diff --git a/meta/lib/oeqa/sdk/cases/python.py b/meta/lib/oeqa/sdk/cases/python.py index 5ea992b9f3..51284949f5 100644 --- a/meta/lib/oeqa/sdk/cases/python.py +++ b/meta/lib/oeqa/sdk/cases/python.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: MIT # -import subprocess, unittest +import unittest from oeqa.sdk.case import OESDKTestCase from oeqa.utils.subprocesstweak import errors_have_output diff --git a/meta/lib/oeqa/sdk/cases/rust.py b/meta/lib/oeqa/sdk/cases/rust.py index f5d437bb19..a54245851b 100644 --- a/meta/lib/oeqa/sdk/cases/rust.py +++ b/meta/lib/oeqa/sdk/cases/rust.py @@ -8,7 +8,6 @@ import os import shutil import unittest -from oeqa.core.utils.path import remove_safe from oeqa.sdk.case import OESDKTestCase from oeqa.utils.subprocesstweak import errors_have_output diff --git a/meta/lib/oeqa/sdkext/cases/devtool.py b/meta/lib/oeqa/sdkext/cases/devtool.py index 5ffb732556..d0746e68eb 100644 --- a/meta/lib/oeqa/sdkext/cases/devtool.py +++ b/meta/lib/oeqa/sdkext/cases/devtool.py @@ -69,10 +69,9 @@ class DevtoolTest(OESDKExtTestCase): self._test_devtool_build(self.myapp_cmake_dst) def test_extend_autotools_recipe_creation(self): - req = 'https://github.com/rdfa/librdfa' - recipe = "librdfa" - self._run('devtool sdk-install libxml2') - self._run('devtool add %s %s' % (recipe, req) ) + recipe = "test-dbus-wait" + self._run('devtool sdk-install dbus') + self._run('devtool add %s https://git.yoctoproject.org/git/dbus-wait' % (recipe) ) try: self._run('devtool build %s' % recipe) finally: diff --git a/meta/lib/oeqa/selftest/cases/debuginfod.py b/meta/lib/oeqa/selftest/cases/debuginfod.py index 505b4be837..46c0cd87bb 100644 --- a/meta/lib/oeqa/selftest/cases/debuginfod.py +++ b/meta/lib/oeqa/selftest/cases/debuginfod.py @@ -62,7 +62,7 @@ class Debuginfod(OESelftestTestCase): raise TimeoutError("Cannot connect debuginfod, still %d scan jobs running" % latest) - def start_debuginfod(self): + def start_debuginfod(self, feed_dir): # We assume that the caller has already bitbake'd elfutils-native:do_addto_recipe_sysroot # Save some useful paths for later @@ -82,7 +82,7 @@ class Debuginfod(OESelftestTestCase): # Disable rescanning, this is a one-shot test "--rescan-time=0", "--groom-time=0", - get_bb_var("DEPLOY_DIR"), + feed_dir, ] format = get_bb_var("PACKAGE_CLASSES").split()[0] @@ -114,11 +114,12 @@ class Debuginfod(OESelftestTestCase): self.write_config(""" TMPDIR = "${TOPDIR}/tmp-debuginfod" DISTRO_FEATURES:append = " debuginfod" +INHERIT += "localpkgfeed" """) - bitbake("elfutils-native:do_addto_recipe_sysroot xz xz:do_package") + bitbake("elfutils-native:do_addto_recipe_sysroot xz xz:do_package xz:do_localpkgfeed") try: - self.start_debuginfod() + self.start_debuginfod(get_bb_var("LOCALPKGFEED_DIR", "xz")) env = os.environ.copy() env["DEBUGINFOD_URLS"] = "http://localhost:%d/" % self.port @@ -141,12 +142,13 @@ DISTRO_FEATURES:append = " debuginfod" self.write_config(""" TMPDIR = "${TOPDIR}/tmp-debuginfod" DISTRO_FEATURES:append = " debuginfod" +INHERIT += "localpkgfeed" CORE_IMAGE_EXTRA_INSTALL += "elfutils xz" """) - bitbake("core-image-minimal elfutils-native:do_addto_recipe_sysroot") + bitbake("core-image-minimal elfutils-native:do_addto_recipe_sysroot xz:do_localpkgfeed") try: - self.start_debuginfod() + self.start_debuginfod(get_bb_var("LOCALPKGFEED_DIR", "xz")) with runqemu("core-image-minimal", runqemuparams="nographic") as qemu: cmd = "DEBUGINFOD_URLS=http://%s:%d/ debuginfod-find debuginfo /usr/bin/xz" % (qemu.server_ip, self.port) diff --git a/meta/lib/oeqa/selftest/cases/devtool.py b/meta/lib/oeqa/selftest/cases/devtool.py index 51949e3c93..c8bf7d9e44 100644 --- a/meta/lib/oeqa/selftest/cases/devtool.py +++ b/meta/lib/oeqa/selftest/cases/devtool.py @@ -286,10 +286,13 @@ class DevtoolTestCase(OESelftestTestCase): else: self.skipTest('No tap devices found - you must set up tap devices with scripts/runqemu-gen-tapdevs before running this test') - def _test_devtool_add_git_url(self, git_url, version, pn, resulting_src_uri): + def _test_devtool_add_git_url(self, git_url, version, pn, resulting_src_uri, srcrev=None): self.track_for_cleanup(self.workspacedir) self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') - result = runCmd('devtool add --version %s %s %s' % (version, pn, git_url)) + command = 'devtool add --version %s %s %s' % (version, pn, git_url) + if srcrev : + command += ' --srcrev %s' %srcrev + result = runCmd(command) self.assertExists(os.path.join(self.workspacedir, 'conf', 'layer.conf'), 'Workspace directory not created') # Check the recipe name is correct recipefile = get_bb_var('FILE', pn) @@ -479,11 +482,12 @@ class DevtoolAddTests(DevtoolBase): def test_devtool_add_git_style2(self): version = 'v3.1.0' + srcrev = 'v3.1.0' pn = 'mbedtls' # this will trigger reformat_git_uri with branch parameter in url git_url = "'git://git@github.com/ARMmbed/mbedtls.git;protocol=https'" - resulting_src_uri = "gitsm://git@github.com/ARMmbed/mbedtls.git;protocol=https;branch=master" - self._test_devtool_add_git_url(git_url, version, pn, resulting_src_uri) + resulting_src_uri = "git://git@github.com/ARMmbed/mbedtls.git;protocol=https;branch=master" + self._test_devtool_add_git_url(git_url, version, pn, resulting_src_uri, srcrev) def test_devtool_add_library(self): # Fetch source @@ -875,13 +879,8 @@ class DevtoolModifyTests(DevtoolBase): self.add_command_to_tearDown('bitbake -c clean %s' % testrecipe) self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir)) - srcfile = os.path.join(tempdir, 'oe-local-files/share/dot.bashrc') - srclink = os.path.join(tempdir, 'share/dot.bashrc') + srcfile = os.path.join(tempdir, 'share/dot.bashrc') self.assertExists(srcfile, 'Extracted source could not be found') - if os.path.islink(srclink) and os.path.exists(srclink) and os.path.samefile(srcfile, srclink): - correct_symlink = True - self.assertTrue(correct_symlink, 'Source symlink to oe-local-files is broken') - matches = glob.glob(os.path.join(self.workspacedir, 'appends', '%s_*.bbappend' % testrecipe)) self.assertTrue(matches, 'bbappend not created') # Test devtool status @@ -952,9 +951,9 @@ class DevtoolModifyTests(DevtoolBase): # others git:// in SRC_URI # cointains a patch testrecipe = 'hello-rs' - bb_vars = get_bb_vars(['SRC_URI', 'FILE', 'WORKDIR', 'CARGO_HOME'], testrecipe) + bb_vars = get_bb_vars(['SRC_URI', 'FILE', 'UNPACKDIR', 'CARGO_HOME'], testrecipe) recipefile = bb_vars['FILE'] - workdir = bb_vars['WORKDIR'] + unpackdir = bb_vars['UNPACKDIR'] cargo_home = bb_vars['CARGO_HOME'] src_uri = bb_vars['SRC_URI'].split() self.assertTrue(src_uri[0].startswith('git://'), @@ -1025,7 +1024,7 @@ class DevtoolModifyTests(DevtoolBase): self.assertEqual(parms['type'], 'git-dependency', 'git dependencies uri should have "type=git-dependency"') raw_url = raw_url.replace("git://", '%s://' % parms['protocol']) patch_line = '[patch."%s"]' % raw_url - path_patched = os.path.join(workdir, parms['destsuffix']) + path_patched = os.path.join(unpackdir, parms['destsuffix']) path_override_line = '%s = { path = "%s" }' % (parms['name'], path_patched) # Would have been better to use tomllib to read this file :/ self.assertIn(patch_line, cargo_config_contents) @@ -1274,7 +1273,7 @@ class DevtoolUpdateTests(DevtoolBase): with open(bbappendfile, 'r') as f: self.assertEqual(expectedlines, f.readlines()) # Drop new commit and check patch gets deleted - result = runCmd('git reset HEAD^', cwd=tempsrcdir) + result = runCmd('git reset HEAD^ --hard', cwd=tempsrcdir) result = runCmd('devtool update-recipe %s -a %s' % (testrecipe, templayerdir)) self.assertNotExists(patchfile, 'Patch file not deleted') expectedlines2 = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n', @@ -1283,6 +1282,7 @@ class DevtoolUpdateTests(DevtoolBase): self.assertEqual(expectedlines2, f.readlines()) # Put commit back and check we can run it if layer isn't in bblayers.conf os.remove(bbappendfile) + result = runCmd("sed 's!\\(#define VERSION\\W*\"[^\"]*\\)\"!\\1-custom\"!' -i ReadMe.c", cwd=tempsrcdir) result = runCmd('git commit -a -m "Add our custom version"', cwd=tempsrcdir) result = runCmd('bitbake-layers remove-layer %s' % templayerdir, cwd=self.builddir) result = runCmd('devtool update-recipe %s -a %s' % (testrecipe, templayerdir)) @@ -1357,7 +1357,7 @@ class DevtoolUpdateTests(DevtoolBase): with open(bbappendfile, 'r') as f: self.assertEqual(expectedlines, set(f.readlines())) # Drop new commit and check SRCREV changes - result = runCmd('git reset HEAD^', cwd=tempsrcdir) + result = runCmd('git reset HEAD^ --hard', cwd=tempsrcdir) result = runCmd('devtool update-recipe -m srcrev %s -a %s' % (testrecipe, templayerdir)) self.assertNotExists(os.path.join(appenddir, testrecipe), 'Patch directory should not be created') result = runCmd('git rev-parse HEAD', cwd=tempsrcdir) @@ -1369,6 +1369,7 @@ class DevtoolUpdateTests(DevtoolBase): self.assertEqual(expectedlines, set(f.readlines())) # Put commit back and check we can run it if layer isn't in bblayers.conf os.remove(bbappendfile) + result = runCmd('echo "# Additional line" >> Makefile.am', cwd=tempsrcdir) result = runCmd('git commit -a -m "Change the Makefile"', cwd=tempsrcdir) result = runCmd('bitbake-layers remove-layer %s' % templayerdir, cwd=self.builddir) result = runCmd('devtool update-recipe -m srcrev %s -a %s' % (testrecipe, templayerdir)) @@ -1400,11 +1401,12 @@ class DevtoolUpdateTests(DevtoolBase): # Try building just to ensure we haven't broken that bitbake("%s" % testrecipe) # Edit / commit local source - runCmd('echo "/* Foobar */" >> oe-local-files/makedevs.c', cwd=tempdir) - runCmd('echo "Foo" > oe-local-files/new-local', cwd=tempdir) + runCmd('echo "/* Foobar */" >> makedevs.c', cwd=tempdir) + runCmd('echo "Foo" > new-local', cwd=tempdir) runCmd('echo "Bar" > new-file', cwd=tempdir) runCmd('git add new-file', cwd=tempdir) runCmd('git commit -m "Add new file"', cwd=tempdir) + runCmd('git add new-local', cwd=tempdir) runCmd('devtool update-recipe %s' % testrecipe) expected_status = [(' M', '.*/%s$' % os.path.basename(recipefile)), (' M', '.*/makedevs/makedevs.c$'), @@ -1430,8 +1432,8 @@ class DevtoolUpdateTests(DevtoolBase): self.assertExists(local_file, 'File makedevs.c not created') self.assertExists(patchfile, 'File new_local not created') - def test_devtool_update_recipe_local_files_2(self): - """Check local source files support when oe-local-files is in Git""" + def _test_devtool_update_recipe_local_files_2(self): + """Check local source files support when editing local files in Git""" testrecipe = 'devtool-test-local' recipefile = get_bb_var('FILE', testrecipe) recipedir = os.path.dirname(recipefile) @@ -1446,17 +1448,13 @@ class DevtoolUpdateTests(DevtoolBase): result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir)) # Check git repo self._check_src_repo(tempdir) - # Add oe-local-files to Git - runCmd('rm oe-local-files/.gitignore', cwd=tempdir) - runCmd('git add oe-local-files', cwd=tempdir) - runCmd('git commit -m "Add local sources"', cwd=tempdir) # Edit / commit local sources - runCmd('echo "# Foobar" >> oe-local-files/file1', cwd=tempdir) + runCmd('echo "# Foobar" >> file1', cwd=tempdir) runCmd('git commit -am "Edit existing file"', cwd=tempdir) - runCmd('git rm oe-local-files/file2', cwd=tempdir) + runCmd('git rm file2', cwd=tempdir) runCmd('git commit -m"Remove file"', cwd=tempdir) - runCmd('echo "Foo" > oe-local-files/new-local', cwd=tempdir) - runCmd('git add oe-local-files/new-local', cwd=tempdir) + runCmd('echo "Foo" > new-local', cwd=tempdir) + runCmd('git add new-local', cwd=tempdir) runCmd('git commit -m "Add new local file"', cwd=tempdir) runCmd('echo "Gar" > new-file', cwd=tempdir) runCmd('git add new-file', cwd=tempdir) @@ -1465,7 +1463,7 @@ class DevtoolUpdateTests(DevtoolBase): os.path.dirname(recipefile)) # Checkout unmodified file to working copy -> devtool should still pick # the modified version from HEAD - runCmd('git checkout HEAD^ -- oe-local-files/file1', cwd=tempdir) + runCmd('git checkout HEAD^ -- file1', cwd=tempdir) runCmd('devtool update-recipe %s' % testrecipe) expected_status = [(' M', '.*/%s$' % os.path.basename(recipefile)), (' M', '.*/file1$'), @@ -1540,7 +1538,7 @@ class DevtoolUpdateTests(DevtoolBase): # (don't bother with cleaning the recipe on teardown, we won't be building it) result = runCmd('devtool modify %s' % testrecipe) # Modify one file - runCmd('echo "Another line" >> file2', cwd=os.path.join(self.workspacedir, 'sources', testrecipe, 'oe-local-files')) + runCmd('echo "Another line" >> file2', cwd=os.path.join(self.workspacedir, 'sources', testrecipe)) self.add_command_to_tearDown('cd %s; rm %s/*; git checkout %s %s' % (os.path.dirname(recipefile), testrecipe, testrecipe, os.path.basename(recipefile))) result = runCmd('devtool update-recipe %s' % testrecipe) expected_status = [(' M', '.*/%s/file2$' % testrecipe)] @@ -1769,6 +1767,8 @@ class DevtoolExtractTests(DevtoolBase): # Definitions testrecipe = 'mdadm' testfile = '/sbin/mdadm' + if "usrmerge" in get_bb_var('DISTRO_FEATURES'): + testfile = '/usr/sbin/mdadm' testimage = 'oe-selftest-image' testcommand = '/sbin/mdadm --help' # Build an image to run diff --git a/meta/lib/oeqa/selftest/cases/layerappend.py b/meta/lib/oeqa/selftest/cases/layerappend.py index 379ed589ad..64b17117cc 100644 --- a/meta/lib/oeqa/selftest/cases/layerappend.py +++ b/meta/lib/oeqa/selftest/cases/layerappend.py @@ -37,7 +37,7 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" SRC_URI:append = " file://appendtest.txt" sysroot_stage_all:append() { - install -m 644 ${WORKDIR}/appendtest.txt ${SYSROOT_DESTDIR}/ + install -m 644 ${UNPACKDIR}/appendtest.txt ${SYSROOT_DESTDIR}/ } """ diff --git a/meta/lib/oeqa/selftest/cases/recipetool.py b/meta/lib/oeqa/selftest/cases/recipetool.py index aebea42502..42202b7831 100644 --- a/meta/lib/oeqa/selftest/cases/recipetool.py +++ b/meta/lib/oeqa/selftest/cases/recipetool.py @@ -120,9 +120,15 @@ class RecipetoolAppendTests(RecipetoolBase): self._try_recipetool_appendfile_fail('/dev/console', self.testfile, ['ERROR: /dev/console cannot be handled by this tool']) def test_recipetool_appendfile_alternatives(self): + lspath = '/bin/ls' + dirname = "base_bindir" + if "usrmerge" in get_bb_var('DISTRO_FEATURES'): + lspath = '/usr/bin/ls' + dirname = "bindir" + # Now try with a file we know should be an alternative # (this is very much a fake example, but one we know is reliably an alternative) - self._try_recipetool_appendfile_fail('/bin/ls', self.testfile, ['ERROR: File /bin/ls is an alternative possibly provided by the following recipes:', 'coreutils', 'busybox']) + self._try_recipetool_appendfile_fail(lspath, self.testfile, ['ERROR: File %s is an alternative possibly provided by the following recipes:' % lspath, 'coreutils', 'busybox']) # Need a test file - should be executable testfile2 = os.path.join(self.corebase, 'oe-init-build-env') testfile2name = os.path.basename(testfile2) @@ -131,12 +137,12 @@ class RecipetoolAppendTests(RecipetoolBase): 'SRC_URI += "file://%s"\n' % testfile2name, '\n', 'do_install:append() {\n', - ' install -d ${D}${base_bindir}\n', - ' install -m 0755 ${WORKDIR}/%s ${D}${base_bindir}/ls\n' % testfile2name, + ' install -d ${D}${%s}\n' % dirname, + ' install -m 0755 ${UNPACKDIR}/%s ${D}${%s}/ls\n' % (testfile2name, dirname), '}\n'] - self._try_recipetool_appendfile('coreutils', '/bin/ls', testfile2, '-r coreutils', expectedlines, [testfile2name]) + self._try_recipetool_appendfile('coreutils', lspath, testfile2, '-r coreutils', expectedlines, [testfile2name]) # Now try bbappending the same file again, contents should not change - bbappendfile, _ = self._try_recipetool_appendfile('coreutils', '/bin/ls', self.testfile, '-r coreutils', expectedlines, [testfile2name]) + bbappendfile, _ = self._try_recipetool_appendfile('coreutils', lspath, self.testfile, '-r coreutils', expectedlines, [testfile2name]) # But file should have copiedfile = os.path.join(os.path.dirname(bbappendfile), 'coreutils', testfile2name) result = runCmd('diff -q %s %s' % (testfile2, copiedfile), ignore_status=True) @@ -158,7 +164,7 @@ class RecipetoolAppendTests(RecipetoolBase): '\n', 'do_install:append() {\n', ' install -d ${D}${datadir}\n', - ' install -m 0644 ${WORKDIR}/testfile ${D}${datadir}/something\n', + ' install -m 0644 ${UNPACKDIR}/testfile ${D}${datadir}/something\n', '}\n'] self._try_recipetool_appendfile('netbase', '/usr/share/something', self.testfile, '-r netbase', expectedlines, ['testfile']) # Try adding another file, this time where the source file is executable @@ -173,8 +179,8 @@ class RecipetoolAppendTests(RecipetoolBase): '\n', 'do_install:append() {\n', ' install -d ${D}${datadir}\n', - ' install -m 0644 ${WORKDIR}/testfile ${D}${datadir}/something\n', - ' install -m 0755 ${WORKDIR}/%s ${D}${datadir}/scriptname\n' % testfile2name, + ' install -m 0644 ${UNPACKDIR}/testfile ${D}${datadir}/something\n', + ' install -m 0755 ${UNPACKDIR}/%s ${D}${datadir}/scriptname\n' % testfile2name, '}\n'] self._try_recipetool_appendfile('netbase', '/usr/share/scriptname', testfile2, '-r netbase', expectedlines, ['testfile', testfile2name]) @@ -186,7 +192,7 @@ class RecipetoolAppendTests(RecipetoolBase): '\n', 'do_install:append() {\n', ' install -d ${D}${bindir}\n', - ' install -m 0755 ${WORKDIR}/testfile ${D}${bindir}/selftest-recipetool-testbin\n', + ' install -m 0755 ${UNPACKDIR}/testfile ${D}${bindir}/selftest-recipetool-testbin\n', '}\n'] _, output = self._try_recipetool_appendfile('netbase', '/usr/bin/selftest-recipetool-testbin', self.testfile, '-r netbase', expectedlines, ['testfile']) self.assertNotIn('WARNING: ', output) @@ -201,7 +207,7 @@ class RecipetoolAppendTests(RecipetoolBase): '\n', 'do_install:append:mymachine() {\n', ' install -d ${D}${datadir}\n', - ' install -m 0644 ${WORKDIR}/testfile ${D}${datadir}/something\n', + ' install -m 0644 ${UNPACKDIR}/testfile ${D}${datadir}/something\n', '}\n'] _, output = self._try_recipetool_appendfile('netbase', '/usr/share/something', self.testfile, '-r netbase -m mymachine', expectedlines, ['mymachine/testfile']) self.assertNotIn('WARNING: ', output) @@ -235,7 +241,7 @@ class RecipetoolAppendTests(RecipetoolBase): '\n', 'do_install:append() {\n', ' install -d ${D}${datadir}\n', - ' install -m 0644 ${WORKDIR}/testfile ${D}${datadir}/selftest-replaceme-subdir\n', + ' install -m 0644 ${UNPACKDIR}/testfile ${D}${datadir}/selftest-replaceme-subdir\n', '}\n'] _, output = self._try_recipetool_appendfile('selftest-recipetool-appendfile', '/usr/share/selftest-replaceme-subdir', self.testfile, '', expectedlines, ['testfile']) self.assertNotIn('WARNING: ', output) @@ -262,7 +268,7 @@ class RecipetoolAppendTests(RecipetoolBase): '\n', 'do_install:append() {\n', ' install -d ${D}${sysconfdir}\n', - ' install -m 0644 ${WORKDIR}/testfile ${D}${sysconfdir}/selftest-replaceme-patched\n', + ' install -m 0644 ${UNPACKDIR}/testfile ${D}${sysconfdir}/selftest-replaceme-patched\n', '}\n'] _, output = self._try_recipetool_appendfile('selftest-recipetool-appendfile', '/etc/selftest-replaceme-patched', self.testfile, '', expectedlines, ['testfile']) for line in output.splitlines(): @@ -280,7 +286,7 @@ class RecipetoolAppendTests(RecipetoolBase): '\n', 'do_install:append() {\n', ' install -d ${D}${datadir}\n', - ' install -m 0644 ${WORKDIR}/testfile ${D}${datadir}/selftest-replaceme-scripted\n', + ' install -m 0644 ${UNPACKDIR}/testfile ${D}${datadir}/selftest-replaceme-scripted\n', '}\n'] _, output = self._try_recipetool_appendfile('selftest-recipetool-appendfile', '/usr/share/selftest-replaceme-scripted', self.testfile, '', expectedlines, ['testfile']) self.assertNotIn('WARNING: ', output) @@ -303,7 +309,7 @@ class RecipetoolAppendTests(RecipetoolBase): '\n', 'do_install:append() {\n', ' install -d ${D}${datadir}\n', - ' install -m 0644 ${WORKDIR}/testfile ${D}${datadir}/selftest-replaceme-postinst\n', + ' install -m 0644 ${UNPACKDIR}/testfile ${D}${datadir}/selftest-replaceme-postinst\n', '}\n'] _, output = self._try_recipetool_appendfile('selftest-recipetool-appendfile', '/usr/share/selftest-replaceme-postinst', self.testfile, '-r selftest-recipetool-appendfile', expectedlines, ['testfile']) diff --git a/meta/lib/oeqa/selftest/cases/recipeutils.py b/meta/lib/oeqa/selftest/cases/recipeutils.py index 2cb4445f81..9949737172 100644 --- a/meta/lib/oeqa/selftest/cases/recipeutils.py +++ b/meta/lib/oeqa/selftest/cases/recipeutils.py @@ -72,7 +72,7 @@ class RecipeUtilsTests(OESelftestTestCase): expected_patch = """ --- a/recipes-test/recipeutils/recipeutils-test_1.2.bb +++ b/recipes-test/recipeutils/recipeutils-test_1.2.bb -@@ -8,6 +8,4 @@ +@@ -11,6 +11,4 @@ BBCLASSEXTEND = "native nativesdk" @@ -97,7 +97,7 @@ class RecipeUtilsTests(OESelftestTestCase): expected_patch = """ --- a/recipes-test/recipeutils/recipeutils-test_1.2.bb +++ b/recipes-test/recipeutils/recipeutils-test_1.2.bb -@@ -8,6 +8,3 @@ +@@ -11,6 +11,3 @@ BBCLASSEXTEND = "native nativesdk" diff --git a/meta/lib/oeqa/selftest/cases/runtime_test.py b/meta/lib/oeqa/selftest/cases/runtime_test.py index 12000aac16..13aa5f16c9 100644 --- a/meta/lib/oeqa/selftest/cases/runtime_test.py +++ b/meta/lib/oeqa/selftest/cases/runtime_test.py @@ -273,7 +273,7 @@ TEST_RUNQEMUPARAMS += " slirp" import subprocess, os distro = oe.lsb.distro_identifier() - if distro and (distro in ['debian-9', 'debian-10', 'centos-7', 'centos-8', 'ubuntu-16.04', 'ubuntu-18.04'] or + if distro and (distro in ['debian-9', 'debian-10', 'centos-7', 'centos-8', 'centos-9', 'ubuntu-16.04', 'ubuntu-18.04'] or distro.startswith('almalinux') or distro.startswith('rocky')): self.skipTest('virgl headless cannot be tested with %s' %(distro)) diff --git a/meta/lib/patchtest/repo.py b/meta/lib/patchtest/repo.py index d3788f466d..5f361ac500 100644 --- a/meta/lib/patchtest/repo.py +++ b/meta/lib/patchtest/repo.py @@ -11,6 +11,7 @@ import os import utils import logging +import git from patch import PatchTestPatch logger = logging.getLogger('patchtest') @@ -21,15 +22,17 @@ class PatchTestRepo(object): # prefixes used for temporal branches/stashes prefix = 'patchtest' + def __init__(self, patch, repodir, commit=None, branch=None): self._repodir = repodir + self._repo = git.Repo.init(repodir) self._patch = PatchTestPatch(patch) - self._current_branch = self._get_current_branch() + self._current_branch = self._repo.active_branch.name # targeted branch defined on the patch may be invalid, so make sure there # is a corresponding remote branch valid_patch_branch = None - if self._patch.branch in self.upstream_branches(): + if self._patch.branch in self._repo.branches: valid_patch_branch = self._patch.branch # Target Branch @@ -52,22 +55,19 @@ class PatchTestRepo(object): self._workingbranch = "%s_%s" % (PatchTestRepo.prefix, os.getpid()) - # create working branch - self._exec({'cmd': ['git', 'checkout', '-b', self._workingbranch, self._commit]}) + # create working branch. Use the '-B' flag so that we just + # check out the existing one if it's there + self._repo.git.execute(['git', 'checkout', '-B', self._workingbranch, self._commit]) self._patchmerged = False # Check if patch can be merged using git-am self._patchcanbemerged = True try: - self._exec({'cmd': ['git', 'am', '--keep-cr'], 'input': self._patch.contents}) - except utils.CmdException as ce: - self._exec({'cmd': ['git', 'am', '--abort']}) + # Make sure to get the absolute path of the file + self._repo.git.execute(['git', 'apply', '--check', os.path.abspath(self._patch.path)], with_exceptions=True) + except git.exc.GitCommandError as ce: self._patchcanbemerged = False - finally: - # if patch was applied, remove it - if self._patchcanbemerged: - self._exec({'cmd':['git', 'reset', '--hard', self._commit]}) # for debugging purposes, print all repo parameters logger.debug("Parameters") @@ -97,78 +97,24 @@ class PatchTestRepo(object): def canbemerged(self): return self._patchcanbemerged - def _exec(self, cmds): - _cmds = [] - if isinstance(cmds, dict): - _cmds.append(cmds) - elif isinstance(cmds, list): - _cmds = cmds - else: - raise utils.CmdException({'cmd':str(cmds)}) - - results = [] - cmdfailure = False - try: - results = utils.exec_cmds(_cmds, self._repodir) - except utils.CmdException as ce: - cmdfailure = True - raise ce - finally: - if cmdfailure: - for cmd in _cmds: - logger.debug("CMD: %s" % ' '.join(cmd['cmd'])) - else: - for result in results: - cmd, rc, stdout, stderr = ' '.join(result['cmd']), result['returncode'], result['stdout'], result['stderr'] - logger.debug("CMD: %s RCODE: %s STDOUT: %s STDERR: %s" % (cmd, rc, stdout, stderr)) - - return results - - def _get_current_branch(self, commit='HEAD'): - cmd = {'cmd':['git', 'rev-parse', '--abbrev-ref', commit]} - cb = self._exec(cmd)[0]['stdout'] - if cb == commit: - logger.warning('You may be detached so patchtest will checkout to master after execution') - cb = 'master' - return cb - def _get_commitid(self, commit): if not commit: return None try: - cmd = {'cmd':['git', 'rev-parse', '--short', commit]} - return self._exec(cmd)[0]['stdout'] - except utils.CmdException as ce: - # try getting the commit under any remotes - cmd = {'cmd':['git', 'remote']} - remotes = self._exec(cmd)[0]['stdout'] - for remote in remotes.splitlines(): - cmd = {'cmd':['git', 'rev-parse', '--short', '%s/%s' % (remote, commit)]} - try: - return self._exec(cmd)[0]['stdout'] - except utils.CmdException: - pass + return self._repo.rev_parse(commit).hexsha + except Exception as e: + print(f"Couldn't find commit {commit} in repo") return None - def upstream_branches(self): - cmd = {'cmd':['git', 'branch', '--remotes']} - remote_branches = self._exec(cmd)[0]['stdout'] - - # just get the names, without the remote name - branches = set(branch.split('/')[-1] for branch in remote_branches.splitlines()) - return branches - def merge(self): if self._patchcanbemerged: - self._exec({'cmd': ['git', 'am', '--keep-cr'], - 'input': self._patch.contents, - 'updateenv': {'PTRESOURCE':self._patch.path}}) + self._repo.git.execute(['git', 'am', '--keep-cr', os.path.abspath(self._patch.path)]) self._patchmerged = True def clean(self): - self._exec({'cmd':['git', 'checkout', '%s' % self._current_branch]}) - self._exec({'cmd':['git', 'branch', '-D', self._workingbranch]}) + self._repo.git.execute(['git', 'checkout', self._current_branch]) + self._repo.git.execute(['git', 'branch', '-D', self._workingbranch]) self._patchmerged = False diff --git a/meta/lib/patchtest/requirements.txt b/meta/lib/patchtest/requirements.txt index ba55ff905e..4247b91f09 100644 --- a/meta/lib/patchtest/requirements.txt +++ b/meta/lib/patchtest/requirements.txt @@ -1,5 +1,6 @@ boto3 git-pw>=2.5.0 +GitPython jinja2 pylint pyparsing>=3.0.9 diff --git a/meta/lib/patchtest/selftest/files/TestMbox.test_bugzilla_entry_format.fail b/meta/lib/patchtest/selftest/files/TestMbox.test_bugzilla_entry_format.fail index 80f409e952..854d7eb8c7 100644 --- a/meta/lib/patchtest/selftest/files/TestMbox.test_bugzilla_entry_format.fail +++ b/meta/lib/patchtest/selftest/files/TestMbox.test_bugzilla_entry_format.fail @@ -1,25 +1,26 @@ -From fdfd605e565d874502522c4b70b786c8c5aa0bad Mon Sep 17 00:00:00 2001 +From f06e14633723c1e78bc7a4b0fd0d3b79d09f0c68 Mon Sep 17 00:00:00 2001 From: name@somedomain.com <email@address.com> -Date: Fri, 17 Feb 2017 16:29:21 -0600 -Subject: [PATCH] README: adds 'foo' to the header +Date: Thu, 2 May 2024 10:21:45 -0400 +Subject: [PATCH] README.OE-Core.md: Add foo to header -This test patch adds 'foo' to the header +This test patch adds 'foo' to the header of README.OE-Core.md [YOCTO 1234] -Signed-off-by: Daniela Plascencia <daniela.plascencia@linux.intel.com> +Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com> --- - README | 1 + + README.OE-Core.md | 1 + 1 file changed, 1 insertion(+) -diff --git a/README b/README -index 521916cd4f..cdf29dcea3 100644 ---- a/README -+++ b/README +diff --git a/README.OE-Core.md b/README.OE-Core.md +index 687c58e410c..9d863891134 100644 +--- a/README.OE-Core.md ++++ b/README.OE-Core.md @@ -1,3 +1,4 @@ +**** FOO **** OpenEmbedded-Core ================= + +-- +2.44.0 --- -2.11.0 diff --git a/meta/lib/patchtest/utils.py b/meta/lib/patchtest/utils.py index dd0abc22d9..8eddf3e85f 100644 --- a/meta/lib/patchtest/utils.py +++ b/meta/lib/patchtest/utils.py @@ -14,109 +14,6 @@ import logging import re import mailbox -class CmdException(Exception): - """ Simple exception class where its attributes are the ones passed when instantiated """ - def __init__(self, cmd): - self._cmd = cmd - def __getattr__(self, name): - value = None - if self._cmd.has_key(name): - value = self._cmd[name] - return value - -def exec_cmd(cmd, cwd, ignore_error=False, input=None, strip=True, updateenv={}): - """ - Input: - - cmd: dict containing the following keys: - - cmd : the command itself as an array of strings - ignore_error: if False, no exception is raised - strip: indicates if strip is done on the output (stdout and stderr) - input: input data to the command (stdin) - updateenv: environment variables to be appended to the current - process environment variables - - NOTE: keys 'ignore_error' and 'input' are optional; if not included, - the defaults are the ones specify in the arguments - cwd: directory where commands are executed - ignore_error: raise CmdException if command fails to execute and - this value is False - input: input data (stdin) for the command - - Output: dict containing the following keys: - - cmd: the same as input - ignore_error: the same as input - strip: the same as input - input: the same as input - stdout: Standard output after command's execution - stderr: Standard error after command's execution - returncode: Return code after command's execution - - """ - cmddefaults = { - 'cmd':'', - 'ignore_error':ignore_error, - 'strip':strip, - 'input':input, - 'updateenv':updateenv, - } - - # update input values if necessary - cmddefaults.update(cmd) - - _cmd = cmddefaults - - if not _cmd['cmd']: - raise CmdException({'cmd':None, 'stderr':'no command given'}) - - # update the environment - env = os.environ - env.update(_cmd['updateenv']) - - _command = [e for e in _cmd['cmd']] - p = subprocess.Popen(_command, - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - universal_newlines=True, - cwd=cwd, - env=env) - - # execute the command and strip output - (_stdout, _stderr) = p.communicate(_cmd['input']) - if _cmd['strip']: - _stdout, _stderr = map(str.strip, [_stdout, _stderr]) - - # generate the result - result = _cmd - result.update({'cmd':_command,'stdout':_stdout,'stderr':_stderr,'returncode':p.returncode}) - - # launch exception if necessary - if not _cmd['ignore_error'] and p.returncode: - raise CmdException(result) - - return result - -def exec_cmds(cmds, cwd): - """ Executes commands - - Input: - cmds: Array of commands - cwd: directory where commands are executed - - Output: Array of output commands - """ - results = [] - _cmds = cmds - - for cmd in _cmds: - result = exec_cmd(cmd, cwd) - results.append(result) - - return results - def logger_create(name): logger = logging.getLogger(name) loggerhandler = logging.StreamHandler() @@ -125,20 +22,6 @@ def logger_create(name): logger.setLevel(logging.INFO) return logger -def get_subject_prefix(path): - prefix = "" - mbox = mailbox.mbox(path) - - if len(mbox): - subject = mbox[0]['subject'] - if subject: - pattern = re.compile(r"(\[.*\])", re.DOTALL) - match = pattern.search(subject) - if match: - prefix = match.group(1) - - return prefix - def valid_branch(branch): """ Check if branch is valid name """ lbranch = branch.lower() @@ -153,7 +36,17 @@ def valid_branch(branch): def get_branch(path): """ Get the branch name from mbox """ - fullprefix = get_subject_prefix(path) + fullprefix = "" + mbox = mailbox.mbox(path) + + if len(mbox): + subject = mbox[0]['subject'] + if subject: + pattern = re.compile(r"(\[.*\])", re.DOTALL) + match = pattern.search(subject) + if match: + fullprefix = match.group(1) + branch, branches, valid_branches = None, [], [] if fullprefix: |