diff options
Diffstat (limited to 'meta/classes/devtool-source.bbclass')
-rw-r--r-- | meta/classes/devtool-source.bbclass | 87 |
1 files changed, 22 insertions, 65 deletions
diff --git a/meta/classes/devtool-source.bbclass b/meta/classes/devtool-source.bbclass index 41900e651f..2e0070486b 100644 --- a/meta/classes/devtool-source.bbclass +++ b/meta/classes/devtool-source.bbclass | |||
@@ -1,3 +1,9 @@ | |||
1 | # | ||
2 | # Copyright OpenEmbedded Contributors | ||
3 | # | ||
4 | # SPDX-License-Identifier: MIT | ||
5 | # | ||
6 | |||
1 | # Development tool - source extraction helper class | 7 | # Development tool - source extraction helper class |
2 | # | 8 | # |
3 | # NOTE: this class is intended for use by devtool and should not be | 9 | # NOTE: this class is intended for use by devtool and should not be |
@@ -20,8 +26,6 @@ | |||
20 | 26 | ||
21 | 27 | ||
22 | DEVTOOL_TEMPDIR ?= "" | 28 | DEVTOOL_TEMPDIR ?= "" |
23 | DEVTOOL_PATCH_SRCDIR = "${DEVTOOL_TEMPDIR}/patchworkdir" | ||
24 | |||
25 | 29 | ||
26 | python() { | 30 | python() { |
27 | tempdir = d.getVar('DEVTOOL_TEMPDIR') | 31 | tempdir = d.getVar('DEVTOOL_TEMPDIR') |
@@ -54,7 +58,6 @@ python() { | |||
54 | else: | 58 | else: |
55 | unpacktask = 'do_unpack' | 59 | unpacktask = 'do_unpack' |
56 | d.appendVarFlag(unpacktask, 'postfuncs', ' devtool_post_unpack') | 60 | d.appendVarFlag(unpacktask, 'postfuncs', ' devtool_post_unpack') |
57 | d.prependVarFlag('do_patch', 'prefuncs', ' devtool_pre_patch') | ||
58 | d.appendVarFlag('do_patch', 'postfuncs', ' devtool_post_patch') | 61 | d.appendVarFlag('do_patch', 'postfuncs', ' devtool_post_patch') |
59 | 62 | ||
60 | # NOTE: in order for the patch stuff to be fully functional, | 63 | # NOTE: in order for the patch stuff to be fully functional, |
@@ -73,69 +76,25 @@ python devtool_post_unpack() { | |||
73 | 76 | ||
74 | tempdir = d.getVar('DEVTOOL_TEMPDIR') | 77 | tempdir = d.getVar('DEVTOOL_TEMPDIR') |
75 | workdir = d.getVar('WORKDIR') | 78 | workdir = d.getVar('WORKDIR') |
79 | unpackdir = d.getVar('UNPACKDIR') | ||
76 | srcsubdir = d.getVar('S') | 80 | srcsubdir = d.getVar('S') |
77 | 81 | ||
78 | def _move_file(src, dst): | 82 | # Add locally copied files to gitignore as we add back to the metadata directly |
79 | """Move a file. Creates all the directory components of destination path.""" | ||
80 | dst_d = os.path.dirname(dst) | ||
81 | if dst_d: | ||
82 | bb.utils.mkdirhier(dst_d) | ||
83 | shutil.move(src, dst) | ||
84 | |||
85 | def _ls_tree(directory): | ||
86 | """Recursive listing of files in a directory""" | ||
87 | ret = [] | ||
88 | for root, dirs, files in os.walk(directory): | ||
89 | ret.extend([os.path.relpath(os.path.join(root, fname), directory) for | ||
90 | fname in files]) | ||
91 | return ret | ||
92 | |||
93 | is_kernel_yocto = bb.data.inherits_class('kernel-yocto', d) | ||
94 | # Move local source files into separate subdir | ||
95 | recipe_patches = [os.path.basename(patch) for patch in | ||
96 | oe.recipeutils.get_recipe_patches(d)] | ||
97 | local_files = oe.recipeutils.get_recipe_local_files(d) | 83 | local_files = oe.recipeutils.get_recipe_local_files(d) |
98 | |||
99 | if is_kernel_yocto: | ||
100 | for key in [f for f in local_files if f.endswith('scc')]: | ||
101 | with open(local_files[key], 'r') as sccfile: | ||
102 | for l in sccfile: | ||
103 | line = l.split() | ||
104 | if line and line[0] in ('kconf', 'patch'): | ||
105 | cfg = os.path.join(os.path.dirname(local_files[key]), line[-1]) | ||
106 | if cfg not in local_files.values(): | ||
107 | local_files[line[-1]] = cfg | ||
108 | shutil.copy2(cfg, workdir) | ||
109 | |||
110 | # Ignore local files with subdir={BP} | ||
111 | srcabspath = os.path.abspath(srcsubdir) | 84 | srcabspath = os.path.abspath(srcsubdir) |
112 | local_files = [fname for fname in local_files if | 85 | local_files = [fname for fname in local_files if |
113 | os.path.exists(os.path.join(workdir, fname)) and | 86 | os.path.exists(os.path.join(unpackdir, fname)) and |
114 | (srcabspath == workdir or not | 87 | srcabspath == unpackdir] |
115 | os.path.join(workdir, fname).startswith(srcabspath + | ||
116 | os.sep))] | ||
117 | if local_files: | 88 | if local_files: |
118 | for fname in local_files: | 89 | with open(os.path.join(tempdir, '.gitignore'), 'a+') as f: |
119 | _move_file(os.path.join(workdir, fname), | 90 | f.write('# Ignore local files, by default. Remove following lines' |
120 | os.path.join(tempdir, 'oe-local-files', fname)) | 91 | 'if you want to commit the directory to Git\n') |
121 | with open(os.path.join(tempdir, 'oe-local-files', '.gitignore'), | 92 | for fname in local_files: |
122 | 'w') as f: | 93 | f.write('%s\n' % fname) |
123 | f.write('# Ignore local files, by default. Remove this file ' | 94 | |
124 | 'if you want to commit the directory to Git\n*\n') | 95 | if srcsubdir.startswith(unpackdir) and os.path.dirname(srcsubdir) != unpackdir: |
125 | |||
126 | if srcsubdir == workdir: | ||
127 | # Find non-patch non-local sources that were "unpacked" to srctree | ||
128 | # directory | ||
129 | src_files = [fname for fname in _ls_tree(workdir) if | ||
130 | os.path.basename(fname) not in recipe_patches] | ||
131 | srcsubdir = d.getVar('DEVTOOL_PATCH_SRCDIR') | ||
132 | # Move source files to S | ||
133 | for path in src_files: | ||
134 | _move_file(os.path.join(workdir, path), | ||
135 | os.path.join(srcsubdir, path)) | ||
136 | elif os.path.dirname(srcsubdir) != workdir: | ||
137 | # Handle if S is set to a subdirectory of the source | 96 | # Handle if S is set to a subdirectory of the source |
138 | srcsubdir = os.path.join(workdir, os.path.relpath(srcsubdir, workdir).split(os.sep)[0]) | 97 | srcsubdir = os.path.normpath(os.path.join(unpackdir, os.path.relpath(srcsubdir, unpackdir).split(os.sep)[0])) |
139 | 98 | ||
140 | scriptutils.git_convert_standalone_clone(srcsubdir) | 99 | scriptutils.git_convert_standalone_clone(srcsubdir) |
141 | 100 | ||
@@ -158,11 +117,6 @@ python devtool_post_unpack() { | |||
158 | f.write(srcsubdir) | 117 | f.write(srcsubdir) |
159 | } | 118 | } |
160 | 119 | ||
161 | python devtool_pre_patch() { | ||
162 | if d.getVar('S') == d.getVar('WORKDIR'): | ||
163 | d.setVar('S', '${DEVTOOL_PATCH_SRCDIR}') | ||
164 | } | ||
165 | |||
166 | python devtool_post_patch() { | 120 | python devtool_post_patch() { |
167 | import shutil | 121 | import shutil |
168 | tempdir = d.getVar('DEVTOOL_TEMPDIR') | 122 | tempdir = d.getVar('DEVTOOL_TEMPDIR') |
@@ -225,7 +179,10 @@ python devtool_post_patch() { | |||
225 | # (otherwise we'd likely be left with identical commits that have different hashes) | 179 | # (otherwise we'd likely be left with identical commits that have different hashes) |
226 | bb.process.run('git rebase devtool-no-overrides', cwd=srcsubdir) | 180 | bb.process.run('git rebase devtool-no-overrides', cwd=srcsubdir) |
227 | bb.process.run('git checkout %s' % devbranch, cwd=srcsubdir) | 181 | bb.process.run('git checkout %s' % devbranch, cwd=srcsubdir) |
228 | bb.process.run('git tag -f devtool-patched', cwd=srcsubdir) | 182 | bb.process.run('git tag -f --no-sign devtool-patched', cwd=srcsubdir) |
183 | if os.path.exists(os.path.join(srcsubdir, '.gitmodules')): | ||
184 | bb.process.run('git submodule foreach --recursive "git tag -f --no-sign devtool-patched"', cwd=srcsubdir) | ||
185 | |||
229 | } | 186 | } |
230 | 187 | ||
231 | python devtool_post_configure() { | 188 | python devtool_post_configure() { |