mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] [PATCH 1/7] kernel: bump default version and md5sum
@ 2020-09-21 22:17 Roland Hieber
  2020-09-21 22:17 ` [ptxdist] [PATCH 2/7] platform: bump default toolchain version Roland Hieber
                   ` (6 more replies)
  0 siblings, 7 replies; 16+ messages in thread
From: Roland Hieber @ 2020-09-21 22:17 UTC (permalink / raw)
  To: ptxdist; +Cc: Roland Hieber

Provide reasonably recent default values for new BSPs.

Signed-off-by: Roland Hieber <rhi@pengutronix.de>
---
 platforms/kernel.in | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/platforms/kernel.in b/platforms/kernel.in
index 34d05c825929..7bcfac5d8f2d 100644
--- a/platforms/kernel.in
+++ b/platforms/kernel.in
@@ -41,11 +41,12 @@ config KERNEL_MODULES_INSTALL
 config KERNEL_VERSION
 	prompt "kernel version"
 	string
-	default "4.15"
+	default "5.8"
 
 config KERNEL_MD5
 	prompt "kernel source md5sum"
 	string
+	default "0e5c4c15266218ef26c50fac0016095b"
 
 choice
 	prompt "Image Type          "
-- 
2.28.0


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de
To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ptxdist] [PATCH 2/7] platform: bump default toolchain version
  2020-09-21 22:17 [ptxdist] [PATCH 1/7] kernel: bump default version and md5sum Roland Hieber
@ 2020-09-21 22:17 ` Roland Hieber
  2020-09-21 22:17 ` [ptxdist] [PATCH 3/7] kernel, barebox: add descriptive help text for md5sum config options Roland Hieber
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 16+ messages in thread
From: Roland Hieber @ 2020-09-21 22:17 UTC (permalink / raw)
  To: ptxdist; +Cc: Roland Hieber

Provide reasonably recent default values for new platforms.

Signed-off-by: Roland Hieber <rhi@pengutronix.de>
---
 platforms/toolchain.in | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/platforms/toolchain.in b/platforms/toolchain.in
index 026e4395c3ad..86e624329afd 100644
--- a/platforms/toolchain.in
+++ b/platforms/toolchain.in
@@ -5,7 +5,7 @@ menu "toolchain                     "
 config CROSSCHAIN_VENDOR
 	string
 	prompt "check for specific toolchain vendor"
-	default "OSELAS.Toolchain-2019.09"
+	default "OSELAS.Toolchain-2020.08"
 	help
 	  Add here an unique vendor string to ensure this project will
 	  be build with the correct toolchain.
@@ -19,7 +19,7 @@ config CROSSCHAIN_VENDOR
 config CROSSCHAIN_CHECK
 	string
 	prompt "check for specific gcc version"
-	default "9.2.1"
+	default "10.2.1"
 	help
 	  PTXdist calls your cross compiler with -dumpversion and
 	  compares the output with this string. This should help
@@ -47,7 +47,7 @@ if LIBC_GLIBC
 config GLIBC_VERSION
 	string
 	prompt "glibc version"
-	default "2.30"
+	default "2.32"
 	help
 	  Specify the glibc version this BSP shall be built with. This information
 	  is used to guess the toolchain path if you use "ptxdist toolchain"
-- 
2.28.0


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de
To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ptxdist] [PATCH 3/7] kernel, barebox: add descriptive help text for md5sum config options
  2020-09-21 22:17 [ptxdist] [PATCH 1/7] kernel: bump default version and md5sum Roland Hieber
  2020-09-21 22:17 ` [ptxdist] [PATCH 2/7] platform: bump default toolchain version Roland Hieber
@ 2020-09-21 22:17 ` Roland Hieber
  2020-09-21 22:17 ` [ptxdist] [PATCH 4/7] image-root-tgz: build by default, and add a help text Roland Hieber
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 16+ messages in thread
From: Roland Hieber @ 2020-09-21 22:17 UTC (permalink / raw)
  To: ptxdist; +Cc: Roland Hieber

Signed-off-by: Roland Hieber <rhi@pengutronix.de>
---
 platforms/barebox.in     | 3 +++
 platforms/barebox_mlo.in | 3 +++
 platforms/kernel.in      | 3 +++
 3 files changed, 9 insertions(+)

diff --git a/platforms/barebox.in b/platforms/barebox.in
index 526d7ede42ad..70d175fb5a03 100644
--- a/platforms/barebox.in
+++ b/platforms/barebox.in
@@ -30,6 +30,9 @@ config BAREBOX_VERSION
 config BAREBOX_MD5
 	prompt "barebox source md5sum"
 	string
+	help
+	  To ensure integrity of the downloaded source tarball, fill in its
+	  MD5 sum here.
 
 config BAREBOX_CONFIG
 	prompt "config file"
diff --git a/platforms/barebox_mlo.in b/platforms/barebox_mlo.in
index 8cdea75f7567..cb7dac1ec9ba 100644
--- a/platforms/barebox_mlo.in
+++ b/platforms/barebox_mlo.in
@@ -19,6 +19,9 @@ config BAREBOX_MLO_MD5
 	prompt "barebox source md5sum"		if !BAREBOX
 	string
 	default "${PTXCONF_BAREBOX_MD5}"	if BAREBOX
+	help
+	  To ensure integrity of the downloaded source tarball, fill in its
+	  MD5 sum here.
 
 config BAREBOX_MLO_ARCH_STRING
 	string
diff --git a/platforms/kernel.in b/platforms/kernel.in
index 7bcfac5d8f2d..88dae947f2ad 100644
--- a/platforms/kernel.in
+++ b/platforms/kernel.in
@@ -47,6 +47,9 @@ config KERNEL_MD5
 	prompt "kernel source md5sum"
 	string
 	default "0e5c4c15266218ef26c50fac0016095b"
+	help
+	  To ensure integrity of the downloaded source tarball, fill in its
+	  MD5 sum here.
 
 choice
 	prompt "Image Type          "
-- 
2.28.0


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de
To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ptxdist] [PATCH 4/7] image-root-tgz: build by default, and add a help text
  2020-09-21 22:17 [ptxdist] [PATCH 1/7] kernel: bump default version and md5sum Roland Hieber
  2020-09-21 22:17 ` [ptxdist] [PATCH 2/7] platform: bump default toolchain version Roland Hieber
  2020-09-21 22:17 ` [ptxdist] [PATCH 3/7] kernel, barebox: add descriptive help text for md5sum config options Roland Hieber
@ 2020-09-21 22:17 ` Roland Hieber
  2020-09-22  8:17   ` Michael Olbrich
  2020-09-21 22:17 ` [ptxdist] [PATCH 5/7] ptxdist: implement 'defconfig' commands for kconfig packages Roland Hieber
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Roland Hieber @ 2020-09-21 22:17 UTC (permalink / raw)
  To: ptxdist; +Cc: Roland Hieber

The root.tgz is needed for all other rootfs images, so it makes sense to
build it by default. Also provide at least one image by default for
newly added platforms.

Signed-off-by: Roland Hieber <rhi@pengutronix.de>
---
 platforms/image-root-tgz.in | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/platforms/image-root-tgz.in b/platforms/image-root-tgz.in
index c325209ded6d..cfd4f3f83600 100644
--- a/platforms/image-root-tgz.in
+++ b/platforms/image-root-tgz.in
@@ -2,9 +2,10 @@
 
 menuconfig IMAGE_ROOT_TGZ
 	tristate
+	default y
 	prompt "Generate images/root.tgz      "
 	help
-	  FIXME
+	  Build a tar.gz archive containing the root file system.
 
 if IMAGE_ROOT_TGZ
 
-- 
2.28.0


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de
To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ptxdist] [PATCH 5/7] ptxdist: implement 'defconfig' commands for kconfig packages
  2020-09-21 22:17 [ptxdist] [PATCH 1/7] kernel: bump default version and md5sum Roland Hieber
                   ` (2 preceding siblings ...)
  2020-09-21 22:17 ` [ptxdist] [PATCH 4/7] image-root-tgz: build by default, and add a help text Roland Hieber
@ 2020-09-21 22:17 ` Roland Hieber
  2020-09-22  8:26   ` Michael Olbrich
  2020-09-21 22:17 ` [ptxdist] [PATCH 6/7] rules: move magic symbol into rules/ptxdist-version.in Roland Hieber
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Roland Hieber @ 2020-09-21 22:17 UTC (permalink / raw)
  To: ptxdist; +Cc: Roland Hieber

The current process to generate a kernel .config file from a defconfig
is a bit cumbersome:

  $ ptxdist extract kernel
  $ cd platform-foo/build-target/linux-<version>
  $ make ARCH=... CROSS_COMPILE=... foo_defconfig
  $ cp .config ../../../configs/platform-foo/kernelconfig

All kernel and barebox rules and templates already support the
<package>_%config target since commit b0f9f2fe33ca9027a554 (2020-08-07,
"barebox, kernel: enable use of {allyes, allno, allmod, alldef,
rand}config"), so we only need to wire them into the command line
parser, and then we can easily get a defconfig like this:

  $ ptxdist defconfig kernel                # most ARCHs
  $ ptxdist imx_v6_v7_defconfig kernel      # e.g. with ARCH=arm

Signed-off-by: Roland Hieber <rhi@pengutronix.de>
---
 bin/ptxdist           | 15 ++++++++++++++-
 doc/ref_parameter.rst |  9 +++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/bin/ptxdist b/bin/ptxdist
index 0d5e4328e1d6..c2cf744f70a8 100755
--- a/bin/ptxdist
+++ b/bin/ptxdist
@@ -705,6 +705,9 @@ Setup and Project Actions:
 
   menuconfig barebox		configure the bootloader Barebox
 
+  [<prefix>]defconfig [<pkg>]	generate a default config file for <pkg>
+				e.g.: ptxdist multi_v7_defconfig kernel
+
   oldconfig			run 'make oldconfig' on ptxconfig file
   allmodconfig			run 'make allmodconfig' on ptxconfig file
   allyesconfig			run 'make allyesconfig' on ptxconfig file
@@ -1267,6 +1270,16 @@ do_config()
 	case "${config}" in
 	menuconfig|nconfig|oldconfig|all*config|randconfig)
 		;;
+	*defconfig)
+		case "${part}" in
+			"ptx"|"ptxdist"|""|"setup"|"platform"|"board"|"user"|"collection")
+				echo
+				echo "${PTXDIST_LOG_PROMPT}error: cannot do a '${config}' for part '${part}'"
+				echo
+				exit 1
+				;;
+		esac
+		;;
 	*)
 		echo
 		echo "${PTXDIST_LOG_PROMPT}error: invalid use of '${FUNCNAME} ${@}'"
@@ -1625,7 +1638,7 @@ parse_second()
 
 ######## *config, *setup, toolchain
 
-		menuconfig|nconfig|oldconfig|allmodconfig|allyesconfig|allnoconfig|alldefconfig|randconfig)
+		menuconfig|nconfig|oldconfig|allmodconfig|allyesconfig|allnoconfig|*defconfig|randconfig)
 			do_config "${cmd}" "${@}"
 			exit
 			;;
diff --git a/doc/ref_parameter.rst b/doc/ref_parameter.rst
index 1d54fa4b4428..ac1e06c5335e 100644
--- a/doc/ref_parameter.rst
+++ b/doc/ref_parameter.rst
@@ -95,6 +95,15 @@ Setup and Project Actions
   functionality as ``menuconfig``. It can be used instead of ``menuconfig``
   for all the component described above.
 
+``[<prefix>]defconfig [<package>]``
+  generate a default config file for kconfig-based packages (kernel, barebox).
+  The ``[<prefix>]`` can be given optionally to use a specific defconfig file,
+  which depends on the respective package and the architecture.
+  Examples::
+
+    $ ptxdist defconfig kernel                # most ARCHs
+    $ ptxdist imx_v6_v7_defconfig kernel      # e.g. for ARCH=arm
+
 ``oldconfig [<component>]``, ``allmodconfig [<component>]``, ``allyesconfig [<component>]``, ``allnoconfig [<component>]``, ``alldefconfig [<component>]``, ``randconfig [<component>]``
   this action will run the corresponding kconfig action for the specified
   component. ``oldconfig`` will prompt for all new options.
-- 
2.28.0


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de
To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ptxdist] [PATCH 6/7] rules: move magic symbol into rules/ptxdist-version.in
  2020-09-21 22:17 [ptxdist] [PATCH 1/7] kernel: bump default version and md5sum Roland Hieber
                   ` (3 preceding siblings ...)
  2020-09-21 22:17 ` [ptxdist] [PATCH 5/7] ptxdist: implement 'defconfig' commands for kconfig packages Roland Hieber
@ 2020-09-21 22:17 ` Roland Hieber
  2020-09-21 22:17 ` [ptxdist] [PATCH 7/7] ptxdist: add 'init' commands to create new configs Roland Hieber
  2020-09-22  8:13 ` [ptxdist] [PATCH 1/7] kernel: bump default version and md5sum Michael Olbrich
  6 siblings, 0 replies; 16+ messages in thread
From: Roland Hieber @ 2020-09-21 22:17 UTC (permalink / raw)
  To: ptxdist; +Cc: Roland Hieber

Inspired by platforms/platform.in, this makes it possible to re-use the
magic symbol in a slimmed-down kconfig menu.

Signed-off-by: Roland Hieber <rhi@pengutronix.de>
---
 rules/Kconfig            | 5 -----
 rules/ptxdist-version.in | 5 +++++
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/rules/Kconfig b/rules/Kconfig
index 1e40b5b08298..de3156c256ed 100644
--- a/rules/Kconfig
+++ b/rules/Kconfig
@@ -5,11 +5,6 @@
 
 source "generated/ptxdist_version.in"
 
-config _ptxconfig_MAGIC__
-	bool
-	option modules
-	default y
-
 comment "--------- Host Options -------------"
 
 menu "PTXdist Options               "
