mirror of
https://git.yoctoproject.org/poky
synced 2026-06-01 00:59:48 +00:00
devtool: update-recipe: better 'auto' mode
Enhance the logic behind the 'auto' mode a bit by only updating the SRCREV if the changes are already found upstream. The logic is simple: update SRCREV only if the current local HEAD commit is found in the remote branch (i.e. 'origin/<branch_name>'). Otherwise resort to patching. This affects a couple of the oe-selftest tests so update those as well. [YOCTO #7907] (From OE-Core rev: 9b9733b7d74032aef4979bec553019421e77da14) Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com> Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
0d0e50810a
commit
3dd9fc39ab
@@ -547,8 +547,8 @@ class DevtoolTests(DevtoolBase):
|
|||||||
result = runCmd('echo "A new file" > devtool-new-file', cwd=tempdir)
|
result = runCmd('echo "A new file" > devtool-new-file', cwd=tempdir)
|
||||||
result = runCmd('git add devtool-new-file', cwd=tempdir)
|
result = runCmd('git add devtool-new-file', cwd=tempdir)
|
||||||
result = runCmd('git commit -m "Add a new file"', cwd=tempdir)
|
result = runCmd('git commit -m "Add a new file"', cwd=tempdir)
|
||||||
self.add_command_to_tearDown('cd %s; git checkout %s %s' % (os.path.dirname(recipefile), testrecipe, os.path.basename(recipefile)))
|
self.add_command_to_tearDown('cd %s; rm -rf %s; git checkout %s %s' % (os.path.dirname(recipefile), testrecipe, testrecipe, os.path.basename(recipefile)))
|
||||||
result = runCmd('devtool update-recipe %s' % testrecipe)
|
result = runCmd('devtool update-recipe -m srcrev %s' % testrecipe)
|
||||||
result = runCmd('git status . --porcelain', cwd=os.path.dirname(recipefile))
|
result = runCmd('git status . --porcelain', cwd=os.path.dirname(recipefile))
|
||||||
self.assertNotEqual(result.output.strip(), "", '%s recipe should be modified' % testrecipe)
|
self.assertNotEqual(result.output.strip(), "", '%s recipe should be modified' % testrecipe)
|
||||||
status = result.output.splitlines()
|
status = result.output.splitlines()
|
||||||
@@ -585,6 +585,26 @@ class DevtoolTests(DevtoolBase):
|
|||||||
matched = True
|
matched = True
|
||||||
break
|
break
|
||||||
self.assertTrue(matched, 'Unexpected diff remove line: %s' % line)
|
self.assertTrue(matched, 'Unexpected diff remove line: %s' % line)
|
||||||
|
# Now try with auto mode
|
||||||
|
runCmd('cd %s; git checkout %s %s' % (os.path.dirname(recipefile), testrecipe, os.path.basename(recipefile)))
|
||||||
|
result = runCmd('devtool update-recipe %s' % testrecipe)
|
||||||
|
result = runCmd('git rev-parse --show-toplevel')
|
||||||
|
topleveldir = result.output.strip()
|
||||||
|
result = runCmd('git status . --porcelain', cwd=os.path.dirname(recipefile))
|
||||||
|
status = result.output.splitlines()
|
||||||
|
relpatchpath = os.path.join(os.path.relpath(os.path.dirname(recipefile), topleveldir), testrecipe)
|
||||||
|
expectedstatus = [('M', os.path.relpath(recipefile, topleveldir)),
|
||||||
|
('??', '%s/0001-Change-the-Makefile.patch' % relpatchpath),
|
||||||
|
('??', '%s/0002-Add-a-new-file.patch' % relpatchpath)]
|
||||||
|
for line in status:
|
||||||
|
statusline = line.split(None, 1)
|
||||||
|
for fstatus, fn in expectedstatus:
|
||||||
|
if fn == statusline[1]:
|
||||||
|
if fstatus != statusline[0]:
|
||||||
|
self.fail('Unexpected status in line: %s' % line)
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
self.fail('Unexpected modified file in line: %s' % line)
|
||||||
|
|
||||||
@testcase(1170)
|
@testcase(1170)
|
||||||
def test_devtool_update_recipe_append(self):
|
def test_devtool_update_recipe_append(self):
|
||||||
@@ -708,7 +728,7 @@ class DevtoolTests(DevtoolBase):
|
|||||||
self.add_command_to_tearDown('bitbake-layers remove-layer %s || true' % templayerdir)
|
self.add_command_to_tearDown('bitbake-layers remove-layer %s || true' % templayerdir)
|
||||||
result = runCmd('bitbake-layers add-layer %s' % templayerdir, cwd=self.builddir)
|
result = runCmd('bitbake-layers add-layer %s' % templayerdir, cwd=self.builddir)
|
||||||
# Create the bbappend
|
# Create the bbappend
|
||||||
result = runCmd('devtool update-recipe %s -a %s' % (testrecipe, templayerdir))
|
result = runCmd('devtool update-recipe -m srcrev %s -a %s' % (testrecipe, templayerdir))
|
||||||
self.assertNotIn('WARNING:', result.output)
|
self.assertNotIn('WARNING:', result.output)
|
||||||
# Check recipe is still clean
|
# Check recipe is still clean
|
||||||
result = runCmd('git status . --porcelain', cwd=os.path.dirname(recipefile))
|
result = runCmd('git status . --porcelain', cwd=os.path.dirname(recipefile))
|
||||||
@@ -729,12 +749,12 @@ class DevtoolTests(DevtoolBase):
|
|||||||
self.assertEqual(expectedlines, f.readlines())
|
self.assertEqual(expectedlines, f.readlines())
|
||||||
|
|
||||||
# Check we can run it again and bbappend isn't modified
|
# Check we can run it again and bbappend isn't modified
|
||||||
result = runCmd('devtool update-recipe %s -a %s' % (testrecipe, templayerdir))
|
result = runCmd('devtool update-recipe -m srcrev %s -a %s' % (testrecipe, templayerdir))
|
||||||
with open(bbappendfile, 'r') as f:
|
with open(bbappendfile, 'r') as f:
|
||||||
self.assertEqual(expectedlines, f.readlines())
|
self.assertEqual(expectedlines, f.readlines())
|
||||||
# Drop new commit and check SRCREV changes
|
# Drop new commit and check SRCREV changes
|
||||||
result = runCmd('git reset HEAD^', cwd=tempsrcdir)
|
result = runCmd('git reset HEAD^', cwd=tempsrcdir)
|
||||||
result = runCmd('devtool update-recipe %s -a %s' % (testrecipe, templayerdir))
|
result = runCmd('devtool update-recipe -m srcrev %s -a %s' % (testrecipe, templayerdir))
|
||||||
self.assertFalse(os.path.exists(os.path.join(appenddir, testrecipe)), 'Patch directory should not be created')
|
self.assertFalse(os.path.exists(os.path.join(appenddir, testrecipe)), 'Patch directory should not be created')
|
||||||
result = runCmd('git rev-parse HEAD', cwd=tempsrcdir)
|
result = runCmd('git rev-parse HEAD', cwd=tempsrcdir)
|
||||||
expectedlines = ['SRCREV = "%s"\n' % result.output,
|
expectedlines = ['SRCREV = "%s"\n' % result.output,
|
||||||
@@ -747,7 +767,7 @@ class DevtoolTests(DevtoolBase):
|
|||||||
os.remove(bbappendfile)
|
os.remove(bbappendfile)
|
||||||
result = runCmd('git commit -a -m "Change the Makefile"', cwd=tempsrcdir)
|
result = runCmd('git commit -a -m "Change the Makefile"', cwd=tempsrcdir)
|
||||||
result = runCmd('bitbake-layers remove-layer %s' % templayerdir, cwd=self.builddir)
|
result = runCmd('bitbake-layers remove-layer %s' % templayerdir, cwd=self.builddir)
|
||||||
result = runCmd('devtool update-recipe %s -a %s' % (testrecipe, templayerdir))
|
result = runCmd('devtool update-recipe -m srcrev %s -a %s' % (testrecipe, templayerdir))
|
||||||
self.assertIn('WARNING: Specified layer is not currently enabled in bblayers.conf', result.output)
|
self.assertIn('WARNING: Specified layer is not currently enabled in bblayers.conf', result.output)
|
||||||
self.assertFalse(os.path.exists(os.path.join(appenddir, testrecipe)), 'Patch directory should not be created')
|
self.assertFalse(os.path.exists(os.path.join(appenddir, testrecipe)), 'Patch directory should not be created')
|
||||||
result = runCmd('git rev-parse HEAD', cwd=tempsrcdir)
|
result = runCmd('git rev-parse HEAD', cwd=tempsrcdir)
|
||||||
|
|||||||
@@ -757,6 +757,31 @@ def _update_recipe_patch(args, config, srctree, rd, config_data):
|
|||||||
|
|
||||||
_remove_patch_files(args, removepatches, destpath)
|
_remove_patch_files(args, removepatches, destpath)
|
||||||
|
|
||||||
|
def _guess_recipe_update_mode(srctree, rdata):
|
||||||
|
"""Guess the recipe update mode to use"""
|
||||||
|
src_uri = (rdata.getVar('SRC_URI', False) or '').split()
|
||||||
|
git_uris = [uri for uri in src_uri if uri.startswith('git://')]
|
||||||
|
if not git_uris:
|
||||||
|
return 'patch'
|
||||||
|
# Just use the first URI for now
|
||||||
|
uri = git_uris[0]
|
||||||
|
# Check remote branch
|
||||||
|
upstr_branch = 'master'
|
||||||
|
for paramdef in uri.split(';')[1:]:
|
||||||
|
name, value = paramdef.split('=', 1)
|
||||||
|
if name == 'branch':
|
||||||
|
upstr_branch = value
|
||||||
|
# Check if current branch HEAD is found in upstream branch
|
||||||
|
stdout, _ = bb.process.run('git rev-parse HEAD', cwd=srctree)
|
||||||
|
head_rev = stdout.rstrip()
|
||||||
|
stdout, _ = bb.process.run('git branch -r --contains %s' % head_rev,
|
||||||
|
cwd=srctree)
|
||||||
|
remote_brs = [branch.strip() for branch in stdout.splitlines()]
|
||||||
|
if 'origin/' + upstr_branch in remote_brs:
|
||||||
|
return 'srcrev'
|
||||||
|
|
||||||
|
return 'patch'
|
||||||
|
|
||||||
def update_recipe(args, config, basepath, workspace):
|
def update_recipe(args, config, basepath, workspace):
|
||||||
"""Entry point for the devtool 'update-recipe' subcommand"""
|
"""Entry point for the devtool 'update-recipe' subcommand"""
|
||||||
if not args.recipename in workspace:
|
if not args.recipename in workspace:
|
||||||
@@ -777,17 +802,12 @@ def update_recipe(args, config, basepath, workspace):
|
|||||||
if not rd:
|
if not rd:
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
orig_src_uri = rd.getVar('SRC_URI', False) or ''
|
srctree = workspace[args.recipename]['srctree']
|
||||||
if args.mode == 'auto':
|
if args.mode == 'auto':
|
||||||
if 'git://' in orig_src_uri:
|
mode = _guess_recipe_update_mode(srctree, rd)
|
||||||
mode = 'srcrev'
|
|
||||||
else:
|
|
||||||
mode = 'patch'
|
|
||||||
else:
|
else:
|
||||||
mode = args.mode
|
mode = args.mode
|
||||||
|
|
||||||
srctree = workspace[args.recipename]['srctree']
|
|
||||||
|
|
||||||
if mode == 'srcrev':
|
if mode == 'srcrev':
|
||||||
_update_recipe_srcrev(args, srctree, rd, tinfoil.config_data)
|
_update_recipe_srcrev(args, srctree, rd, tinfoil.config_data)
|
||||||
elif mode == 'patch':
|
elif mode == 'patch':
|
||||||
|
|||||||
Reference in New Issue
Block a user