Bug 7642

Summary: devtool: add recipe upgrade functionality
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Paul Eggleton <bluelightning>
Component: devtools / tool chainAssignee: Leonardo Sandoval Gonzalez <leonardo.sandoval.gonzalez>
Status: VERIFIED FIXED QA Contact: Costin <costin.c.constantin>
Severity: enhancement    
Priority: High CC: alexandru.c.georgescu, anibal.limon, meta.mr.watcher, meta.watcher, richard.purdie, sgw
Version: 1.8   
Target Milestone: 1.9 M3   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Yes (doc changes required)

Description Paul Eggleton 2015-04-22 10:12:23 UTC
The Automatic Upgrade Helper has the ability to do recipe upgrades, but quite often the process of recipe upgrading requires fixing/updating associated patches (and possibly adding new ones), which is an interactive process. We have the infrastructure for making this easier in devtool, so it would make sense to add the ability to start a recipe upgrade from devtool (or finish an upgrade that has been started by the AUH and emailed to the maintainer for fixing/review).
Comment 1 Aníbal Limón 2015-05-12 15:21:13 UTC
For the upgrade flow i propose,

upgrade -t version source
validate version/source
download source
copy old recipe to new recipe / handle include files
update license check sums
get a list of current patches
remove all patches

patch cycle (if applies)
apply patch
        - if not apply did a interactive action
                maybe remove or rebase
end patching

test recipe/deploy
Comment 2 Paul Eggleton 2015-05-12 15:36:12 UTC
I had assumed it would be:

  devtool upgrade recipename [-V version]

This would do all of the steps before "test recipe/deploy", leaving you with the upgraded recipe in the workspace layer once all patches have been dealt with. If you then do devtool update-recipe it would then replace the original recipe with the upgraded one.

We already have pretty much all of this logic in the AUH though, right?
Comment 3 Paul Eggleton 2015-05-12 15:37:01 UTC
(Oops, I missed out the source tree path parameter in the above.)
Comment 4 Aníbal Limón 2015-05-12 16:56:26 UTC
(In reply to comment #3)
> (Oops, I missed out the source tree path parameter in the above.)

(In reply to comment #2)
> I had assumed it would be:
> 
>   devtool upgrade recipename [-V version]
> 
> This would do all of the steps before "test recipe/deploy", leaving you with
> the upgraded recipe in the workspace layer once all patches have been dealt
> with. If you then do devtool update-recipe it would then replace the
> original recipe with the upgraded one.
> 
> We already have pretty much all of this logic in the AUH though, right?

Almost yes the AUH does not handle patches because it requires an interactive action of the developer.
Comment 5 Paul Eggleton 2015-05-12 17:08:37 UTC
Right. For the patch handling, devtool's patch application code uses our normal do_patch logic - which means we may be able to get away with setting PATCHRESOLVE = "user" for that (you'd have to try it though, I don't know how well that works in the context devtool runs it).
Comment 6 Leonardo Sandoval Gonzalez 2015-07-21 22:24:53 UTC
(In reply to comment #2)
> I had assumed it would be:
> 
>   devtool upgrade recipename [-V version]
> 
> This would do all of the steps before "test recipe/deploy", leaving you with
> the upgraded recipe in the workspace layer once all patches have been dealt
> with. If you then do devtool update-recipe it would then replace the
> original recipe with the upgraded one.
> 
> We already have pretty much all of this logic in the AUH though, right?

Paul, after spending some time I got to the conclusion that we should use the AUH code for this feature (as you mentioned before).

We have two ways, 1) taking the relevant code from AUH and place it into the poky's script/lib/devtool folder or 2) from devtool call the AUH app. Of course, 2) implies having the AUH repository somewhere on the host machine, making devtool dependent of AUH. I would go for 1 at this moment, but this means that we would have duplicated code, something not really wanted. Let me know what you think.
Comment 7 Paul Eggleton 2015-07-22 11:07:31 UTC
I think it has to be #1, but I would like it to be done in a way that the AUH code gets updated to make use of the new code brought across at the same time, so we don't end up with any duplication. This should also be an opportunity to have the AUH code use the functions in recipeutils to make changes to the recipe files rather than using its own implementation as it does now. Can you work with Anibal on that?
Comment 8 Leonardo Sandoval Gonzalez 2015-07-26 02:29:52 UTC
(In reply to comment #7)
> I think it has to be #1, but I would like it to be done in a way that the
> AUH code gets updated to make use of the new code brought across at the same
> time, so we don't end up with any duplication. This should also be an
> opportunity to have the AUH code use the functions in recipeutils to make
> changes to the recipe files rather than using its own implementation as it
> does now. Can you work with Anibal on that?

Paul,
I finished this task. On Monday, I will review it with Anibal. I do not want to send the patch until we review it and create also some tests. At the end, I did not use the recipeutils library, so code is almost as the AUH code at this point. Future improvements should use the latter library and AUH should call devtool for recipe's upgrade operation. I am afraid I can make it for 1.9M2, but next week this work should be done.
Comment 9 Leonardo Sandoval Gonzalez 2015-08-04 13:49:23 UTC
The implementation is currently being review by the AUH maintainer (Anibal Limon). Sending the final patch to the OE-Core list this week.
Comment 10 Leonardo Sandoval Gonzalez 2015-08-11 22:17:16 UTC
An RFC patch sent to the ML, waiting for comments.

Subject: [PATCH 0/1][RFC] devtool: Upgrade feature
From: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>

There are several approaches when upgrading a recipe and on this patch
it was decided to reused the code from the auto-upgrade-helper [1] and ported it into
the devtool. There are several pending tasks as described in the patch's description. 
The progress of this feature is being track on [2].

[1] http://git.yoctoproject.org/cgit/cgit.cgi/auto-upgrade-helper/
[2] https://bugzilla.yoctoproject.org/show_bug.cgi?id=7642
Comment 11 Leonardo Sandoval Gonzalez 2015-08-17 17:09:48 UTC
V1 patches had several comments from Paul, so It will take around 10 days to complete.
Comment 12 Leonardo Sandoval Gonzalez 2015-08-31 16:18:46 UTC
V3 set of patches sent to the ML.
Comment 13 Leonardo Sandoval Gonzalez 2015-09-15 14:22:16 UTC
Patch now in master branch (8be95c5)

http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=8be95c5fbe6ad970943edabe288fd47d1dcac288
Comment 14 Costin 2015-10-15 10:43:37 UTC
Hello,

Tested on master with d302c98822efe2cb78a63b620aed1b94b4ed4a68 on Ubuntu 15.04

To test, i just reproduced the related oe-selftest  testcase devtool.DevtoolTests.test_devtool_upgrade

Marking as verified