diff --git a/rules/ptxdist-version.in b/rules/ptxdist-version.in
index af4907e8f26a..8ab8bcaaac73 100644
--- a/rules/ptxdist-version.in
+++ b/rules/ptxdist-version.in
@@ -3,3 +3,8 @@
 config CONFIGFILE_VERSION
 	string
 	default "$(PTXDIST_VERSION_FULL)"
+
+config _ptxconfig_MAGIC__
+	bool
+	option modules
+	default y
-- 
2.28.0


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de
To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [ptxdist] [PATCH 7/7] ptxdist: add 'init' commands to create new configs
  2020-09-21 22:17 [ptxdist] [PATCH 1/7] kernel: bump default version and md5sum Roland Hieber
                   ` (4 preceding siblings ...)
  2020-09-21 22:17 ` [ptxdist] [PATCH 6/7] rules: move magic symbol into rules/ptxdist-version.in Roland Hieber
@ 2020-09-21 22:17 ` Roland Hieber
  2020-09-22  9:46   ` Michael Olbrich
  2020-09-22  8:13 ` [ptxdist] [PATCH 1/7] kernel: bump default version and md5sum Michael Olbrich
  6 siblings, 1 reply; 16+ messages in thread
From: Roland Hieber @ 2020-09-21 22:17 UTC (permalink / raw)
  To: ptxdist; +Cc: Roland Hieber

The goal here is to give users a way to create a working BSP or platform
from scratch by asking only a minimal set of relevant questions and
letting the user press Enter about 15 times, instead of asking every
question in the whole platform and ptxconfig menu, which would require
pressing Enter about 428 times.

For that, we create two separate Kconfig menus, rules/Kconfig-init for
the ptxconfig, and platforms/Kconfig-init for the platformconfig, which
include only the relevant .in files from the full menus. Still, some
options from these .in files can be set to reasonable defaults for new
BSPs or platforms, which is done with two new defconfig files instead of
further outsourcing the relevant config options into single .in files.

With the 'init' subcommand, PTXdist first creates a standard directory
structure under configs/ if necessary, then creates a minimal config
file from the respective defconfig, and finally calls kconfig on the
respective Kconfig-init menu, asking the user for the remaining config
options. A silenced oldconfig run on the full menu file then takes care
to set all other config options to their defaults.

Signed-off-by: Roland Hieber <rhi@pengutronix.de>
---
 bin/ptxdist                     | 46 ++++++++++++++++
 doc/ref_parameter.rst           |  5 ++
 platforms/Kconfig-init          | 13 +++++
 platforms/init_defconfig        | 18 +++++++
 rules/Kconfig-init              | 62 +++++++++++++++++++++
 rules/init_defconfig            | 21 ++++++++
 rules/initmethod.in             |  3 ++
 scripts/lib/ptxd_lib_init.sh    | 96 +++++++++++++++++++++++++++++++++
 scripts/lib/ptxd_lib_kconfig.sh | 10 ++++
 9 files changed, 274 insertions(+)
 create mode 100644 platforms/Kconfig-init
 create mode 100644 platforms/init_defconfig
 create mode 100644 rules/Kconfig-init
 create mode 100644 rules/init_defconfig
 create mode 100644 scripts/lib/ptxd_lib_init.sh

diff --git a/bin/ptxdist b/bin/ptxdist
index c2cf744f70a8..a3d2f0deef56 100755
--- a/bin/ptxdist
+++ b/bin/ptxdist
@@ -687,6 +687,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
@@ -1803,6 +1806,49 @@ EOF
 			do_${cmd}
 			exit
 			;;
+		init)
+			local do_ptxconfig=1
+			if [ "$1" = "platform" ]; then
+				shift
+				do_ptxconfig=
+			fi
+
+			local platform="$1"
+			if [ -z "$platform" ]; then
+				echo
+				echo "${PTXDIST_LOG_PROMPT}error: Please specify a platform name."
+				echo
+				exit 1
+			fi
+
+			PTXDIST_PLATFORMCONFIG="configs/platform-${platform}/platformconfig"
+			PTXDIST_PTXCONFIG="configs/ptxconfig"
+
+			# abort early
+			ptxd_lib_init_platform_check &&
+			if [ -n "$do_ptxconfig" ]; then
+				ptxd_lib_init_check
+			fi &&
+
+			ptxd_lib_init_platform "${platform}" &&
+			if [ -n "$do_ptxconfig" ]; then
+				ptxd_lib_init
+			fi &&
+
+			if [ -n "$do_ptxconfig" ]; then
+				ptxd_dialog_msgbox \
+					"Adapt the new BSP to your needs by running:\n\n" \
+					"    ptxdist menuconfig\n" \
+					"    ptxdist menuconfig platform\n" \
+					"    ptxdist menuconfig kernel"
+			else
+				ptxd_dialog_msgbox \
+					"Adapt the new platform to your needs by running:\n\n" \
+					"    ptxdist menuconfig platform\n" \
+					"    ptxdist menuconfig kernel"
+			fi
+			exit
+			;;
 		image)
 			PTXDIST_OPTIMIZE_IO=true
 			if [ ${#} -eq 0 ]; then
diff --git a/doc/ref_parameter.rst b/doc/ref_parameter.rst
index ac1e06c5335e..edd489af831f 100644
--- a/doc/ref_parameter.rst
+++ b/doc/ref_parameter.rst
@@ -12,6 +12,11 @@ PTXdist is a command line tool, which is basically called as:
 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/platforms/Kconfig-init b/platforms/Kconfig-init
new file mode 100644
index 000000000000..9e42556d77d3
--- /dev/null
+++ b/platforms/Kconfig-init
@@ -0,0 +1,13 @@
+#
+# a kconfig menu structure that asks only a minimal amount of questions to
+# quickly get started with a new platform
+#
+source "generated/platform_version.in"
+source "platforms/architecture.in"
+source "platforms/toolchain.in"
+
+# dependencies for kernel rule:
+source "generated/hosttools_noprompt.in"
+source "generated/hosttools_platform.in"
+
+source "platforms/kernel.in"
diff --git a/platforms/init_defconfig b/platforms/init_defconfig
new file mode 100644
index 000000000000..5e44c536f314
--- /dev/null
+++ b/platforms/init_defconfig
@@ -0,0 +1,18 @@
+PTXCONF_PLATFORM_VERSION="-${PTXDIST_BSP_AUTOVERSION}"
+PTXCONF_COMPILER_PREFIX_KERNEL="${PTXCONF_COMPILER_PREFIX}"
+PTXCONF_COMPILER_PREFIX_BOOTLOADER="${PTXCONF_COMPILER_PREFIX}"
+PTXCONF_LIBC_GLIBC=y
+# PTXCONF_LIBC_UCLIBC is not set
+PTXCONF_KERNEL=y
+# PTXCONF_KERNEL_MODULES is not set
+# PTXCONF_KERNEL_ZSTD is not set
+# PTXCONF_KERNEL_XZ is not set
+# PTXCONF_KERNEL_LZOP is not set
+# PTXCONF_KERNEL_LZ4 is not set
+# PTXCONF_KERNEL_OPENSSL is not set
+# PTXCONF_KERNEL_LIBELF is not set
+# PTXCONF_KERNEL_GCC_PLUGINS is not set
+# PTXCONF_KERNEL_CONFIG_BASE_VERSION is not set
+PTXCONF_KERNEL_SERIES="series"
+PTXCONF_KERNEL_CONFIG="kernelconfig-${PTXCONF_KERNEL_VERSION}"
+PTXCONF_KERNEL_EXTRA_MAKEVARS=""
diff --git a/rules/Kconfig-init b/rules/Kconfig-init
new file mode 100644
index 000000000000..2355d070de9b
--- /dev/null
+++ b/rules/Kconfig-init
@@ -0,0 +1,62 @@
+#
+# a kconfig menu structure that asks only a minimal amount of questions to
+# quickly get started with a new BSP
+#
+source "rules/ptxdist-dgen.in"
+source "rules/ptxdist-version.in"
+source "generated/ptxdist_options.in"
+
+source "rules/project-name.in"
+
+#
+# stubs for options that we want to ask for or enable by default, but not ask
+# for all their suboptions
+#
+
+config BUSYBOX
+	default y
+	bool
+
+# busybox installs init, poweroff, halt etc. by default. This conflicts with
+# systemd, but since busybox brings its own kconfig menu in-tree, we cannot
+# easily influence its defaults. Therefore we first disable those options in
+# init_defconfig, and explicitely select them when needed.
+# Note: these option need to have a prompt, otherwise kconfig doesn't write them
+# to the config file if they are disabled, and busybox's default will kick in.
+config BUSYBOX_HALT
+	bool "busybox /usr/sbin/halt"
+config BUSYBOX_INIT
+	bool "busybox /usr/sbin/init"
+config BUSYBOX_POWEROFF
+	bool "busybox /usr/sbin/poweroff"
+config BUSYBOX_REBOOT
+	bool "busybox /usr/sbin/reboot"
+config BUSYBOX_RUNLEVEL
+	bool "busybox /usr/sbin/runlevel"
+
+choice
+	prompt "init method"
+	default INITMETHOD_SYSTEMD
+
+	config INITMETHOD_BBINIT
+		bool
+		prompt "busybox init    "
+		select BUSYBOX_HALT
+		select BUSYBOX_INIT
+		select BUSYBOX_POWEROFF
+		select BUSYBOX_REBOOT
+		select BUSYBOX_RUNLEVEL
+
+	config INITMETHOD_SYSTEMD
+		bool
+		prompt "systemd         "
+
+	config INITMETHOD_INITRAMFS
+		bool
+		prompt "initramfs init  "
+		select BUSYBOX_HALT
+		select BUSYBOX_INIT
+		select BUSYBOX_POWEROFF
+		select BUSYBOX_REBOOT
+		select BUSYBOX_RUNLEVEL
+endchoice
diff --git a/rules/init_defconfig b/rules/init_defconfig
new file mode 100644
index 000000000000..9fa9ab00a60b
--- /dev/null
+++ b/rules/init_defconfig
@@ -0,0 +1,21 @@
+# PTXCONF_ALLYES is not set
+# PTXCONF_BROKEN is not set
+PTXCONF_FIX_PERMISSIONS=y
+PTXCONF_PROJECT_VERSION="-${PTXDIST_BSP_AUTOVERSION}"
+# PTXCONF_PROJECT_CREATE_DEVPKGS is not set
+# PTXCONF_PROJECT_USE_DEVPKGS is not set
+PTXCONF_PROJECT_DEVPKGDIR=""
+PTXCONF_PROJECT_DEVMIRROR=""
+# PTXCONF_PROJECT_CHECK_LICENSES is not set
+PTXCONF_REPRODUCIBLE_TIMESTAMP_PTXDIST=y
+# PTXCONF_REPRODUCIBLE_TIMESTAMP_TOOLCHAIN is not set
+# PTXCONF_REPRODUCIBLE_TIMESTAMP_CUSTOM is not set
+# PTXCONF_REPRODUCIBLE_TIMESTAMP_STRING is not set
+PTXCONF_DEBUG_PACKAGES=y
+# initmethod will enable the following busybox tools if needed:
+# PTXCONF_BUSYBOX_HALT is not set
+# PTXCONF_BUSYBOX_INIT is not set
+# PTXCONF_BUSYBOX_POWEROFF is not set
+# PTXCONF_BUSYBOX_REBOOT is not set
+# PTXCONF_BUSYBOX_RUNLEVEL is not set
+# PTXCONF_STAGING is not set
diff --git a/rules/initmethod.in b/rules/initmethod.in
index b8c0b9f97b30..604fae3b4f7b 100644
--- a/rules/initmethod.in
+++ b/rules/initmethod.in
@@ -10,6 +10,9 @@ menuconfig INITMETHOD
 if INITMETHOD
 
 choice
+	#
+	# NOTE: if you add options here, also add them to rules/init_defconfig
+	#
 	prompt "init method"
 	default INITMETHOD_SYSTEMD
 
diff --git a/scripts/lib/ptxd_lib_init.sh b/scripts/lib/ptxd_lib_init.sh
new file mode 100644
index 000000000000..54fcb4d27eee
--- /dev/null
+++ b/scripts/lib/ptxd_lib_init.sh
@@ -0,0 +1,96 @@
+#!/bin/bash
+
+ptxd_lib_init_check() {
+	if [ -z "${PTXDIST_PTXCONFIG}" ]; then
+		echo
+		echo "${PTXDIST_LOG_PROMPT}error: cannot create empty ptxconfig file."
+		echo
+		return 1
+	fi
+
+	if [ -z "${PTXDIST_FORCE}" ] && [ -e "${PTXDIST_PTXCONFIG}" ]; then
+		echo
+		echo "${PTXDIST_LOG_PROMPT}error: the file '${PTXDIST_PTXCONFIG}' already exists,"
+		echo "${PTXDIST_LOG_PROMPT}       use '--force' to overwrite it."
+		echo
+		return 1
+	fi
+
+	if [ -z "${PTXDIST_FORCE}" ] && [ -e "${PTXDIST_PTXCONFIG_DEFAULT}" ]; then
+		echo
+		echo "${PTXDIST_LOG_PROMPT}error: the file '${PTXDIST_PTXCONFIG_DEFAULT}' already exists,"
+		echo "${PTXDIST_LOG_PROMPT}       use '--force' to overwrite it."
+		echo
+		return 1
+	fi
+}
+export -f ptxd_lib_init_check
+
+ptxd_lib_init() {
+	ptxd_lib_init_check &&
+
+	mkdir -p "$(dirname "${PTXDIST_PTXCONFIG}")" &&
+	cat "${PTXDIST_TOPDIR}/rules/init_defconfig" > "${PTXDIST_PTXCONFIG}" &&
+
+	PTXDIST_FORCE=true do_select ptxconfig "${PTXDIST_PTXCONFIG}" &&
+
+	# only ask the important questions first, then do silentdefconfig for
+	# all other options
+	PTXDIST_DEP_TARGET="all" ptxd_kconfig oldconfig "init-ptx" &&
+
+	# ... then do a silent defconfig for all other defaults
+	PTXDIST_DEP_TARGET="all" PTXDIST_FORCE=true \
+		yes '' | ptxd_kconfig oldconfig ptx > /dev/null
+}
+export -f ptxd_lib_init
+
+ptxd_lib_init_platform_check() {
+	if [ -z "${PTXDIST_PLATFORMCONFIG}" ]; then
+		echo
+		echo "${PTXDIST_LOG_PROMPT}error: cannot create empty platformconfig file."
+		echo
+		return 1
+	fi
+
+	if [ -z "${PTXDIST_FORCE}" ] && [ -e "${PTXDIST_PLATFORMCONFIG}" ]; then
+		echo
+		echo "${PTXDIST_LOG_PROMPT}error: the file '${PTXDIST_PLATFORMCONFIG}' already exists,"
+		echo "${PTXDIST_LOG_PROMPT}       use '--force' to overwrite it."
+		echo
+		return 1
+	fi
+
+	if [ -z "${PTXDIST_FORCE}" ] && [ -e "${PTXDIST_PLATFORMCONFIG_DEFAULT}" ]; then
+		echo
+		echo "${PTXDIST_LOG_PROMPT}error: the file '${PTXDIST_PLATFORMCONFIG_DEFAULT}' already exists,"
+		echo "${PTXDIST_LOG_PROMPT}       use '--force' to overwrite it."
+		echo
+		return 1
+	fi
+}
+export -f ptxd_lib_init_platform_check
+
+ptxd_lib_init_platform() {
+	local platformname="$1"
+	ptxd_lib_init_platform_check &&
+
+	mkdir -p "$(dirname "${PTXDIST_PLATFORMCONFIG}")" &&
+
+	# pre-prime with defaults
+	echo "PTXCONF_PLATFORM=\"${platformname}\"" > "${PTXDIST_PLATFORMCONFIG}" &&
+	cat "${PTXDIST_TOPDIR}/platforms/init_defconfig" >> "${PTXDIST_PLATFORMCONFIG}" &&
+
+	# pretend we have a toolchain, otherwise do_select will try to
+	# autodetect it from an incomplete platformconfig
+	PTX_toolchain_SET=true PTXDIST_FORCE=true \
+		do_select platformconfig "${PTXDIST_PLATFORMCONFIG}" &&
+	
+	# only ask the important questions first...
+	PTXDIST_DEP_TARGET="all" \
+		ptxd_kconfig oldconfig init-platform &&
+
+	# ... then do a silent defconfig for all other defaults
+	PTXDIST_DEP_TARGET="all" PTXDIST_FORCE=true \
+		yes '' | ptxd_kconfig oldconfig platform > /dev/null
+}
+export -f ptxd_lib_init_platform
diff --git a/scripts/lib/ptxd_lib_kconfig.sh b/scripts/lib/ptxd_lib_kconfig.sh
index ca56a65a19c3..58f45e056182 100644
--- a/scripts/lib/ptxd_lib_kconfig.sh
+++ b/scripts/lib/ptxd_lib_kconfig.sh
@@ -687,11 +687,21 @@ ptxd_kconfig() {
 	file_kconfig="${ptxd_reply}"
 	file_dotconfig="${PTXDIST_PTXCONFIG}"
 	;;
+    init-ptx)
+	part="ptx"
+	file_kconfig="rules/Kconfig-init"
+	file_dotconfig="${PTXDIST_PTXCONFIG}"
+	;;
     platform)
 	ptxd_in_path PTXDIST_PATH_LAYERS "platforms/Kconfig"
 	file_kconfig="${ptxd_reply}"
 	file_dotconfig="${PTXDIST_PLATFORMCONFIG}"
 	;;
+    init-platform)
+	part="platform"
+	file_kconfig="platforms/Kconfig-init"
+	file_dotconfig="${PTXDIST_PLATFORMCONFIG}"
+	;;
     collection)
 	file_dotconfig="${PTXDIST_PTXCONFIG}"
 	ptxd_normalize_config
-- 
2.28.0


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de
To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [ptxdist] [PATCH 1/7] kernel: bump default version and md5sum
  2020-09-21 22:17 [ptxdist] [PATCH 1/7] kernel: bump default version and md5sum Roland Hieber
                   ` (5 preceding siblings ...)
  2020-09-21 22:17 ` [ptxdist] [PATCH 7/7] ptxdist: add 'init' commands to create new configs Roland Hieber
@ 2020-09-22  8:13 ` Michael Olbrich
  2020-09-22  9:17   ` Roland Hieber
  6 siblings, 1 reply; 16+ messages in thread
From: Michael Olbrich @ 2020-09-22  8:13 UTC (permalink / raw)
  To: ptxdist

On Tue, Sep 22, 2020 at 12:17:22AM +0200, Roland Hieber wrote:
> Provide reasonably recent default values for new BSPs.
> 
> Signed-off-by: Roland Hieber <rhi@pengutronix.de>
> ---
>  platforms/kernel.in | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/platforms/kernel.in b/platforms/kernel.in
> index 34d05c825929..7bcfac5d8f2d 100644
> --- a/platforms/kernel.in
> +++ b/platforms/kernel.in
> @@ -41,11 +41,12 @@ config KERNEL_MODULES_INSTALL
>  config KERNEL_VERSION
>  	prompt "kernel version"
>  	string
> -	default "4.15"
> +	default "5.8"
>  
>  config KERNEL_MD5
>  	prompt "kernel source md5sum"
>  	string
> +	default "0e5c4c15266218ef26c50fac0016095b"

Hmmm, I'm not sure I like this. We really don't want to people to use v5.8
here, without thinking about it. They should use the latest stable version.
And we cannot keep up with that here anyways.

Michael

>  
>  choice
>  	prompt "Image Type          "
> -- 
> 2.28.0
> 
> 
> _______________________________________________
> ptxdist mailing list
> ptxdist@pengutronix.de
> To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de
> 

-- 
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
To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [ptxdist] [PATCH 4/7] image-root-tgz: build by default, and add a help text
  2020-09-21 22:17 ` [ptxdist] [PATCH 4/7] image-root-tgz: build by default, and add a help text Roland Hieber
