DistroKit Mailinglist
 help / color / mirror / Atom feed
From: Roland Hieber <rhi@pengutronix.de>
To: distrokit@pengutronix.de
Cc: Roland Hieber <rhi@pengutronix.de>
Subject: [DistroKit] [PATCH 1/8] rauc-udev: add a compatibility layer for mapping partitions
Date: Sun, 12 Feb 2023 23:14:42 +0100	[thread overview]
Message-ID: <20230212221449.1644628-2-rhi@pengutronix.de> (raw)
In-Reply-To: <20230212221449.1644628-1-rhi@pengutronix.de>

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 <rhi@pengutronix.de>
---
 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 <rhi@pengutronix.de>
+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 <rhi@pengutronix.de>
+
+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 <rhi@pengutronix.de>
+#
+# 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 <rhi@pengutronix.de>")
+	@$(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




  reply	other threads:[~2023-02-12 22:15 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-12 22:14 [DistroKit] [PATCH 0/8] v7a: add redundant update support via RAUC Roland Hieber
2023-02-12 22:14 ` Roland Hieber [this message]
2023-02-13  9:43   ` [DistroKit] [PATCH 1/8] rauc-udev: add a compatibility layer for mapping partitions Michael Olbrich
2023-03-02  9:33     ` Roland Hieber
2023-02-12 22:14 ` [DistroKit] [PATCH 2/8] v7a: add RAUC support for qemu-vexpress Roland Hieber
2023-03-08  9:33   ` Roland Hieber
2023-02-12 22:14 ` [DistroKit] [PATCH 3/8] v7a: add RAUC support for beaglebone black Roland Hieber
2023-02-12 22:14 ` [DistroKit] [PATCH 4/8] v7a: add RAUC support for rpi3 Roland Hieber
2023-02-12 22:14 ` [DistroKit] [PATCH 5/8] v7a: add RAUC support for riotboard Roland Hieber
2023-02-12 22:14 ` [DistroKit] [PATCH 6/8] v7a: kernel: enable features necessary for RAUC Roland Hieber
2023-02-13  7:33   ` Jan Lübbe
2023-02-12 22:14 ` [DistroKit] [PATCH 7/8] rauc: add initial support Roland Hieber
2023-02-13  7:37   ` Jan Lübbe
2023-03-02  9:41     ` Roland Hieber
2023-03-02 10:34       ` Jan Lübbe
2023-03-02 16:09         ` Michael Olbrich
2023-03-08  9:45           ` Roland Hieber
2023-02-12 22:14 ` [DistroKit] [PATCH 8/8] v7a: enable RAUC bundle creation Roland Hieber
2023-02-13  7:42   ` Jan Lübbe
2023-04-25 18:38     ` Roland Hieber
2023-02-13  7:48 ` [DistroKit] [PATCH 0/8] v7a: add redundant update support via RAUC Marco Felsch
2023-02-13  9:35   ` Roland Hieber
2023-03-07 12:04 ` Ahmad Fatoum
2023-03-08 10:11   ` Roland Hieber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230212221449.1644628-2-rhi@pengutronix.de \
    --to=rhi@pengutronix.de \
    --cc=distrokit@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox