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 <[email protected]>
>
> ---
>
> 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.
> +
> + PTXDIST_FORCE=1
> + mkdir -p "$(dirname "${PTXDIST_PTXCONFIG}")" &&
> + echo > "${PTXDIST_PTXCONFIG}" &&
touch?
> + do_select ptxconfig "${PTXDIST_PTXCONFIG}" &&
I'd like to avoid that. It should not be necessary with only one config.
> + 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.
> +
> + PTXDIST_FORCE=1
> + mkdir -p "$(dirname "${PTXDIST_PLATFORMCONFIG}")" &&
> + echo "PTXCONF_PLATFORM=\"${platformname}\"" >
> "${PTXDIST_PLATFORMCONFIG}" &&
> + do_select platformconfig "${PTXDIST_PLATFORMCONFIG}" &&
same as above.
> + do_config oldconfig platform
Why oldconfig here and alldefconfig above?
Michael
> +}
> --
> 2.24.0
>
>
> _______________________________________________
> ptxdist mailing list
> [email protected]
>
--
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
[email protected]