@ 2020-09-22  8:17   ` Michael Olbrich
  2020-09-22  9:08     ` Roland Hieber
  0 siblings, 1 reply; 16+ messages in thread
From: Michael Olbrich @ 2020-09-22  8:17 UTC (permalink / raw)
  To: ptxdist; +Cc: Roland Hieber

On Tue, Sep 22, 2020 at 12:17:25AM +0200, Roland Hieber wrote:
> The root.tgz is needed for all other rootfs images, so it makes sense to
> build it by default. Also provide at least one image by default for
> newly added platforms.

No. Unused default stuff is never disabled unless it actually breaks
things. So in BSPs that don't actually use this, the image will probably
built anyways and just wastes space and time.

Michael

> Signed-off-by: Roland Hieber <rhi@pengutronix.de>
> ---
>  platforms/image-root-tgz.in | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/platforms/image-root-tgz.in b/platforms/image-root-tgz.in
> index c325209ded6d..cfd4f3f83600 100644
> --- a/platforms/image-root-tgz.in
> +++ b/platforms/image-root-tgz.in
> @@ -2,9 +2,10 @@
>  
>  menuconfig IMAGE_ROOT_TGZ
>  	tristate
> +	default y
>  	prompt "Generate images/root.tgz      "
>  	help
> -	  FIXME
> +	  Build a tar.gz archive containing the root file system.
>  
>  if IMAGE_ROOT_TGZ
>  
> -- 
> 2.28.0
> 
> 
> _______________________________________________
> ptxdist mailing list
> ptxdist@pengutronix.de
> To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de
> 

-- 
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
To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [ptxdist] [PATCH 5/7] ptxdist: implement 'defconfig' commands for kconfig packages
  2020-09-21 22:17 ` [ptxdist] [PATCH 5/7] ptxdist: implement 'defconfig' commands for kconfig packages Roland Hieber
@ 2020-09-22  8:26   ` Michael Olbrich
  0 siblings, 0 replies; 16+ messages in thread
From: Michael Olbrich @ 2020-09-22  8:26 UTC (permalink / raw)
  To: ptxdist; +Cc: Roland Hieber

On Tue, Sep 22, 2020 at 12:17:26AM +0200, Roland Hieber wrote:
> The current process to generate a kernel .config file from a defconfig
> is a bit cumbersome:
> 
>   $ ptxdist extract kernel
>   $ cd platform-foo/build-target/linux-<version>
>   $ make ARCH=... CROSS_COMPILE=... foo_defconfig
>   $ cp .config ../../../configs/platform-foo/kernelconfig
> 
> All kernel and barebox rules and templates already support the
> <package>_%config target since commit b0f9f2fe33ca9027a554 (2020-08-07,
> "barebox, kernel: enable use of {allyes, allno, allmod, alldef,
> rand}config"), so we only need to wire them into the command line
> parser, and then we can easily get a defconfig like this:
> 
>   $ ptxdist defconfig kernel                # most ARCHs
>   $ ptxdist imx_v6_v7_defconfig kernel      # e.g. with ARCH=arm
> 
> Signed-off-by: Roland Hieber <rhi@pengutronix.de>
> ---
>  bin/ptxdist           | 15 ++++++++++++++-
>  doc/ref_parameter.rst |  9 +++++++++
>  2 files changed, 23 insertions(+), 1 deletion(-)
> 
> diff --git a/bin/ptxdist b/bin/ptxdist
> index 0d5e4328e1d6..c2cf744f70a8 100755
> --- a/bin/ptxdist
> +++ b/bin/ptxdist
> @@ -705,6 +705,9 @@ Setup and Project Actions:
>  
>    menuconfig barebox		configure the bootloader Barebox
>  
> +  [<prefix>]defconfig [<pkg>]	generate a default config file for <pkg>
> +				e.g.: ptxdist multi_v7_defconfig kernel
> +

'[]' means something is optional and this is not the case for the package:

  [<prefix>]defconfig <pkg>

>    oldconfig			run 'make oldconfig' on ptxconfig file
>    allmodconfig			run 'make allmodconfig' on ptxconfig file
>    allyesconfig			run 'make allyesconfig' on ptxconfig file
> @@ -1267,6 +1270,16 @@ do_config()
>  	case "${config}" in
>  	menuconfig|nconfig|oldconfig|all*config|randconfig)
>  		;;
> +	*defconfig)
> +		case "${part}" in
> +			"ptx"|"ptxdist"|""|"setup"|"platform"|"board"|"user"|"collection")
> +				echo
> +				echo "${PTXDIST_LOG_PROMPT}error: cannot do a '${config}' for part '${part}'"
> +				echo
> +				exit 1
> +				;;
> +		esac
> +		;;
>  	*)
>  		echo
>  		echo "${PTXDIST_LOG_PROMPT}error: invalid use of '${FUNCNAME} ${@}'"
> @@ -1625,7 +1638,7 @@ parse_second()
>  
>  ######## *config, *setup, toolchain
>  
> -		menuconfig|nconfig|oldconfig|allmodconfig|allyesconfig|allnoconfig|alldefconfig|randconfig)
> +		menuconfig|nconfig|oldconfig|allmodconfig|allyesconfig|allnoconfig|*defconfig|randconfig)
>  			do_config "${cmd}" "${@}"
>  			exit
>  			;;
> diff --git a/doc/ref_parameter.rst b/doc/ref_parameter.rst
> index 1d54fa4b4428..ac1e06c5335e 100644
> --- a/doc/ref_parameter.rst
> +++ b/doc/ref_parameter.rst
> @@ -95,6 +95,15 @@ Setup and Project Actions
>    functionality as ``menuconfig``. It can be used instead of ``menuconfig``
>    for all the component described above.
>  
> +``[<prefix>]defconfig [<package>]``

Same here. The package is not optional.

Michael

> +  generate a default config file for kconfig-based packages (kernel, barebox).
> +  The ``[<prefix>]`` can be given optionally to use a specific defconfig file,
> +  which depends on the respective package and the architecture.
> +  Examples::
> +
> +    $ ptxdist defconfig kernel                # most ARCHs
> +    $ ptxdist imx_v6_v7_defconfig kernel      # e.g. for ARCH=arm
> +
>  ``oldconfig [<component>]``, ``allmodconfig [<component>]``, ``allyesconfig [<component>]``, ``allnoconfig [<component>]``, ``alldefconfig [<component>]``, ``randconfig [<component>]``
>    this action will run the corresponding kconfig action for the specified
>    component. ``oldconfig`` will prompt for all new options.
> -- 
> 2.28.0
> 
> 
> _______________________________________________
> ptxdist mailing list
> ptxdist@pengutronix.de
> To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de
> 

-- 
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
To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [ptxdist] [PATCH 4/7] image-root-tgz: build by default, and add a help text
  2020-09-22  8:17   ` Michael Olbrich
@ 2020-09-22  9:08     ` Roland Hieber
  0 siblings, 0 replies; 16+ messages in thread
From: Roland Hieber @ 2020-09-22  9:08 UTC (permalink / raw)
  To: ptxdist

On Tue, Sep 22, 2020 at 10:17:43AM +0200, Michael Olbrich wrote:
> On Tue, Sep 22, 2020 at 12:17:25AM +0200, Roland Hieber wrote:
> > The root.tgz is needed for all other rootfs images, so it makes sense to
> > build it by default. Also provide at least one image by default for
> > newly added platforms.
> 
> No. Unused default stuff is never disabled unless it actually breaks
> things. So in BSPs that don't actually use this, the image will probably
> built anyways and just wastes space and time.

OK, I'll add it to the new init_defconfig instead.

 - Roland

