diff options
Diffstat (limited to 'meta/classes/devtool-source.bbclass')
-rw-r--r-- | meta/classes/devtool-source.bbclass | 89 |
1 files changed, 23 insertions, 66 deletions
diff --git a/meta/classes/devtool-source.bbclass b/meta/classes/devtool-source.bbclass index a8110006fb..3e24800dcb 100644 --- a/meta/classes/devtool-source.bbclass +++ b/meta/classes/devtool-source.bbclass @@ -1,3 +1,9 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# + # Development tool - source extraction helper class # # NOTE: this class is intended for use by devtool and should not be @@ -20,8 +26,6 @@ DEVTOOL_TEMPDIR ?= "" -DEVTOOL_PATCH_SRCDIR = "${DEVTOOL_TEMPDIR}/patchworkdir" - python() { tempdir = d.getVar('DEVTOOL_TEMPDIR') @@ -54,7 +58,6 @@ python() { else: unpacktask = 'do_unpack' d.appendVarFlag(unpacktask, 'postfuncs', ' devtool_post_unpack') - d.prependVarFlag('do_patch', 'prefuncs', ' devtool_pre_patch') d.appendVarFlag('do_patch', 'postfuncs', ' devtool_post_patch') # NOTE: in order for the patch stuff to be fully functional, @@ -73,69 +76,23 @@ python devtool_post_unpack() { tempdir = d.getVar('DEVTOOL_TEMPDIR') workdir = d.getVar('WORKDIR') + unpackdir = d.getVar('UNPACKDIR') srcsubdir = d.getVar('S') - def _move_file(src, dst): - """Move a file. Creates all the directory components of destination path.""" - dst_d = os.path.dirname(dst) - if dst_d: - bb.utils.mkdirhier(dst_d) - shutil.move(src, dst) - - def _ls_tree(directory): - """Recursive listing of files in a directory""" - ret = [] - for root, dirs, files in os.walk(directory): - ret.extend([os.path.relpath(os.path.join(root, fname), directory) for - fname in files]) - return ret - - is_kernel_yocto = bb.data.inherits_class('kernel-yocto', d) - # Move local source files into separate subdir - recipe_patches = [os.path.basename(patch) for patch in - oe.recipeutils.get_recipe_patches(d)] + # Add locally copied files to gitignore as we add back to the metadata directly local_files = oe.recipeutils.get_recipe_local_files(d) - - if is_kernel_yocto: - for key in local_files.copy(): - if key.endswith('scc'): - sccfile = open(local_files[key], 'r') - for l in sccfile: - line = l.split() - if line and line[0] in ('kconf', 'patch'): - cfg = os.path.join(os.path.dirname(local_files[key]), line[-1]) - if not cfg in local_files.values(): - local_files[line[-1]] = cfg - shutil.copy2(cfg, workdir) - sccfile.close() - - # Ignore local files with subdir={BP} srcabspath = os.path.abspath(srcsubdir) local_files = [fname for fname in local_files if - os.path.exists(os.path.join(workdir, fname)) and - (srcabspath == workdir or not - os.path.join(workdir, fname).startswith(srcabspath + - os.sep))] + os.path.exists(os.path.join(unpackdir, fname)) and + srcabspath == unpackdir] if local_files: - for fname in local_files: - _move_file(os.path.join(workdir, fname), - os.path.join(tempdir, 'oe-local-files', fname)) - with open(os.path.join(tempdir, 'oe-local-files', '.gitignore'), - 'w') as f: - f.write('# Ignore local files, by default. Remove this file ' - 'if you want to commit the directory to Git\n*\n') - - if srcsubdir == workdir: - # Find non-patch non-local sources that were "unpacked" to srctree - # directory - src_files = [fname for fname in _ls_tree(workdir) if - os.path.basename(fname) not in recipe_patches] - srcsubdir = d.getVar('DEVTOOL_PATCH_SRCDIR') - # Move source files to S - for path in src_files: - _move_file(os.path.join(workdir, path), - os.path.join(srcsubdir, path)) - elif os.path.dirname(srcsubdir) != workdir: + with open(os.path.join(tempdir, '.gitignore'), 'a+') as f: + f.write('# Ignore local files, by default. Remove following lines' + 'if you want to commit the directory to Git\n') + for fname in local_files: + f.write('%s\n' % fname) + + if os.path.dirname(srcsubdir) != workdir: # Handle if S is set to a subdirectory of the source srcsubdir = os.path.join(workdir, os.path.relpath(srcsubdir, workdir).split(os.sep)[0]) @@ -160,11 +117,6 @@ python devtool_post_unpack() { f.write(srcsubdir) } -python devtool_pre_patch() { - if d.getVar('S') == d.getVar('WORKDIR'): - d.setVar('S', '${DEVTOOL_PATCH_SRCDIR}') -} - python devtool_post_patch() { import shutil tempdir = d.getVar('DEVTOOL_TEMPDIR') @@ -201,6 +153,7 @@ python devtool_post_patch() { # Run do_patch function with the override applied localdata = bb.data.createCopy(d) localdata.setVar('OVERRIDES', ':'.join(no_overrides)) + localdata.setVar('FILESOVERRIDES', ':'.join(no_overrides)) bb.build.exec_func('do_patch', localdata) rm_patches() # Now we need to reconcile the dev branch with the no-overrides one @@ -218,7 +171,8 @@ python devtool_post_patch() { # Reset back to the initial commit on a new branch bb.process.run('git checkout %s -b devtool-override-%s' % (initial_rev, override), cwd=srcsubdir) # Run do_patch function with the override applied - localdata.appendVar('OVERRIDES', ':%s' % override) + localdata.setVar('OVERRIDES', ':'.join(no_overrides + [override])) + localdata.setVar('FILESOVERRIDES', ':'.join(no_overrides + [override])) bb.build.exec_func('do_patch', localdata) rm_patches() # Now we need to reconcile the new branch with the no-overrides one @@ -226,6 +180,9 @@ python devtool_post_patch() { bb.process.run('git rebase devtool-no-overrides', cwd=srcsubdir) bb.process.run('git checkout %s' % devbranch, cwd=srcsubdir) bb.process.run('git tag -f devtool-patched', cwd=srcsubdir) + if os.path.exists(os.path.join(srcsubdir, '.gitmodules')): + bb.process.run('git submodule foreach --recursive "git tag -f devtool-patched"', cwd=srcsubdir) + } python devtool_post_configure() { |