From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Sun, 12 Feb 2023 23:15:10 +0100 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pRKcp-005asN-Nu for lore@lore.pengutronix.de; Sun, 12 Feb 2023 23:15:10 +0100 Received: from localhost ([127.0.0.1] helo=metis.ext.pengutronix.de) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1pRKcl-00070E-SO; Sun, 12 Feb 2023 23:15:07 +0100 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pRKcc-0006p8-94; Sun, 12 Feb 2023 23:14:58 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pRKca-004WV9-FS; Sun, 12 Feb 2023 23:14:57 +0100 Received: from rhi by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pRKcZ-006uAV-Se; Sun, 12 Feb 2023 23:14:55 +0100 From: Roland Hieber To: distrokit@pengutronix.de Date: Sun, 12 Feb 2023 23:14:42 +0100 Message-Id: <20230212221449.1644628-2-rhi@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230212221449.1644628-1-rhi@pengutronix.de> References: <20230212221449.1644628-1-rhi@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [DistroKit] [PATCH 1/8] rauc-udev: add a compatibility layer for mapping partitions X-BeenThere: distrokit@pengutronix.de X-Mailman-Version: 2.1.29 Precedence: list List-Id: DistroKit Mailinglist List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roland Hieber Sender: "DistroKit" X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: distrokit-bounces@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false When we add RAUC support for different platforms later, we need a way to specify their respective root partitions in RAUC's system.conf; however, the names of the actual partitions can differ on different hardware platforms. Add a short udev rule that can add symlinks to the actual partitions based on the device tree compatible. This way we can refer to the partitions in system.conf using the symlinks on all boards that we want to support. This commit only adds a stub for now; we will add the code that creates the actual symlinks for each hardware in later commits. Signed-off-by: Roland Hieber --- configs/ptxconfig | 1 + projectroot/usr/lib/udev/of_base_compatible | 4 ++ .../lib/udev/rules.d/90-rauc-partitions.rules | 12 ++++++ rules/rauc-udev.in | 8 ++++ rules/rauc-udev.make | 37 +++++++++++++++++++ 5 files changed, 62 insertions(+) create mode 100755 projectroot/usr/lib/udev/of_base_compatible create mode 100644 projectroot/usr/lib/udev/rules.d/90-rauc-partitions.rules create mode 100644 rules/rauc-udev.in create mode 100644 rules/rauc-udev.make diff --git a/configs/ptxconfig b/configs/ptxconfig index 3c8c001aaf8e..a6a3f29afb53 100644 --- a/configs/ptxconfig +++ b/configs/ptxconfig @@ -3,6 +3,7 @@ # PTXdist 2022.12.0 # PTXCONF_DATAPARTITION=y +PTXCONF_RAUC_UDEV=y # # ------------------------------------ diff --git a/projectroot/usr/lib/udev/of_base_compatible b/projectroot/usr/lib/udev/of_base_compatible new file mode 100755 index 000000000000..6b59c9cc569d --- /dev/null +++ b/projectroot/usr/lib/udev/of_base_compatible @@ -0,0 +1,4 @@ +#!/bin/sh +# SPDX-License-Identifier: 0-BSD +# SPDX-FileCopyrightText: 2021 Roland Hieber, Pengutronix +printf 'OF_BASE_COMPATIBLE="%s"\n' "$(xargs -0 printf "%s " < /sys/firmware/devicetree/base/compatible)" diff --git a/projectroot/usr/lib/udev/rules.d/90-rauc-partitions.rules b/projectroot/usr/lib/udev/rules.d/90-rauc-partitions.rules new file mode 100644 index 000000000000..0300e8b9daad --- /dev/null +++ b/projectroot/usr/lib/udev/rules.d/90-rauc-partitions.rules @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: 0-BSD +# SPDX-FileCopyrightText: 2021 Roland Hieber, Pengutronix + +ACTION=="remove", GOTO="rauc_partitions_end" +SUBSYSTEM!="block", GOTO="rauc_partitions_end" + +IMPORT{program}="of_base_compatible" + +# Add symlinks named /dev/disk/by-usage/{data,rootfs0,rootfs1} pointing +# to the correct partitions based on the device tree compatible + +LABEL="rauc_partitions_end" diff --git a/rules/rauc-udev.in b/rules/rauc-udev.in new file mode 100644 index 000000000000..4e90343ba2dc --- /dev/null +++ b/rules/rauc-udev.in @@ -0,0 +1,8 @@ +## SECTION=project_specific + +config RAUC_UDEV + tristate + prompt "rauc udev rules" + select UDEV if RUNTIME + help + udev rules for cross-hardware-compatible partition symlinks diff --git a/rules/rauc-udev.make b/rules/rauc-udev.make new file mode 100644 index 000000000000..6a806fc43e34 --- /dev/null +++ b/rules/rauc-udev.make @@ -0,0 +1,37 @@ +# -*-makefile-*- +# +# Copyright (C) 2021 by Roland Hieber, Pengutronix +# +# For further information about the PTXdist project and license conditions +# see the README file. +# + +# +# We provide this package +# +PACKAGES-$(PTXCONF_RAUC_UDEV) += rauc-udev + +RAUC_UDEV_VERSION := 1 +RAUC_UDEV_LICENSE := 0-BSD + +# ---------------------------------------------------------------------------- +# Target-Install +# ---------------------------------------------------------------------------- + +$(STATEDIR)/rauc-udev.targetinstall: + @$(call targetinfo) + + @$(call install_init, rauc-udev) + @$(call install_fixup,rauc-udev,PRIORITY,optional) + @$(call install_fixup,rauc-udev,SECTION,base) + @$(call install_fixup,rauc-udev,AUTHOR,"Roland Hieber, Pengutronix ") + @$(call install_fixup,rauc-udev,DESCRIPTION,missing) + + @$(call install_alternative, rauc-udev, 0, 0, 0755, /usr/lib/udev/of_base_compatible) + @$(call install_alternative, rauc-udev, 0, 0, 0644, /usr/lib/udev/rules.d/90-rauc-partitions.rules) + + @$(call install_finish,rauc-udev) + + @$(call touch) + +# vim: syntax=make -- 2.30.2