> 
> Michael
> 
> > Signed-off-by: Roland Hieber <rhi@pengutronix.de>
> > ---
> >  platforms/image-root-tgz.in | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/platforms/image-root-tgz.in b/platforms/image-root-tgz.in
> > index c325209ded6d..cfd4f3f83600 100644
> > --- a/platforms/image-root-tgz.in
> > +++ b/platforms/image-root-tgz.in
> > @@ -2,9 +2,10 @@
> >  
> >  menuconfig IMAGE_ROOT_TGZ
> >  	tristate
> > +	default y
> >  	prompt "Generate images/root.tgz      "
> >  	help
> > -	  FIXME
> > +	  Build a tar.gz archive containing the root file system.
> >  
> >  if IMAGE_ROOT_TGZ
> >  
> > -- 
> > 2.28.0
> > 
> > 
> > _______________________________________________
> > ptxdist mailing list
> > ptxdist@pengutronix.de
> > To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de
> > 
> 
> -- 
> 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 |
> 

-- 
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
To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [ptxdist] [PATCH 1/7] kernel: bump default version and md5sum
  2020-09-22  8:13 ` [ptxdist] [PATCH 1/7] kernel: bump default version and md5sum Michael Olbrich
@ 2020-09-22  9:17   ` Roland Hieber
  0 siblings, 0 replies; 16+ messages in thread
From: Roland Hieber @ 2020-09-22  9:17 UTC (permalink / raw)
  To: ptxdist

On Tue, Sep 22, 2020 at 10:13:30AM +0200, Michael Olbrich wrote:
> On Tue, Sep 22, 2020 at 12:17:22AM +0200, Roland Hieber wrote:
> > Provide reasonably recent default values for new BSPs.
> > 
> > Signed-off-by: Roland Hieber <rhi@pengutronix.de>
> > ---
> >  platforms/kernel.in | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/platforms/kernel.in b/platforms/kernel.in
> > index 34d05c825929..7bcfac5d8f2d 100644
> > --- a/platforms/kernel.in
> > +++ b/platforms/kernel.in
> > @@ -41,11 +41,12 @@ config KERNEL_MODULES_INSTALL
> >  config KERNEL_VERSION
> >  	prompt "kernel version"
> >  	string
> > -	default "4.15"
> > +	default "5.8"
> >  
> >  config KERNEL_MD5
> >  	prompt "kernel source md5sum"
> >  	string
> > +	default "0e5c4c15266218ef26c50fac0016095b"
> 
> Hmmm, I'm not sure I like this. We really don't want to people to use v5.8
> here, without thinking about it. They should use the latest stable version.
> And we cannot keep up with that here anyways.

The same argument could be made about v4.15, and at least v5.8 is less
outdated. But I also don't have a good solution here, so I'll leave this
patch out for the next iteration.

 - Roland

> 
> Michael
> 
> >  
> >  choice
> >  	prompt "Image Type          "
> > -- 
> > 2.28.0
> > 
> > 
> > _______________________________________________
> > ptxdist mailing list
> > ptxdist@pengutronix.de
> > To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de
> > 
> 
> -- 
> 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
> To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de
> 

-- 
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
To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [ptxdist] [PATCH 7/7] ptxdist: add 'init' commands to create new configs
  2020-09-21 22:17 ` [ptxdist] [PATCH 7/7] ptxdist: add 'init' commands to create new configs Roland Hieber
@ 2020-09-22  9:46   ` Michael Olbrich
  2020-09-23 12:22     ` Roland Hieber
  0 siblings, 1 reply; 16+ messages in thread
From: Michael Olbrich @ 2020-09-22  9:46 UTC (permalink / raw)
  To: ptxdist; +Cc: Roland Hieber

On Tue, Sep 22, 2020 at 12:17:28AM +0200, Roland Hieber wrote:
> The goal here is to give users a way to create a working BSP or platform
> from scratch by asking only a minimal set of relevant questions and
> letting the user press Enter about 15 times, instead of asking every
> question in the whole platform and ptxconfig menu, which would require
> pressing Enter about 428 times.
> 
> For that, we create two separate Kconfig menus, rules/Kconfig-init for
> the ptxconfig, and platforms/Kconfig-init for the platformconfig, which
> include only the relevant .in files from the full menus. Still, some
> options from these .in files can be set to reasonable defaults for new
> BSPs or platforms, which is done with two new defconfig files instead of
> further outsourcing the relevant config options into single .in files.
> 
> With the 'init' subcommand, PTXdist first creates a standard directory
> structure under configs/ if necessary, then creates a minimal config
> file from the respective defconfig, and finally calls kconfig on the
> respective Kconfig-init menu, asking the user for the remaining config
> options. A silenced oldconfig run on the full menu file then takes care
> to set all other config options to their defaults.
> 
> Signed-off-by: Roland Hieber <rhi@pengutronix.de>
> ---
>  bin/ptxdist                     | 46 ++++++++++++++++
>  doc/ref_parameter.rst           |  5 ++
>  platforms/Kconfig-init          | 13 +++++
>  platforms/init_defconfig        | 18 +++++++
>  rules/Kconfig-init              | 62 +++++++++++++++++++++
>  rules/init_defconfig            | 21 ++++++++
>  rules/initmethod.in             |  3 ++
>  scripts/lib/ptxd_lib_init.sh    | 96 +++++++++++++++++++++++++++++++++
>  scripts/lib/ptxd_lib_kconfig.sh | 10 ++++
>  9 files changed, 274 insertions(+)
>  create mode 100644 platforms/Kconfig-init
>  create mode 100644 platforms/init_defconfig
>  create mode 100644 rules/Kconfig-init
>  create mode 100644 rules/init_defconfig
>  create mode 100644 scripts/lib/ptxd_lib_init.sh

Hmmm, this name seems a bit too generic. Maybe ptxd_lib_bsp_init.sh

> 
> diff --git a/bin/ptxdist b/bin/ptxdist
> index c2cf744f70a8..a3d2f0deef56 100755
> --- a/bin/ptxdist
> +++ b/bin/ptxdist
> @@ -687,6 +687,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
> @@ -1803,6 +1806,49 @@ EOF
>  			do_${cmd}
>  			exit
>  			;;
> +		init)
> +			local do_ptxconfig=1
> +			if [ "$1" = "platform" ]; then
> +				shift
> +				do_ptxconfig=
> +			fi
> +
> +			local platform="$1"
> +			if [ -z "$platform" ]; then
> +				echo
> +				echo "${PTXDIST_LOG_PROMPT}error: Please specify a platform name."
> +				echo
> +				exit 1
> +			fi
> +
> +			PTXDIST_PLATFORMCONFIG="configs/platform-${platform}/platformconfig"
> +			PTXDIST_PTXCONFIG="configs/ptxconfig"
> +
> +			# abort early
> +			ptxd_lib_init_platform_check &&
> +			if [ -n "$do_ptxconfig" ]; then
> +				ptxd_lib_init_check
> +			fi &&
> +
> +			ptxd_lib_init_platform "${platform}" &&
> +			if [ -n "$do_ptxconfig" ]; then
> +				ptxd_lib_init
> +			fi &&
> +
> +			if [ -n "$do_ptxconfig" ]; then
> +				ptxd_dialog_msgbox \
> +					"Adapt the new BSP to your needs by running:\n\n" \
> +					"    ptxdist menuconfig\n" \
> +					"    ptxdist menuconfig platform\n" \
> +					"    ptxdist menuconfig kernel"
> +			else
> +				ptxd_dialog_msgbox \
> +					"Adapt the new platform to your needs by running:\n\n" \
> +					"    ptxdist menuconfig platform\n" \
> +					"    ptxdist menuconfig kernel"
> +			fi

Put this stuff in a function too. And in scripts/lib/ as well. I try to
avoid adding new stuff in the ptxdist script because that part cannot be
overwritten in a BSP.

> +			exit
> +			;;
>  		image)
>  			PTXDIST_OPTIMIZE_IO=true
>  			if [ ${#} -eq 0 ]; then
> diff --git a/doc/ref_parameter.rst b/doc/ref_parameter.rst
> index ac1e06c5335e..edd489af831f 100644
> --- a/doc/ref_parameter.rst
> +++ b/doc/ref_parameter.rst
> @@ -12,6 +12,11 @@ PTXdist is a command line tool, which is basically called as:
>  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/platforms/Kconfig-init b/platforms/Kconfig-init
> new file mode 100644
> index 000000000000..9e42556d77d3
> --- /dev/null
> +++ b/platforms/Kconfig-init

I think this (and the defconfig) should be somewhere in config/.

> @@ -0,0 +1,13 @@
> +#
> +# a kconfig menu structure that asks only a minimal amount of questions to
> +# quickly get started with a new platform
> +#
> +source "generated/platform_version.in"
> +source "platforms/architecture.in"
> +source "platforms/toolchain.in"
> +
> +# dependencies for kernel rule:
> +source "generated/hosttools_noprompt.in"
> +source "generated/hosttools_platform.in"
> +
> +source "platforms/kernel.in"
> diff --git a/platforms/init_defconfig b/platforms/init_defconfig
> new file mode 100644
> index 000000000000..5e44c536f314
> --- /dev/null
> +++ b/platforms/init_defconfig
> @@ -0,0 +1,18 @@
> +PTXCONF_PLATFORM_VERSION="-${PTXDIST_BSP_AUTOVERSION}"
> +PTXCONF_COMPILER_PREFIX_KERNEL="${PTXCONF_COMPILER_PREFIX}"
> +PTXCONF_COMPILER_PREFIX_BOOTLOADER="${PTXCONF_COMPILER_PREFIX}"
> +PTXCONF_LIBC_GLIBC=y
> +# PTXCONF_LIBC_UCLIBC is not set
> +PTXCONF_KERNEL=y
> +# PTXCONF_KERNEL_MODULES is not set

No modules by default? This seems wrong.

> +# PTXCONF_KERNEL_ZSTD is not set
> +# PTXCONF_KERNEL_XZ is not set
> +# PTXCONF_KERNEL_LZOP is not set
> +# PTXCONF_KERNEL_LZ4 is not set
> +# PTXCONF_KERNEL_OPENSSL is not set
> +# PTXCONF_KERNEL_LIBELF is not set

Keeping all of those off is just asking for trouble.
e.g. PTXCONF_KERNEL_LIBELF is needed by default on x86

> +# PTXCONF_KERNEL_GCC_PLUGINS is not set

This seems wrong. If you don't care about plugins, then they should be
disabled. Otherwise the question should be explicit.

> +# PTXCONF_KERNEL_CONFIG_BASE_VERSION is not set
> +PTXCONF_KERNEL_SERIES="series"
> +PTXCONF_KERNEL_CONFIG="kernelconfig-${PTXCONF_KERNEL_VERSION}"

I thought I changed that default. Please change this and the default value
to just "kernelconfig". The version just causes problems in most cases.

> +PTXCONF_KERNEL_EXTRA_MAKEVARS=""
> diff --git a/rules/Kconfig-init b/rules/Kconfig-init
> new file mode 100644
> index 000000000000..2355d070de9b
> --- /dev/null
> +++ b/rules/Kconfig-init

Also in config/...

> @@ -0,0 +1,62 @@
> +#
> +# a kconfig menu structure that asks only a minimal amount of questions to
> +# quickly get started with a new BSP
> +#
> +source "rules/ptxdist-dgen.in"
> +source "rules/ptxdist-version.in"
> +source "generated/ptxdist_options.in"
> +
> +source "rules/project-name.in"
> +
> +#
> +# stubs for options that we want to ask for or enable by default, but not ask
> +# for all their suboptions
> +#
> +
> +config BUSYBOX
> +	default y
> +	bool
> +
> +# busybox installs init, poweroff, halt etc. by default. This conflicts with
> +# systemd, but since busybox brings its own kconfig menu in-tree, we cannot
> +# easily influence its defaults. Therefore we first disable those options in
> +# init_defconfig, and explicitely select them when needed.
> +# Note: these option need to have a prompt, otherwise kconfig doesn't write them
> +# to the config file if they are disabled, and busybox's default will kick in.
> +config BUSYBOX_HALT
> +	bool "busybox /usr/sbin/halt"
> +config BUSYBOX_INIT
> +	bool "busybox /usr/sbin/init"
> +config BUSYBOX_POWEROFF
> +	bool "busybox /usr/sbin/poweroff"
> +config BUSYBOX_REBOOT
> +	bool "busybox /usr/sbin/reboot"
> +config BUSYBOX_RUNLEVEL
> +	bool "busybox /usr/sbin/runlevel"

I think we should look at my experiments to patch the busybox Kconfig files
during import. We cannot change the dependencies, but changing the defaults
is ok.
But I'm not sure if my sed scripting is enough for this.

> +choice
> +	prompt "init method"
> +	default INITMETHOD_SYSTEMD
> +
> +	config INITMETHOD_BBINIT
> +		bool
> +		prompt "busybox init    "
> +		select BUSYBOX_HALT
> +		select BUSYBOX_INIT
> +		select BUSYBOX_POWEROFF
> +		select BUSYBOX_REBOOT
> +		select BUSYBOX_RUNLEVEL
> +
> +	config INITMETHOD_SYSTEMD
> +		bool
> +		prompt "systemd         "
> +
> +	config INITMETHOD_INITRAMFS
> +		bool
> +		prompt "initramfs init  "
> +		select BUSYBOX_HALT
> +		select BUSYBOX_INIT
> +		select BUSYBOX_POWEROFF
> +		select BUSYBOX_REBOOT
> +		select BUSYBOX_RUNLEVEL

I don't think the dependencies make sense here.

> +endchoice
> diff --git a/rules/init_defconfig b/rules/init_defconfig
> new file mode 100644
> index 000000000000..9fa9ab00a60b
> --- /dev/null
> +++ b/rules/init_defconfig
> @@ -0,0 +1,21 @@
> +# PTXCONF_ALLYES is not set
> +# PTXCONF_BROKEN is not set
> +PTXCONF_FIX_PERMISSIONS=y
> +PTXCONF_PROJECT_VERSION="-${PTXDIST_BSP_AUTOVERSION}"
> +# PTXCONF_PROJECT_CREATE_DEVPKGS is not set
> +# PTXCONF_PROJECT_USE_DEVPKGS is not set
> +PTXCONF_PROJECT_DEVPKGDIR=""
> +PTXCONF_PROJECT_DEVMIRROR=""
> +# PTXCONF_PROJECT_CHECK_LICENSES is not set
> +PTXCONF_REPRODUCIBLE_TIMESTAMP_PTXDIST=y
> +# PTXCONF_REPRODUCIBLE_TIMESTAMP_TOOLCHAIN is not set
> +# PTXCONF_REPRODUCIBLE_TIMESTAMP_CUSTOM is not set
> +# PTXCONF_REPRODUCIBLE_TIMESTAMP_STRING is not set
> +PTXCONF_DEBUG_PACKAGES=y
> +# initmethod will enable the following busybox tools if needed:
> +# PTXCONF_BUSYBOX_HALT is not set
> +# PTXCONF_BUSYBOX_INIT is not set
> +# PTXCONF_BUSYBOX_POWEROFF is not set
> +# PTXCONF_BUSYBOX_REBOOT is not set
> +# PTXCONF_BUSYBOX_RUNLEVEL is not set
> +# PTXCONF_STAGING is not set

How can we keep these files up-to-date?

> diff --git a/rules/initmethod.in b/rules/initmethod.in
> index b8c0b9f97b30..604fae3b4f7b 100644
> --- a/rules/initmethod.in
> +++ b/rules/initmethod.in
> @@ -10,6 +10,9 @@ menuconfig INITMETHOD
>  if INITMETHOD
>  
>  choice
> +	#
> +	# NOTE: if you add options here, also add them to rules/init_defconfig
> +	#
>  	prompt "init method"
>  	default INITMETHOD_SYSTEMD
>  
> diff --git a/scripts/lib/ptxd_lib_init.sh b/scripts/lib/ptxd_lib_init.sh
> new file mode 100644
> index 000000000000..54fcb4d27eee
> --- /dev/null
> +++ b/scripts/lib/ptxd_lib_init.sh
> @@ -0,0 +1,96 @@
> +#!/bin/bash
> +
> +ptxd_lib_init_check() {
> +	if [ -z "${PTXDIST_PTXCONFIG}" ]; then
> +		echo
> +		echo "${PTXDIST_LOG_PROMPT}error: cannot create empty ptxconfig file."
> +		echo
> +		return 1
> +	fi
> +
> +	if [ -z "${PTXDIST_FORCE}" ] && [ -e "${PTXDIST_PTXCONFIG}" ]; then
> +		echo
> +		echo "${PTXDIST_LOG_PROMPT}error: the file '${PTXDIST_PTXCONFIG}' already exists,"
> +		echo "${PTXDIST_LOG_PROMPT}       use '--force' to overwrite it."
> +		echo
> +		return 1
> +	fi
> +
> +	if [ -z "${PTXDIST_FORCE}" ] && [ -e "${PTXDIST_PTXCONFIG_DEFAULT}" ]; then
> +		echo
> +		echo "${PTXDIST_LOG_PROMPT}error: the file '${PTXDIST_PTXCONFIG_DEFAULT}' already exists,"
> +		echo "${PTXDIST_LOG_PROMPT}       use '--force' to overwrite it."
> +		echo
> +		return 1
> +	fi
> +}
> +export -f ptxd_lib_init_check
> +
> +ptxd_lib_init() {
> +	ptxd_lib_init_check &&
> +
> +	mkdir -p "$(dirname "${PTXDIST_PTXCONFIG}")" &&
> +	cat "${PTXDIST_TOPDIR}/rules/init_defconfig" > "${PTXDIST_PTXCONFIG}" &&
> +
> +	PTXDIST_FORCE=true do_select ptxconfig "${PTXDIST_PTXCONFIG}" &&
> +
> +	# only ask the important questions first, then do silentdefconfig for
> +	# all other options
> +	PTXDIST_DEP_TARGET="all" ptxd_kconfig oldconfig "init-ptx" &&
> +
> +	# ... then do a silent defconfig for all other defaults
> +	PTXDIST_DEP_TARGET="all" PTXDIST_FORCE=true \
> +		yes '' | ptxd_kconfig oldconfig ptx > /dev/null

I think we can use alldefconfig here.

> +}
> +export -f ptxd_lib_init
> +
> +ptxd_lib_init_platform_check() {
> +	if [ -z "${PTXDIST_PLATFORMCONFIG}" ]; then
> +		echo
> +		echo "${PTXDIST_LOG_PROMPT}error: cannot create empty platformconfig file."
> +		echo
> +		return 1
> +	fi
> +
> +	if [ -z "${PTXDIST_FORCE}" ] && [ -e "${PTXDIST_PLATFORMCONFIG}" ]; then
> +		echo
> +		echo "${PTXDIST_LOG_PROMPT}error: the file '${PTXDIST_PLATFORMCONFIG}' already exists,"
> +		echo "${PTXDIST_LOG_PROMPT}       use '--force' to overwrite it."
> +		echo
> +		return 1
> +	fi
> +
> +	if [ -z "${PTXDIST_FORCE}" ] && [ -e "${PTXDIST_PLATFORMCONFIG_DEFAULT}" ]; then
> +		echo
> +		echo "${PTXDIST_LOG_PROMPT}error: the file '${PTXDIST_PLATFORMCONFIG_DEFAULT}' already exists,"
> +		echo "${PTXDIST_LOG_PROMPT}       use '--force' to overwrite it."
> +		echo
> +		return 1
> +	fi
> +}
> +export -f ptxd_lib_init_platform_check
> +
> +ptxd_lib_init_platform() {
> +	local platformname="$1"
> +	ptxd_lib_init_platform_check &&
> +
> +	mkdir -p "$(dirname "${PTXDIST_PLATFORMCONFIG}")" &&
> +
> +	# pre-prime with defaults
> +	echo "PTXCONF_PLATFORM=\"${platformname}\"" > "${PTXDIST_PLATFORMCONFIG}" &&
> +	cat "${PTXDIST_TOPDIR}/platforms/init_defconfig" >> "${PTXDIST_PLATFORMCONFIG}" &&
> +
> +	# pretend we have a toolchain, otherwise do_select will try to
> +	# autodetect it from an incomplete platformconfig
> +	PTX_toolchain_SET=true PTXDIST_FORCE=true \
> +		do_select platformconfig "${PTXDIST_PLATFORMCONFIG}" &&
> +	

trailing whitespace.

> +	# only ask the important questions first...
> +	PTXDIST_DEP_TARGET="all" \
> +		ptxd_kconfig oldconfig init-platform &&
> +
> +	# ... then do a silent defconfig for all other defaults
> +	PTXDIST_DEP_TARGET="all" PTXDIST_FORCE=true \
> +		yes '' | ptxd_kconfig oldconfig platform > /dev/null

alldefconfig

Michael

> +}
> +export -f ptxd_lib_init_platform
> diff --git a/scripts/lib/ptxd_lib_kconfig.sh b/scripts/lib/ptxd_lib_kconfig.sh
> index ca56a65a19c3..58f45e056182 100644
> --- a/scripts/lib/ptxd_lib_kconfig.sh
> +++ b/scripts/lib/ptxd_lib_kconfig.sh
> @@ -687,11 +687,21 @@ ptxd_kconfig() {
>  	file_kconfig="${ptxd_reply}"
>  	file_dotconfig="${PTXDIST_PTXCONFIG}"
>  	;;
> +    init-ptx)
> +	part="ptx"
> +	file_kconfig="rules/Kconfig-init"
> +	file_dotconfig="${PTXDIST_PTXCONFIG}"
> +	;;
>      platform)
>  	ptxd_in_path PTXDIST_PATH_LAYERS "platforms/Kconfig"
>  	file_kconfig="${ptxd_reply}"
>  	file_dotconfig="${PTXDIST_PLATFORMCONFIG}"
>  	;;
> +    init-platform)
> +	part="platform"
> +	file_kconfig="platforms/Kconfig-init"
> +	file_dotconfig="${PTXDIST_PLATFORMCONFIG}"
> +	;;
>      collection)
>  	file_dotconfig="${PTXDIST_PTXCONFIG}"
>  	ptxd_normalize_config
> -- 
> 2.28.0
> 
> 
> _______________________________________________
> ptxdist mailing list
> ptxdist@pengutronix.de
> To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de
> 

-- 
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
To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [ptxdist] [PATCH 7/7] ptxdist: add 'init' commands to create new configs
  2020-09-22  9:46   ` Michael Olbrich
