[OE-core] [PATCH 2/2] devtool: add option to remove backported patch automatically during upgrade

Chen Qi Qi.Chen at windriver.com
Mon Dec 2 06:03:11 UTC 2019


When upgrading a package, most likely the backported patches are not
needed any more, so add an option to `devtool upgrade' to handle such
situation.

Signed-off-by: Chen Qi <Qi.Chen at windriver.com>
---
 scripts/lib/devtool/standard.py | 14 +++++++++++++-
 scripts/lib/devtool/upgrade.py  |  3 ++-
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index 1c0cd8ab51..5fe848b6b8 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -487,7 +487,7 @@ def symlink_oelocal_files_srctree(rd,srctree):
             bb.process.run('git %s commit -m "Committing local file symlinks\n\n%s"' % (' '.join(useroptions), oe.patch.GitApplyTree.ignore_commit_prefix), cwd=srctree)
 
 
-def _extract_source(srctree, keep_temp, devbranch, sync, config, basepath, workspace, fixed_setup, d, tinfoil, no_overrides=False):
+def _extract_source(srctree, keep_temp, devbranch, sync, config, basepath, workspace, fixed_setup, d, tinfoil, no_overrides=False, no_backported=False):
     """Extract sources of a recipe"""
     import oe.recipeutils
     import oe.patch
@@ -555,6 +555,14 @@ def _extract_source(srctree, keep_temp, devbranch, sync, config, basepath, works
     tempbasedir = d.getVar('WORKDIR')
     bb.utils.mkdirhier(tempbasedir)
     tempdir = tempfile.mkdtemp(prefix='devtooltmp-', dir=tempbasedir)
+    patches = oe.recipeutils.get_recipe_patches(d)
+    backported_patches = []
+    for patch in patches:
+        with open(patch, 'r') as pf:
+            for line in pf.readlines():
+                if 'Upstream-Status: Backport' in line:
+                    backported_patches.append(os.path.basename(patch))
+                    break
     try:
         tinfoil.logger.setLevel(logging.WARNING)
 
@@ -579,6 +587,10 @@ def _extract_source(srctree, keep_temp, devbranch, sync, config, basepath, works
                 f.write('DEVTOOL_EXTRA_OVERRIDES = "%s"\n' % ':'.join(extra_overrides))
             f.write('inherit devtool-source\n')
             f.write('###--- _extract_source\n')
+            # deal with backported patches
+            if no_backported and len(backported_patches) > 0:
+                for patch_name in backported_patches:
+                    f.write('SRC_URI_remove = "file://%s"' % patch_name)
 
         update_unlockedsigs(basepath, workspace, fixed_setup, [pn])
 
diff --git a/scripts/lib/devtool/upgrade.py b/scripts/lib/devtool/upgrade.py
index cb6dce378a..d5e04ecdc5 100644
--- a/scripts/lib/devtool/upgrade.py
+++ b/scripts/lib/devtool/upgrade.py
@@ -549,7 +549,7 @@ def upgrade(args, config, basepath, workspace):
         license_diff = None
         try:
             logger.info('Extracting current version source...')
-            rev1, srcsubdir1 = standard._extract_source(srctree, False, 'devtool-orig', False, config, basepath, workspace, args.fixed_setup, rd, tinfoil, no_overrides=args.no_overrides)
+            rev1, srcsubdir1 = standard._extract_source(srctree, False, 'devtool-orig', False, config, basepath, workspace, args.fixed_setup, rd, tinfoil, no_overrides=args.no_overrides, no_backported=args.no_backported)
             old_licenses = _extract_licenses(srctree, rd.getVar('LIC_FILES_CHKSUM'))
             logger.info('Extracting upgraded version source...')
             rev2, md5, sha256, srcbranch, srcsubdir2 = _extract_new_source(args.version, srctree, args.no_patch,
@@ -628,6 +628,7 @@ def register_commands(subparsers, context):
     parser_upgrade.add_argument('--branch', '-b', default="devtool", help='Name for new development branch to checkout (default "%(default)s")')
     parser_upgrade.add_argument('--no-patch', action="store_true", help='Do not apply patches from the recipe to the new source code')
     parser_upgrade.add_argument('--no-overrides', '-O', action="store_true", help='Do not create branches for other override configurations')
+    parser_upgrade.add_argument('--no-backported', action="store_true", help='Do not apply backported patches to the new source code')
     group = parser_upgrade.add_mutually_exclusive_group()
     group.add_argument('--same-dir', '-s', help='Build in same directory as source', action="store_true")
     group.add_argument('--no-same-dir', help='Force build in a separate build directory', action="store_true")
-- 
2.17.1



More information about the Openembedded-core mailing list