diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2016-11-10 14:45:17 +1300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-11-23 11:02:27 +0000 |
commit | e47d21624dfec6f71742b837e91da553f18a28c5 (patch) | |
tree | 4d5296657218b97ee68070f5f04087bdf74a20ab /meta | |
parent | d9971f5dc8eb7de551fd6f5e058fd24770ef5d78 (diff) | |
download | openembedded-core-e47d21624dfec6f71742b837e91da553f18a28c5.tar.gz openembedded-core-e47d21624dfec6f71742b837e91da553f18a28c5.tar.bz2 openembedded-core-e47d21624dfec6f71742b837e91da553f18a28c5.zip |
devtool: update-recipe: fix handling of compressed local patches
It is possible to use gzip or bzip2 to compress patches and still refer
to them in compressed form in the SRC_URI value within a recipe. If you
run "devtool modify" on such a recipe, make changes to the commit for
the patch and then run devtool update-recipe, we need to correctly
associate the commit back to the compressed patch file and re-compress
the patch, neither of which we were doing previously.
Additionally, add an oe-selftest test to ensure this doesn't regress in
future.
Fixes [YOCTO #8278].
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/classes/patch.bbclass | 9 | ||||
-rw-r--r-- | meta/lib/oe/recipeutils.py | 6 | ||||
-rw-r--r-- | meta/lib/oeqa/selftest/devtool.py | 24 |
3 files changed, 32 insertions, 7 deletions
diff --git a/meta/classes/patch.bbclass b/meta/classes/patch.bbclass index 1f6927be04..2c1f58cbdc 100644 --- a/meta/classes/patch.bbclass +++ b/meta/classes/patch.bbclass @@ -10,13 +10,13 @@ PATCH_GIT_USER_EMAIL ?= "oe.patch@oe" inherit terminal -def src_patches(d, all = False ): +def src_patches(d, all=False, expand=True): workdir = d.getVar('WORKDIR', True) fetch = bb.fetch2.Fetch([], d) patches = [] sources = [] for url in fetch.urls: - local = patch_path(url, fetch, workdir) + local = patch_path(url, fetch, workdir, expand) if not local: if all: local = fetch.localpath(url) @@ -55,13 +55,14 @@ def src_patches(d, all = False ): return patches -def patch_path(url, fetch, workdir): +def patch_path(url, fetch, workdir, expand=True): """Return the local path of a patch, or None if this isn't a patch""" local = fetch.localpath(url) base, ext = os.path.splitext(os.path.basename(local)) if ext in ('.gz', '.bz2', '.Z'): - local = os.path.join(workdir, base) + if expand: + local = os.path.join(workdir, base) ext = os.path.splitext(base)[1] urldata = fetch.ud[url] diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py index 6caae5f7d4..ab4177aa81 100644 --- a/meta/lib/oe/recipeutils.py +++ b/meta/lib/oe/recipeutils.py @@ -397,7 +397,7 @@ def get_recipe_local_files(d, patches=False): for uri in uris: if fetch.ud[uri].type == 'file': if (not patches and - bb.utils.exec_flat_python_func('patch_path', uri, fetch, '')): + bb.utils.exec_flat_python_func('patch_path', uri, fetch, '', expand=False)): continue # Skip files that are referenced by absolute path fname = fetch.ud[uri].basepath @@ -418,7 +418,7 @@ def get_recipe_patches(d): patchfiles = [] # Execute src_patches() defined in patch.bbclass - this works since that class # is inherited globally - patches = bb.utils.exec_flat_python_func('src_patches', d) + patches = bb.utils.exec_flat_python_func('src_patches', d, expand=False) for patch in patches: _, _, local, _, _, parm = bb.fetch.decodeurl(patch) patchfiles.append(local) @@ -437,7 +437,7 @@ def get_recipe_patched_files(d): import oe.patch # Execute src_patches() defined in patch.bbclass - this works since that class # is inherited globally - patches = bb.utils.exec_flat_python_func('src_patches', d) + patches = bb.utils.exec_flat_python_func('src_patches', d, expand=False) patchedfiles = {} for patch in patches: _, _, patchfile, _, _, parm = bb.fetch.decodeurl(patch) diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py index f6226c1ad9..92dc5e5869 100644 --- a/meta/lib/oeqa/selftest/devtool.py +++ b/meta/lib/oeqa/selftest/devtool.py @@ -948,6 +948,30 @@ class DevtoolTests(DevtoolBase): expected_status = [(' M', '.*/%s/file2$' % testrecipe)] self._check_repo_status(os.path.dirname(recipefile), expected_status) + def test_devtool_update_recipe_local_patch_gz(self): + # First, modify the recipe + testrecipe = 'devtool-test-patch-gz' + recipefile = get_bb_var('FILE', testrecipe) + src_uri = get_bb_var('SRC_URI', testrecipe) + 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') + # (don't bother with cleaning the recipe on teardown, we won't be building it) + result = runCmd('devtool modify %s' % testrecipe) + # Modify one file + srctree = os.path.join(self.workspacedir, 'sources', testrecipe) + runCmd('echo "Another line" >> README', cwd=srctree) + runCmd('git commit -a --amend --no-edit', cwd=srctree) + 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/readme.patch.gz$' % testrecipe)] + self._check_repo_status(os.path.dirname(recipefile), expected_status) + patch_gz = os.path.join(os.path.dirname(recipefile), testrecipe, 'readme.patch.gz') + result = runCmd('file %s' % patch_gz) + if 'gzip compressed data' not in result.output: + self.fail('New patch file is not gzipped - file reports:\n%s' % result.output) + @testcase(1163) def test_devtool_extract(self): tempdir = tempfile.mkdtemp(prefix='devtoolqa') |