From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Mon, 13 Feb 2023 10:43:48 +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 1pRVNG-0065Il-50 for lore@lore.pengutronix.de; Mon, 13 Feb 2023 10:43:48 +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 1pRVND-0003B2-CJ; Mon, 13 Feb 2023 10:43:47 +0100 Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pRVNA-0003Am-82; Mon, 13 Feb 2023 10:43:44 +0100 Received: from mol by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1pRVNA-0004J6-0r; Mon, 13 Feb 2023 10:43:44 +0100 Date: Mon, 13 Feb 2023 10:43:43 +0100 From: Michael Olbrich To: Roland Hieber Message-ID: <20230213094343.GG30852@pengutronix.de> Mail-Followup-To: Roland Hieber , distrokit@pengutronix.de References: <20230212221449.1644628-1-rhi@pengutronix.de> <20230212221449.1644628-2-rhi@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230212221449.1644628-2-rhi@pengutronix.de> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-Accept-Language: de,en X-Accept-Content-Type: text/plain User-Agent: Mutt/1.10.1 (2018-07-13) Subject: Re: [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: distrokit@pengutronix.de 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 On Sun, Feb 12, 2023 at 11:14:42PM +0100, Roland Hieber wrote: > 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)" This seems overly complicated. Why do you need xargs and two printf here? Michael > 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 > > > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |