DRAFT mcf: Only update layers and generate bblayers.conf if build-templates are not present (v7.1.0)
This commit is contained in:
parent
e48dcbebd3
commit
039b32e324
96
scripts/mcf
96
scripts/mcf
|
@ -28,7 +28,7 @@ import glob
|
||||||
import importlib.util
|
import importlib.util
|
||||||
import importlib.machinery
|
import importlib.machinery
|
||||||
|
|
||||||
__version__ = "7.0.0"
|
__version__ = "7.1.0
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ def process_file(f, replacements):
|
||||||
with open(ofile, 'w') as f:
|
with open(ofile, 'w') as f:
|
||||||
f.write(status)
|
f.write(status)
|
||||||
|
|
||||||
def getopts():
|
def getopts(bblayers_only):
|
||||||
mcfcommand_option = '--command'
|
mcfcommand_option = '--command'
|
||||||
mcfcommand_dest = 'mcfcommand'
|
mcfcommand_dest = 'mcfcommand'
|
||||||
# be careful when changing this, jenkins-job.sh is doing
|
# be careful when changing this, jenkins-job.sh is doing
|
||||||
|
@ -95,14 +95,23 @@ def getopts():
|
||||||
mcfcommand_choices = ['configure', 'update', 'update+configure']
|
mcfcommand_choices = ['configure', 'update', 'update+configure']
|
||||||
mcfcommand_default = 'update+configure'
|
mcfcommand_default = 'update+configure'
|
||||||
|
|
||||||
# Just parse the --command argument here, so that we can select a parser
|
if bblayers_only:
|
||||||
mcfcommand_parser = argparse.ArgumentParser(add_help=False)
|
mcfcommand = 'update'
|
||||||
mcfcommand_parser.add_argument(mcfcommand_option, dest=mcfcommand_dest, choices=mcfcommand_choices, default=mcfcommand_default)
|
mcfcommand_choices = [mcfcommand]
|
||||||
mcfcommand_parser_result = mcfcommand_parser.parse_known_args()
|
mcfcommand_default = mcfcommand
|
||||||
mcfcommand = mcfcommand_parser_result[0].mcfcommand
|
mcfcommand_help = argparse.SUPPRESS
|
||||||
|
configfile_help_append = '(default: none)'
|
||||||
# Put --command back in (as the first option) so that the main parser sees everything
|
arglist = [mcfcommand_option, mcfcommand ] + sys.argv[1:]
|
||||||
arglist = [mcfcommand_option, mcfcommand ] + mcfcommand_parser_result[1]
|
else:
|
||||||
|
# Just parse the --command argument here, so that we can select a parser
|
||||||
|
mcfcommand_parser = argparse.ArgumentParser(add_help=False)
|
||||||
|
mcfcommand_parser.add_argument(mcfcommand_option, dest=mcfcommand_dest, choices=mcfcommand_choices, default=mcfcommand_default)
|
||||||
|
mcfcommand_parser_result = mcfcommand_parser.parse_known_args()
|
||||||
|
mcfcommand = mcfcommand_parser_result[0].mcfcommand
|
||||||
|
mcfcommand_help = 'command to mcf; if update is given, none of the remaining options nor MACHINE can be specified (default: %(default)s)'
|
||||||
|
configfile_help_append = '(default: weboslayers.py in same directory as this script)'
|
||||||
|
# Put --command back in (as the first option) so that the main parser sees everything
|
||||||
|
arglist = [mcfcommand_option, mcfcommand ] + mcfcommand_parser_result[1]
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
|
|
||||||
|
@ -119,7 +128,7 @@ def getopts():
|
||||||
general.add_argument(mcfcommand_option, dest=mcfcommand_dest, choices=mcfcommand_choices, default=mcfcommand_default,
|
general.add_argument(mcfcommand_option, dest=mcfcommand_dest, choices=mcfcommand_choices, default=mcfcommand_default,
|
||||||
help='command to mcf; if update is given, none of the remaining options nor MACHINE can be specified (default: %(default)s)')
|
help='command to mcf; if update is given, none of the remaining options nor MACHINE can be specified (default: %(default)s)')
|
||||||
|
|
||||||
general.add_argument('-f', '--config-file', dest='configfile', help='.mcf/.py file specifying the build configuration (default: weboslayers.py in same directory as this script)')
|
general.add_argument('-f', '--config-file', dest='configfile', help=('.mcf/.py file specifying the build configuration ' + configfile_help_append))
|
||||||
|
|
||||||
if mcfcommand in ('configure','update+configure'):
|
if mcfcommand in ('configure','update+configure'):
|
||||||
variations = parser.add_argument_group('Build Instructions')
|
variations = parser.add_argument_group('Build Instructions')
|
||||||
|
@ -268,7 +277,7 @@ def location_to_dirname(location):
|
||||||
str1 = location.split('/')
|
str1 = location.split('/')
|
||||||
return os.path.splitext(str1[len(str1)-1])[0]
|
return os.path.splitext(str1[len(str1)-1])[0]
|
||||||
|
|
||||||
def read_mcfconfigfile(configfile):
|
def read_mcfconfigfile(configfile, bblayers_only):
|
||||||
if not os.path.isfile(configfile):
|
if not os.path.isfile(configfile):
|
||||||
raise Exception("Error: Configuration file %s does not exist!" % configfile)
|
raise Exception("Error: Configuration file %s does not exist!" % configfile)
|
||||||
|
|
||||||
|
@ -446,7 +455,7 @@ def parse_collections(srcdir):
|
||||||
else:
|
else:
|
||||||
raise Exception("Error: Directory '%s' does not exist, you probably need to call update" % layer["location"])
|
raise Exception("Error: Directory '%s' does not exist, you probably need to call update" % layer["location"])
|
||||||
|
|
||||||
def write_bblayers_conf(sourcedir):
|
def write_bblayers_conf(sourcedir, append):
|
||||||
locations = ""
|
locations = ""
|
||||||
bblayers = ""
|
bblayers = ""
|
||||||
priorities = ""
|
priorities = ""
|
||||||
|
@ -469,6 +478,18 @@ def write_bblayers_conf(sourcedir):
|
||||||
bblayers += " ${%s_LAYER} \\\n" % layer_name
|
bblayers += " ${%s_LAYER} \\\n" % layer_name
|
||||||
priorities += "BBFILE_PRIORITY_%s_forcevariable = \"%s\"\n" % (layer["collection_name"], layer["priority"])
|
priorities += "BBFILE_PRIORITY_%s_forcevariable = \"%s\"\n" % (layer["collection_name"], layer["priority"])
|
||||||
|
|
||||||
|
if not append:
|
||||||
|
with open(os.path.join(sourcedir, "conf", "bblayers.conf"), 'w') as f:
|
||||||
|
# XXX Figure out a way to find openembedded-core/meta/conf/bblayers.conf.sample so that it can be used as a template
|
||||||
|
# instead of the hardcoding below.
|
||||||
|
f.write('# LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf\n')
|
||||||
|
f.write('# changes incompatibly\n')
|
||||||
|
f.write('LCONF_VERSION = "7"\n')
|
||||||
|
f.write('\n')
|
||||||
|
f.write('TOPDIR = "' + sourcedir + '"\n')
|
||||||
|
f.write('\n')
|
||||||
|
f.write('BBPATH = "${TOPDIR}"\n')
|
||||||
|
|
||||||
with open(os.path.join(sourcedir, "conf", "bblayers.conf"), 'a') as f:
|
with open(os.path.join(sourcedir, "conf", "bblayers.conf"), 'a') as f:
|
||||||
f.write('\n')
|
f.write('\n')
|
||||||
f.write(locations)
|
f.write(locations)
|
||||||
|
@ -793,7 +814,7 @@ def recover_current_mcf_state(srcdir, origoptions):
|
||||||
commandlinereconstructed.append(lline)
|
commandlinereconstructed.append(lline)
|
||||||
|
|
||||||
sys.argv = commandlinereconstructed
|
sys.argv = commandlinereconstructed
|
||||||
options = getopts()
|
options = getopts(False)
|
||||||
# always use clean/verbose/silent flags from origoptions not mcf.status
|
# always use clean/verbose/silent flags from origoptions not mcf.status
|
||||||
options.clean = origoptions.clean
|
options.clean = origoptions.clean
|
||||||
options.verbose = origoptions.verbose
|
options.verbose = origoptions.verbose
|
||||||
|
@ -827,6 +848,10 @@ def sanitycheck(options):
|
||||||
if options.premirror:
|
if options.premirror:
|
||||||
checkmirror('premirror', options.premirror)
|
checkmirror('premirror', options.premirror)
|
||||||
|
|
||||||
|
def generate_bblayers(srcdir, append):
|
||||||
|
parse_collections(srcdir)
|
||||||
|
write_bblayers_conf(srcdir, append)
|
||||||
|
|
||||||
def configure_build(srcdir, options):
|
def configure_build(srcdir, options):
|
||||||
files = [
|
files = [
|
||||||
[os.path.join(srcdir, 'build-templates', 'mcf-status.in'), 'mcf.status' ],
|
[os.path.join(srcdir, 'build-templates', 'mcf-status.in'), 'mcf.status' ],
|
||||||
|
@ -888,8 +913,7 @@ def configure_build(srcdir, options):
|
||||||
logger.info('MCF-%s: Configuring build directory BUILD' % __version__)
|
logger.info('MCF-%s: Configuring build directory BUILD' % __version__)
|
||||||
for f in files:
|
for f in files:
|
||||||
process_file(f, replacements)
|
process_file(f, replacements)
|
||||||
parse_collections(srcdir)
|
generate_bblayers(srcdir, True)
|
||||||
write_bblayers_conf(srcdir)
|
|
||||||
logger.info('MCF-%s: Done configuring build directory BUILD' % __version__)
|
logger.info('MCF-%s: Done configuring build directory BUILD' % __version__)
|
||||||
|
|
||||||
echo_check_call('/bin/chmod a+x mcf.status', options.verbose)
|
echo_check_call('/bin/chmod a+x mcf.status', options.verbose)
|
||||||
|
@ -901,18 +925,26 @@ if __name__ == '__main__':
|
||||||
# Use the same timestamp for everything created by this invocation of mcf
|
# Use the same timestamp for everything created by this invocation of mcf
|
||||||
timestamp = strftime("%Y%m%d%H%M%S", gmtime())
|
timestamp = strftime("%Y%m%d%H%M%S", gmtime())
|
||||||
|
|
||||||
options = getopts()
|
# If the templates aren't present, then only we update the layers and generate conf/bblayers.conf using the configuration file
|
||||||
|
# (which must be specified with -f/--config-file).
|
||||||
|
srcdir = os.path.dirname(progname)
|
||||||
|
bblayers_only = not os.path.exists(os.path.join(srcdir, 'build-templates'))
|
||||||
|
|
||||||
|
options = getopts(bblayers_only)
|
||||||
|
|
||||||
if options.configfile:
|
if options.configfile:
|
||||||
srcdir = "."
|
srcdir = "."
|
||||||
configfile = options.configfile
|
configfile = options.configfile
|
||||||
else:
|
else:
|
||||||
srcdir = os.path.dirname(progname)
|
if bblayers_only:
|
||||||
configfile = os.path.join(srcdir, "weboslayers.py")
|
logger.error("Configuration file must be specified")
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
configfile = os.path.join(srcdir, "weboslayers.py")
|
||||||
|
|
||||||
abs_srcdir = os.path.abspath(srcdir)
|
abs_srcdir = os.path.abspath(srcdir)
|
||||||
|
|
||||||
if options.mcfcommand == 'update':
|
if options.mcfcommand == 'update' and not bblayers_only:
|
||||||
# recover current mcf state
|
# recover current mcf state
|
||||||
options = recover_current_mcf_state(srcdir, options)
|
options = recover_current_mcf_state(srcdir, options)
|
||||||
|
|
||||||
|
@ -921,16 +953,26 @@ if __name__ == '__main__':
|
||||||
if options.clean:
|
if options.clean:
|
||||||
enable_clean()
|
enable_clean()
|
||||||
|
|
||||||
read_mcfconfigfile(configfile)
|
read_mcfconfigfile(configfile, bblayers_only)
|
||||||
for M in options.MACHINE:
|
|
||||||
if M not in SUPPORTED_MACHINES:
|
if not bblayers_only:
|
||||||
logger.error("MACHINE argument '%s' isn't supported (does not appear in Machines in %s: '%s')" % (M, options.configfile, SUPPORTED_MACHINES))
|
for M in options.MACHINE:
|
||||||
sys.exit(1)
|
if M not in SUPPORTED_MACHINES:
|
||||||
|
logger.error("MACHINE argument '%s' isn't supported (does not appear in Machines in weboslayers.py '%s')" % (M, SUPPORTED_MACHINES))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
if options.mcfcommand != 'configure':
|
if options.mcfcommand != 'configure':
|
||||||
update_layers(srcdir)
|
update_layers(srcdir)
|
||||||
|
|
||||||
configure_build(srcdir, options)
|
if bblayers_only:
|
||||||
|
logger.info('MCF-%s: Generating conf/bblayers.conf' % __version__)
|
||||||
|
if not os.path.exists("conf"):
|
||||||
|
logger.error("'conf' subdirectory does not exist")
|
||||||
|
sys.exit(1)
|
||||||
|
generate_bblayers(abs_srcdir, False)
|
||||||
|
logger.info('MCF-%s: Done generating conf/bblayers.conf' % __version__)
|
||||||
|
else:
|
||||||
|
configure_build(srcdir, options)
|
||||||
|
sanitycheck(options)
|
||||||
|
|
||||||
sanitycheck(options)
|
|
||||||
logger.info('Done.')
|
logger.info('Done.')
|
||||||
|
|
Loading…
Reference in New Issue