From 1f4d6e6f1d4cdbe25ba30a0e12e1259662e7ba96 Mon Sep 17 00:00:00 2001 From: Nicolas Adenis-Lamarre Date: Mon, 26 Sep 2022 20:24:34 +0000 Subject: [PATCH] batocera.conf default values by board Signed-off-by: Nicolas Adenis-Lamarre --- .../core/batocera-audio/S27audioconfig | 6 ++-- .../batocera-settings-get-master | 29 +++++++++++++++++ .../batocera-settings/batocera-settings.mk | 4 +++ .../core/batocera-system/batocera-system.mk | 32 +++---------------- 4 files changed, 40 insertions(+), 31 deletions(-) create mode 100755 package/batocera/core/batocera-settings/batocera-settings-get-master diff --git a/package/batocera/core/batocera-audio/S27audioconfig b/package/batocera/core/batocera-audio/S27audioconfig index e2677283053..2c619f74632 100755 --- a/package/batocera/core/batocera-audio/S27audioconfig +++ b/package/batocera/core/batocera-audio/S27audioconfig @@ -72,9 +72,9 @@ start_audioconfig() { # and thus, we let splash before config here while udev is the services taking the most time # set default device and volume - DEVICE=$(/usr/bin/batocera-settings-get audio.device) - PROFILE=$(/usr/bin/batocera-settings-get audio.profile) - VOLUME=$(/usr/bin/batocera-settings-get audio.volume) + DEVICE=$(/usr/bin/batocera-settings-get-master audio.device) + PROFILE=$(/usr/bin/batocera-settings-get-master audio.profile) + VOLUME=$(/usr/bin/batocera-settings-get-master audio.volume) test -z "${DEVICE}" && DEVICE=auto test -z "${PROFILE}" && PROFILE=auto test -z "${VOLUME}" && VOLUME=80 diff --git a/package/batocera/core/batocera-settings/batocera-settings-get-master b/package/batocera/core/batocera-settings/batocera-settings-get-master new file mode 100755 index 00000000000..e8f53651f6c --- /dev/null +++ b/package/batocera/core/batocera-settings/batocera-settings-get-master @@ -0,0 +1,29 @@ +#!/bin/bash + +# this script can be used by values that can have a default value by board + +KEY=$1 + +# prefer the user value +batocera-settings-get "${KEY}" && exit 0 + +BOARD_MODEL=$(cat /sys/firmware/devicetree/base/model 2>/dev/null | sed -e s+"[^A-Za-z0-9]"+"_"+g) +if test -z "${BOARD_MODEL}" +then + # give an other chance with dmi + BOARD_MODEL=$(cat /sys/devices/virtual/dmi/id/board_name 2>/dev/null | sed -e s+"[^A-Za-z0-9]"+"_"+g) +fi + +# prefer the board value +if test -e "/usr/share/batocera/sysconfigs/batocera.conf.${BOARD_MODEL}" +then + batocera-settings-get -f "/usr/share/batocera/sysconfigs/batocera.conf.${BOARD_MODEL}" "${KEY}" && exit 0 +fi + +# prefer the general value +if test -e "/usr/share/batocera/sysconfigs/batocera.conf" +then + batocera-settings-get -f "/usr/share/batocera/sysconfigs/batocera.conf" "${KEY}" && exit 0 +fi + +exit 1 diff --git a/package/batocera/core/batocera-settings/batocera-settings.mk b/package/batocera/core/batocera-settings/batocera-settings.mk index ee08670f2cb..5a5d6e8bcf4 100644 --- a/package/batocera/core/batocera-settings/batocera-settings.mk +++ b/package/batocera/core/batocera-settings/batocera-settings.mk @@ -12,4 +12,8 @@ BATOCERA_SETTINGS_CONF_OPTS = \ -Dget_exe_name=batocera-settings-get \ -Dset_exe_name=batocera-settings-set +define BATOCERA_SETTINGS_INSTALL_TARGET_CMDS + install -m 0755 $(BR2_EXTERNAL_BATOCERA_PATH)/package/batocera/core/batocera-settings/batocera-settings-get-master $(TARGET_DIR)/usr/bin/batocera-settings-get-master +endef + $(eval $(meson-package)) diff --git a/package/batocera/core/batocera-system/batocera-system.mk b/package/batocera/core/batocera-system/batocera-system.mk index 5a8e2188c54..a6d4c3713d6 100644 --- a/package/batocera/core/batocera-system/batocera-system.mk +++ b/package/batocera/core/batocera-system/batocera-system.mk @@ -13,88 +13,60 @@ BATOCERA_SYSTEM_DEPENDENCIES = tzdata ifeq ($(BR2_PACKAGE_BATOCERA_TARGET_BCM2837),y) BATOCERA_SYSTEM_ARCH=bcm2837 - BATOCERA_SYSTEM_BATOCERA_CONF=bcm2837 else ifeq ($(BR2_PACKAGE_BATOCERA_TARGET_RK3399),y) BATOCERA_SYSTEM_ARCH=rk3399 - BATOCERA_SYSTEM_BATOCERA_CONF=rk3399 else ifeq ($(BR2_PACKAGE_BATOCERA_TARGET_RG552),y) BATOCERA_SYSTEM_ARCH=rg552 - BATOCERA_SYSTEM_BATOCERA_CONF=rg552 else ifeq ($(BR2_PACKAGE_BATOCERA_TARGET_RK3288),y) BATOCERA_SYSTEM_ARCH=rk3288 - BATOCERA_SYSTEM_BATOCERA_CONF=rk3288 else ifeq ($(BR2_PACKAGE_BATOCERA_TARGET_TRITIUM_H5),y) BATOCERA_SYSTEM_ARCH=tritium_h5 - BATOCERA_SYSTEM_BATOCERA_CONF=tritium_h5 else ifeq ($(BR2_PACKAGE_BATOCERA_TARGET_ORANGEPI_ZERO2),y) BATOCERA_SYSTEM_ARCH=orangepi_zero2 - BATOCERA_SYSTEM_BATOCERA_CONF=orangepi_zero2 else ifeq ($(BR2_PACKAGE_BATOCERA_TARGET_ORANGEPI_PC),y) BATOCERA_SYSTEM_ARCH=orangepi_pc - BATOCERA_SYSTEM_BATOCERA_CONF=orangepi_pc else ifeq ($(BR2_PACKAGE_BATOCERA_TARGET_CHA),y) BATOCERA_SYSTEM_ARCH=cha - BATOCERA_SYSTEM_BATOCERA_CONF=cha else ifeq ($(BR2_PACKAGE_BATOCERA_TARGET_S812),y) BATOCERA_SYSTEM_ARCH=s812 - BATOCERA_SYSTEM_BATOCERA_CONF=s812 else ifeq ($(BR2_PACKAGE_BATOCERA_TARGET_S922X),y) BATOCERA_SYSTEM_ARCH=s922x - BATOCERA_SYSTEM_BATOCERA_CONF=s922x else ifeq ($(BR2_PACKAGE_BATOCERA_TARGET_RK3326),y) BATOCERA_SYSTEM_ARCH=rk3326 - BATOCERA_SYSTEM_BATOCERA_CONF=rk3326 else ifeq ($(BR2_PACKAGE_BATOCERA_TARGET_RK3128),y) BATOCERA_SYSTEM_ARCH=rk3128 - BATOCERA_SYSTEM_BATOCERA_CONF=rk3128 else ifeq ($(BR2_PACKAGE_BATOCERA_TARGET_XU4),y) BATOCERA_SYSTEM_ARCH=odroidxu4 - BATOCERA_SYSTEM_BATOCERA_CONF=xu4 else ifeq ($(BR2_PACKAGE_BATOCERA_TARGET_S905),y) BATOCERA_SYSTEM_ARCH=s905 - BATOCERA_SYSTEM_BATOCERA_CONF=s905 else ifeq ($(BR2_PACKAGE_BATOCERA_TARGET_S905GEN2),y) BATOCERA_SYSTEM_ARCH=s905gen2 - BATOCERA_SYSTEM_BATOCERA_CONF=s905gen2 else ifeq ($(BR2_PACKAGE_BATOCERA_TARGET_S905GEN3),y) BATOCERA_SYSTEM_ARCH=s905gen3 - BATOCERA_SYSTEM_BATOCERA_CONF=s905gen3 else ifeq ($(BR2_PACKAGE_BATOCERA_TARGET_S912),y) BATOCERA_SYSTEM_ARCH=s912 - BATOCERA_SYSTEM_BATOCERA_CONF=s912 else ifeq ($(BR2_PACKAGE_BATOCERA_TARGET_X86),y) BATOCERA_SYSTEM_ARCH=x86 - BATOCERA_SYSTEM_BATOCERA_CONF=x86 else ifeq ($(BR2_PACKAGE_BATOCERA_TARGET_X86_64),y) BATOCERA_SYSTEM_ARCH=x86_64 - BATOCERA_SYSTEM_BATOCERA_CONF=x86_64 else ifeq ($(BR2_PACKAGE_BATOCERA_TARGET_PS4),y) BATOCERA_SYSTEM_ARCH=ps4 - BATOCERA_SYSTEM_BATOCERA_CONF=ps4 else ifeq ($(BR2_PACKAGE_BATOCERA_TARGET_ZNVER2),y) BATOCERA_SYSTEM_ARCH=znver2 - BATOCERA_SYSTEM_BATOCERA_CONF=znver2 else ifeq ($(BR2_PACKAGE_BATOCERA_TARGET_BCM2836),y) BATOCERA_SYSTEM_ARCH=bcm2836 - BATOCERA_SYSTEM_BATOCERA_CONF=bcm2836 else ifeq ($(BR2_PACKAGE_BATOCERA_TARGET_BCM2835),y) BATOCERA_SYSTEM_ARCH=bcm2835 - BATOCERA_SYSTEM_BATOCERA_CONF=bcm2835 else ifeq ($(BR2_PACKAGE_BATOCERA_TARGET_RPIZERO2),y) BATOCERA_SYSTEM_ARCH=rpizero2 - BATOCERA_SYSTEM_BATOCERA_CONF=rpizero2 else ifeq ($(BR2_PACKAGE_BATOCERA_TARGET_BCM2711),y) BATOCERA_SYSTEM_ARCH=bcm2711 - BATOCERA_SYSTEM_BATOCERA_CONF=bcm2711 else ifeq ($(BR2_PACKAGE_BATOCERA_TARGET_ODIN),y) BATOCERA_SYSTEM_ARCH=odin - BATOCERA_SYSTEM_BATOCERA_CONF=odin else ifeq ($(BR2_PACKAGE_BATOCERA_TARGET_ORANGEPI_3_LTS),y) BATOCERA_SYSTEM_ARCH=orangepi_3_lts - BATOCERA_SYSTEM_BATOCERA_CONF=orangepi_3_lts else BATOCERA_SYSTEM_ARCH=unknown - BATOCERA_SYSTEM_BATOCERA_CONF=unknown endif ifneq (,$(findstring dev,$(BATOCERA_SYSTEM_VERSION))) @@ -117,6 +89,10 @@ define BATOCERA_SYSTEM_INSTALL_TARGET_CMDS # batocera-boot.conf $(INSTALL) -D -m 0644 $(BR2_EXTERNAL_BATOCERA_PATH)/package/batocera/core/batocera-system/batocera-boot.conf $(BINARIES_DIR)/batocera-boot.conf + # sysconfigs (default batocera.conf for boards) + mkdir -p $(TARGET_DIR)/usr/share/batocera/sysconfigs + test -d $(BR2_EXTERNAL_BATOCERA_PATH)/package/batocera/core/batocera-system/sysconfigs/${BATOCERA_SYSTEM_ARCH} && cp -pr $(BR2_EXTERNAL_BATOCERA_PATH)/package/batocera/core/batocera-system/sysconfigs/${BATOCERA_SYSTEM_ARCH}/* $(TARGET_DIR)/usr/share/batocera/sysconfigs + # mounts mkdir -p $(TARGET_DIR)/boot $(TARGET_DIR)/overlay $(TARGET_DIR)/userdata