summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorAlexander Kanavin <alex.kanavin@gmail.com>2022-12-13 12:10:56 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-01-06 17:33:23 +0000
commit45f3a4fd63503262499f98dd501bdb8da07a174f (patch)
tree14aabd4f6802a8da014a1a34cf631fddf0d3b502 /scripts
parent24cdd5bb636b9557cf4ae5be712096ca998ceda6 (diff)
downloadpoky-45f3a4fd63503262499f98dd501bdb8da07a174f.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: 22f210f9f4dfc9e13fdc229147fd1677db5a35ec) Signed-off-by: Alexander Kanavin <alex@linutronix.de> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> (cherry picked from commit 0817aa5537a8d7cc9591c53dfaa1d225f4c327f7) Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/devtool/standard.py19
-rw-r--r--scripts/lib/devtool/upgrade.py18
2 files changed, 19 insertions, 18 deletions
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index c98bfe8195..4bbf9dd5a5 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -765,6 +765,16 @@ def get_staging_kbranch(srcdir):
765 staging_kbranch = "".join(branch.split('\n')[0]) 765 staging_kbranch = "".join(branch.split('\n')[0])
766 return staging_kbranch 766 return staging_kbranch
767 767
768def get_real_srctree(srctree, s, workdir):
769 # Check that recipe isn't using a shared workdir
770 s = os.path.abspath(s)
771 workdir = os.path.abspath(workdir)
772 if s.startswith(workdir) and s != workdir and os.path.dirname(s) != workdir:
773 # Handle if S is set to a subdirectory of the source
774 srcsubdir = os.path.relpath(s, workdir).split(os.sep, 1)[1]
775 srctree = os.path.join(srctree, srcsubdir)
776 return srctree
777
768def modify(args, config, basepath, workspace): 778def modify(args, config, basepath, workspace):
769 """Entry point for the devtool 'modify' subcommand""" 779 """Entry point for the devtool 'modify' subcommand"""
770 import bb 780 import bb
@@ -923,14 +933,7 @@ def modify(args, config, basepath, workspace):
923 933
924 # Need to grab this here in case the source is within a subdirectory 934 # Need to grab this here in case the source is within a subdirectory
925 srctreebase = srctree 935 srctreebase = srctree
926 936 srctree = get_real_srctree(srctree, rd.getVar('S'), rd.getVar('WORKDIR'))
927 # Check that recipe isn't using a shared workdir
928 s = os.path.abspath(rd.getVar('S'))
929 workdir = os.path.abspath(rd.getVar('WORKDIR'))
930 if s.startswith(workdir) and s != workdir and os.path.dirname(s) != workdir:
931 # Handle if S is set to a subdirectory of the source
932 srcsubdir = os.path.relpath(s, workdir).split(os.sep, 1)[1]
933 srctree = os.path.join(srctree, srcsubdir)
934 937
935 bb.utils.mkdirhier(os.path.dirname(appendfile)) 938 bb.utils.mkdirhier(os.path.dirname(appendfile))
936 with open(appendfile, 'w') as f: 939 with open(appendfile, 'w') as f:
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