diff options
Diffstat (limited to 'scripts/lib/devtool/upgrade.py')
-rw-r--r-- | scripts/lib/devtool/upgrade.py | 196 |
1 files changed, 120 insertions, 76 deletions
diff --git a/scripts/lib/devtool/upgrade.py b/scripts/lib/devtool/upgrade.py index 5a057e95f5..fa5b8ef3c7 100644 --- a/scripts/lib/devtool/upgrade.py +++ b/scripts/lib/devtool/upgrade.py | |||
@@ -35,6 +35,8 @@ def _get_srctree(tmpdir): | |||
35 | dirs = scriptutils.filter_src_subdirs(tmpdir) | 35 | dirs = scriptutils.filter_src_subdirs(tmpdir) |
36 | if len(dirs) == 1: | 36 | if len(dirs) == 1: |
37 | srctree = os.path.join(tmpdir, dirs[0]) | 37 | srctree = os.path.join(tmpdir, dirs[0]) |
38 | else: | ||
39 | raise DevtoolError("Cannot determine where the source tree is after unpacking in {}: {}".format(tmpdir,dirs)) | ||
38 | return srctree | 40 | return srctree |
39 | 41 | ||
40 | def _copy_source_code(orig, dest): | 42 | def _copy_source_code(orig, dest): |
@@ -71,7 +73,8 @@ def _rename_recipe_dirs(oldpv, newpv, path): | |||
71 | if oldfile.find(oldpv) != -1: | 73 | if oldfile.find(oldpv) != -1: |
72 | newfile = oldfile.replace(oldpv, newpv) | 74 | newfile = oldfile.replace(oldpv, newpv) |
73 | if oldfile != newfile: | 75 | if oldfile != newfile: |
74 | os.rename(os.path.join(path, oldfile), os.path.join(path, newfile)) | 76 | bb.utils.rename(os.path.join(path, oldfile), |
77 | os.path.join(path, newfile)) | ||
75 | 78 | ||
76 | def _rename_recipe_file(oldrecipe, bpn, oldpv, newpv, path): | 79 | def _rename_recipe_file(oldrecipe, bpn, oldpv, newpv, path): |
77 | oldrecipe = os.path.basename(oldrecipe) | 80 | oldrecipe = os.path.basename(oldrecipe) |
@@ -87,7 +90,7 @@ def _rename_recipe_files(oldrecipe, bpn, oldpv, newpv, path): | |||
87 | _rename_recipe_dirs(oldpv, newpv, path) | 90 | _rename_recipe_dirs(oldpv, newpv, path) |
88 | return _rename_recipe_file(oldrecipe, bpn, oldpv, newpv, path) | 91 | return _rename_recipe_file(oldrecipe, bpn, oldpv, newpv, path) |
89 | 92 | ||
90 | def _write_append(rc, 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): |
91 | """Writes an append file""" | 94 | """Writes an append file""" |
92 | if not os.path.exists(rc): | 95 | if not os.path.exists(rc): |
93 | raise DevtoolError("bbappend not created because %s does not exist" % rc) | 96 | raise DevtoolError("bbappend not created because %s does not exist" % rc) |
@@ -102,36 +105,38 @@ def _write_append(rc, srctree, same_dir, no_same_dir, rev, copied, workspace, d) | |||
102 | pn = d.getVar('PN') | 105 | pn = d.getVar('PN') |
103 | af = os.path.join(appendpath, '%s.bbappend' % brf) | 106 | af = os.path.join(appendpath, '%s.bbappend' % brf) |
104 | with open(af, 'w') as f: | 107 | with open(af, 'w') as f: |
105 | f.write('FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"\n\n') | 108 | f.write('FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n\n') |
109 | # Local files can be modified/tracked in separate subdir under srctree | ||
110 | # Mostly useful for packages with S != WORKDIR | ||
111 | f.write('FILESPATH:prepend := "%s:"\n' % | ||
112 | os.path.join(srctreebase, 'oe-local-files')) | ||
113 | f.write('# srctreebase: %s\n' % srctreebase) | ||
106 | f.write('inherit externalsrc\n') | 114 | f.write('inherit externalsrc\n') |
107 | f.write(('# NOTE: We use pn- overrides here to avoid affecting' | 115 | f.write(('# NOTE: We use pn- overrides here to avoid affecting' |
108 | 'multiple variants in the case where the recipe uses BBCLASSEXTEND\n')) | 116 | 'multiple variants in the case where the recipe uses BBCLASSEXTEND\n')) |
109 | f.write('EXTERNALSRC_pn-%s = "%s"\n' % (pn, srctree)) | 117 | f.write('EXTERNALSRC:pn-%s = "%s"\n' % (pn, srctree)) |
110 | b_is_s = use_external_build(same_dir, no_same_dir, d) | 118 | b_is_s = use_external_build(same_dir, no_same_dir, d) |
111 | if b_is_s: | 119 | if b_is_s: |
112 | f.write('EXTERNALSRC_BUILD_pn-%s = "%s"\n' % (pn, srctree)) | 120 | f.write('EXTERNALSRC_BUILD:pn-%s = "%s"\n' % (pn, srctree)) |
113 | f.write('\n') | 121 | f.write('\n') |
114 | if rev: | 122 | if revs: |
115 | f.write('# initial_rev: %s\n' % rev) | 123 | for name, rev in revs.items(): |
124 | f.write('# initial_rev %s: %s\n' % (name, rev)) | ||
116 | if copied: | 125 | if copied: |
117 | 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'))) |
118 | f.write('# original_files: %s\n' % ' '.join(copied)) | 127 | f.write('# original_files: %s\n' % ' '.join(copied)) |
119 | return af | 128 | return af |
120 | 129 | ||
121 | def _cleanup_on_error(rf, srctree): | 130 | def _cleanup_on_error(rd, srctree): |
122 | rfp = os.path.split(rf)[0] # recipe folder | 131 | if os.path.exists(rd): |
123 | rfpp = os.path.split(rfp)[0] # recipes folder | 132 | shutil.rmtree(rd) |
124 | if os.path.exists(rfp): | ||
125 | shutil.rmtree(rfp) | ||
126 | if not len(os.listdir(rfpp)): | ||
127 | os.rmdir(rfpp) | ||
128 | srctree = os.path.abspath(srctree) | 133 | srctree = os.path.abspath(srctree) |
129 | if os.path.exists(srctree): | 134 | if os.path.exists(srctree): |
130 | shutil.rmtree(srctree) | 135 | shutil.rmtree(srctree) |
131 | 136 | ||
132 | def _upgrade_error(e, rf, srctree, keep_failure=False, extramsg=None): | 137 | def _upgrade_error(e, rd, srctree, keep_failure=False, extramsg=None): |
133 | if rf and not keep_failure: | 138 | if not keep_failure: |
134 | _cleanup_on_error(rf, srctree) | 139 | _cleanup_on_error(rd, srctree) |
135 | logger.error(e) | 140 | logger.error(e) |
136 | if extramsg: | 141 | if extramsg: |
137 | logger.error(extramsg) | 142 | logger.error(extramsg) |
@@ -178,12 +183,16 @@ def _extract_new_source(newpv, srctree, no_patch, srcrev, srcbranch, branch, kee | |||
178 | uri, rev = _get_uri(crd) | 183 | uri, rev = _get_uri(crd) |
179 | if srcrev: | 184 | if srcrev: |
180 | rev = srcrev | 185 | rev = srcrev |
186 | paths = [srctree] | ||
181 | if uri.startswith('git://') or uri.startswith('gitsm://'): | 187 | if uri.startswith('git://') or uri.startswith('gitsm://'): |
182 | __run('git fetch') | 188 | __run('git fetch') |
183 | __run('git checkout %s' % rev) | 189 | __run('git checkout %s' % rev) |
184 | __run('git tag -f devtool-base-new') | 190 | __run('git tag -f devtool-base-new') |
185 | md5 = None | 191 | __run('git submodule update --recursive') |
186 | sha256 = None | 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()] | ||
195 | checksums = {} | ||
187 | _, _, _, _, _, params = bb.fetch2.decodeurl(uri) | 196 | _, _, _, _, _, params = bb.fetch2.decodeurl(uri) |
188 | srcsubdir_rel = params.get('destsuffix', 'git') | 197 | srcsubdir_rel = params.get('destsuffix', 'git') |
189 | if not srcbranch: | 198 | if not srcbranch: |
@@ -191,14 +200,15 @@ def _extract_new_source(newpv, srctree, no_patch, srcrev, srcbranch, branch, kee | |||
191 | get_branch = [x.strip() for x in check_branch.splitlines()] | 200 | get_branch = [x.strip() for x in check_branch.splitlines()] |
192 | # Remove HEAD reference point and drop remote prefix | 201 | # Remove HEAD reference point and drop remote prefix |
193 | get_branch = [x.split('/', 1)[1] for x in get_branch if not x.startswith('origin/HEAD')] | 202 | get_branch = [x.split('/', 1)[1] for x in get_branch if not x.startswith('origin/HEAD')] |
194 | if 'master' in get_branch: | 203 | if len(get_branch) == 1: |
195 | # If it is master, we do not need to append 'branch=master' as this is default. | 204 | # If srcrev is on only ONE branch, then use that branch |
196 | # Even with the case where get_branch has multiple objects, if 'master' is one | ||
197 | # of them, we should default take from 'master' | ||
198 | srcbranch = '' | ||
199 | elif len(get_branch) == 1: | ||
200 | # If 'master' isn't in get_branch and get_branch contains only ONE object, then store result into 'srcbranch' | ||
201 | srcbranch = get_branch[0] | 205 | srcbranch = get_branch[0] |
206 | elif 'main' in get_branch: | ||
207 | # If srcrev is on multiple branches, then choose 'main' if it is one of them | ||
208 | srcbranch = 'main' | ||
209 | elif 'master' in get_branch: | ||
210 | # Otherwise choose 'master' if it is one of the branches | ||
211 | srcbranch = 'master' | ||
202 | else: | 212 | else: |
203 | # If get_branch contains more than one objects, then display error and exit. | 213 | # If get_branch contains more than one objects, then display error and exit. |
204 | mbrch = '\n ' + '\n '.join(get_branch) | 214 | mbrch = '\n ' + '\n '.join(get_branch) |
@@ -215,9 +225,6 @@ def _extract_new_source(newpv, srctree, no_patch, srcrev, srcbranch, branch, kee | |||
215 | if ftmpdir and keep_temp: | 225 | if ftmpdir and keep_temp: |
216 | logger.info('Fetch temp directory is %s' % ftmpdir) | 226 | logger.info('Fetch temp directory is %s' % ftmpdir) |
217 | 227 | ||
218 | md5 = checksums['md5sum'] | ||
219 | sha256 = checksums['sha256sum'] | ||
220 | |||
221 | tmpsrctree = _get_srctree(tmpdir) | 228 | tmpsrctree = _get_srctree(tmpdir) |
222 | srctree = os.path.abspath(srctree) | 229 | srctree = os.path.abspath(srctree) |
223 | srcsubdir_rel = os.path.relpath(tmpsrctree, tmpdir) | 230 | srcsubdir_rel = os.path.relpath(tmpsrctree, tmpdir) |
@@ -251,30 +258,50 @@ def _extract_new_source(newpv, srctree, no_patch, srcrev, srcbranch, branch, kee | |||
251 | __run('git %s commit -q -m "Commit of upstream changes at version %s" --allow-empty' % (' '.join(useroptions), newpv)) | 258 | __run('git %s commit -q -m "Commit of upstream changes at version %s" --allow-empty' % (' '.join(useroptions), newpv)) |
252 | __run('git tag -f devtool-base-%s' % newpv) | 259 | __run('git tag -f devtool-base-%s' % newpv) |
253 | 260 | ||
254 | (stdout, _) = __run('git rev-parse HEAD') | 261 | revs = {} |
255 | rev = stdout.rstrip() | 262 | for path in paths: |
263 | (stdout, _) = _run('git rev-parse HEAD', cwd=path) | ||
264 | revs[os.path.relpath(path, srctree)] = stdout.rstrip() | ||
256 | 265 | ||
257 | if no_patch: | 266 | if no_patch: |
258 | patches = oe.recipeutils.get_recipe_patches(crd) | 267 | patches = oe.recipeutils.get_recipe_patches(crd) |
259 | if patches: | 268 | if patches: |
260 | 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])) | 269 | 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])) |
261 | else: | 270 | else: |
262 | __run('git checkout devtool-patched -b %s' % branch) | 271 | for path in paths: |
263 | skiptag = False | 272 | _run('git checkout devtool-patched -b %s' % branch, cwd=path) |
264 | try: | 273 | (stdout, _) = _run('git branch --list devtool-override-*', cwd=path) |
265 | __run('git rebase %s' % rev) | 274 | branches_to_rebase = [branch] + stdout.split() |
266 | except bb.process.ExecutionError as e: | 275 | target_branch = revs[os.path.relpath(path, srctree)] |
267 | skiptag = True | 276 | |
268 | if 'conflict' in e.stdout: | 277 | # There is a bug (or feature?) in git rebase where if a commit with |
269 | 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())) | 278 | # a note is fully rebased away by being part of an old commit, the |
270 | else: | 279 | # note is still attached to the old commit. Avoid this by making |
271 | logger.warning('Command \'%s\' failed:\n%s' % (e.command, e.stdout)) | 280 | # sure all old devtool related commits have a note attached to them |
272 | if not skiptag: | 281 | # (this assumes git config notes.rewriteMode is set to ignore). |
273 | if uri.startswith('git://') or uri.startswith('gitsm://'): | 282 | (stdout, _) = __run('git rev-list devtool-base..%s' % target_branch) |
274 | suffix = 'new' | 283 | for rev in stdout.splitlines(): |
275 | else: | 284 | if not oe.patch.GitApplyTree.getNotes(path, rev): |
276 | suffix = newpv | 285 | oe.patch.GitApplyTree.addNote(path, rev, "dummy") |
277 | __run('git tag -f devtool-patched-%s' % suffix) | 286 | |
287 | for b in branches_to_rebase: | ||
288 | logger.info("Rebasing {} onto {}".format(b, target_branch)) | ||
289 | _run('git checkout %s' % b, cwd=path) | ||
290 | try: | ||
291 | _run('git rebase %s' % target_branch, cwd=path) | ||
292 | except bb.process.ExecutionError as e: | ||
293 | if 'conflict' in e.stdout: | ||
294 | 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())) | ||
295 | _run('git rebase --abort', cwd=path) | ||
296 | else: | ||
297 | logger.warning('Command \'%s\' failed:\n%s' % (e.command, e.stdout)) | ||
298 | |||
299 | # Remove any dummy notes added above. | ||
300 | (stdout, _) = __run('git rev-list devtool-base..%s' % target_branch) | ||
301 | for rev in stdout.splitlines(): | ||
302 | oe.patch.GitApplyTree.removeNote(path, rev, "dummy") | ||
303 | |||
304 | _run('git checkout %s' % branch, cwd=path) | ||
278 | 305 | ||
279 | if tmpsrctree: | 306 | if tmpsrctree: |
280 | if keep_temp: | 307 | if keep_temp: |
@@ -284,7 +311,7 @@ def _extract_new_source(newpv, srctree, no_patch, srcrev, srcbranch, branch, kee | |||
284 | if tmpdir != tmpsrctree: | 311 | if tmpdir != tmpsrctree: |
285 | shutil.rmtree(tmpdir) | 312 | shutil.rmtree(tmpdir) |
286 | 313 | ||
287 | return (rev, md5, sha256, srcbranch, srcsubdir_rel) | 314 | return (revs, checksums, srcbranch, srcsubdir_rel) |
288 | 315 | ||
289 | def _add_license_diff_to_recipe(path, diff): | 316 | def _add_license_diff_to_recipe(path, diff): |
290 | notice_text = """# FIXME: the LIC_FILES_CHKSUM values have been updated by 'devtool upgrade'. | 317 | notice_text = """# FIXME: the LIC_FILES_CHKSUM values have been updated by 'devtool upgrade'. |
@@ -305,7 +332,7 @@ def _add_license_diff_to_recipe(path, diff): | |||
305 | f.write("\n#\n\n".encode()) | 332 | f.write("\n#\n\n".encode()) |
306 | f.write(orig_content) | 333 | f.write(orig_content) |
307 | 334 | ||
308 | def _create_new_recipe(newpv, md5, sha256, srcrev, srcbranch, srcsubdir_old, srcsubdir_new, workspace, tinfoil, rd, license_diff, new_licenses, srctree, keep_failure): | 335 | def _create_new_recipe(newpv, checksums, srcrev, srcbranch, srcsubdir_old, srcsubdir_new, workspace, tinfoil, rd, license_diff, new_licenses, srctree, keep_failure): |
309 | """Creates the new recipe under workspace""" | 336 | """Creates the new recipe under workspace""" |
310 | 337 | ||
311 | bpn = rd.getVar('BPN') | 338 | bpn = rd.getVar('BPN') |
@@ -336,7 +363,10 @@ def _create_new_recipe(newpv, md5, sha256, srcrev, srcbranch, srcsubdir_old, src | |||
336 | replacing = True | 363 | replacing = True |
337 | new_src_uri = [] | 364 | new_src_uri = [] |
338 | for entry in src_uri: | 365 | for entry in src_uri: |
339 | scheme, network, path, user, passwd, params = bb.fetch2.decodeurl(entry) | 366 | try: |
367 | scheme, network, path, user, passwd, params = bb.fetch2.decodeurl(entry) | ||
368 | except bb.fetch2.MalformedUrl as e: | ||
369 | raise DevtoolError("Could not decode SRC_URI: {}".format(e)) | ||
340 | if replacing and scheme in ['git', 'gitsm']: | 370 | if replacing and scheme in ['git', 'gitsm']: |
341 | branch = params.get('branch', 'master') | 371 | branch = params.get('branch', 'master') |
342 | if rd.expand(branch) != srcbranch: | 372 | if rd.expand(branch) != srcbranch: |
@@ -374,30 +404,39 @@ def _create_new_recipe(newpv, md5, sha256, srcrev, srcbranch, srcsubdir_old, src | |||
374 | addnames.append(params['name']) | 404 | addnames.append(params['name']) |
375 | # Find what's been set in the original recipe | 405 | # Find what's been set in the original recipe |
376 | oldnames = [] | 406 | oldnames = [] |
407 | oldsums = [] | ||
377 | noname = False | 408 | noname = False |
378 | for varflag in rd.getVarFlags('SRC_URI'): | 409 | for varflag in rd.getVarFlags('SRC_URI'): |
379 | if varflag.endswith(('.md5sum', '.sha256sum')): | 410 | for checksum in checksums: |
380 | name = varflag.rsplit('.', 1)[0] | 411 | if varflag.endswith('.' + checksum): |
381 | if name not in oldnames: | 412 | name = varflag.rsplit('.', 1)[0] |
382 | oldnames.append(name) | 413 | if name not in oldnames: |
383 | elif varflag in ['md5sum', 'sha256sum']: | 414 | oldnames.append(name) |
384 | noname = True | 415 | oldsums.append(checksum) |
416 | elif varflag == checksum: | ||
417 | noname = True | ||
418 | oldsums.append(checksum) | ||
385 | # Even if SRC_URI has named entries it doesn't have to actually use the name | 419 | # Even if SRC_URI has named entries it doesn't have to actually use the name |
386 | if noname and addnames and addnames[0] not in oldnames: | 420 | if noname and addnames and addnames[0] not in oldnames: |
387 | addnames = [] | 421 | addnames = [] |
388 | # Drop any old names (the name actually might include ${PV}) | 422 | # Drop any old names (the name actually might include ${PV}) |
389 | for name in oldnames: | 423 | for name in oldnames: |
390 | if name not in newnames: | 424 | if name not in newnames: |
391 | newvalues['SRC_URI[%s.md5sum]' % name] = None | 425 | for checksum in oldsums: |
392 | newvalues['SRC_URI[%s.sha256sum]' % name] = None | 426 | newvalues['SRC_URI[%s.%s]' % (name, checksum)] = None |
393 | 427 | ||
394 | if sha256: | 428 | nameprefix = '%s.' % addnames[0] if addnames else '' |
395 | if addnames: | 429 | |
396 | nameprefix = '%s.' % addnames[0] | 430 | # md5sum is deprecated, remove any traces of it. If it was the only old |
397 | else: | 431 | # checksum, then replace it with the default checksums. |
398 | nameprefix = '' | 432 | if 'md5sum' in oldsums: |
399 | newvalues['SRC_URI[%smd5sum]' % nameprefix] = None | 433 | newvalues['SRC_URI[%smd5sum]' % nameprefix] = None |
400 | newvalues['SRC_URI[%ssha256sum]' % nameprefix] = sha256 | 434 | oldsums.remove('md5sum') |
435 | if not oldsums: | ||
436 | oldsums = ["%ssum" % s for s in bb.fetch2.SHOWN_CHECKSUM_LIST] | ||
437 | |||
438 | for checksum in oldsums: | ||
439 | newvalues['SRC_URI[%s%s]' % (nameprefix, checksum)] = checksums[checksum] | ||
401 | 440 | ||
402 | if srcsubdir_new != srcsubdir_old: | 441 | if srcsubdir_new != srcsubdir_old: |
403 | s_subdir_old = os.path.relpath(os.path.abspath(rd.getVar('S')), rd.getVar('WORKDIR')) | 442 | s_subdir_old = os.path.relpath(os.path.abspath(rd.getVar('S')), rd.getVar('WORKDIR')) |
@@ -422,10 +461,11 @@ def _create_new_recipe(newpv, md5, sha256, srcrev, srcbranch, srcsubdir_old, src | |||
422 | newvalues["LIC_FILES_CHKSUM"] = newlicchksum | 461 | newvalues["LIC_FILES_CHKSUM"] = newlicchksum |
423 | _add_license_diff_to_recipe(fullpath, license_diff) | 462 | _add_license_diff_to_recipe(fullpath, license_diff) |
424 | 463 | ||
464 | tinfoil.modified_files() | ||
425 | try: | 465 | try: |
426 | rd = tinfoil.parse_recipe_file(fullpath, False) | 466 | rd = tinfoil.parse_recipe_file(fullpath, False) |
427 | except bb.tinfoil.TinfoilCommandFailed as e: | 467 | except bb.tinfoil.TinfoilCommandFailed as e: |
428 | _upgrade_error(e, fullpath, srctree, keep_failure, 'Parsing of upgraded recipe failed') | 468 | _upgrade_error(e, os.path.dirname(fullpath), srctree, keep_failure, 'Parsing of upgraded recipe failed') |
429 | oe.recipeutils.patch_recipe(rd, fullpath, newvalues) | 469 | oe.recipeutils.patch_recipe(rd, fullpath, newvalues) |
430 | 470 | ||
431 | return fullpath, copied | 471 | return fullpath, copied |
@@ -434,7 +474,7 @@ def _create_new_recipe(newpv, md5, sha256, srcrev, srcbranch, srcsubdir_old, src | |||
434 | def _check_git_config(): | 474 | def _check_git_config(): |
435 | def getconfig(name): | 475 | def getconfig(name): |
436 | try: | 476 | try: |
437 | value = bb.process.run('git config --global %s' % name)[0].strip() | 477 | value = bb.process.run('git config %s' % name)[0].strip() |
438 | except bb.process.ExecutionError as e: | 478 | except bb.process.ExecutionError as e: |
439 | if e.exitcode == 1: | 479 | if e.exitcode == 1: |
440 | value = None | 480 | value = None |
@@ -521,6 +561,8 @@ def upgrade(args, config, basepath, workspace): | |||
521 | else: | 561 | else: |
522 | srctree = standard.get_default_srctree(config, pn) | 562 | srctree = standard.get_default_srctree(config, pn) |
523 | 563 | ||
564 | srctree_s = standard.get_real_srctree(srctree, rd.getVar('S'), rd.getVar('WORKDIR')) | ||
565 | |||
524 | # try to automatically discover latest version and revision if not provided on command line | 566 | # try to automatically discover latest version and revision if not provided on command line |
525 | if not args.version and not args.srcrev: | 567 | if not args.version and not args.srcrev: |
526 | version_info = oe.recipeutils.get_recipe_upstream_version(rd) | 568 | version_info = oe.recipeutils.get_recipe_upstream_version(rd) |
@@ -550,21 +592,20 @@ def upgrade(args, config, basepath, workspace): | |||
550 | try: | 592 | try: |
551 | logger.info('Extracting current version source...') | 593 | logger.info('Extracting current version source...') |
552 | rev1, srcsubdir1 = standard._extract_source(srctree, False, 'devtool-orig', False, config, basepath, workspace, args.fixed_setup, rd, tinfoil, no_overrides=args.no_overrides) | 594 | rev1, srcsubdir1 = standard._extract_source(srctree, False, 'devtool-orig', False, config, basepath, workspace, args.fixed_setup, rd, tinfoil, no_overrides=args.no_overrides) |
553 | old_licenses = _extract_licenses(srctree, (rd.getVar('LIC_FILES_CHKSUM') or "")) | 595 | old_licenses = _extract_licenses(srctree_s, (rd.getVar('LIC_FILES_CHKSUM') or "")) |
554 | logger.info('Extracting upgraded version source...') | 596 | logger.info('Extracting upgraded version source...') |
555 | rev2, md5, sha256, srcbranch, srcsubdir2 = _extract_new_source(args.version, srctree, args.no_patch, | 597 | rev2, checksums, srcbranch, srcsubdir2 = _extract_new_source(args.version, srctree, args.no_patch, |
556 | args.srcrev, args.srcbranch, args.branch, args.keep_temp, | 598 | args.srcrev, args.srcbranch, args.branch, args.keep_temp, |
557 | tinfoil, rd) | 599 | tinfoil, rd) |
558 | new_licenses = _extract_licenses(srctree, (rd.getVar('LIC_FILES_CHKSUM') or "")) | 600 | new_licenses = _extract_licenses(srctree_s, (rd.getVar('LIC_FILES_CHKSUM') or "")) |
559 | license_diff = _generate_license_diff(old_licenses, new_licenses) | 601 | license_diff = _generate_license_diff(old_licenses, new_licenses) |
560 | rf, copied = _create_new_recipe(args.version, md5, sha256, args.srcrev, srcbranch, srcsubdir1, srcsubdir2, config.workspace_path, tinfoil, rd, license_diff, new_licenses, srctree, args.keep_failure) | 602 | rf, copied = _create_new_recipe(args.version, checksums, args.srcrev, srcbranch, srcsubdir1, srcsubdir2, config.workspace_path, tinfoil, rd, license_diff, new_licenses, srctree, args.keep_failure) |
561 | except bb.process.CmdError as e: | 603 | except (bb.process.CmdError, DevtoolError) as e: |
562 | _upgrade_error(e, rf, srctree, args.keep_failure) | 604 | recipedir = os.path.join(config.workspace_path, 'recipes', rd.getVar('BPN')) |
563 | except DevtoolError as e: | 605 | _upgrade_error(e, recipedir, srctree, args.keep_failure) |
564 | _upgrade_error(e, rf, srctree, args.keep_failure) | ||
565 | standard._add_md5(config, pn, os.path.dirname(rf)) | 606 | standard._add_md5(config, pn, os.path.dirname(rf)) |
566 | 607 | ||
567 | af = _write_append(rf, srctree, args.same_dir, args.no_same_dir, rev2, | 608 | af = _write_append(rf, srctree, srctree_s, args.same_dir, args.no_same_dir, rev2, |
568 | copied, config.workspace_path, rd) | 609 | copied, config.workspace_path, rd) |
569 | standard._add_md5(config, pn, af) | 610 | standard._add_md5(config, pn, af) |
570 | 611 | ||
@@ -574,6 +615,9 @@ def upgrade(args, config, basepath, workspace): | |||
574 | logger.info('New recipe is %s' % rf) | 615 | logger.info('New recipe is %s' % rf) |
575 | if license_diff: | 616 | if license_diff: |
576 | logger.info('License checksums have been updated in the new recipe; please refer to it for the difference between the old and the new license texts.') | 617 | logger.info('License checksums have been updated in the new recipe; please refer to it for the difference between the old and the new license texts.') |
618 | preferred_version = rd.getVar('PREFERRED_VERSION_%s' % rd.getVar('PN')) | ||
619 | if preferred_version: | ||
620 | logger.warning('Version is pinned to %s via PREFERRED_VERSION; it may need adjustment to match the new version before any further steps are taken' % preferred_version) | ||
577 | finally: | 621 | finally: |
578 | tinfoil.shutdown() | 622 | tinfoil.shutdown() |
579 | return 0 | 623 | return 0 |
@@ -605,7 +649,7 @@ def check_upgrade_status(args, config, basepath, workspace): | |||
605 | for result in results: | 649 | for result in results: |
606 | # pn, update_status, current, latest, maintainer, latest_commit, no_update_reason | 650 | # pn, update_status, current, latest, maintainer, latest_commit, no_update_reason |
607 | if args.all or result[1] != 'MATCH': | 651 | if args.all or result[1] != 'MATCH': |
608 | logger.info("{:25} {:15} {:15} {} {} {}".format( result[0], | 652 | print("{:25} {:15} {:15} {} {} {}".format( result[0], |
609 | result[2], | 653 | result[2], |
610 | result[1] if result[1] != 'UPDATE' else (result[3] if not result[3].endswith("new-commits-available") else "new commits"), | 654 | result[1] if result[1] != 'UPDATE' else (result[3] if not result[3].endswith("new-commits-available") else "new commits"), |
611 | result[4], | 655 | result[4], |