From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iVccB-0001AX-NP for ptxdist@pengutronix.de; Fri, 15 Nov 2019 15:30:23 +0100 Received: from rhi by ptx.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1iVccB-00066A-ET for ptxdist@pengutronix.de; Fri, 15 Nov 2019 15:30:23 +0100 Date: Fri, 15 Nov 2019 15:30:23 +0100 From: Roland Hieber Message-ID: <20191115143023.7nf5pknt55i74tyw@pengutronix.de> References: <20191114160116.20379-1-rhi@pengutronix.de> <20191114160116.20379-3-rhi@pengutronix.de> <20191115140940.GD1287@pengutronix.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20191115140940.GD1287@pengutronix.de> Subject: Re: [ptxdist] [PATCH 3/3] ptxdist: add 'init', 'init-platform' commands to create new configs List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: ptxdist@pengutronix.de Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ptxdist-bounces@pengutronix.de Sender: "ptxdist" To: ptxdist@pengutronix.de 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 > > > > --- > > > > 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 [] initialise a new BSP in the current directory > > + init-platform [] 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 ``, ``init-platform `` > > + 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? > > + 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. - Roland -- Roland Hieber, Pengutronix e.K. | r.hieber@pengutronix.de | Steuerwalder Str. 21 | https://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