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

Alexander Kanavin alex.kanavin at gmail.com
Mon Dec 2 11:35:48 UTC 2019


I would say this is a dangerous option, and I wouldn'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.

Also, 'devtool upgrade' is using 'git rebase' to rebase all patches onto
the newer code base, and most backports are dropped automatically at that
step. If they aren't there's usually a merge conflict, where you can easily
issue 'git rebase --skip' to remove the backport, or resolve conflicts if
the backport needs to stay.

What prompted you to implement this?

Alex

On Mon, 2 Dec 2019 at 07:03, Chen Qi <Qi.Chen at windriver.com> wrote:

> 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
>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core at lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openembedded.org/pipermail/openembedded-core/attachments/20191202/8e0b12e2/attachment-0001.html>


More information about the Openembedded-core mailing list