@ 2020-09-23 12:22     ` Roland Hieber
  2020-09-24 13:42       ` Michael Olbrich
  0 siblings, 1 reply; 16+ messages in thread
From: Roland Hieber @ 2020-09-23 12:22 UTC (permalink / raw)
  To: ptxdist

On Tue, Sep 22, 2020 at 11:46:22AM +0200, Michael Olbrich wrote:
> On Tue, Sep 22, 2020 at 12:17:28AM +0200, Roland Hieber wrote:
> > The goal here is to give users a way to create a working BSP or platform
> > from scratch by asking only a minimal set of relevant questions and
> > letting the user press Enter about 15 times, instead of asking every
> > question in the whole platform and ptxconfig menu, which would require
> > pressing Enter about 428 times.
> > 
> > For that, we create two separate Kconfig menus, rules/Kconfig-init for
> > the ptxconfig, and platforms/Kconfig-init for the platformconfig, which
> > include only the relevant .in files from the full menus. Still, some
> > options from these .in files can be set to reasonable defaults for new
> > BSPs or platforms, which is done with two new defconfig files instead of
> > further outsourcing the relevant config options into single .in files.
> > 
> > With the 'init' subcommand, PTXdist first creates a standard directory
> > structure under configs/ if necessary, then creates a minimal config
> > file from the respective defconfig, and finally calls kconfig on the
> > respective Kconfig-init menu, asking the user for the remaining config
> > options. A silenced oldconfig run on the full menu file then takes care
> > to set all other config options to their defaults.
> > 
> > Signed-off-by: Roland Hieber <rhi@pengutronix.de>
> > ---
> >  bin/ptxdist                     | 46 ++++++++++++++++
> >  doc/ref_parameter.rst           |  5 ++
> >  platforms/Kconfig-init          | 13 +++++
> >  platforms/init_defconfig        | 18 +++++++
> >  rules/Kconfig-init              | 62 +++++++++++++++++++++
> >  rules/init_defconfig            | 21 ++++++++
> >  rules/initmethod.in             |  3 ++
> >  scripts/lib/ptxd_lib_init.sh    | 96 +++++++++++++++++++++++++++++++++
> >  scripts/lib/ptxd_lib_kconfig.sh | 10 ++++
> >  9 files changed, 274 insertions(+)
> >  create mode 100644 platforms/Kconfig-init
> >  create mode 100644 platforms/init_defconfig
> >  create mode 100644 rules/Kconfig-init
> >  create mode 100644 rules/init_defconfig
> >  create mode 100644 scripts/lib/ptxd_lib_init.sh
> 
> Hmmm, this name seems a bit too generic. Maybe ptxd_lib_bsp_init.sh

Yeah, seems reasonable to me.

> > diff --git a/bin/ptxdist b/bin/ptxdist
> > index c2cf744f70a8..a3d2f0deef56 100755
> > --- a/bin/ptxdist
> > +++ b/bin/ptxdist
> > @@ -687,6 +687,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
> > @@ -1803,6 +1806,49 @@ EOF
> >  			do_${cmd}
> >  			exit
> >  			;;
> > +		init)
> > +			local do_ptxconfig=1
> > +			if [ "$1" = "platform" ]; then
> > +				shift
> > +				do_ptxconfig=
> > +			fi
> > +
> > +			local platform="$1"
> > +			if [ -z "$platform" ]; then
> > +				echo
> > +				echo "${PTXDIST_LOG_PROMPT}error: Please specify a platform name."
> > +				echo
> > +				exit 1
> > +			fi
> > +
> > +			PTXDIST_PLATFORMCONFIG="configs/platform-${platform}/platformconfig"
> > +			PTXDIST_PTXCONFIG="configs/ptxconfig"
> > +
> > +			# abort early
> > +			ptxd_lib_init_platform_check &&
> > +			if [ -n "$do_ptxconfig" ]; then
> > +				ptxd_lib_init_check
> > +			fi &&
> > +
> > +			ptxd_lib_init_platform "${platform}" &&
> > +			if [ -n "$do_ptxconfig" ]; then
> > +				ptxd_lib_init
> > +			fi &&
> > +
> > +			if [ -n "$do_ptxconfig" ]; then
> > +				ptxd_dialog_msgbox \
> > +					"Adapt the new BSP to your needs by running:\n\n" \
> > +					"    ptxdist menuconfig\n" \
> > +					"    ptxdist menuconfig platform\n" \
> > +					"    ptxdist menuconfig kernel"
> > +			else
> > +				ptxd_dialog_msgbox \
> > +					"Adapt the new platform to your needs by running:\n\n" \
> > +					"    ptxdist menuconfig platform\n" \
> > +					"    ptxdist menuconfig kernel"
> > +			fi
> 
> Put this stuff in a function too. And in scripts/lib/ as well. I try to
> avoid adding new stuff in the ptxdist script because that part cannot be
> overwritten in a BSP.

Ah, good idea, I forgot that rationale.

