mirror of
https://git.yoctoproject.org/poky
synced 2026-04-22 15:32:14 +02:00
recipetool / devtool: set a fixed SRCREV by default when fetching from git
If fetching source from a git repository, typically within OpenEmbedded
we encourage setting SRCREV to a fixed revision, so change to do that by
default and add a -a/--autorev option to use "${AUTOREV}" instead.
(From OE-Core rev: 000480c42797dd2f03ebc3bc6d1dabfc6a7b75f5)
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
0a7c699b33
commit
49557a5e9d
@@ -207,12 +207,14 @@ class DevtoolTests(DevtoolBase):
|
||||
tempdir = tempfile.mkdtemp(prefix='devtoolqa')
|
||||
self.track_for_cleanup(tempdir)
|
||||
pn = 'dbus-wait'
|
||||
srcrev = '6cc6077a36fe2648a5f993fe7c16c9632f946517'
|
||||
# We choose an https:// git URL here to check rewriting the URL works
|
||||
url = 'https://git.yoctoproject.org/git/dbus-wait'
|
||||
# Force fetching to "noname" subdir so we verify we're picking up the name from autoconf
|
||||
# instead of the directory name
|
||||
result = runCmd('git clone %s noname' % url, cwd=tempdir)
|
||||
srcdir = os.path.join(tempdir, 'noname')
|
||||
result = runCmd('git reset --hard %s' % srcrev, cwd=srcdir)
|
||||
self.assertTrue(os.path.isfile(os.path.join(srcdir, 'configure.ac')), 'Unable to find configure script in source directory')
|
||||
# Test devtool add
|
||||
self.track_for_cleanup(self.workspacedir)
|
||||
@@ -235,7 +237,7 @@ class DevtoolTests(DevtoolBase):
|
||||
checkvars['S'] = '${WORKDIR}/git'
|
||||
checkvars['PV'] = '0.1+git${SRCPV}'
|
||||
checkvars['SRC_URI'] = 'git://git.yoctoproject.org/git/dbus-wait;protocol=https'
|
||||
checkvars['SRCREV'] = '${AUTOREV}'
|
||||
checkvars['SRCREV'] = srcrev
|
||||
checkvars['DEPENDS'] = set(['dbus'])
|
||||
self._test_recipe_contents(recipefile, checkvars, [])
|
||||
|
||||
@@ -345,7 +347,7 @@ class DevtoolTests(DevtoolBase):
|
||||
self.track_for_cleanup(self.workspacedir)
|
||||
self.add_command_to_tearDown('bitbake -c cleansstate %s' % testrecipe)
|
||||
self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
|
||||
result = runCmd('devtool add %s %s -f %s' % (testrecipe, srcdir, url))
|
||||
result = runCmd('devtool add %s %s -a -f %s' % (testrecipe, srcdir, url))
|
||||
self.assertTrue(os.path.exists(os.path.join(self.workspacedir, 'conf', 'layer.conf')), 'Workspace directory not created: %s' % result.output)
|
||||
self.assertTrue(os.path.isfile(os.path.join(srcdir, 'configure.ac')), 'Unable to find configure.ac in source directory')
|
||||
# Test devtool status
|
||||
|
||||
@@ -144,6 +144,8 @@ def add(args, config, basepath, workspace):
|
||||
extracmdopts += ' --also-native'
|
||||
if args.src_subdir:
|
||||
extracmdopts += ' --src-subdir "%s"' % args.src_subdir
|
||||
if args.autorev:
|
||||
extracmdopts += ' -a'
|
||||
|
||||
tempdir = tempfile.mkdtemp(prefix='devtool')
|
||||
try:
|
||||
@@ -1390,6 +1392,7 @@ def register_commands(subparsers, context):
|
||||
parser_add.add_argument('--fetch', '-f', help='Fetch the specified URI and extract it to create the source tree (deprecated - pass as positional argument instead)', metavar='URI')
|
||||
parser_add.add_argument('--version', '-V', help='Version to use within recipe (PV)')
|
||||
parser_add.add_argument('--no-git', '-g', help='If fetching source, do not set up source tree as a git repository', action="store_true")
|
||||
parser_add.add_argument('--autorev', '-a', help='When fetching from a git repository, set SRCREV in the recipe to a floating revision instead of fixed', action="store_true")
|
||||
parser_add.add_argument('--binary', '-b', help='Treat the source tree as something that should be installed verbatim (no compilation, same directory structure). Useful with binary packages e.g. RPMs.', action='store_true')
|
||||
parser_add.add_argument('--also-native', help='Also add native variant (i.e. support building recipe for the build host as well as the target machine)', action='store_true')
|
||||
parser_add.add_argument('--src-subdir', help='Specify subdirectory within source tree to use', metavar='SUBDIR')
|
||||
|
||||
@@ -563,6 +563,10 @@ def create_recipe(args):
|
||||
lines_before.append('')
|
||||
lines_before.append('# Modify these as desired')
|
||||
lines_before.append('PV = "%s+git${SRCPV}"' % (realpv or '1.0'))
|
||||
if not args.autorev and srcrev == '${AUTOREV}':
|
||||
if os.path.exists(os.path.join(srctree, '.git')):
|
||||
(stdout, _) = bb.process.run('git rev-parse HEAD', cwd=srctree)
|
||||
srcrev = stdout.rstrip()
|
||||
lines_before.append('SRCREV = "%s"' % srcrev)
|
||||
lines_before.append('')
|
||||
|
||||
@@ -1049,5 +1053,6 @@ def register_commands(subparsers):
|
||||
parser_create.add_argument('-b', '--binary', help='Treat the source tree as something that should be installed verbatim (no compilation, same directory structure)', action='store_true')
|
||||
parser_create.add_argument('--also-native', help='Also add native variant (i.e. support building recipe for the build host as well as the target machine)', action='store_true')
|
||||
parser_create.add_argument('--src-subdir', help='Specify subdirectory within source tree to use', metavar='SUBDIR')
|
||||
parser_create.add_argument('-a', '--autorev', help='When fetching from a git repository, set SRCREV in the recipe to a floating revision instead of fixed', action="store_true")
|
||||
parser_create.set_defaults(func=create_recipe)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user