From b9577ef790c090445e1a26836d644ac146b9290e Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Thu, 14 Nov 2024 21:45:12 +0100 Subject: [PATCH] rauc: prepare support for locating the config in /usr or /run RAUC PR #1557[1] extends RAUC to look up its system.conf in /etc/rauc, /run/rauc or /usr/lib/rauc in that order. The RAUC recipe understandably hardcodes the assumption that the system.conf must be supplied and that it must be located in /etc/rauc. To make the recipe more useful with RAUC once #1557 is merged, let's do two tiny adjustments: - Add RAUC_CONF_DIR, which default to /etc/rauc, but can be set by the user to be /usr/lib/rauc instead for hermetic-usr use cases. - Add RAUC_CONF_INSTALL, which allows skipping installation of the config altogether. This is useful if the RAUC config is always dynamically generated in /run/rauc and having an always masked /usr/lib/rauc/system.conf would just be confusing. To avoid breaking existing users, the defaults are chosen, so the system.conf continues to be installed in /etc. This PR does not break anything for current RAUC versions, so it should be fine to merge it independent of the update to a future RAUC release that integrates the upstream PR. [1]: https://github.com/rauc/rauc/pull/1557 Signed-off-by: Ahmad Fatoum --- README.rst | 6 +++--- recipes-core/rauc/files/system.conf | 6 +++--- recipes-core/rauc/rauc-target.inc | 25 ++++++++++++++++--------- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/README.rst b/README.rst index 7b305db0..b6033862 100644 --- a/README.rst +++ b/README.rst @@ -88,9 +88,9 @@ you have to follow at least the following steps: DISTRO_FEATURES += "rauc" 2. Add a ``rauc_%.bbappend`` in your device-specific (BSP) layer - that installs your RAUC system configuration file under - ``/etc/rauc/system.conf``. For information on how to write the RAUC - update file, please refer to the RAUC user documentation [1]_:: + that installs your RAUC system configuration, so RAUC can find it. + For information on how to write the RAUC update file, please refer to + the RAUC user documentation [1]_:: FILESEXTRAPATHS:prepend := "${THISDIR}/files:" SRC_URI:append := " file://system.conf" diff --git a/recipes-core/rauc/files/system.conf b/recipes-core/rauc/files/system.conf index a89a21fc..57c19898 100644 --- a/recipes-core/rauc/files/system.conf +++ b/recipes-core/rauc/files/system.conf @@ -1,6 +1,6 @@ -## This is an example RAUC system configuration. This file will be installed -## into /etc/rauc/system.conf on your target and describes your system from the -## perspective of the RAUC update service. +## This is an example RAUC system configuration. This file will be be looked up +## in {/etc,/run,/usr/lib}/rauc/system.conf on your target and describes your +## system from the # perspective of the RAUC update service. ## ## Adapt and extend the below configuration to your needs and place it in the ## BSP layer of you project. Create a rauc .bbappend file that adds this file diff --git a/recipes-core/rauc/rauc-target.inc b/recipes-core/rauc/rauc-target.inc index 0bde7be5..7bf8af96 100644 --- a/recipes-core/rauc/rauc-target.inc +++ b/recipes-core/rauc/rauc-target.inc @@ -1,10 +1,12 @@ RAUC_KEYRING_FILE ??= "ca.cert.pem" RAUC_KEYRING_URI ??= "file://${RAUC_KEYRING_FILE}" +RAUC_CONF_INSTALL ??= "1" +RAUC_CONF_DIR ??= "${sysconfdir}/rauc" RRECOMMENDS:${PN} = "squashfs-tools" SRC_URI:append = " \ - file://system.conf \ + ${@oe.utils.conditional('RAUC_CONF_INSTALL', '1', 'file://system.conf', '', d)} \ ${RAUC_KEYRING_URI} \ file://rauc-mark-good.service \ file://rauc-mark-good.init \ @@ -22,20 +24,23 @@ inherit systemd update-rc.d do_install () { meson_do_install - # Create rauc config dir - # Warn if system configuration was not overwritten - if ! grep -q "^[^#]" ${WORKDIR}/system.conf; then - bbwarn "Please overwrite example system.conf with a project specific one!" + if [ "${RAUC_CONF_INSTALL}" = 1 ]; then + # Create rauc config dir + # Warn if system configuration was not overwritten + if ! grep -q "^[^#]" ${WORKDIR}/system.conf; then + bbwarn "Please overwrite example system.conf with a project specific one!" + fi + + install -d ${D}${RAUC_CONF_DIR} + install -m 0644 ${WORKDIR}/system.conf ${D}${RAUC_CONF_DIR}/system.conf fi - install -d ${D}${sysconfdir}/rauc - install -m 0644 ${WORKDIR}/system.conf ${D}${sysconfdir}/rauc/system.conf # Warn if CA file was not overwritten if ! grep -q "^[^#]" ${WORKDIR}/${RAUC_KEYRING_FILE}; then bbwarn "Please overwrite example ca.cert.pem with a project specific one, or set the RAUC_KEYRING_FILE variable with your file!" fi - install -d ${D}${sysconfdir}/rauc/ - install -m 0644 ${WORKDIR}/${RAUC_KEYRING_FILE} ${D}${sysconfdir}/rauc/ + install -d ${D}${RAUC_CONF_DIR}/ + install -m 0644 ${WORKDIR}/${RAUC_KEYRING_FILE} ${D}${RAUC_CONF_DIR}/ install -d ${D}${systemd_unitdir}/system/ install -m 0644 ${WORKDIR}/rauc-mark-good.service ${D}${systemd_unitdir}/system/ @@ -45,6 +50,8 @@ do_install () { install -m 755 "${WORKDIR}/rauc-mark-good.init" "${D}${sysconfdir}/init.d/rauc-mark-good" } +FILES:${PN} += "${RAUC_CONF_DIR}" + PACKAGES =+ "${PN}-mark-good" # some magic to get the tool to interact with bootloader storage