Make-initrd development discussion
 help / color / mirror / Atom feed
From: Leonid Krivoshein <klark.devel@gmail.com>
To: make-initrd@lists.altlinux.org
Subject: [make-initrd] [PATCH v1 30/41] fork pipeline: bootchain-sh-functions: API extended
Date: Fri, 24 Sep 2021 18:58:38 +0300
Message-ID: <3c3a685a-898d-08f9-5401-0c0c52a48d58@gmail.com> (raw)

---
  .../data/bin/bootchain-sh-functions           | 128 ++++++++++++++++++
  1 file changed, 128 insertions(+)

diff --git 
a/make-initrd/features/bootchain-core/data/bin/bootchain-sh-functions 
b/make-initrd/features/bootchain-core/data/bin/bootchain-sh-functions
index 35cee1e..f8a6e30 100644
--- a/make-initrd/features/bootchain-core/data/bin/bootchain-sh-functions
+++ b/make-initrd/features/bootchain-core/data/bin/bootchain-sh-functions
@@ -3,14 +3,38 @@
  if [ -z "${__bootchain_sh_functions-}" ]; then
  __bootchain_sh_functions=1
  +BC_DEBUG=
+BC_LOG_VT=3
+
+[ ! -s /etc/sysconfig/bootchain ] ||
+	. /etc/sysconfig/bootchain
+
  . /.initrd/initenv
  . shell-signal
  +message_time=1
+
+if [ "${ROOT-}" = pipeline ]; then
+	BC_LOGFILE="${BC_LOGFILE:-/var/log/pipelined.log}"
+	mntdir="${mntdir:-/dev/pipeline}"
+	pipeline_mode=1
+else
+	BC_LOGFILE="${BC_LOGFILE:-/var/log/bootchained.log}"
+	mntdir="${mntdir:-/dev/bootchain}"
+	pipeline_mode=
+fi
+
+[ -n "$BC_DEBUG" ] && BC_FGVT_ACTIVATE=1 ||
+	BC_FGVT_ACTIVATE="${BC_FGVT_ACTIVATE:-7}"
+BC_NEXTCHAIN=/.initrd/bootchain/bootchain.next
+BC_PASSED=/.initrd/bootchain/passed
  handlerdir=/lib/bootchain
  +
  check_parameter()
  {
  	local _v
+
  	eval "_v=\"\${$1-}\""
  	[ -n "${_v}" ] ||
  		fatal "Parameter '$1' required"
@@ -50,10 +74,114 @@ resolve_target()
  	printf '%s' "$target"
  }
  +debug()
+{
+	[ -z "$BC_DEBUG" ] ||
+		message "[$callnum] $*"
+}
+
+enter()
+{
+	debug "ENTER: $*"
+}
+
+leave()
+{
+	debug "LEAVE: $*"
+}
+
  run()
  {
  	debug "RUN: $*"
  	"$@" || return $?
  }
  +fdump()
+{
+	[ -n "$BC_DEBUG" ] && [ -f "$1" ] ||
+		return 0
+	{ printf '============================================================\n'
+	  cat -- "$1" ||:
+	  printf 
'============================================================\n\n'
+	} 1>&2
+}
+
+assign()
+{
+	local _v="" _k="$1" _e="${2-}"
+
+	eval "_v=\"${_e}\""
+	eval "${_k}=\"${_e}\""
+	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/bootchain-loop"
+
+	leave "break_bc_loop"
+}
+
+bc_reboot()
+{
+	enter "bc_reboot"
+
+	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 ] ||
+		. /etc/initrd-release
+	local __version="${VERSION_ID-}"
+	printf '%s' "INITRAMFS${__version:+ $__version}"
+}
+
  fi # __bootchain_sh_functions
-- 
2.21.0




                 reply	other threads:[~2021-09-24 15:58 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=3c3a685a-898d-08f9-5401-0c0c52a48d58@gmail.com \
    --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