> > +			exit
> > +			;;
> >  		image)
> >  			PTXDIST_OPTIMIZE_IO=true
> >  			if [ ${#} -eq 0 ]; then
> > diff --git a/doc/ref_parameter.rst b/doc/ref_parameter.rst
> > index ac1e06c5335e..edd489af831f 100644
> > --- a/doc/ref_parameter.rst
> > +++ b/doc/ref_parameter.rst
> > @@ -12,6 +12,11 @@ PTXdist is a command line tool, which is basically called as:
> >  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/platforms/Kconfig-init b/platforms/Kconfig-init
> > new file mode 100644
> > index 000000000000..9e42556d77d3
> > --- /dev/null
> > +++ b/platforms/Kconfig-init
> 
> I think this (and the defconfig) should be somewhere in config/.

Not sure. I put it next to the already existing platform/Kconfig, which
is used as the file_kconfig in ptxd_kconfig(), so I think it fits well
here…

> > @@ -0,0 +1,13 @@
> > +#
> > +# a kconfig menu structure that asks only a minimal amount of questions to
> > +# quickly get started with a new platform
> > +#
> > +source "generated/platform_version.in"
> > +source "platforms/architecture.in"
> > +source "platforms/toolchain.in"
> > +
> > +# dependencies for kernel rule:
> > +source "generated/hosttools_noprompt.in"
> > +source "generated/hosttools_platform.in"
> > +
> > +source "platforms/kernel.in"
> > diff --git a/platforms/init_defconfig b/platforms/init_defconfig
> > new file mode 100644
> > index 000000000000..5e44c536f314
> > --- /dev/null
> > +++ b/platforms/init_defconfig
> > @@ -0,0 +1,18 @@
> > +PTXCONF_PLATFORM_VERSION="-${PTXDIST_BSP_AUTOVERSION}"
> > +PTXCONF_COMPILER_PREFIX_KERNEL="${PTXCONF_COMPILER_PREFIX}"
> > +PTXCONF_COMPILER_PREFIX_BOOTLOADER="${PTXCONF_COMPILER_PREFIX}"
> > +PTXCONF_LIBC_GLIBC=y
> > +# PTXCONF_LIBC_UCLIBC is not set
> > +PTXCONF_KERNEL=y
> > +# PTXCONF_KERNEL_MODULES is not set
> 
> No modules by default? This seems wrong.

Modules don't seem to be frequently used in the embedded world. But I
guess we can leave it out of the defconfig and ask for it instead.

> > +# PTXCONF_KERNEL_ZSTD is not set
> > +# PTXCONF_KERNEL_XZ is not set
> > +# PTXCONF_KERNEL_LZOP is not set
> > +# PTXCONF_KERNEL_LZ4 is not set
> > +# PTXCONF_KERNEL_OPENSSL is not set
> > +# PTXCONF_KERNEL_LIBELF is not set
> 
> Keeping all of those off is just asking for trouble.
> e.g. PTXCONF_KERNEL_LIBELF is needed by default on x86

OK, I'll have to look into this. Since the platformconfig is added
before the kernel is configured, I'm not really sure what to do here if
users configure their kernel e.g. to produce signed images, but
KERNEL_OPENSSL is disabled in platformconfig. They would need to enable
that afterwards anyways. Unless we just enable all those KERNEL_* host
tools options unconditionally, which will always do the right thing,
although lead to a longer build time.

> > +# PTXCONF_KERNEL_GCC_PLUGINS is not set
> 
> This seems wrong. If you don't care about plugins, then they should be
> disabled. Otherwise the question should be explicit.

OK.

> > +# PTXCONF_KERNEL_CONFIG_BASE_VERSION is not set
> > +PTXCONF_KERNEL_SERIES="series"
> > +PTXCONF_KERNEL_CONFIG="kernelconfig-${PTXCONF_KERNEL_VERSION}"
> 
> I thought I changed that default. Please change this and the default value
> to just "kernelconfig". The version just causes problems in most cases.

Oh, right. I remember a discussion about it.

> > +PTXCONF_KERNEL_EXTRA_MAKEVARS=""
> > diff --git a/rules/Kconfig-init b/rules/Kconfig-init
> > new file mode 100644
> > index 000000000000..2355d070de9b
> > --- /dev/null
> > +++ b/rules/Kconfig-init
> 
> Also in config/...

Right, after having a look at ptxd_kconfig() again, this makes sense to
me now.

> > @@ -0,0 +1,62 @@
> > +#
> > +# a kconfig menu structure that asks only a minimal amount of questions to
> > +# quickly get started with a new BSP
> > +#
> > +source "rules/ptxdist-dgen.in"
> > +source "rules/ptxdist-version.in"
> > +source "generated/ptxdist_options.in"
> > +
> > +source "rules/project-name.in"
> > +
> > +#
> > +# stubs for options that we want to ask for or enable by default, but not ask
> > +# for all their suboptions
> > +#
> > +
> > +config BUSYBOX
> > +	default y
> > +	bool
> > +
> > +# busybox installs init, poweroff, halt etc. by default. This conflicts with
> > +# systemd, but since busybox brings its own kconfig menu in-tree, we cannot
> > +# easily influence its defaults. Therefore we first disable those options in
> > +# init_defconfig, and explicitely select them when needed.
> > +# Note: these option need to have a prompt, otherwise kconfig doesn't write them
> > +# to the config file if they are disabled, and busybox's default will kick in.
> > +config BUSYBOX_HALT
> > +	bool "busybox /usr/sbin/halt"
> > +config BUSYBOX_INIT
> > +	bool "busybox /usr/sbin/init"
> > +config BUSYBOX_POWEROFF
> > +	bool "busybox /usr/sbin/poweroff"
> > +config BUSYBOX_REBOOT
> > +	bool "busybox /usr/sbin/reboot"
> > +config BUSYBOX_RUNLEVEL
> > +	bool "busybox /usr/sbin/runlevel"
> 
> I think we should look at my experiments to patch the busybox Kconfig files
> during import. We cannot change the dependencies, but changing the defaults
> is ok.
> But I'm not sure if my sed scripting is enough for this.

Are there patches anywhere I can look at it? :-)

> > +choice
> > +	prompt "init method"
> > +	default INITMETHOD_SYSTEMD
> > +
> > +	config INITMETHOD_BBINIT
> > +		bool
> > +		prompt "busybox init    "
> > +		select BUSYBOX_HALT
> > +		select BUSYBOX_INIT
> > +		select BUSYBOX_POWEROFF
> > +		select BUSYBOX_REBOOT
> > +		select BUSYBOX_RUNLEVEL
> > +
> > +	config INITMETHOD_SYSTEMD
> > +		bool
> > +		prompt "systemd         "
> > +
> > +	config INITMETHOD_INITRAMFS
> > +		bool
> > +		prompt "initramfs init  "
> > +		select BUSYBOX_HALT
> > +		select BUSYBOX_INIT
> > +		select BUSYBOX_POWEROFF
> > +		select BUSYBOX_REBOOT
> > +		select BUSYBOX_RUNLEVEL
> 
> I don't think the dependencies make sense here.

I have no experience with initramfs-tools to be honest, but who will
supply /sbin/halt, /sbin/poweroff etc. in this case if not busybox?

> > +endchoice
> > diff --git a/rules/init_defconfig b/rules/init_defconfig
> > new file mode 100644
> > index 000000000000..9fa9ab00a60b
> > --- /dev/null
> > +++ b/rules/init_defconfig
> > @@ -0,0 +1,21 @@
> > +# PTXCONF_ALLYES is not set
> > +# PTXCONF_BROKEN is not set
> > +PTXCONF_FIX_PERMISSIONS=y
> > +PTXCONF_PROJECT_VERSION="-${PTXDIST_BSP_AUTOVERSION}"
> > +# PTXCONF_PROJECT_CREATE_DEVPKGS is not set
> > +# PTXCONF_PROJECT_USE_DEVPKGS is not set
> > +PTXCONF_PROJECT_DEVPKGDIR=""
> > +PTXCONF_PROJECT_DEVMIRROR=""
> > +# PTXCONF_PROJECT_CHECK_LICENSES is not set
> > +PTXCONF_REPRODUCIBLE_TIMESTAMP_PTXDIST=y
> > +# PTXCONF_REPRODUCIBLE_TIMESTAMP_TOOLCHAIN is not set
> > +# PTXCONF_REPRODUCIBLE_TIMESTAMP_CUSTOM is not set
> > +# PTXCONF_REPRODUCIBLE_TIMESTAMP_STRING is not set
> > +PTXCONF_DEBUG_PACKAGES=y
> > +# initmethod will enable the following busybox tools if needed:
> > +# PTXCONF_BUSYBOX_HALT is not set
> > +# PTXCONF_BUSYBOX_INIT is not set
> > +# PTXCONF_BUSYBOX_POWEROFF is not set
> > +# PTXCONF_BUSYBOX_REBOOT is not set
> > +# PTXCONF_BUSYBOX_RUNLEVEL is not set
> > +# PTXCONF_STAGING is not set
> 
> How can we keep these files up-to-date?

I guess like for everything else: patches or bug reports if someone
notices that it's broken. And the only way it can break will just lead
to more unnecessary questions being asked, which is a bit annoying but
not a tragedy, or defaults from the Kconfig options being used, which
should be fine.

Alternatively I think kconfig has a "save_defconfig" function which
could help us.

> > diff --git a/rules/initmethod.in b/rules/initmethod.in
> > index b8c0b9f97b30..604fae3b4f7b 100644
> > --- a/rules/initmethod.in
> > +++ b/rules/initmethod.in
> > @@ -10,6 +10,9 @@ menuconfig INITMETHOD
> >  if INITMETHOD
> >  
> >  choice
> > +	#
> > +	# NOTE: if you add options here, also add them to rules/init_defconfig
> > +	#

Or should I add more comments like this…?

> >  	prompt "init method"
> >  	default INITMETHOD_SYSTEMD
> >  
> > diff --git a/scripts/lib/ptxd_lib_init.sh b/scripts/lib/ptxd_lib_init.sh
> > new file mode 100644
> > index 000000000000..54fcb4d27eee
> > --- /dev/null
> > +++ b/scripts/lib/ptxd_lib_init.sh
> > @@ -0,0 +1,96 @@
> > +#!/bin/bash
> > +
> > +ptxd_lib_init_check() {
> > +	if [ -z "${PTXDIST_PTXCONFIG}" ]; then
> > +		echo
> > +		echo "${PTXDIST_LOG_PROMPT}error: cannot create empty ptxconfig file."
> > +		echo
> > +		return 1
> > +	fi
> > +
> > +	if [ -z "${PTXDIST_FORCE}" ] && [ -e "${PTXDIST_PTXCONFIG}" ]; then
> > +		echo
> > +		echo "${PTXDIST_LOG_PROMPT}error: the file '${PTXDIST_PTXCONFIG}' already exists,"
> > +		echo "${PTXDIST_LOG_PROMPT}       use '--force' to overwrite it."
> > +		echo
> > +		return 1
> > +	fi
> > +
> > +	if [ -z "${PTXDIST_FORCE}" ] && [ -e "${PTXDIST_PTXCONFIG_DEFAULT}" ]; then
> > +		echo
> > +		echo "${PTXDIST_LOG_PROMPT}error: the file '${PTXDIST_PTXCONFIG_DEFAULT}' already exists,"
> > +		echo "${PTXDIST_LOG_PROMPT}       use '--force' to overwrite it."
> > +		echo
> > +		return 1
> > +	fi
> > +}
> > +export -f ptxd_lib_init_check
> > +
> > +ptxd_lib_init() {
> > +	ptxd_lib_init_check &&
> > +
> > +	mkdir -p "$(dirname "${PTXDIST_PTXCONFIG}")" &&
> > +	cat "${PTXDIST_TOPDIR}/rules/init_defconfig" > "${PTXDIST_PTXCONFIG}" &&
> > +
> > +	PTXDIST_FORCE=true do_select ptxconfig "${PTXDIST_PTXCONFIG}" &&
> > +
> > +	# only ask the important questions first, then do silentdefconfig for
> > +	# all other options
> > +	PTXDIST_DEP_TARGET="all" ptxd_kconfig oldconfig "init-ptx" &&
> > +
> > +	# ... then do a silent defconfig for all other defaults
> > +	PTXDIST_DEP_TARGET="all" PTXDIST_FORCE=true \
> > +		yes '' | ptxd_kconfig oldconfig ptx > /dev/null
> 
> I think we can use alldefconfig here.

I had this in my first draft, but alldefconfig will reset all previously
pre-primed options from the init_defconfig to their respective defaults
as defined in Kconfig, and we don't want that here.

> > +}
> > +export -f ptxd_lib_init
> > +
> > +ptxd_lib_init_platform_check() {
> > +	if [ -z "${PTXDIST_PLATFORMCONFIG}" ]; then
> > +		echo
> > +		echo "${PTXDIST_LOG_PROMPT}error: cannot create empty platformconfig file."
> > +		echo
> > +		return 1
> > +	fi
> > +
> > +	if [ -z "${PTXDIST_FORCE}" ] && [ -e "${PTXDIST_PLATFORMCONFIG}" ]; then
> > +		echo
> > +		echo "${PTXDIST_LOG_PROMPT}error: the file '${PTXDIST_PLATFORMCONFIG}' already exists,"
> > +		echo "${PTXDIST_LOG_PROMPT}       use '--force' to overwrite it."
> > +		echo
> > +		return 1
> > +	fi
> > +
> > +	if [ -z "${PTXDIST_FORCE}" ] && [ -e "${PTXDIST_PLATFORMCONFIG_DEFAULT}" ]; then
> > +		echo
> > +		echo "${PTXDIST_LOG_PROMPT}error: the file '${PTXDIST_PLATFORMCONFIG_DEFAULT}' already exists,"
> > +		echo "${PTXDIST_LOG_PROMPT}       use '--force' to overwrite it."
> > +		echo
> > +		return 1
> > +	fi
> > +}
> > +export -f ptxd_lib_init_platform_check
> > +
> > +ptxd_lib_init_platform() {
> > +	local platformname="$1"
> > +	ptxd_lib_init_platform_check &&
> > +
> > +	mkdir -p "$(dirname "${PTXDIST_PLATFORMCONFIG}")" &&
> > +
> > +	# pre-prime with defaults
> > +	echo "PTXCONF_PLATFORM=\"${platformname}\"" > "${PTXDIST_PLATFORMCONFIG}" &&
> > +	cat "${PTXDIST_TOPDIR}/platforms/init_defconfig" >> "${PTXDIST_PLATFORMCONFIG}" &&
> > +
> > +	# pretend we have a toolchain, otherwise do_select will try to
> > +	# autodetect it from an incomplete platformconfig
> > +	PTX_toolchain_SET=true PTXDIST_FORCE=true \
> > +		do_select platformconfig "${PTXDIST_PLATFORMCONFIG}" &&
> > +	
> 
> trailing whitespace.

Thanks!

> > +	# only ask the important questions first...
> > +	PTXDIST_DEP_TARGET="all" \
> > +		ptxd_kconfig oldconfig init-platform &&
> > +
> > +	# ... then do a silent defconfig for all other defaults
> > +	PTXDIST_DEP_TARGET="all" PTXDIST_FORCE=true \
> > +		yes '' | ptxd_kconfig oldconfig platform > /dev/null
> 
> alldefconfig

Same as above.

  - Roland

> 
> Michael
> 
> > +}
> > +export -f ptxd_lib_init_platform
> > diff --git a/scripts/lib/ptxd_lib_kconfig.sh b/scripts/lib/ptxd_lib_kconfig.sh
> > index ca56a65a19c3..58f45e056182 100644
> > --- a/scripts/lib/ptxd_lib_kconfig.sh
> > +++ b/scripts/lib/ptxd_lib_kconfig.sh
> > @@ -687,11 +687,21 @@ ptxd_kconfig() {
> >  	file_kconfig="${ptxd_reply}"
> >  	file_dotconfig="${PTXDIST_PTXCONFIG}"
> >  	;;
> > +    init-ptx)
> > +	part="ptx"
> > +	file_kconfig="rules/Kconfig-init"
> > +	file_dotconfig="${PTXDIST_PTXCONFIG}"
> > +	;;
> >      platform)
> >  	ptxd_in_path PTXDIST_PATH_LAYERS "platforms/Kconfig"
> >  	file_kconfig="${ptxd_reply}"
> >  	file_dotconfig="${PTXDIST_PLATFORMCONFIG}"
> >  	;;
> > +    init-platform)
> > +	part="platform"
> > +	file_kconfig="platforms/Kconfig-init"
> > +	file_dotconfig="${PTXDIST_PLATFORMCONFIG}"
> > +	;;
> >      collection)
> >  	file_dotconfig="${PTXDIST_PTXCONFIG}"
> >  	ptxd_normalize_config
> > -- 
> > 2.28.0
> 
> -- 
> 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 |

