<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 4, 2015 at 7:48 AM, Paul Eggleton <span dir="ltr"><<a href="mailto:paul.eggleton@linux.intel.com" target="_blank">paul.eggleton@linux.intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div>On Monday 26 October 2015 10:29:24 Tzu-Jung Lee wrote:<br>
> Hi Paul<br>
><br>
> On Mon, Oct 26, 2015 at 2:20 AM, Paul Eggleton <<br>
><br>
> <a href="mailto:paul.eggleton@linux.intel.com" target="_blank">paul.eggleton@linux.intel.com</a>> wrote:<br>
> > Hi Tzu-Jung,<br>
> ><br>
> > Thanks for the patch.<br>
> ><br>
> > On Wednesday 21 October 2015 23:06:45 Tzu-Jung Lee wrote:<br>
> > > The sync command is similar to the extract command, except it<br>
> > > fetches the sync'ed and patched branch to an existing git repository.<br>
> > ><br>
> > > This enables users to keep track the upstream development while<br>
> > > maintaining their own local git repository at the same time.<br>
> > ><br>
> > > Signed-off-by: Tzu-Jung Lee <<a href="mailto:roylee17@currantlabs.com" target="_blank">roylee17@currantlabs.com</a>><br>
> > > ---<br>
> > ><br>
> > > scripts/lib/devtool/standard.py | 73<br>
> > ><br>
> > > +++++++++++++++++++++++++++++++---------- 1 file changed, 56<br>
> ><br>
> > insertions(+),<br>
> ><br>
> > > 17 deletions(-)<br>
> > ><br>
> > > diff --git a/scripts/lib/devtool/standard.py<br>
> > > b/scripts/lib/devtool/standard.py index 5d7e903..2c6b7b3 100644<br>
> > > --- a/scripts/lib/devtool/standard.py<br>
> > > +++ b/scripts/lib/devtool/standard.py<br>
> > ><br>
> > > @@ -234,7 +234,29 @@ def extract(args, config, basepath, workspace):<br>
> > > return 1<br>
> > ><br>
> > > srctree = os.path.abspath(args.srctree)<br>
> > ><br>
> > > - initial_rev = _extract_source(srctree, args.keep_temp, args.branch,<br>
> ><br>
> > rd)<br>
> ><br>
> > > + initial_rev = _extract_source(srctree, args.keep_temp, args.branch,<br>
> > > False, rd)<br>
> > > + <a href="http://logger.info" rel="noreferrer" target="_blank">logger.info</a>('Source tree extracted to %s' % srctree)<br>
> > > +<br>
> > > + if initial_rev:<br>
> > > + return 0<br>
> > > + else:<br>
> > > + return 1<br>
> ><br>
> > Hmm, so your patch shows this check being added but it's there in master.<br>
> > Are<br>
> > you patching an older version?<br>
><br>
> Not really, it was patched against the tip of master.<br>
> But git is sometimes confused by the boundary of back-to-back similar<br>
> functions.<br>
> So that checks are actually belongs to "def sync", which was copied from<br>
> "def extract"<br>
><br>
> def extract<br>
> ...<br>
> --------------------<br>
><br>
> | [checks]<br>
> |<br>
> | def sync<br>
> |<br>
> | ...<br>
><br>
> --------------------<br>
> [checks]<br>
><br>
> > +def sync(args, config, basepath, workspace):<br>
> > > + """Entry point for the devtool 'sync' subcommand"""<br>
> > > + import bb<br>
> > > +<br>
> > > + tinfoil = _prep_extract_operation(config, basepath,<br>
> > > args.recipename)<br>
> > > + if not tinfoil:<br>
> > > + # Error already shown<br>
> > > + return 1<br>
> > > +<br>
> > > + rd = parse_recipe(config, tinfoil, args.recipename, True)<br>
> > > + if not rd:<br>
> > > + return 1<br>
> > > +<br>
> > > + srctree = os.path.abspath(args.srctree)<br>
> > > + initial_rev = _extract_source(srctree, args.keep_temp, args.branch,<br>
> > > True, rd) <a href="http://logger.info" rel="noreferrer" target="_blank">logger.info</a>('Source tree extracted to %s' % srctree)<br>
> > ><br>
> > > if initial_rev:<br>
> > > @@ -289,7 +311,7 @@ def _prep_extract_operation(config, basepath,<br>
> > > recipename): return tinfoil<br>
> > ><br>
> > ><br>
> > > -def _extract_source(srctree, keep_temp, devbranch, d):<br>
> > ><br>
> > > +def _extract_source(srctree, keep_temp, devbranch, sync, d):<br>
> > > """Extract sources of a recipe"""<br>
> > > import bb.event<br>
> > > import oe.recipeutils<br>
> > ><br>
> > > @@ -308,21 +330,26 @@ def _extract_source(srctree, keep_temp, devbranch,<br>
> ><br>
> > d):<br>
> > > _check_compatible_recipe(pn, d)<br>
> > ><br>
> > > - if os.path.exists(srctree):<br>
> > > - if not os.path.isdir(srctree):<br>
> > > - raise DevtoolError("output path %s exists and is not a<br>
> > > directory" % - srctree)<br>
> > > - elif os.listdir(srctree):<br>
> > > - raise DevtoolError("output path %s already exists and is "<br>
> > > - "non-empty" % srctree)<br>
> > > + if sync:<br>
> > > + if not os.path.exists(srctree):<br>
> > > + raise DevtoolError("output path %s does not exist" %<br>
> > > srctree) + else:<br>
> > > + if os.path.exists(srctree):<br>
> > > + if not os.path.isdir(srctree):<br>
> > > + raise DevtoolError("output path %s exists and is not a<br>
> > > directory" % + srctree)<br>
> > > + elif os.listdir(srctree):<br>
> > > + raise DevtoolError("output path %s already exists and<br>
> ><br>
> > is "<br>
> ><br>
> > > + "non-empty" % srctree)<br>
> > ><br>
> > > - if 'noexec' in (d.getVarFlags('do_unpack', False) or []):<br>
> > > - raise DevtoolError("The %s recipe has do_unpack disabled,<br>
> ><br>
> > unable to<br>
> ><br>
> > > " - "extract source" % pn)<br>
> > > + if 'noexec' in (d.getVarFlags('do_unpack', False) or []):<br>
> > > + raise DevtoolError("The %s recipe has do_unpack disabled,<br>
> > > unable to " + "extract source" % pn)<br>
> > ><br>
> > > - # Prepare for shutil.move later on<br>
> > > - bb.utils.mkdirhier(srctree)<br>
> > > - os.rmdir(srctree)<br>
> > > + if not sync:<br>
> > > + # Prepare for shutil.move later on<br>
> > > + bb.utils.mkdirhier(srctree)<br>
> > > + os.rmdir(srctree)<br>
> > ><br>
> > > # We don't want notes to be printed, they are too verbose<br>
> > > origlevel = bb.logger.getEffectiveLevel()<br>
> > ><br>
> > > @@ -431,8 +458,11 @@ def _extract_source(srctree, keep_temp, devbranch,<br>
> ><br>
> > d):<br>
> > > <a href="http://logger.info" rel="noreferrer" target="_blank">logger.info</a>('Adding local source files to srctree...')<br>
> > > shutil.move(os.path.join(tempdir, 'oe-local-files'),<br>
> ><br>
> > srcsubdir)<br>
> ><br>
> > > + if sync:<br>
> > > + bb.process.run('git fetch file://' + srcsubdir + ' ' +<br>
> > > devbranch + ':' + devbranch, cwd=srctree)<br>
> > > + else:<br>
> > > + shutil.move(srcsubdir, srctree)<br>
> > ><br>
> > > - shutil.move(srcsubdir, srctree)<br>
> > ><br>
> > > finally:<br>
> > > bb.logger.setLevel(origlevel)<br>
> > ><br>
> > > @@ -532,7 +562,7 @@ def modify(args, config, basepath, workspace):<br>
> > > commits = []<br>
> > > srctree = os.path.abspath(args.srctree)<br>
> > ><br>
> > > if args.extract:<br>
> > > - initial_rev = _extract_source(args.srctree, False, args.branch,<br>
> ><br>
> > rd)<br>
> ><br>
> > > + initial_rev = _extract_source(args.srctree, False, args.branch,<br>
> > ><br>
> > > False, rd) if not initial_rev:<br>
> > > return 1<br>
> > ><br>
> > > <a href="http://logger.info" rel="noreferrer" target="_blank">logger.info</a>('Source tree extracted to %s' % srctree)<br>
> > ><br>
> > > @@ -1107,6 +1137,15 @@ def register_commands(subparsers, context):<br>
> > > parser_extract.add_argument('--keep-temp', action="store_true",<br>
> > ><br>
> > > help='Keep temporary directory (for debugging)')<br>
> > > parser_extract.set_defaults(func=extract)<br>
> > ><br>
> > > + parser_sync = subparsers.add_parser('sync', help='Synchronize the<br>
> > > source for an existing recipe', +<br>
> > > description='Synchronize the source for an existing recipe', +<br>
> > ><br>
> > > formatter_class=argparse.ArgumentDefaultsHelpFormatter) +<br>
> > > parser_sync.add_argument('recipename', help='Name for recipe to sync the<br>
> > > source for') + parser_sync.add_argument('srctree', help='Path to<br>
> > > where<br>
> > > to sync the source tree') + parser_sync.add_argument('--branch',<br>
> > > '-b',<br>
> > > default="devtool", help='Name for development branch to checkout') +<br>
> > > parser_sync.add_argument('--keep-temp', action="store_true", help='Keep<br>
> > > temporary directory (for debugging)') +<br>
> > > parser_sync.set_defaults(func=sync)<br>
> > > +<br>
> > ><br>
> > > parser_update_recipe = subparsers.add_parser('update-recipe',<br>
> > ><br>
> > > help='Apply changes from external source tree to recipe',<br>
> > > description='Applies changes from external source tree to a recipe<br>
> > > (updating/adding/removing patches as necessary, or by updating SRCREV)')<br>
> > > parser_update_recipe.add_argument('recipename', help='Name of recipe to<br>
> > > update')<br>
> ><br>
> > Exploring the use case a bit more, do you anticipate using this sync<br>
> > command<br>
> > in conjunction with a recipe that's in the workspace, or standalone?<br>
><br>
> The use case is for workspace to keep git repos up-to-date. (Kind of<br>
> rebasing) So the assumption is that the recipes have a corresponding git<br>
> repository already, which could be an existing internal one, or a freshly<br>
> constructed by an earlier devtool modify/extract. For standalone recipes,<br>
> they can still go through the workspace :-)<br>
<br>
</div></div>I guess what I was wondering was is there a way we can better fit this in with<br>
devtool's workflow for when the recipe is in the workspace. However, other than<br>
perhaps not expecting the path to the source tree when the recipe is in the<br>
workspace I can't think of anything though. I guess we can always improve it<br>
later.<br></blockquote><div><br></div><div>Maybe we can fit it like the following:</div><div><br></div><div>1. Start to modify a recipe by either:</div><div><br></div><div> a. reusing an existing <srctree></div><div><br></div><div> $ devtool modify <recipename> <srctree></div><div><br></div><div> b. or creating a new one with the -x option</div><div><br></div><div> $ devtool modify <recipename> -x <srctree></div><div><br></div><div>2. Work on the <srctree> </div><div><br></div><div>3. After a while, the upstream of <recipename> moves forward before we contribute our changes back.</div><div><br></div><div>4. Sync up the upstream changes into <srctree> with a new branch <branchname></div><div><br></div><div> $ devtool sync <recipename> <srctree> --branch <branchname></div><div><br></div><div>5. Rebase our working branch onto the tip of the upstream <branchname> </div><div><br></div><div> $ git rebase <branchname> devtool</div><div><br></div><div>[ Repeat 2 - 5 ]</div><div><br></div><div>6. Apply the changes back to the recipe.</div><div><br></div><div> $ devtool update-recipe <branchname></div><div><br></div><div>- Roy</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Acked-by: Paul Eggleton <<a href="mailto:paul.eggleton@linux.intel.com" target="_blank">paul.eggleton@linux.intel.com</a>><br>
<div><div><br>
Cheers,<br>
Paul<br>
<br>
--<br>
<br>
Paul Eggleton<br>
Intel Open Source Technology Centre<br>
</div></div></blockquote></div><br></div></div>