From: Jan Kiszka <jan.kiszka@siemens.com>
To: Quirin Gylstorff <Quirin.Gylstorff@siemens.com>,
cip-dev@lists.cip-project.org
Subject: Re: [cip-dev][isar-cip-core][RFC v2 2/6] add factory-reset-helper to set the marker file
Date: Thu, 8 May 2025 14:51:37 +0200 [thread overview]
Message-ID: <e6dbfadf-97b4-43fb-a407-c740ef343bd4@siemens.com> (raw)
In-Reply-To: <20250506120807.255675-3-Quirin.Gylstorff@siemens.com>
On 06.05.25 14:07, Quirin Gylstorff wrote:
> From: Quirin Gylstorff <quirin.gylstorff@siemens.com>
>
> This adds an helper script
> `/usr/lib/factory-reset/set-factory-reset-marker` which writes the marker file to
> the correct location.
>
Missing description how to use this. This way, it's just some piece of
script, lying around in a folder that is on no one's radar.
> Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
> ---
> .../factory-reset-helper_0.1.bb | 34 +++++++++++++++++++
> .../files/set-factory-reset-marker.sh.tmpl | 28 +++++++++++++++
> 2 files changed, 62 insertions(+)
> create mode 100644 recipes-support/factory-reset-helper/factory-reset-helper_0.1.bb
> create mode 100644 recipes-support/factory-reset-helper/files/set-factory-reset-marker.sh.tmpl
>
> diff --git a/recipes-support/factory-reset-helper/factory-reset-helper_0.1.bb b/recipes-support/factory-reset-helper/factory-reset-helper_0.1.bb
> new file mode 100644
> index 0000000..72cf5fd
> --- /dev/null
> +++ b/recipes-support/factory-reset-helper/factory-reset-helper_0.1.bb
> @@ -0,0 +1,34 @@
> +#
> +# CIP Core, generic profile
> +#
> +# Copyright (c) Siemens AG, 2025
> +#
> +# Authors:
> +# Quirin Gylstorff <quirin.gylstorff@siemens.com>
> +#
> +# SPDX-License-Identifier: MIT
> +
> +inherit dpkg-raw
> +DPKG_ARCH = "all"
> +DESCRIPTION = "helper script to execute a factory reset with a file"
...to request the reset via a marker file. It's not executing anything.
> +
> +# if this file exists execute a factory reset for the given
> +# list of factory-reset targets.
> +INITRAMFS_FACTORY_RESET_MARKER ?= ".factory-reset"
> +# use labels as crypt setup replaces the label links if
> +# an partition is encrypted
> +INITRAMFS_FACTORY_RESET_MARKER_STORAGE_DEVICE ??= "/dev/disk/by-partlabel/var"
This is duplicating configuration of initramfs-factory-reset-hook. You
should make clear that the expectation is that these variable are tuned
at global conf level, not in the recipes.
That leads the point that we are missing some overview document that
describes the adaptation and usage of this new feature.
Jan
> +
> +SRC_URI = "file://set-factory-reset-marker.sh.tmpl"
> +
> +TEMPLATE_FILES += "set-factory-reset-marker.sh.tmpl"
> +TEMPLATE_VARS += " INITRAMFS_FACTORY_RESET_MARKER \
> + INITRAMFS_FACTORY_RESET_MARKER_STORAGE_DEVICE"
> +DEBIAN_DEPENDS .= ", coreutils, util-linux"
> +
> +do_install[cleandirs] += "${D}/usr/lib/factory-reset/"
> +do_install:prepend() {
> + install -m 0755 "${WORKDIR}/set-factory-reset-marker.sh" \
> + "${D}/usr/lib/factory-reset/"
> +}
> +
> diff --git a/recipes-support/factory-reset-helper/files/set-factory-reset-marker.sh.tmpl b/recipes-support/factory-reset-helper/files/set-factory-reset-marker.sh.tmpl
> new file mode 100644
> index 0000000..eacb8fb
> --- /dev/null
> +++ b/recipes-support/factory-reset-helper/files/set-factory-reset-marker.sh.tmpl
> @@ -0,0 +1,28 @@
> +#!/bin/sh
> +#
> +# CIP Core, generic profile
> +#
> +# Copyright (c) Siemens AG, 2025
> +#
> +# Authors:
> +# Quirin Gylstorff <quirin.gylstorff@siemens.com>
> +#
> +# SPDX-License-Identifier: MIT
> +
> +
> +marker="$(basename "${INITRAMFS_FACTORY_RESET_MARKER}")"
> +marker_storage_device="${INITRAMFS_FACTORY_RESET_MARKER_STORAGE_DEVICE}"
> +
> +marker_mnt="$(findmnt --first-only --output TARGET --noheadings "${marker_storage_device}")"
> +tmp_mnt=$(mktemp -d)
> +if [ -z "$marker_mnt" ]; then
> + mount "${marker_storage_device}" "$tmp_mnt"
> + marker_mnt="${tmp_mnt}"
> +fi
> +touch "${marker_mnt}/${marker}"
> +
> +if mountpoint -q "$tmp_mnt"; then
> + umount "$tmp_mnt"
> +fi
> +rmdir "$tmp_mnt"
> +
--
Siemens AG, Foundational Technologies
Linux Expert Center
next prev parent reply other threads:[~2025-05-08 12:51 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-06 12:07 [cip-dev][isar-cip-core][RFC v2 0/6] Add factory-reset Quirin Gylstorff
2025-05-06 12:07 ` [cip-dev][isar-cip-core][RFC v2 1/6] add factory-reset initramfs hook Quirin Gylstorff
2025-05-07 8:10 ` [cip-dev][isar-cip-core][PATCH v3 " Quirin Gylstorff
2025-05-08 12:50 ` Jan Kiszka
2025-05-06 12:07 ` [cip-dev][isar-cip-core][RFC v2 2/6] add factory-reset-helper to set the marker file Quirin Gylstorff
2025-05-08 12:51 ` Jan Kiszka [this message]
2025-05-09 8:01 ` Quirin Gylstorff
2025-05-06 12:07 ` [cip-dev][isar-cip-core][RFC v2 3/6] encrypt-data.yml: Add factory-reset information to encrypt-data Quirin Gylstorff
2025-05-08 12:53 ` Jan Kiszka
2025-05-06 12:07 ` [cip-dev][isar-cip-core][RFC v2 4/6] cip-core-image: add factory-reset helper Quirin Gylstorff
2025-05-06 12:07 ` [cip-dev][isar-cip-core][RFC v2 5/6] add factory-reset to initramfs Quirin Gylstorff
2025-05-06 12:07 ` [cip-dev][isar-cip-core][RFC v2 6/6] Add settings for factory-reset with a separate home partition Quirin Gylstorff
2025-05-15 13:12 ` [cip-dev][isar-cip-core][RFC v2 0/6] Add factory-reset Quirin Gylstorff
2025-05-15 16:37 ` Jan Kiszka
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=e6dbfadf-97b4-43fb-a407-c740ef343bd4@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=Quirin.Gylstorff@siemens.com \
--cc=cip-dev@lists.cip-project.org \
/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