[2/3] kas: Select machine before the distro

Message ID 20241207161031.714-3-ubely@ilbers.de
State Accepted, archived
Headers show
Series Select machine before the distro | expand

Commit Message

Uladzimir Bely Dec. 7, 2024, 4:09 p.m. UTC
Existing approach made user select the distro first so that machines
supporting it became available in machine submenu.

New approach is more user-friendly and native. First, user selects
the board and thus receives a list of distros that it supports.

Signed-off-by: Uladzimir Bely <ubely@ilbers.de>
---
 Kconfig             |   4 +-
 kas/distro/Kconfig  |  45 ++++++++++++++++
 kas/machine/Kconfig | 127 ++++++++++++++++++++++++++++++++++----------
 3 files changed, 148 insertions(+), 28 deletions(-)

Patch

diff --git a/Kconfig b/Kconfig
index 538c0a1b..683c0da5 100644
--- a/Kconfig
+++ b/Kconfig
@@ -1,6 +1,8 @@ 
 # This software is a part of ISAR.
 # Copyright (C) 2023 ilbers GmbH
 #
+# SPDX-License-Identifier: MIT
+#
 # Authors:
 #  Uladzimir Bely <ubely@ilbers.de>
 
@@ -14,8 +16,8 @@  config KAS_BUILD_SYSTEM
 	string
 	default "isar"
 
-source "kas/distro/Kconfig"
 source "kas/machine/Kconfig"
+source "kas/distro/Kconfig"
 source "kas/image/Kconfig"
 source "kas/package/Kconfig"
 source "kas/opt/Kconfig"
diff --git a/kas/distro/Kconfig b/kas/distro/Kconfig
index 31492121..3ddc3ef3 100644
--- a/kas/distro/Kconfig
+++ b/kas/distro/Kconfig
@@ -1,44 +1,89 @@ 
 # This software is a part of Isar.
 # Copyright (C) 2023-2024 ilbers GmbH
 #
+# SPDX-License-Identifier: MIT
+#
 # Authors:
 #  Uladzimir Bely <ubely@ilbers.de>
 
 menu "Distro selection"
 
+config DISTRO_DEBIAN
+	bool
+
+config DISTRO_RASPIOS
+	bool
+
+config DISTRO_UBUNTU
+	bool
+
+config CODENAME_BUSTER
+	bool
+
+config CODENAME_BULLSEYE
+	bool
+
+config CODENAME_BOOKWORM
+	bool
+
+config CODENAME_TRIXIE
+	bool
+
+config CODENAME_SID
+	bool
+
+config CODENAME_FOCAL
+	bool
+
+config CODENAME_JAMMY
+	bool
+
+config CODENAME_NOBLE
+	bool
+
 choice
 	prompt "Distro selection"
 	default DEBIAN_BOOKWORM
 
 config DEBIAN_BUSTER
 	bool "Debian 10 (buster)"
+	depends on DISTRO_DEBIAN && CODENAME_BUSTER
 
 config DEBIAN_BULLSEYE
 	bool "Debian 11 (bullseye)"
+	depends on DISTRO_DEBIAN && CODENAME_BULLSEYE
 
 config DEBIAN_BOOKWORM
 	bool "Debian 12 (bookworm)"
+	depends on DISTRO_DEBIAN && CODENAME_BOOKWORM
 
 config DEBIAN_TRIXIE
 	bool "Debian 13 (trixie)"
+	depends on DISTRO_DEBIAN && CODENAME_TRIXIE
 
 config DEBIAN_SID
 	bool "Debian Sid (unstable)"
+	depends on DISTRO_DEBIAN && CODENAME_SID
 
 config RASPIOS_BULLSEYE
 	bool "Raspberry Pi OS Debian 11 (bullseye)"
+	depends on DISTRO_RASPIOS && CODENAME_BULLSEYE
 
 config RASPIOS_BOOKWORM
 	bool "Raspberry Pi OS Debian 12 (bookworm)"
+	depends on DISTRO_RASPIOS && CODENAME_BOOKWORM
 
 config UBUNTU_FOCAL
 	bool "Ubuntu 20.04 (Focal)"
+	depends on DISTRO_UBUNTU && CODENAME_FOCAL
 
 config UBUNTU_JAMMY
 	bool "Ubuntu 22.04 (Jammy)"
+	depends on DISTRO_UBUNTU && CODENAME_JAMMY
 
 config UBUNTU_NOBLE
 	bool "Ubuntu 24.04 (Noble)"
+	depends on DISTRO_UBUNTU && CODENAME_NOBLE
 
 endchoice
 
diff --git a/kas/machine/Kconfig b/kas/machine/Kconfig
index a4549476..0d1e0dd9 100644
--- a/kas/machine/Kconfig
+++ b/kas/machine/Kconfig
@@ -1,6 +1,8 @@ 
 # This software is a part of Isar.
 # Copyright (C) 2023-2024 ilbers GmbH
 #
+# SPDX-License-Identifier: MIT
+#
 # Authors:
 #  Uladzimir Bely <ubely@ilbers.de>
 
@@ -30,137 +32,208 @@  choice
 
 config MACHINE_BANANAPI
 	bool "bananapi"
-	depends on DEBIAN_BUSTER || DEBIAN_BULLSEYE || DEBIAN_BOOKWORM
+	select DISTRO_DEBIAN
+	select CODENAME_BUSTER
+	select CODENAME_BULLSEYE
+	select CODENAME_BOOKWORM
 	select ARCH_ARMHF
 
 config MACHINE_BEAGLEPLAY
 	bool "beagleplay"
-	depends on DEBIAN_BOOKWORM
+	select DISTRO_DEBIAN
+	select CODENAME_BOOKWORM
 	select ARCH_ARM64
 
 config MACHINE_CONTAINER_AMD64
 	bool "container-amd64"
-	depends on DEBIAN_BUSTER || DEBIAN_BULLSEYE || DEBIAN_BOOKWORM
+	select DISTRO_DEBIAN
+	select CODENAME_BUSTER
+	select CODENAME_BULLSEYE
+	select CODENAME_BOOKWORM
 	select ARCH_AMD64
 
 config MACHINE_DE0_NANO_SOC
 	bool "de0-nano-soc"
-	depends on DEBIAN_BUSTER || DEBIAN_BULLSEYE || DEBIAN_BOOKWORM
+	select DISTRO_DEBIAN
+	select CODENAME_BUSTER
+	select CODENAME_BULLSEYE
+	select CODENAME_BOOKWORM
 	select ARCH_ARMHF
 
 config MACHINE_HIKEY
 	bool "hikey"
-	depends on DEBIAN_BULLSEYE || DEBIAN_BOOKWORM
+	select DISTRO_DEBIAN
+	select CODENAME_BULLSEYE
+	select CODENAME_BOOKWORM
 	select ARCH_ARM64
 
 config MACHINE_IMX6_SABRELITE
 	bool "imx6-sabrelite"
-	depends on DEBIAN_BUSTER || DEBIAN_BULLSEYE
+	select DISTRO_DEBIAN
+	select CODENAME_BUSTER
+	select CODENAME_BULLSEYE
 	select ARCH_ARMHF
 
 config MACHINE_NANOPI_NEO
 	bool "nanopi-neo"
-	depends on DEBIAN_BUSTER || DEBIAN_BULLSEYE || DEBIAN_BOOKWORM
+	select DISTRO_DEBIAN
+	select CODENAME_BUSTER
+	select CODENAME_BULLSEYE
+	select CODENAME_BOOKWORM
 	select ARCH_ARMHF
 
 config MACHINE_NANOPI_NEO_EFI
 	bool "nanopi-neo-efi"
-	depends on DEBIAN_BOOKWORM
+	select DISTRO_DEBIAN
+	select CODENAME_BOOKWORM
 	select ARCH_ARMHF
 
 config MACHINE_PHYBOARD_MIRA
 	bool "phyboard-mira"
-	depends on DEBIAN_BULLSEYE || DEBIAN_BOOKWORM
+	select DISTRO_DEBIAN
+	select CODENAME_BULLSEYE
+	select CODENAME_BOOKWORM
 	select ARCH_ARMHF
 
 config MACHINE_QEMU_AMD64_CIP
 	bool "qemuamd64-cip"
-	depends on DEBIAN_BOOKWORM
+	select DISTRO_DEBIAN
+	select CODENAME_BOOKWORM
 	select ARCH_AMD64
 
 config MACHINE_QEMU_AMD64_SB
 	bool "qemuamd64-sb"
-	depends on DEBIAN_BULLSEYE
+	select CODENAME_BULLSEYE
 	select ARCH_AMD64
 
 config MACHINE_QEMU_AMD64
 	bool "qemuamd64"
-	depends on DEBIAN_BUSTER || DEBIAN_BULLSEYE || DEBIAN_BOOKWORM || DEBIAN_TRIXIE || UBUNTU_FOCAL || UBUNTU_JAMMY || UBUNTU_NOBLE
+	select DISTRO_DEBIAN
+	select CODENAME_BUSTER
+	select CODENAME_BULLSEYE
+	select CODENAME_BOOKWORM
+	select CODENAME_TRIXIE
+	select DISTRO_UBUNTU
+	select CODENAME_FOCAL
+	select CODENAME_JAMMY
+	select CODENAME_NOBLE
 	select ARCH_AMD64
 
 config MACHINE_QEMU_ARM
 	bool "qemuarm"
-	depends on DEBIAN_BUSTER || DEBIAN_BULLSEYE || DEBIAN_BOOKWORM || DEBIAN_TRIXIE
+	select DISTRO_DEBIAN
+	select CODENAME_BUSTER
+	select CODENAME_BULLSEYE
+	select CODENAME_BOOKWORM
+	select CODENAME_TRIXIE
 	select ARCH_ARMHF
 
 config MACHINE_QEMU_ARM64
 	bool "qemuarm64"
-	depends on DEBIAN_BUSTER || DEBIAN_BULLSEYE || DEBIAN_BOOKWORM || DEBIAN_TRIXIE || UBUNTU_FOCAL || UBUNTU_JAMMY || UBUNTU_NOBLE
+	select DISTRO_DEBIAN
+	select CODENAME_BUSTER
+	select CODENAME_BULLSEYE
+	select CODENAME_BOOKWORM
+	select CODENAME_TRIXIE
+	select DISTRO_UBUNTU
+	select CODENAME_FOCAL
+	select CODENAME_JAMMY
+	select CODENAME_NOBLE
 	select ARCH_ARM64
 
 config MACHINE_QEMU_I386
 	bool "qemui386"
-	depends on DEBIAN_BUSTER || DEBIAN_BULLSEYE || DEBIAN_BOOKWORM
+	select DISTRO_DEBIAN
+	select CODENAME_BUSTER
+	select CODENAME_BULLSEYE
+	select CODENAME_BOOKWORM
 	select ARCH_I386
 
 config MACHINE_QEMU_MIPSEL
 	bool "qemumipsel"
-	depends on DEBIAN_BULLSEYE || DEBIAN_BOOKWORM
+	select DISTRO_DEBIAN
+	select CODENAME_BULLSEYE
+	select CODENAME_BOOKWORM
 	select ARCH_MIPSEL
 
 config MACHINE_QEMU_RISCV64
 	bool "qemuriscv64"
-	depends on DEBIAN_TRIXIE || DEBIAN_SID
+	select DISTRO_DEBIAN
+	select CODENAME_TRIXIE
+	select CODENAME_SID
 	select ARCH_RISCV64
 
 config MACHINE_RPI_ARM_V7
 	bool "rpi-arm-v7"
-	depends on RASPIOS_BULLSEYE || RASPIOS_BOOKWORM
+	select DISTRO_RASPIOS
+	select CODENAME_BULLSEYE
+	select CODENAME_BOOKWORM
 	select ARCH_ARMHF
 
 config MACHINE_RPI_ARM_V7L
 	bool "rpi-arm-v7l"
-	depends on RASPIOS_BULLSEYE || RASPIOS_BOOKWORM
+	select DISTRO_RASPIOS
+	select CODENAME_BULLSEYE
+	select CODENAME_BOOKWORM
 	select ARCH_ARMHF
 
 config MACHINE_RPI_ARM
 	bool "rpi-arm"
-	depends on RASPIOS_BULLSEYE || RASPIOS_BOOKWORM
+	select DISTRO_RASPIOS
+	select CODENAME_BULLSEYE
+	select CODENAME_BOOKWORM
 	select ARCH_ARMHF
 
 config MACHINE_RPI_ARM64_V8
 	bool "rpi-arm64-v8"
-	depends on RASPIOS_BULLSEYE || RASPIOS_BOOKWORM
+	select DISTRO_RASPIOS
+	select CODENAME_BULLSEYE
+	select CODENAME_BOOKWORM
 	select ARCH_ARM64
 
 config MACHINE_SIFIVE_FU540
 	bool "sifive-fu540"
-	depends on DEBIAN_TRIXIE || DEBIAN_SID
+	select DISTRO_DEBIAN
+	select CODENAME_TRIXIE
+	select CODENAME_SID
 	select ARCH_RISCV64
 
 config MACHINE_STARFIVE_VISIONFIVE2
 	bool "starfive-visionfive2"
-	depends on DEBIAN_TRIXIE || DEBIAN_SID
+	select DISTRO_DEBIAN
+	select CODENAME_TRIXIE
+	select CODENAME_SID
 	select ARCH_RISCV64
 
 config MACHINE_STM32MP15X
 	bool "stm32mp15x"
-	depends on DEBIAN_BULLSEYE
+	select DISTRO_DEBIAN
+	select CODENAME_BULLSEYE
 	select ARCH_ARMHF
 
 config MACHINE_VIRTUALBOX
 	bool "virtualbox"
-	depends on DEBIAN_BULLSEYE || DEBIAN_BOOKWORM
+	select DISTRO_DEBIAN
+	select CODENAME_BULLSEYE
+	select CODENAME_BOOKWORM
 	select ARCH_AMD64
 
 config MACHINE_VMWARE
 	bool "vmware"
-	depends on DEBIAN_BULLSEYE
+	select DISTRO_DEBIAN
+	select CODENAME_BULLSEYE
 	select ARCH_AMD64
 
 config MACHINE_X86_PC
 	bool "x86 PC"
-	depends on DEBIAN_BULLSEYE || DEBIAN_BOOKWORM || DEBIAN_TRIXIE || UBUNTU_FOCAL || UBUNTU_JAMMY || UBUNTU_NOBLE
+	select DISTRO_DEBIAN
+	select CODENAME_BULLSEYE
+	select CODENAME_BOOKWORM
+	select CODENAME_TRIXIE
+	select DISTRO_UBUNTU
+	select CODENAME_FOCAL
+	select CODENAME_JAMMY
+	select CODENAME_NOBLE
 	select ARCH_AMD64
 
 endchoice