-- 
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
To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [ptxdist] [PATCH 7/7] ptxdist: add 'init' commands to create new configs
  2020-09-23 12:22     ` Roland Hieber
@ 2020-09-24 13:42       ` Michael Olbrich
  2020-09-27 21:46         ` Roland Hieber
  0 siblings, 1 reply; 16+ messages in thread
From: Michael Olbrich @ 2020-09-24 13:42 UTC (permalink / raw)
  To: ptxdist; +Cc: Roland Hieber

On Wed, Sep 23, 2020 at 02:22:59PM +0200, Roland Hieber wrote:
> On Tue, Sep 22, 2020 at 11:46:22AM +0200, Michael Olbrich wrote:
> > On Tue, Sep 22, 2020 at 12:17:28AM +0200, Roland Hieber wrote:
> > > The goal here is to give users a way to create a working BSP or platform
> > > from scratch by asking only a minimal set of relevant questions and
> > > letting the user press Enter about 15 times, instead of asking every
> > > question in the whole platform and ptxconfig menu, which would require
> > > pressing Enter about 428 times.
> > > 
> > > For that, we create two separate Kconfig menus, rules/Kconfig-init for
> > > the ptxconfig, and platforms/Kconfig-init for the platformconfig, which
> > > include only the relevant .in files from the full menus. Still, some
> > > options from these .in files can be set to reasonable defaults for new
> > > BSPs or platforms, which is done with two new defconfig files instead of
> > > further outsourcing the relevant config options into single .in files.
> > > 
> > > With the 'init' subcommand, PTXdist first creates a standard directory
> > > structure under configs/ if necessary, then creates a minimal config
> > > file from the respective defconfig, and finally calls kconfig on the
> > > respective Kconfig-init menu, asking the user for the remaining config
> > > options. A silenced oldconfig run on the full menu file then takes care
> > > to set all other config options to their defaults.
> > > 
> > > Signed-off-by: Roland Hieber <rhi@pengutronix.de>
> > > ---
> > >  bin/ptxdist                     | 46 ++++++++++++++++
> > >  doc/ref_parameter.rst           |  5 ++
> > >  platforms/Kconfig-init          | 13 +++++
> > >  platforms/init_defconfig        | 18 +++++++
> > >  rules/Kconfig-init              | 62 +++++++++++++++++++++
> > >  rules/init_defconfig            | 21 ++++++++
> > >  rules/initmethod.in             |  3 ++
> > >  scripts/lib/ptxd_lib_init.sh    | 96 +++++++++++++++++++++++++++++++++
> > >  scripts/lib/ptxd_lib_kconfig.sh | 10 ++++
> > >  9 files changed, 274 insertions(+)
> > >  create mode 100644 platforms/Kconfig-init
> > >  create mode 100644 platforms/init_defconfig
> > >  create mode 100644 rules/Kconfig-init
> > >  create mode 100644 rules/init_defconfig
> > >  create mode 100644 scripts/lib/ptxd_lib_init.sh
> > 
> > Hmmm, this name seems a bit too generic. Maybe ptxd_lib_bsp_init.sh
> 
> Yeah, seems reasonable to me.
> 
> > > diff --git a/bin/ptxdist b/bin/ptxdist
> > > index c2cf744f70a8..a3d2f0deef56 100755
> > > --- a/bin/ptxdist
> > > +++ b/bin/ptxdist
> > > @@ -687,6 +687,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
> > > @@ -1803,6 +1806,49 @@ EOF
> > >  			do_${cmd}
> > >  			exit
> > >  			;;
> > > +		init)
> > > +			local do_ptxconfig=1
> > > +			if [ "$1" = "platform" ]; then
> > > +				shift
> > > +				do_ptxconfig=
> > > +			fi
> > > +
> > > +			local platform="$1"
> > > +			if [ -z "$platform" ]; then
> > > +				echo
> > > +				echo "${PTXDIST_LOG_PROMPT}error: Please specify a platform name."
> > > +				echo
> > > +				exit 1
> > > +			fi
> > > +
> > > +			PTXDIST_PLATFORMCONFIG="configs/platform-${platform}/platformconfig"
> > > +			PTXDIST_PTXCONFIG="configs/ptxconfig"
> > > +
> > > +			# abort early
> > > +			ptxd_lib_init_platform_check &&
> > > +			if [ -n "$do_ptxconfig" ]; then
> > > +				ptxd_lib_init_check
> > > +			fi &&
> > > +
> > > +			ptxd_lib_init_platform "${platform}" &&
> > > +			if [ -n "$do_ptxconfig" ]; then
> > > +				ptxd_lib_init
> > > +			fi &&
> > > +
> > > +			if [ -n "$do_ptxconfig" ]; then
> > > +				ptxd_dialog_msgbox \
> > > +					"Adapt the new BSP to your needs by running:\n\n" \
> > > +					"    ptxdist menuconfig\n" \
> > > +					"    ptxdist menuconfig platform\n" \
> > > +					"    ptxdist menuconfig kernel"
> > > +			else
> > > +				ptxd_dialog_msgbox \
> > > +					"Adapt the new platform to your needs by running:\n\n" \
> > > +					"    ptxdist menuconfig platform\n" \
> > > +					"    ptxdist menuconfig kernel"
> > > +			fi
> > 
> > Put this stuff in a function too. And in scripts/lib/ as well. I try to
> > avoid adding new stuff in the ptxdist script because that part cannot be
> > overwritten in a BSP.
> 
> Ah, good idea, I forgot that rationale.
> 
> > > +			exit
> > > +			;;
> > >  		image)
> > >  			PTXDIST_OPTIMIZE_IO=true
> > >  			if [ ${#} -eq 0 ]; then
> > > diff --git a/doc/ref_parameter.rst b/doc/ref_parameter.rst
> > > index ac1e06c5335e..edd489af831f 100644
> > > --- a/doc/ref_parameter.rst
> > > +++ b/doc/ref_parameter.rst
> > > @@ -12,6 +12,11 @@ PTXdist is a command line tool, which is basically called as:
> > >  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/platforms/Kconfig-init b/platforms/Kconfig-init
> > > new file mode 100644
> > > index 000000000000..9e42556d77d3
> > > --- /dev/null
> > > +++ b/platforms/Kconfig-init
> > 
> > I think this (and the defconfig) should be somewhere in config/.
> 
> Not sure. I put it next to the already existing platform/Kconfig, which
> is used as the file_kconfig in ptxd_kconfig(), so I think it fits well
> here…

Maybe, but the default config really doesn't fit here. And I'd like to keep
them together.
Also, this is a rather special use-case and I'd like to keep rules/ and
platforms/ clean. There are enough files there already.


> > > @@ -0,0 +1,13 @@
> > > +#
> > > +# a kconfig menu structure that asks only a minimal amount of questions to
> > > +# quickly get started with a new platform
> > > +#
> > > +source "generated/platform_version.in"
> > > +source "platforms/architecture.in"
> > > +source "platforms/toolchain.in"
> > > +
> > > +# dependencies for kernel rule:
> > > +source "generated/hosttools_noprompt.in"
> > > +source "generated/hosttools_platform.in"
> > > +
> > > +source "platforms/kernel.in"
> > > diff --git a/platforms/init_defconfig b/platforms/init_defconfig
> > > new file mode 100644
> > > index 000000000000..5e44c536f314
> > > --- /dev/null
> > > +++ b/platforms/init_defconfig
> > > @@ -0,0 +1,18 @@
> > > +PTXCONF_PLATFORM_VERSION="-${PTXDIST_BSP_AUTOVERSION}"
> > > +PTXCONF_COMPILER_PREFIX_KERNEL="${PTXCONF_COMPILER_PREFIX}"
> > > +PTXCONF_COMPILER_PREFIX_BOOTLOADER="${PTXCONF_COMPILER_PREFIX}"
> > > +PTXCONF_LIBC_GLIBC=y
> > > +# PTXCONF_LIBC_UCLIBC is not set
> > > +PTXCONF_KERNEL=y
> > > +# PTXCONF_KERNEL_MODULES is not set
> > 
> > No modules by default? This seems wrong.
> 
> Modules don't seem to be frequently used in the embedded world. But I
> guess we can leave it out of the defconfig and ask for it instead.

In my experience, even in the embedded world most devices use modules. And
any kernel defconfig enables modules as well.

> > > +# PTXCONF_KERNEL_ZSTD is not set
> > > +# PTXCONF_KERNEL_XZ is not set
> > > +# PTXCONF_KERNEL_LZOP is not set
> > > +# PTXCONF_KERNEL_LZ4 is not set
> > > +# PTXCONF_KERNEL_OPENSSL is not set
> > > +# PTXCONF_KERNEL_LIBELF is not set
> > 
> > Keeping all of those off is just asking for trouble.
> > e.g. PTXCONF_KERNEL_LIBELF is needed by default on x86
> 
> OK, I'll have to look into this. Since the platformconfig is added
> before the kernel is configured, I'm not really sure what to do here if
> users configure their kernel e.g. to produce signed images, but
> KERNEL_OPENSSL is disabled in platformconfig. They would need to enable
> that afterwards anyways. Unless we just enable all those KERNEL_* host
> tools options unconditionally, which will always do the right thing,
> although lead to a longer build time.

Just ask the user. This really must be configured correctly. These options
exist for a reason.

> > > +# PTXCONF_KERNEL_GCC_PLUGINS is not set
> > 
> > This seems wrong. If you don't care about plugins, then they should be
> > disabled. Otherwise the question should be explicit.
> 
> OK.
> 
> > > +# PTXCONF_KERNEL_CONFIG_BASE_VERSION is not set
> > > +PTXCONF_KERNEL_SERIES="series"
> > > +PTXCONF_KERNEL_CONFIG="kernelconfig-${PTXCONF_KERNEL_VERSION}"
> > 
> > I thought I changed that default. Please change this and the default value
> > to just "kernelconfig". The version just causes problems in most cases.
> 
> Oh, right. I remember a discussion about it.
> 
> > > +PTXCONF_KERNEL_EXTRA_MAKEVARS=""
> > > diff --git a/rules/Kconfig-init b/rules/Kconfig-init
> > > new file mode 100644
> > > index 000000000000..2355d070de9b
> > > --- /dev/null
> > > +++ b/rules/Kconfig-init
> > 
> > Also in config/...
> 
> Right, after having a look at ptxd_kconfig() again, this makes sense to
> me now.
> 
> > > @@ -0,0 +1,62 @@
> > > +#
> > > +# a kconfig menu structure that asks only a minimal amount of questions to
> > > +# quickly get started with a new BSP
> > > +#
> > > +source "rules/ptxdist-dgen.in"
> > > +source "rules/ptxdist-version.in"
> > > +source "generated/ptxdist_options.in"
> > > +
> > > +source "rules/project-name.in"
> > > +
> > > +#
> > > +# stubs for options that we want to ask for or enable by default, but not ask
> > > +# for all their suboptions
> > > +#
> > > +
> > > +config BUSYBOX
> > > +	default y
> > > +	bool
> > > +
> > > +# busybox installs init, poweroff, halt etc. by default. This conflicts with
> > > +# systemd, but since busybox brings its own kconfig menu in-tree, we cannot
> > > +# easily influence its defaults. Therefore we first disable those options in
> > > +# init_defconfig, and explicitely select them when needed.
> > > +# Note: these option need to have a prompt, otherwise kconfig doesn't write them
> > > +# to the config file if they are disabled, and busybox's default will kick in.
> > > +config BUSYBOX_HALT
> > > +	bool "busybox /usr/sbin/halt"
> > > +config BUSYBOX_INIT
> > > +	bool "busybox /usr/sbin/init"
> > > +config BUSYBOX_POWEROFF
> > > +	bool "busybox /usr/sbin/poweroff"
> > > +config BUSYBOX_REBOOT
> > > +	bool "busybox /usr/sbin/reboot"
> > > +config BUSYBOX_RUNLEVEL
> > > +	bool "busybox /usr/sbin/runlevel"
> > 
> > I think we should look at my experiments to patch the busybox Kconfig files
> > during import. We cannot change the dependencies, but changing the defaults
> > is ok.
> > But I'm not sure if my sed scripting is enough for this.
> 
> Are there patches anywhere I can look at it? :-)

Hmmm, it's been a while. I need to find that branch again...

> > > +choice
> > > +	prompt "init method"
> > > +	default INITMETHOD_SYSTEMD
> > > +
> > > +	config INITMETHOD_BBINIT
> > > +		bool
> > > +		prompt "busybox init    "
> > > +		select BUSYBOX_HALT
> > > +		select BUSYBOX_INIT
> > > +		select BUSYBOX_POWEROFF
> > > +		select BUSYBOX_REBOOT
> > > +		select BUSYBOX_RUNLEVEL
> > > +
> > > +	config INITMETHOD_SYSTEMD
> > > +		bool
> > > +		prompt "systemd         "
> > > +
> > > +	config INITMETHOD_INITRAMFS
> > > +		bool
> > > +		prompt "initramfs init  "
> > > +		select BUSYBOX_HALT
> > > +		select BUSYBOX_INIT
> > > +		select BUSYBOX_POWEROFF
> > > +		select BUSYBOX_REBOOT
> > > +		select BUSYBOX_RUNLEVEL
> > 
> > I don't think the dependencies make sense here.
> 
> I have no experience with initramfs-tools to be honest, but who will
> supply /sbin/halt, /sbin/poweroff etc. in this case if not busybox?

initramfs-tools provide /init and that is used anyways when starting with
an initramfs.

> > > +endchoice
> > > diff --git a/rules/init_defconfig b/rules/init_defconfig
> > > new file mode 100644
> > > index 000000000000..9fa9ab00a60b
> > > --- /dev/null
> > > +++ b/rules/init_defconfig
> > > @@ -0,0 +1,21 @@
> > > +# PTXCONF_ALLYES is not set
> > > +# PTXCONF_BROKEN is not set
> > > +PTXCONF_FIX_PERMISSIONS=y
> > > +PTXCONF_PROJECT_VERSION="-${PTXDIST_BSP_AUTOVERSION}"
> > > +# PTXCONF_PROJECT_CREATE_DEVPKGS is not set
> > > +# PTXCONF_PROJECT_USE_DEVPKGS is not set
> > > +PTXCONF_PROJECT_DEVPKGDIR=""
> > > +PTXCONF_PROJECT_DEVMIRROR=""
> > > +# PTXCONF_PROJECT_CHECK_LICENSES is not set
> > > +PTXCONF_REPRODUCIBLE_TIMESTAMP_PTXDIST=y
> > > +# PTXCONF_REPRODUCIBLE_TIMESTAMP_TOOLCHAIN is not set
> > > +# PTXCONF_REPRODUCIBLE_TIMESTAMP_CUSTOM is not set
> > > +# PTXCONF_REPRODUCIBLE_TIMESTAMP_STRING is not set
> > > +PTXCONF_DEBUG_PACKAGES=y
> > > +# initmethod will enable the following busybox tools if needed:
> > > +# PTXCONF_BUSYBOX_HALT is not set
> > > +# PTXCONF_BUSYBOX_INIT is not set
> > > +# PTXCONF_BUSYBOX_POWEROFF is not set
> > > +# PTXCONF_BUSYBOX_REBOOT is not set
> > > +# PTXCONF_BUSYBOX_RUNLEVEL is not set
> > > +# PTXCONF_STAGING is not set
> > 
> > How can we keep these files up-to-date?
> 
> I guess like for everything else: patches or bug reports if someone
> notices that it's broken. And the only way it can break will just lead
> to more unnecessary questions being asked, which is a bit annoying but
> not a tragedy, or defaults from the Kconfig options being used, which
> should be fine.

This just helps for new options, not old ones. Those just pile up.

> Alternatively I think kconfig has a "save_defconfig" function which
> could help us.

The problem is that we want to provide defaults only for some of the
options.

> > > diff --git a/rules/initmethod.in b/rules/initmethod.in
> > > index b8c0b9f97b30..604fae3b4f7b 100644
> > > --- a/rules/initmethod.in
> > > +++ b/rules/initmethod.in
> > > @@ -10,6 +10,9 @@ menuconfig INITMETHOD
> > >  if INITMETHOD
> > >  
> > >  choice
> > > +	#
> > > +	# NOTE: if you add options here, also add them to rules/init_defconfig
> > > +	#
> 
> Or should I add more comments like this…?

I don't think that will help.

> > >  	prompt "init method"
> > >  	default INITMETHOD_SYSTEMD
> > >  
> > > diff --git a/scripts/lib/ptxd_lib_init.sh b/scripts/lib/ptxd_lib_init.sh
> > > new file mode 100644
> > > index 000000000000..54fcb4d27eee
> > > --- /dev/null
> > > +++ b/scripts/lib/ptxd_lib_init.sh
> > > @@ -0,0 +1,96 @@
> > > +#!/bin/bash
> > > +
> > > +ptxd_lib_init_check() {
> > > +	if [ -z "${PTXDIST_PTXCONFIG}" ]; then
> > > +		echo
> > > +		echo "${PTXDIST_LOG_PROMPT}error: cannot create empty ptxconfig file."
> > > +		echo
> > > +		return 1
> > > +	fi
> > > +
> > > +	if [ -z "${PTXDIST_FORCE}" ] && [ -e "${PTXDIST_PTXCONFIG}" ]; then
> > > +		echo
> > > +		echo "${PTXDIST_LOG_PROMPT}error: the file '${PTXDIST_PTXCONFIG}' already exists,"
> > > +		echo "${PTXDIST_LOG_PROMPT}       use '--force' to overwrite it."
> > > +		echo
> > > +		return 1
> > > +	fi
> > > +
> > > +	if [ -z "${PTXDIST_FORCE}" ] && [ -e "${PTXDIST_PTXCONFIG_DEFAULT}" ]; then
> > > +		echo
> > > +		echo "${PTXDIST_LOG_PROMPT}error: the file '${PTXDIST_PTXCONFIG_DEFAULT}' already exists,"
> > > +		echo "${PTXDIST_LOG_PROMPT}       use '--force' to overwrite it."
> > > +		echo
> > > +		return 1
> > > +	fi
> > > +}
> > > +export -f ptxd_lib_init_check
> > > +
> > > +ptxd_lib_init() {
> > > +	ptxd_lib_init_check &&
> > > +
> > > +	mkdir -p "$(dirname "${PTXDIST_PTXCONFIG}")" &&
> > > +	cat "${PTXDIST_TOPDIR}/rules/init_defconfig" > "${PTXDIST_PTXCONFIG}" &&
> > > +
> > > +	PTXDIST_FORCE=true do_select ptxconfig "${PTXDIST_PTXCONFIG}" &&
> > > +
> > > +	# only ask the important questions first, then do silentdefconfig for
> > > +	# all other options
> > > +	PTXDIST_DEP_TARGET="all" ptxd_kconfig oldconfig "init-ptx" &&
> > > +
> > > +	# ... then do a silent defconfig for all other defaults
> > > +	PTXDIST_DEP_TARGET="all" PTXDIST_FORCE=true \
> > > +		yes '' | ptxd_kconfig oldconfig ptx > /dev/null
> > 
> > I think we can use alldefconfig here.
> 
> I had this in my first draft, but alldefconfig will reset all previously
> pre-primed options from the init_defconfig to their respective defaults
> as defined in Kconfig, and we don't want that here.

You need to set:

KCONFIG_ALLCONFIG=/full/path/to/initial/config

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
To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [ptxdist] [PATCH 7/7] ptxdist: add 'init' commands to create new configs
  2020-09-24 13:42       ` Michael Olbrich
