lib/oe/patch: Make GitApplyTree.extractPatches() return the patches
PATCH v2 1/2 lib/oe/patch: Make GitApplyTree.extractPatches() return the patches
The list of patches will be used by _export_patches() in devtool to add new patches in the correct order.
---
PATCHv2: New patch.
meta/lib/oe/patch.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
meta/lib/oe/patch.py +5 -1
@@ -516,6 +516,7 @@ class GitApplyTree(PatchTree): import tempfile import shutil tempdir = tempfile.mkdtemp(prefix='oepatch') + patches = [] try: for name, rev in startcommits.items(): shellcmd = ["git", "format-patch", "--no-signature", "--no-numbered", rev, "-o", tempdir]
@@ -553,11 +554,14 @@ class GitApplyTree(PatchTree): outfile = notes.get(GitApplyTree.original_patch, os.path.basename(srcfile)) bb.utils.mkdirhier(os.path.join(outdir, name)) - with open(os.path.join(outdir, name, outfile), 'w') as of: + patch = os.path.join(outdir, name, outfile) + with open(patch, 'w') as of: for line in patchlines: of.write(line) + patches.append(patch) finally: shutil.rmtree(tempdir) + return patches def _need_dirty_check(self): fetch = bb.fetch2.Fetch([], self.d)
PATCH v2 2/2 devtool: standard: Add new patches in correct order when finishing
Make sure that new patches that are added as a result of using devtool finish are added to the SRC_URI in the same order they were committed.
Previously, the order was a result of the arbitrary order the patch files were returned by os.walk(), which typically resulted in them being added to the SRC_URI in the reverse order they were committed.
---
PATCHv2: Rely on GitApplyTree.extractPatches() to return the paths to
the patches rather than using os.walk() to find them.
meta/lib/oeqa/selftest/cases/devtool.py | 30 +++++-- scripts/lib/devtool/standard.py | 110 ++++++++++++------------ 2 files changed, 78 insertions(+), 62 deletions(-)
meta/lib/oeqa/selftest/cases/devtool.py +23 -7
@@ -2314,6 +2314,11 @@ class DevtoolUpgradeTests(DevtoolBase): result = runCmd('git status --porcelain', cwd=tempdir) self.assertIn('M maps.c', result.output) result = runCmd('git commit maps.c -m "Add a comment to the code"', cwd=tempdir) + # Make another change to the source + result = runCmd('sed -i \'/^#include "mdadm.h"/a \\/* Here is another comment *\\/\' maps.c', cwd=tempdir) + result = runCmd('git status --porcelain', cwd=tempdir) + self.assertIn('M maps.c', result.output) + result = runCmd('git commit maps.c -m "Add another comment to the code"', cwd=tempdir) for entry in os.listdir(recipedir): filesdir = os.path.join(recipedir, entry) if os.path.isdir(filesdir):
@@ -2333,8 +2338,15 @@ class DevtoolUpgradeTests(DevtoolBase): self.assertNotIn(recipe, result.output, 'Recipe should have been reset by finish but wasn\'t') self.assertNotExists(os.path.join(self.workspacedir, 'recipes', recipe), 'Recipe directory should not exist after finish') expected_status = [(' M', '.*/%s$' % os.path.basename(oldrecipefile)), - ('??', '.*/.*-Add-a-comment-to-the-code.patch$')] + ('??', '.*/.*-Add-a-comment-to-the-code.patch$'), + ('??', '.*/.*-Add-another-comment-to-the-code.patch$')] self._check_repo_status(recipedir, expected_status) + result = runCmd('git diff %s' % os.path.basename(oldrecipefile), cwd=os.path.dirname(oldrecipefile)) + # Check that the recipe got updated as expected + # Can't use self._check_diff() as the order of the added files matter. + result = result.output.splitlines() + self.assertEqual('+ file://0001-Add-a-comment-to-the-code.patch \\', result[8]) + self.assertEqual('+ file://0002-Add-another-comment-to-the-code.patch \\', result[9]) def test_devtool_finish_modify_otherlayer(self): recipe, oldrecipefile, recipedir, filesdir = self._setup_test_devtool_finish_modify()
@@ -2343,7 +2355,7 @@ class DevtoolUpgradeTests(DevtoolBase): relpth = os.path.relpath(recipedir, os.path.join(get_bb_var('COREBASE'), 'meta')) appenddir = os.path.join(get_test_layer(), relpth) self.track_for_cleanup(appenddir) - # Try finish to the original layer + # Try finish to another layer than the original layer self.add_command_to_tearDown('rm -rf %s ; cd %s ; git checkout %s' % (recipedir, os.path.dirname(recipedir), recipedir)) result = runCmd('devtool finish %s meta-selftest' % recipe) result = runCmd('devtool status')
@@ -2356,15 +2368,19 @@ class DevtoolUpgradeTests(DevtoolBase): recipefn = recipefn.split('_')[0] + '_%' appendfile = os.path.join(appenddir, recipefn + '.bbappend') self.assertExists(appendfile, 'bbappend %s should have been created but wasn\'t' % appendfile) + # Check that the bbappend got created as expected + with open(appendfile, 'r') as f: + newlines = f.readlines() + self.assertEqual('SRC_URI += "file://0001-Add-a-comment-to-the-code.patch file://0002-Add-another-comment-to-the-code.patch"\n', newlines[2]) newdir = os.path.join(appenddir, recipe) files = os.listdir(newdir) - foundpatch = None - for fn in files: - if fnmatch.fnmatch(fn, '*-Add-a-comment-to-the-code.patch'): - foundpatch = fn + foundpatch = False + for fn in files[:]: + if fnmatch.fnmatch(fn, '*-Add-a*-comment-to-the-code.patch'): + files.remove(fn) + foundpatch = True if not foundpatch: self.fail('No patch file created next to bbappend') - files.remove(foundpatch) if files: self.fail('Unexpected file(s) copied next to bbappend: %s' % ', '.join(files))
scripts/lib/devtool/standard.py +55 -55
122 lines not on this page · raw message