From: Darren Hart <dvhart@linux.intel.com>
To: tom.zanussi@intel.com
Cc: yocto@yoctoproject.org
Subject: Re: [PATCH 2/5] yocto-layer: new script
Date: Wed, 19 Dec 2012 16:36:12 -0800 [thread overview]
Message-ID: <50D25D7C.5090906@linux.intel.com> (raw)
In-Reply-To: <82ce4e5c6166c96066a84df920cf0732e98ba3dc.1355766001.git.tom.zanussi@intel.com>
On 12/17/2012 09:51 AM, tom.zanussi@intel.com wrote:
> From: Tom Zanussi <tom.zanussi@intel.com>
>
> Implementation of the 'yocto-layer' command-line tool, for creating
> generic layers and listing their input properties.
No specific comments below, looks good.
Would the final version also include a removal of similar code from
yocto-bsp, such that yocto-bsp would call yocto-layer? I'm thinking
about reducing code duplication. I guess not as this is mostly just
argument parsing and all the logic is already abstracted into bsp.engine?
Thanks,
Darren
>
> Signed-off-by: Tom Zanussi <tom.zanussi@intel.com>
> ---
> scripts/yocto-layer | 142 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 142 insertions(+)
> create mode 100755 scripts/yocto-layer
>
> diff --git a/scripts/yocto-layer b/scripts/yocto-layer
> new file mode 100755
> index 0000000..f759275
> --- /dev/null
> +++ b/scripts/yocto-layer
> @@ -0,0 +1,142 @@
> +#!/usr/bin/env python
> +# ex:ts=4:sw=4:sts=4:et
> +# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
> +#
> +# Copyright (c) 2012, Intel Corporation.
> +# All rights reserved.
> +#
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License version 2 as
> +# published by the Free Software Foundation.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License along
> +# with this program; if not, write to the Free Software Foundation, Inc.,
> +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
> +#
> +# DESCRIPTION
> +# 'yocto-layer' is the Yocto Tool that helps users create a new Yocto
> +# layer. Invoking it without any arguments will display help screens
> +# for the 'yocto-layer' command and list the available 'yocto-layer'
> +# subcommands. Invoking a subcommand without any arguments will
> +# likewise display help screens for the specified subcommand. Please
> +# use that interface for detailed help.
> +#
> +# AUTHORS
> +# Tom Zanussi <tom.zanussi (at] intel.com>
> +#
> +
> +__version__ = "0.1.0"
> +
> +import os
> +import sys
> +import optparse
> +import logging
> +
> +scripts_path = os.path.abspath(os.path.dirname(os.path.abspath(sys.argv[0])))
> +lib_path = scripts_path + '/lib'
> +sys.path = sys.path + [lib_path]
> +
> +from bsp.help import *
> +from bsp.engine import *
> +
> +
> +def yocto_layer_create_subcommand(args, usage_str):
> + """
> + Command-line handling for layer creation. The real work is done by
> + bsp.engine.yocto_layer_create()
> + """
> + parser = optparse.OptionParser(usage = usage_str)
> +
> + parser.add_option("-o", "--outdir", dest = "outdir", action = "store",
> + help = "name of layer dir to create")
> + parser.add_option("-i", "--infile", dest = "properties_file", action = "store",
> + help = "name of file containing the values for layer input properties as a JSON file")
> + parser.add_option("-c", "--codedump", dest = "codedump", action = "store_true",
> + default = False, help = "dump the generated code to layergen.out")
> + (options, args) = parser.parse_args(args)
> +
> + if len(args) != 1:
> + logging.error("Wrong number of arguments, exiting\n")
> + parser.print_help()
> + sys.exit(1)
> +
> + layer_name = args[0]
> +
> + if options.outdir:
> + layer_output_dir = options.outdir
> + else:
> + layer_output_dir = "meta-" + layer_name
> +
> + yocto_layer_create(layer_name, scripts_path, layer_output_dir, options.codedump, options.properties_file)
> +
> +
> +def yocto_layer_list_subcommand(args, usage_str):
> + """
> + Command-line handling for listing available layer properties and
> + values. The real work is done by bsp.engine.yocto_layer_list()
> + """
> + parser = optparse.OptionParser(usage = usage_str)
> +
> + parser.add_option("-o", "--outfile", action = "store", dest = "properties_file",
> + help = "dump the possible values for layer properties to a JSON file")
> +
> + (options, args) = parser.parse_args(args)
> +
> + if not yocto_layer_list(args, scripts_path, options.properties_file):
> + logging.error("Bad list arguments, exiting\n")
> + parser.print_help()
> + sys.exit(1)
> +
> +
> +subcommands = {
> + "create": [yocto_layer_create_subcommand,
> + yocto_layer_create_usage,
> + yocto_layer_create_help],
> + "list": [yocto_layer_list_subcommand,
> + yocto_layer_list_usage,
> + yocto_layer_list_help],
> +}
> +
> +
> +def start_logging(loglevel):
> + logging.basicConfig(filname = 'yocto-layer.log', filemode = 'w', level=loglevel)
> +
> +
> +def main():
> + parser = optparse.OptionParser(version = "yocto-layer version %s" % __version__,
> + usage = yocto_layer_usage)
> +
> + parser.disable_interspersed_args()
> + parser.add_option("-D", "--debug", dest = "debug", action = "store_true",
> + default = False, help = "output debug information")
> +
> + (options, args) = parser.parse_args()
> +
> + loglevel = logging.INFO
> + if options.debug:
> + loglevel = logging.DEBUG
> + start_logging(loglevel)
> +
> + if len(args):
> + if args[0] == "help":
> + if len(args) == 1:
> + parser.print_help()
> + sys.exit(1)
> +
> + invoke_subcommand(args, parser, yocto_layer_help_usage, subcommands)
> +
> +
> +if __name__ == "__main__":
> + try:
> + ret = main()
> + except Exception:
> + ret = 1
> + import traceback
> + traceback.print_exc(5)
> + sys.exit(ret)
> +
>
--
Darren Hart
Intel Open Source Technology Center
Yocto Project - Technical Lead - Linux Kernel
next prev parent reply other threads:[~2012-12-20 0:36 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-17 17:51 [PATCH 0/5] RFC: new 'yocto-layer' tool for creating generic Yocto layers tom.zanussi
2012-12-17 17:51 ` [PATCH 1/5] scripts/lib/bsp/engine.py: add yocto_layer_create() tom.zanussi
2012-12-18 14:13 ` Philip Balister
2012-12-18 14:33 ` Tom Zanussi
2012-12-18 16:37 ` Philip Balister
2012-12-18 16:56 ` Tom Zanussi
2012-12-18 17:32 ` Philip Balister
2012-12-17 17:51 ` [PATCH 2/5] yocto-layer: new script tom.zanussi
2012-12-20 0:36 ` Darren Hart [this message]
2012-12-17 17:51 ` [PATCH 3/5] yocto-layer: add help/usage tom.zanussi
2012-12-17 17:51 ` [PATCH 4/5] yocto-layer: add 'layer' template data tom.zanussi
2012-12-20 0:40 ` Darren Hart
2012-12-20 16:23 ` Tom Zanussi
2012-12-20 16:29 ` Gary Thomas
2012-12-20 16:58 ` Tom Zanussi
2013-01-02 17:19 ` Darren Hart
2012-12-17 17:51 ` [PATCH 5/5] scripts/lib/bsp/engine.py: refactor bsp-creation code tom.zanussi
2012-12-20 0:41 ` Darren Hart
2012-12-20 0:34 ` [PATCH 0/5] RFC: new 'yocto-layer' tool for creating generic Yocto layers Darren Hart
2012-12-20 15:47 ` Tom Zanussi
2013-01-02 17:18 ` Darren Hart
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50D25D7C.5090906@linux.intel.com \
--to=dvhart@linux.intel.com \
--cc=tom.zanussi@intel.com \
--cc=yocto@yoctoproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.