@ 2020-09-27 21:46         ` Roland Hieber
  0 siblings, 0 replies; 16+ messages in thread
From: Roland Hieber @ 2020-09-27 21:46 UTC (permalink / raw)
  To: ptxdist

On Thu, Sep 24, 2020 at 03:42:18PM +0200, Michael Olbrich wrote:
> On Wed, Sep 23, 2020 at 02:22:59PM +0200, Roland Hieber wrote:
> > On Tue, Sep 22, 2020 at 11:46:22AM +0200, Michael Olbrich wrote:
> > > On Tue, Sep 22, 2020 at 12:17:28AM +0200, Roland Hieber wrote:
[...]
> > > > +# PTXCONF_KERNEL_CONFIG_BASE_VERSION is not set
> > > > +PTXCONF_KERNEL_SERIES="series"
> > > > +PTXCONF_KERNEL_CONFIG="kernelconfig-${PTXCONF_KERNEL_VERSION}"
> > > 
> > > I thought I changed that default. Please change this and the default value
> > > to just "kernelconfig". The version just causes problems in most cases.
> > 
> > Oh, right. I remember a discussion about it.

I've sent a separate patch for this in <20200927214336.23382-1-rhi@pengutronix.de>
since this series needs some more thought.

[...]
> > > > +endchoice
> > > > diff --git a/rules/init_defconfig b/rules/init_defconfig
> > > > new file mode 100644
> > > > index 000000000000..9fa9ab00a60b
> > > > --- /dev/null
> > > > +++ b/rules/init_defconfig
> > > > @@ -0,0 +1,21 @@
> > > > +# PTXCONF_ALLYES is not set
> > > > +# PTXCONF_BROKEN is not set
> > > > +PTXCONF_FIX_PERMISSIONS=y
> > > > +PTXCONF_PROJECT_VERSION="-${PTXDIST_BSP_AUTOVERSION}"
> > > > +# PTXCONF_PROJECT_CREATE_DEVPKGS is not set
> > > > +# PTXCONF_PROJECT_USE_DEVPKGS is not set
> > > > +PTXCONF_PROJECT_DEVPKGDIR=""
> > > > +PTXCONF_PROJECT_DEVMIRROR=""
> > > > +# PTXCONF_PROJECT_CHECK_LICENSES is not set
> > > > +PTXCONF_REPRODUCIBLE_TIMESTAMP_PTXDIST=y
> > > > +# PTXCONF_REPRODUCIBLE_TIMESTAMP_TOOLCHAIN is not set
> > > > +# PTXCONF_REPRODUCIBLE_TIMESTAMP_CUSTOM is not set
> > > > +# PTXCONF_REPRODUCIBLE_TIMESTAMP_STRING is not set
> > > > +PTXCONF_DEBUG_PACKAGES=y
> > > > +# initmethod will enable the following busybox tools if needed:
> > > > +# PTXCONF_BUSYBOX_HALT is not set
> > > > +# PTXCONF_BUSYBOX_INIT is not set
> > > > +# PTXCONF_BUSYBOX_POWEROFF is not set
> > > > +# PTXCONF_BUSYBOX_REBOOT is not set
> > > > +# PTXCONF_BUSYBOX_RUNLEVEL is not set
> > > > +# PTXCONF_STAGING is not set
> > > 
> > > How can we keep these files up-to-date?
> > 
> > I guess like for everything else: patches or bug reports if someone
> > notices that it's broken. And the only way it can break will just lead
> > to more unnecessary questions being asked, which is a bit annoying but
> > not a tragedy, or defaults from the Kconfig options being used, which
> > should be fine.
> 
> This just helps for new options, not old ones. Those just pile up.
> 
> > Alternatively I think kconfig has a "save_defconfig" function which
> > could help us.
> 
> The problem is that we want to provide defaults only for some of the
> options.

I think I'll solve this problem differently in v3. Since the other
patches are unrelated to this one, if you don't have anything else
against them, feel free to apply them already.

 - 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
To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2020-09-27 21:46 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-21 22:17 [ptxdist] [PATCH 1/7] kernel: bump default version and md5sum Roland Hieber
2020-09-21 22:17 ` [ptxdist] [PATCH 2/7] platform: bump default toolchain version Roland Hieber
2020-09-21 22:17 ` [ptxdist] [PATCH 3/7] kernel, barebox: add descriptive help text for md5sum config options Roland Hieber
2020-09-21 22:17 ` [ptxdist] [PATCH 4/7] image-root-tgz: build by default, and add a help text Roland Hieber
2020-09-22  8:17   ` Michael Olbrich
2020-09-22  9:08     ` Roland Hieber
2020-09-21 22:17 ` [ptxdist] [PATCH 5/7] ptxdist: implement 'defconfig' commands for kconfig packages Roland Hieber
2020-09-22  8:26   ` Michael Olbrich
2020-09-21 22:17 ` [ptxdist] [PATCH 6/7] rules: move magic symbol into rules/ptxdist-version.in Roland Hieber
2020-09-21 22:17 ` [ptxdist] [PATCH 7/7] ptxdist: add 'init' commands to create new configs Roland Hieber
2020-09-22  9:46   ` Michael Olbrich
2020-09-23 12:22     ` Roland Hieber
2020-09-24 13:42       ` Michael Olbrich
2020-09-27 21:46         ` Roland Hieber
2020-09-22  8:13 ` [ptxdist] [PATCH 1/7] kernel: bump default version and md5sum Michael Olbrich
2020-09-22  9:17   ` Roland Hieber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox