summaryrefslogtreecommitdiffstats
path: root/scripts/lib/devtool/upgrade.py
diff options
context:
space:
mode:
authorAlexander Kanavin <alex.kanavin@gmail.com>2022-12-13 12:10:56 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-12-18 19:48:00 +0000
commit04d2a394ea1011e88d7920cf78b0ab6ea547fcb5 (patch)
treea7cb26c186aa6fd79747bef1049836ff982d2b9f /scripts/lib/devtool/upgrade.py
parent70c8d7c07bde64ef756a85e0ce415bef6ce111ed (diff)
downloadpoky-04d2a394ea1011e88d7920cf78b0ab6ea547fcb5.tar.gz
devtool/upgrade: correctly handle recipes where S is a subdir of upstream tree
'devtool modify' writes additional settings to workspace .bbappend so that this can be handled correctly, but 'devtool upgrade' does not. This adds the missing settings. In particular, local files should not anymore mysteriously disappear from SRC_URIs on upgrades. (From OE-Core rev: 0817aa5537a8d7cc9591c53dfaa1d225f4c327f7) Signed-off-by: Alexander Kanavin <alex@linutronix.de> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/devtool/upgrade.py')
-rw-r--r--scripts/lib/devtool/upgrade.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/scripts/lib/devtool/upgrade.py b/scripts/lib/devtool/upgrade.py
index 39a1910a49..967d157077 100644
--- a/scripts/lib/devtool/upgrade.py
+++ b/scripts/lib/devtool/upgrade.py
@@ -88,7 +88,7 @@ def _rename_recipe_files(oldrecipe, bpn, oldpv, newpv, path):
88 _rename_recipe_dirs(oldpv, newpv, path) 88 _rename_recipe_dirs(oldpv, newpv, path)
89 return _rename_recipe_file(oldrecipe, bpn, oldpv, newpv, path) 89 return _rename_recipe_file(oldrecipe, bpn, oldpv, newpv, path)
90 90
91def _write_append(rc, srctree, same_dir, no_same_dir, rev, copied, workspace, d): 91def _write_append(rc, srctreebase, srctree, same_dir, no_same_dir, rev, copied, workspace, d):
92 """Writes an append file""" 92 """Writes an append file"""
93 if not os.path.exists(rc): 93 if not os.path.exists(rc):
94 raise DevtoolError("bbappend not created because %s does not exist" % rc) 94 raise DevtoolError("bbappend not created because %s does not exist" % rc)
@@ -104,6 +104,11 @@ def _write_append(rc, srctree, same_dir, no_same_dir, rev, copied, workspace, d)
104 af = os.path.join(appendpath, '%s.bbappend' % brf) 104 af = os.path.join(appendpath, '%s.bbappend' % brf)
105 with open(af, 'w') as f: 105 with open(af, 'w') as f:
106 f.write('FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n\n') 106 f.write('FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n\n')
107 # Local files can be modified/tracked in separate subdir under srctree
108 # Mostly useful for packages with S != WORKDIR
109 f.write('FILESPATH:prepend := "%s:"\n' %
110 os.path.join(srctreebase, 'oe-local-files'))
111 f.write('# srctreebase: %s\n' % srctreebase)
107 f.write('inherit externalsrc\n') 112 f.write('inherit externalsrc\n')
108 f.write(('# NOTE: We use pn- overrides here to avoid affecting' 113 f.write(('# NOTE: We use pn- overrides here to avoid affecting'
109 'multiple variants in the case where the recipe uses BBCLASSEXTEND\n')) 114 'multiple variants in the case where the recipe uses BBCLASSEXTEND\n'))
@@ -524,14 +529,7 @@ def upgrade(args, config, basepath, workspace):
524 else: 529 else:
525 srctree = standard.get_default_srctree(config, pn) 530 srctree = standard.get_default_srctree(config, pn)
526 531
527 # Check that recipe isn't using a shared workdir 532 srctree_s = standard.get_real_srctree(srctree, rd.getVar('S'), rd.getVar('WORKDIR'))
528 s = os.path.abspath(rd.getVar('S'))
529 workdir = os.path.abspath(rd.getVar('WORKDIR'))
530 srctree_s = srctree
531 if s.startswith(workdir) and s != workdir and os.path.dirname(s) != workdir:
532 # Handle if S is set to a subdirectory of the source
533 srcsubdir = os.path.relpath(s, workdir).split(os.sep, 1)[1]
534 srctree_s = os.path.join(srctree, srcsubdir)
535 533
536 # try to automatically discover latest version and revision if not provided on command line 534 # try to automatically discover latest version and revision if not provided on command line
537 if not args.version and not args.srcrev: 535 if not args.version and not args.srcrev:
@@ -575,7 +573,7 @@ def upgrade(args, config, basepath, workspace):
575 _upgrade_error(e, recipedir, srctree, args.keep_failure) 573 _upgrade_error(e, recipedir, srctree, args.keep_failure)
576 standard._add_md5(config, pn, os.path.dirname(rf)) 574 standard._add_md5(config, pn, os.path.dirname(rf))
577 575
578 af = _write_append(rf, srctree_s, args.same_dir, args.no_same_dir, rev2, 576 af = _write_append(rf, srctree, srctree_s, args.same_dir, args.no_same_dir, rev2,
579 copied, config.workspace_path, rd) 577 copied, config.workspace_path, rd)
580 standard._add_md5(config, pn, af) 578 standard._add_md5(config, pn, af)
581 579