<div dir="ltr"><div>I would say this is a dangerous option, and I wouldn&#39;t want to have or use it. Backported patches may not actually be present in the newer version if they were taken from a development branch that has not yet been released.</div><div><br></div><div>Also, &#39;devtool upgrade&#39; is using &#39;git rebase&#39; to rebase all patches onto the newer code base, and most backports are dropped automatically at that step. If they aren&#39;t there&#39;s usually a merge conflict, where you can easily issue &#39;git rebase --skip&#39; to remove the backport, or resolve conflicts if the backport needs to stay.</div><div><br></div><div>What prompted you to implement this?<br></div><div><br></div><div>Alex<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, 2 Dec 2019 at 07:03, Chen Qi &lt;<a href="mailto:Qi.Chen@windriver.com">Qi.Chen@windriver.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">When upgrading a package, most likely the backported patches are not<br>
needed any more, so add an option to `devtool upgrade&#39; to handle such<br>
situation.<br>
<br>
Signed-off-by: Chen Qi &lt;<a href="mailto:Qi.Chen@windriver.com" target="_blank">Qi.Chen@windriver.com</a>&gt;<br>
---<br>
 scripts/lib/devtool/standard.py | 14 +++++++++++++-<br>
 scripts/lib/devtool/upgrade.py  |  3 ++-<br>
 2 files changed, 15 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py<br>
index 1c0cd8ab51..5fe848b6b8 100644<br>
--- a/scripts/lib/devtool/standard.py<br>
+++ b/scripts/lib/devtool/standard.py<br>
@@ -487,7 +487,7 @@ def symlink_oelocal_files_srctree(rd,srctree):<br>
             bb.process.run(&#39;git %s commit -m &quot;Committing local file symlinks\n\n%s&quot;&#39; % (&#39; &#39;.join(useroptions), oe.patch.GitApplyTree.ignore_commit_prefix), cwd=srctree)<br>
<br>
<br>
-def _extract_source(srctree, keep_temp, devbranch, sync, config, basepath, workspace, fixed_setup, d, tinfoil, no_overrides=False):<br>
+def _extract_source(srctree, keep_temp, devbranch, sync, config, basepath, workspace, fixed_setup, d, tinfoil, no_overrides=False, no_backported=False):<br>
     &quot;&quot;&quot;Extract sources of a recipe&quot;&quot;&quot;<br>
     import oe.recipeutils<br>
     import oe.patch<br>
@@ -555,6 +555,14 @@ def _extract_source(srctree, keep_temp, devbranch, sync, config, basepath, works<br>
     tempbasedir = d.getVar(&#39;WORKDIR&#39;)<br>
     bb.utils.mkdirhier(tempbasedir)<br>
     tempdir = tempfile.mkdtemp(prefix=&#39;devtooltmp-&#39;, dir=tempbasedir)<br>
+    patches = oe.recipeutils.get_recipe_patches(d)<br>
+    backported_patches = []<br>
+    for patch in patches:<br>
+        with open(patch, &#39;r&#39;) as pf:<br>
+            for line in pf.readlines():<br>
+                if &#39;Upstream-Status: Backport&#39; in line:<br>
+                    backported_patches.append(os.path.basename(patch))<br>
+                    break<br>
     try:<br>
         tinfoil.logger.setLevel(logging.WARNING)<br>
<br>
@@ -579,6 +587,10 @@ def _extract_source(srctree, keep_temp, devbranch, sync, config, basepath, works<br>
                 f.write(&#39;DEVTOOL_EXTRA_OVERRIDES = &quot;%s&quot;\n&#39; % &#39;:&#39;.join(extra_overrides))<br>
             f.write(&#39;inherit devtool-source\n&#39;)<br>
             f.write(&#39;###--- _extract_source\n&#39;)<br>
+            # deal with backported patches<br>
+            if no_backported and len(backported_patches) &gt; 0:<br>
+                for patch_name in backported_patches:<br>
+                    f.write(&#39;SRC_URI_remove = &quot;file://%s&quot;&#39; % patch_name)<br>
<br>
         update_unlockedsigs(basepath, workspace, fixed_setup, [pn])<br>
<br>
diff --git a/scripts/lib/devtool/upgrade.py b/scripts/lib/devtool/upgrade.py<br>
index cb6dce378a..d5e04ecdc5 100644<br>
--- a/scripts/lib/devtool/upgrade.py<br>
+++ b/scripts/lib/devtool/upgrade.py<br>
@@ -549,7 +549,7 @@ def upgrade(args, config, basepath, workspace):<br>
         license_diff = None<br>
         try:<br>
             <a href="http://logger.info" rel="noreferrer" target="_blank">logger.info</a>(&#39;Extracting current version source...&#39;)<br>
-            rev1, srcsubdir1 = standard._extract_source(srctree, False, &#39;devtool-orig&#39;, False, config, basepath, workspace, args.fixed_setup, rd, tinfoil, no_overrides=args.no_overrides)<br>
+            rev1, srcsubdir1 = standard._extract_source(srctree, False, &#39;devtool-orig&#39;, False, config, basepath, workspace, args.fixed_setup, rd, tinfoil, no_overrides=args.no_overrides, no_backported=args.no_backported)<br>
             old_licenses = _extract_licenses(srctree, rd.getVar(&#39;LIC_FILES_CHKSUM&#39;))<br>
             <a href="http://logger.info" rel="noreferrer" target="_blank">logger.info</a>(&#39;Extracting upgraded version source...&#39;)<br>
             rev2, md5, sha256, srcbranch, srcsubdir2 = _extract_new_source(args.version, srctree, args.no_patch,<br>
@@ -628,6 +628,7 @@ def register_commands(subparsers, context):<br>
     parser_upgrade.add_argument(&#39;--branch&#39;, &#39;-b&#39;, default=&quot;devtool&quot;, help=&#39;Name for new development branch to checkout (default &quot;%(default)s&quot;)&#39;)<br>
     parser_upgrade.add_argument(&#39;--no-patch&#39;, action=&quot;store_true&quot;, help=&#39;Do not apply patches from the recipe to the new source code&#39;)<br>
     parser_upgrade.add_argument(&#39;--no-overrides&#39;, &#39;-O&#39;, action=&quot;store_true&quot;, help=&#39;Do not create branches for other override configurations&#39;)<br>
+    parser_upgrade.add_argument(&#39;--no-backported&#39;, action=&quot;store_true&quot;, help=&#39;Do not apply backported patches to the new source code&#39;)<br>
     group = parser_upgrade.add_mutually_exclusive_group()<br>
     group.add_argument(&#39;--same-dir&#39;, &#39;-s&#39;, help=&#39;Build in same directory as source&#39;, action=&quot;store_true&quot;)<br>
     group.add_argument(&#39;--no-same-dir&#39;, help=&#39;Force build in a separate build directory&#39;, action=&quot;store_true&quot;)<br>
-- <br>
2.17.1<br>
<br>
-- <br>
_______________________________________________<br>
Openembedded-core mailing list<br>
<a href="mailto:Openembedded-core@lists.openembedded.org" target="_blank">Openembedded-core@lists.openembedded.org</a><br>
<a href="http://lists.openembedded.org/mailman/listinfo/openembedded-core" rel="noreferrer" target="_blank">http://lists.openembedded.org/mailman/listinfo/openembedded-core</a><br>
</blockquote></div>