From: "Leonid Krivoshein" <klark.devel@gmail.com>
To: make-initrd@lists.altlinux.org
Subject: [make-initrd] [PATCH v6 14/22] bootchain-core: extends bootchain-sh-functions API
Date: Sun, 24 Oct 2021 17:22:09 -0000
Message-ID: <20211024172209.h385WkOUvJooYtOYtD7c97fTbBRJn0TgNrN0WHmNwGE@z> (raw)
Signed-off-by: Leonid Krivoshein <klark.devel@gmail.com>
---
features/bootchain-core/README.md | 19 ++++++
.../data/bin/bootchain-sh-functions | 61 +++++++++++++++++++
features/bootchain-core/data/sbin/chaind | 2 +-
3 files changed, 81 insertions(+), 1 deletion(-)
diff --git a/features/bootchain-core/README.md b/features/bootchain-core/README.md
index 14db55f..ffed599 100644
--- a/features/bootchain-core/README.md
+++ b/features/bootchain-core/README.md
@@ -59,6 +59,10 @@ us to optimize fill in `initramfs` only which we are need.
relative addressing it is safe in any case and can often be more convenient.
- Allows you to work with shorter and more familiar paths to special files
devices thanks to the use of `DEVNAME` along with `dev`.
+- Provides the ability to associate the <IN> of a step with the <OUT>
+ of the previous step through symbolic links to mount points inside initramfs,
+ outside the tree the results of the steps, which provides, if necessary, the
+ overlap mounting mechanism inherent in the program `propagator`.
- The daemon can be configured when building initramfs via the included file
configurations of `/etc/sysconfig/bootchain`, and not only through boot
parameters, see the details in the corresponding section.
@@ -134,6 +138,21 @@ own needs.
debugging.
- assign() - assignment of the specified value to a variable that gets into
the log with advanced debugging. The left-hand expression is also computable.
+- next_bootchain() - command to the daemon to change the sequence of the
+ following steps.
+- is_step_passed() - returns 0 if the current step has been passed at
+ least once.
+- launch_step_once() - if the current step has already been completed,
+ it completes the work through the fatal() call.
+- break_bc_loop() - informs the daemon that the current step is the last and
+ after after its successful completion, you can switch to stage2. The script
+ of this step, however, must work to the end and end with a zero status code
+ in order for the daemon to process the received signal.
+- bc_reboot() - performs a logged restart of the computer.
+- bypass_results() - asks the daemon to associate the <OUT> of the previous
+ step with the <IN> the next step. It is also used to inform the daemon about
+ the result (mounted directory) inside the current initramfs root, outside the
+ $mntdir tree.
- initrd_version() - output of the current version of make-initrd. It is proposed
to move to make-initrd/data/bin/initrd-sh-functions after has_module().
diff --git a/features/bootchain-core/data/bin/bootchain-sh-functions b/features/bootchain-core/data/bin/bootchain-sh-functions
index dcc1ab2..d1d0cef 100644
--- a/features/bootchain-core/data/bin/bootchain-sh-functions
+++ b/features/bootchain-core/data/bin/bootchain-sh-functions
@@ -22,6 +22,8 @@ else
mntdir="${mntdir:-/dev/bootchain}"
fi
+BC_NEXTCHAIN=/.initrd/bootchain/bootchain.next
+BC_PASSED=/.initrd/bootchain/passed
handlerdir=/lib/bootchain
@@ -153,6 +155,65 @@ assign()
debug "LET: ${_k}=\"${_v}\""
}
+next_bootchain()
+{
+ local _v="${1-}"
+
+ printf 'chainsteps="%s"\n' "${_v}" >>"$BC_NEXTCHAIN"
+ debug "BOOTCHAIN REPLACED: '${_v}'"
+}
+
+is_step_passed()
+{
+ [ -f "$BC_PASSED/$PROG" ] ||
+ return 1
+}
+
+launch_step_once()
+{
+ [ ! -f "$BC_PASSED/$PROG" ] ||
+ fatal "this step has been already passed"
+}
+
+break_bc_loop()
+{
+ enter "break_bc_loop"
+
+ :> "$BC_PASSED/chaind"
+
+ leave "break_bc_loop"
+}
+
+bc_reboot()
+{
+ run reboot -f -d
+}
+
+bypass_results()
+{
+ enter "bypass_results"
+
+ local realdir="${1-}"
+ local srcdir="${realdir:-$prevdir}"
+
+ if [ -n "$srcdir" ] && [ "$srcdir" != "$destdir" ]; then
+ if [ -d "$realdir" ] || [ -L "$prevdir" ] ||
+ [ "$srcdir" = "${srcdir#$mntdir/}" ]
+ then
+ run rmdir -- "$destdir" ||:
+ run ln -snf -- "$(readlink-e "$srcdir")" "$destdir"
+ elif mountpoint -q -- "$prevdir"; then
+ run mkdir -p -- "$destdir"
+ run mount --move -- "$prevdir" "$destdir"
+ else
+ run rmdir -- "$destdir" ||:
+ run mv -f -- "$prevdir" "$destdir"
+ fi
+ fi
+
+ leave "bypass_results"
+}
+
initrd_version()
{
[ ! -s /etc/initrd-release ] ||
diff --git a/features/bootchain-core/data/sbin/chaind b/features/bootchain-core/data/sbin/chaind
index c1b2451..9224c40 100755
--- a/features/bootchain-core/data/sbin/chaind
+++ b/features/bootchain-core/data/sbin/chaind
@@ -34,7 +34,7 @@ message "Starting server [$(initrd_version)]..."
debug "Booting with /proc/cmdline:"
fdump /proc/cmdline
-run mkdir -p -- "$mntdir"
+run mkdir -p -- "$mntdir" "$BC_PASSED"
mountpoint -q -- "$mntdir" ||
run mount -t tmpfs tmpfs "$mntdir" ||:
--
2.24.1
reply other threads:[~2021-10-24 17:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20211024172209.h385WkOUvJooYtOYtD7c97fTbBRJn0TgNrN0WHmNwGE@z \
--to=klark.devel@gmail.com \
--cc=make-initrd@lists.altlinux.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
Make-initrd development discussion
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://lore.altlinux.org/make-initrd/0 make-initrd/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 make-initrd make-initrd/ http://lore.altlinux.org/make-initrd \
make-initrd@lists.altlinux.org make-initrd@lists.altlinux.ru make-initrd@lists.altlinux.com
public-inbox-index make-initrd
Example config snippet for mirrors.
Newsgroup available over NNTP:
nntp://lore.altlinux.org/org.altlinux.lists.make-initrd
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git