mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
From: Michael Olbrich <m.olbrich@pengutronix.de>
To: ptxdist@pengutronix.de
Subject: Re: [ptxdist] [PATCH 3/3] ptxdist: add 'init', 'init-platform' commands to create new configs
Date: Sat, 16 Nov 2019 11:21:20 +0100	[thread overview]
Message-ID: <20191116102120.2mko7m6wncymple6@pengutronix.de> (raw)
In-Reply-To: <20191115143023.7nf5pknt55i74tyw@pengutronix.de>

On Fri, Nov 15, 2019 at 03:30:23PM +0100, Roland Hieber wrote:
> On Fri, Nov 15, 2019 at 03:09:40PM +0100, Michael Olbrich wrote:
> > On Thu, Nov 14, 2019 at 05:01:16PM +0100, Roland Hieber wrote:
> > > Add small helpers to start from scratch with a new ptxconfig and/or
> > > platformconfig. We do that by creating a standard directory structure,
> > > then creating a minimal config file, selecting it, and calling oldconfig
> > > on the created file while setting PTXDIST_FORCE to ignore all errors
> > > about it not being a valid configuration file.
> > > 
> > > When initialising a new BSP, create the platformconfig first so the
> > > selection of the ptxconfig does not complain about a missing
> > > platformconfig.
> > > 
> > > Signed-off-by: Roland Hieber <rhi@pengutronix.de>
> > > 
> > > ---
> > > 
> > > I was also thinking about using 'alldefconfig' instead of 'oldconfig' so
> > > that PTXdist does not ask so many questions for every package that can
> > > be enabled in the ptxconfig, but then several important settings get
> > > lost, like project name, toolchain/compiler version, compiler triplet
> > > etc. Maybe we can ask those up front instead and pre-prime the config
> > > accordingly, like it is already done now for the platform name in
> > > PLATFORM.
> > > ---
> > >  bin/ptxdist                  | 19 ++++++++++++
> > >  doc/ref_parameter.inc        |  5 ++++
> > >  scripts/lib/ptxd_lib_init.sh | 57 ++++++++++++++++++++++++++++++++++++
> > >  3 files changed, 81 insertions(+)
> > >  create mode 100644 scripts/lib/ptxd_lib_init.sh
> > > 
> > > diff --git a/bin/ptxdist b/bin/ptxdist
> > > index cd673a9f3dd6..e1e0f5f7503d 100755
> > > --- a/bin/ptxdist
> > > +++ b/bin/ptxdist
> > > @@ -938,6 +938,9 @@ PTXdist $(printf "%-24s" ${PTXDIST_VERSION_FULL}) Build System for Embedded Linu
> > >  
> > >  Setup and Project Actions:
> > >  
> > > +  init [<platformname>]		initialise a new BSP in the current directory
> > > +  init-platform [<name>]	initialise a new platform in the current BSP
> > > +
> > >    menu				enter main control menu
> > >  
> > >    setup				setup per-user preferences
> > > @@ -2035,6 +2038,22 @@ EOF
> > >  			do_${cmd}
> > >  			exit
> > >  			;;
> > > +		init)
> > > +			ptxd_lib_init_platform "$@" &&
> > > +			ptxd_lib_init &&
> > > +			ptxd_dialog_msgbox \
> > > +				"Adapt the new BSP to your needs by running:\n\n" \
> > > +				"    ptxdist menuconfig\n" \
> > > +				"    ptxdist menuconfig platform"
> > > +			exit
> > > +			;;
> > > +		init-platform)
> > > +			ptxd_lib_init_platform "$@" &&
> > > +			ptxd_dialog_msgbox \
> > > +				"Adapt the new platform to your needs by running:\n\n" \
> > > +				"    ptxdist menuconfig platform"
> > > +			exit
> > > +			;;
> > >  		image)
> > >  			if [ ${#} -eq 0 ]; then
> > >  				echo "No image given."
> > > diff --git a/doc/ref_parameter.inc b/doc/ref_parameter.inc
> > > index 74689b9d3cff..29203713f879 100644
> > > --- a/doc/ref_parameter.inc
> > > +++ b/doc/ref_parameter.inc
> > > @@ -1,6 +1,11 @@
> > >  Setup and Project Actions
> > >  ~~~~~~~~~~~~~~~~~~~~~~~~~
> > >  
> > > +``init <platformname>``, ``init-platform <platformname>``
> > > +  initialise a new BSP in the current directory, or add a new platform to the
> > > +  current BSP. This action creates all required config files, and then calls
> > > +  *menuconfig* on them, and can be used to start a new BSP from scratch.
> > > +
> > >  ``menu``
> > >    this starts a dialog based frontend for those who do not like typing
> > >    commands. It will gain us access to the most common parameters to
> > > diff --git a/scripts/lib/ptxd_lib_init.sh b/scripts/lib/ptxd_lib_init.sh
> > > new file mode 100644
> > > index 000000000000..a5ff71f557f9
> > > --- /dev/null
> > > +++ b/scripts/lib/ptxd_lib_init.sh
> > > @@ -0,0 +1,57 @@
> > > +#!/bin/bash
> > > +
> > > +ptxd_lib_init() {
> > > +	PTXDIST_PTXCONFIG="configs/ptxconfig"
> > > +
> > > +	if [ -z "${PTXDIST_FORCE}" ] && [ -e "${PTXDIST_PTXCONFIG}" ]; then
> > > +		echo -e \
> > > +			"error: the file '${PTXDIST_PTXCONFIG}' already exists,\n" \
> > > +			"       use '--force' to overwrite it."
> > > +		return 1
> > > +	fi
> > > +
> > > +	if [ -z "${PTXDIST_FORCE}" ] && [ -e "${PTXDIST_PTXCONFIG_DEFAULT}" ]; then
> > > +		ptxd_dialog_msgbox \
> > > +			"error: the file '${PTXDIST_PTXCONFIG_DEFAULT}' already exists,\n" \
> > > +			"       use '--force' to overwrite it."
> > > +		return 1
> > > +	fi
> > 
> > Check with '-h' as well, at least for PTXDIST_PTXCONFIG_DEFAULT. '-e' does
> > not match on broken symlinks.
> 
> Oh, right.
> 
> > > +
> > > +	PTXDIST_FORCE=1
> > > +	mkdir -p "$(dirname "${PTXDIST_PTXCONFIG}")" &&
> > > +	echo > "${PTXDIST_PTXCONFIG}" &&
> > 
> > touch?
> 
> Hmm, that was copied from ptxd_lib_init_platform(), but yes, could be
> a touch too if we stay with 'oldconfig' instead of 'alldefconfig' (see
> below).
> 
> > > +	do_select ptxconfig "${PTXDIST_PTXCONFIG}" &&
> > 
> > I'd like to avoid that. It should not be necessary with only one config.
> 
> Ah, I didn't fully realise that ptxdist chooses configs/ptxconfig
> automatically. Then we don't even need to check for the
> selected_ptxconfig symlink, I guess?

You need to test that. Having a selected_* link when something else was
explicitly used instead had some strange effects in the past. I'm not sure
if that's all fixed.

> > > +	do_config alldefconfig
> > > +}
> > > +
> > > +ptxd_lib_init_platform() {
> > > +	local platformname="$1"
> > > +	if [ -z "$platformname" ]; then
> > > +		read -p 'New platform name? ' platformname
> > > +	fi
> > > +	if [ -z "$platformname" ]; then
> > > +		echo "Platform name cannot be empty."
> > > +		return 1
> > > +	fi
> > > +	PTXDIST_PLATFORMCONFIG="configs/platform-${platformname}/platformconfig"
> > > +
> > > +	if [ -z "${PTXDIST_FORCE}" ] && [ -e "${PTXDIST_PLATFORMCONFIG}" ]; then
> > > +		ptxd_dialog_msgbox \
> > > +			"error: the file '${PTXDIST_PLATFORMCONFIG}' already exists,\n" \
> > > +			"       use '--force' to overwrite it."
> > > +		return 1
> > > +	fi
> > > +
> > > +	if [ -z "${PTXDIST_FORCE}" ] && [ -e "${PTXDIST_PLATFORMCONFIG_DEFAULT}" ]; then
> > > +		ptxd_dialog_msgbox \
> > > +			"error: the file '${PTXDIST_PLATFORMCONFIG_DEFAULT}' already exists,\n" \
> > > +			"       use '--force' to overwrite it."
> > > +		return 1
> > > +	fi
> > 
> > see above.
> 
> OK.
> 
> > > +
> > > +	PTXDIST_FORCE=1
> > > +	mkdir -p "$(dirname "${PTXDIST_PLATFORMCONFIG}")" &&
> > > +	echo "PTXCONF_PLATFORM=\"${platformname}\"" > "${PTXDIST_PLATFORMCONFIG}" &&
> > > +	do_select platformconfig "${PTXDIST_PLATFORMCONFIG}" &&
> > 
> > same as above.
> 
> OK.
> 
> > > +	do_config oldconfig platform
> > 
> > Why oldconfig here and alldefconfig above?
> 
> Because I sent the patch too hastily before catching the train... :)
> That was left over from my previous experiments with alldefconfig and
> oldconfig, see the note below the commit message above. I think I'd
> stick with 'oldconfig' for now (for both configs), even if that means
> pressing Enter a lot on all the available packages in ptxconfig. When we
> ask upfront about the "important" settings before doing 'alldefconfig',
> we would effectively implement the prompting part of kconfig in ptxdist,
> and I don't see the point for that.

The problem with oldconfig is, that it's hard to stop at the important
options. How about explicit prompts for stuff like vendor / project and the
have an actual defconfig for the rest?

It might be nice to have multiple defconfigs to choose from, but I'm
reluctant to do that, because without testing it'll be hard to maintain
something useful.

Michael

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

  reply	other threads:[~2019-11-16 10:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-14 16:01 [ptxdist] [PATCH 1/3] ptxdist: _get_config_ptx: fix --force logic Roland Hieber
2019-11-14 16:01 ` [ptxdist] [PATCH 2/3] platforms: toolchain: bump default toolchain version Roland Hieber
2019-11-14 16:01 ` [ptxdist] [PATCH 3/3] ptxdist: add 'init', 'init-platform' commands to create new configs Roland Hieber
2019-11-15 14:09   ` Michael Olbrich
2019-11-15 14:30     ` Roland Hieber
2019-11-16 10:21       ` Michael Olbrich [this message]
2019-11-27  9:37         ` Roland Hieber

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=20191116102120.2mko7m6wncymple6@pengutronix.de \
    --to=m.olbrich@pengutronix.de \
    --cc=ptxdist@pengutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox