diff options
Diffstat (limited to 'scripts/lib/devtool/upgrade.py')
-rw-r--r-- | scripts/lib/devtool/upgrade.py | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/scripts/lib/devtool/upgrade.py b/scripts/lib/devtool/upgrade.py index 9cd50be3a2..10827a762b 100644 --- a/scripts/lib/devtool/upgrade.py +++ b/scripts/lib/devtool/upgrade.py | |||
@@ -90,7 +90,7 @@ def _rename_recipe_files(oldrecipe, bpn, oldpv, newpv, path): | |||
90 | _rename_recipe_dirs(oldpv, newpv, path) | 90 | _rename_recipe_dirs(oldpv, newpv, path) |
91 | return _rename_recipe_file(oldrecipe, bpn, oldpv, newpv, path) | 91 | return _rename_recipe_file(oldrecipe, bpn, oldpv, newpv, path) |
92 | 92 | ||
93 | def _write_append(rc, srctreebase, srctree, same_dir, no_same_dir, rev, copied, workspace, d): | 93 | def _write_append(rc, srctreebase, srctree, same_dir, no_same_dir, revs, copied, workspace, d): |
94 | """Writes an append file""" | 94 | """Writes an append file""" |
95 | if not os.path.exists(rc): | 95 | if not os.path.exists(rc): |
96 | raise DevtoolError("bbappend not created because %s does not exist" % rc) | 96 | raise DevtoolError("bbappend not created because %s does not exist" % rc) |
@@ -119,8 +119,9 @@ def _write_append(rc, srctreebase, srctree, same_dir, no_same_dir, rev, copied, | |||
119 | if b_is_s: | 119 | if b_is_s: |
120 | f.write('EXTERNALSRC_BUILD:pn-%s = "%s"\n' % (pn, srctree)) | 120 | f.write('EXTERNALSRC_BUILD:pn-%s = "%s"\n' % (pn, srctree)) |
121 | f.write('\n') | 121 | f.write('\n') |
122 | if rev: | 122 | if revs: |
123 | f.write('# initial_rev: %s\n' % rev) | 123 | for name, rev in revs.items(): |
124 | f.write('# initial_rev %s: %s\n' % (name, rev)) | ||
124 | if copied: | 125 | if copied: |
125 | f.write('# original_path: %s\n' % os.path.dirname(d.getVar('FILE'))) | 126 | f.write('# original_path: %s\n' % os.path.dirname(d.getVar('FILE'))) |
126 | f.write('# original_files: %s\n' % ' '.join(copied)) | 127 | f.write('# original_files: %s\n' % ' '.join(copied)) |
@@ -182,10 +183,15 @@ def _extract_new_source(newpv, srctree, no_patch, srcrev, srcbranch, branch, kee | |||
182 | uri, rev = _get_uri(crd) | 183 | uri, rev = _get_uri(crd) |
183 | if srcrev: | 184 | if srcrev: |
184 | rev = srcrev | 185 | rev = srcrev |
186 | paths = [srctree] | ||
185 | if uri.startswith('git://') or uri.startswith('gitsm://'): | 187 | if uri.startswith('git://') or uri.startswith('gitsm://'): |
186 | __run('git fetch') | 188 | __run('git fetch') |
187 | __run('git checkout %s' % rev) | 189 | __run('git checkout %s' % rev) |
188 | __run('git tag -f devtool-base-new') | 190 | __run('git tag -f devtool-base-new') |
191 | __run('git submodule update --recursive') | ||
192 | __run('git submodule foreach \'git tag -f devtool-base-new\'') | ||
193 | (stdout, _) = __run('git submodule --quiet foreach \'echo $sm_path\'') | ||
194 | paths += [os.path.join(srctree, p) for p in stdout.splitlines()] | ||
189 | md5 = None | 195 | md5 = None |
190 | sha256 = None | 196 | sha256 = None |
191 | _, _, _, _, _, params = bb.fetch2.decodeurl(uri) | 197 | _, _, _, _, _, params = bb.fetch2.decodeurl(uri) |
@@ -256,29 +262,32 @@ def _extract_new_source(newpv, srctree, no_patch, srcrev, srcbranch, branch, kee | |||
256 | __run('git %s commit -q -m "Commit of upstream changes at version %s" --allow-empty' % (' '.join(useroptions), newpv)) | 262 | __run('git %s commit -q -m "Commit of upstream changes at version %s" --allow-empty' % (' '.join(useroptions), newpv)) |
257 | __run('git tag -f devtool-base-%s' % newpv) | 263 | __run('git tag -f devtool-base-%s' % newpv) |
258 | 264 | ||
259 | (stdout, _) = __run('git rev-parse HEAD') | 265 | revs = {} |
260 | rev = stdout.rstrip() | 266 | for path in paths: |
267 | (stdout, _) = _run('git rev-parse HEAD', cwd=path) | ||
268 | revs[os.path.relpath(path,srctree)] = stdout.rstrip() | ||
261 | 269 | ||
262 | if no_patch: | 270 | if no_patch: |
263 | patches = oe.recipeutils.get_recipe_patches(crd) | 271 | patches = oe.recipeutils.get_recipe_patches(crd) |
264 | if patches: | 272 | if patches: |
265 | logger.warning('By user choice, the following patches will NOT be applied to the new source tree:\n %s' % '\n '.join([os.path.basename(patch) for patch in patches])) | 273 | logger.warning('By user choice, the following patches will NOT be applied to the new source tree:\n %s' % '\n '.join([os.path.basename(patch) for patch in patches])) |
266 | else: | 274 | else: |
267 | __run('git checkout devtool-patched -b %s' % branch) | 275 | for path in paths: |
268 | (stdout, _) = __run('git branch --list devtool-override-*') | 276 | _run('git checkout devtool-patched -b %s' % branch, cwd=path) |
269 | branches_to_rebase = [branch] + stdout.split() | 277 | (stdout, _) = _run('git branch --list devtool-override-*', cwd=path) |
270 | for b in branches_to_rebase: | 278 | branches_to_rebase = [branch] + stdout.split() |
271 | logger.info("Rebasing {} onto {}".format(b, rev)) | 279 | for b in branches_to_rebase: |
272 | __run('git checkout %s' % b) | 280 | logger.info("Rebasing {} onto {}".format(b, revs[os.path.relpath(path,srctree)])) |
273 | try: | 281 | _run('git checkout %s' % b, cwd=path) |
274 | __run('git rebase %s' % rev) | 282 | try: |
275 | except bb.process.ExecutionError as e: | 283 | _run('git rebase %s' % revs[os.path.relpath(path, srctree)], cwd=path) |
276 | if 'conflict' in e.stdout: | 284 | except bb.process.ExecutionError as e: |
277 | logger.warning('Command \'%s\' failed:\n%s\n\nYou will need to resolve conflicts in order to complete the upgrade.' % (e.command, e.stdout.rstrip())) | 285 | if 'conflict' in e.stdout: |
278 | __run('git rebase --abort') | 286 | logger.warning('Command \'%s\' failed:\n%s\n\nYou will need to resolve conflicts in order to complete the upgrade.' % (e.command, e.stdout.rstrip())) |
279 | else: | 287 | _run('git rebase --abort', cwd=path) |
280 | logger.warning('Command \'%s\' failed:\n%s' % (e.command, e.stdout)) | 288 | else: |
281 | __run('git checkout %s' % branch) | 289 | logger.warning('Command \'%s\' failed:\n%s' % (e.command, e.stdout)) |
290 | _run('git checkout %s' % branch, cwd=path) | ||
282 | 291 | ||
283 | if tmpsrctree: | 292 | if tmpsrctree: |
284 | if keep_temp: | 293 | if keep_temp: |
@@ -288,7 +297,7 @@ def _extract_new_source(newpv, srctree, no_patch, srcrev, srcbranch, branch, kee | |||
288 | if tmpdir != tmpsrctree: | 297 | if tmpdir != tmpsrctree: |
289 | shutil.rmtree(tmpdir) | 298 | shutil.rmtree(tmpdir) |
290 | 299 | ||
291 | return (rev, md5, sha256, srcbranch, srcsubdir_rel) | 300 | return (revs, md5, sha256, srcbranch, srcsubdir_rel) |
292 | 301 | ||
293 | def _add_license_diff_to_recipe(path, diff): | 302 | def _add_license_diff_to_recipe(path, diff): |
294 | notice_text = """# FIXME: the LIC_FILES_CHKSUM values have been updated by 'devtool upgrade'. | 303 | notice_text = """# FIXME: the LIC_FILES_CHKSUM values have been updated by 'devtool upgrade'. |