Skip to content

Commit

Permalink
rauc: prepare support for locating the config in /usr or /run
Browse files Browse the repository at this point in the history
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]: rauc/rauc#1557

Signed-off-by: Ahmad Fatoum <[email protected]>
  • Loading branch information
a3f committed Nov 15, 2024
1 parent b27b59e commit 336917e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
7 changes: 4 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ 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
(in ``/etc/rauc/`` or ``/usr/lib/rauc/```).
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"
Expand Down
6 changes: 3 additions & 3 deletions recipes-core/rauc/files/system.conf
Original file line number Diff line number Diff line change
@@ -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
Expand Down
25 changes: 16 additions & 9 deletions recipes-core/rauc/rauc-target.inc
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -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/
Expand All @@ -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
Expand Down

0 comments on commit 336917e

Please sign in to comment.