Make-initrd development discussion
 help / color / mirror / Atom feed
* [make-initrd] [PATCH v6 04/22] bootchain: separate getimage and waitdev features
@ 2021-10-24 17:20 Leonid Krivoshein
  0 siblings, 0 replies; only message in thread
From: Leonid Krivoshein @ 2021-10-24 17:20 UTC (permalink / raw)
  To: make-initrd

Now bootchain-core will include only really basic functionality.

Signed-off-by: Leonid Krivoshein <klark.devel@gmail.com>
---
 features/bootchain-core/README.md             |  5 ++++
 features/bootchain-core/config.mk             |  5 +---
 .../data/etc/initrd/cmdline.d/bootchain-core  |  2 --
 .../data/etc/rc.d/init.d/bootchain            | 16 +------------
 features/bootchain-core/rules.mk              |  1 -
 features/bootchain-getimage/README.md         | 24 +++++++++++++++++++
 features/bootchain-getimage/config.mk         |  5 ++++
 .../etc/initrd/cmdline.d/bootchain-getimage   |  1 +
 .../data/lib/bootchain/getimage               |  0
 features/bootchain-getimage/rules.mk          |  2 ++
 features/bootchain-waitdev/README.md          | 22 +++++++++++++++++
 features/bootchain-waitdev/config.mk          |  6 +++++
 .../etc/initrd/cmdline.d/bootchain-waitdev    |  1 +
 .../udev/rules.d/50-bootchain-waitdev.rules   |  0
 .../data/lib/bootchain/waitdev                |  0
 .../data/lib/initrd/pre/bootchain/300-waitdev | 12 ++++++++++
 .../data/lib/uevent/filters/bootchain-waitdev |  0
 features/bootchain-waitdev/rules.mk           |  2 ++
 features/pipeline/config.mk                   |  2 +-
 19 files changed, 83 insertions(+), 23 deletions(-)
 create mode 100644 features/bootchain-getimage/README.md
 create mode 100644 features/bootchain-getimage/config.mk
 create mode 100644 features/bootchain-getimage/data/etc/initrd/cmdline.d/bootchain-getimage
 rename features/{bootchain-core => bootchain-getimage}/data/lib/bootchain/getimage (100%)
 create mode 100644 features/bootchain-getimage/rules.mk
 create mode 100644 features/bootchain-waitdev/README.md
 create mode 100644 features/bootchain-waitdev/config.mk
 create mode 100644 features/bootchain-waitdev/data/etc/initrd/cmdline.d/bootchain-waitdev
 rename features/{bootchain-core => bootchain-waitdev}/data/etc/udev/rules.d/50-bootchain-waitdev.rules (100%)
 rename features/{bootchain-core => bootchain-waitdev}/data/lib/bootchain/waitdev (100%)
 create mode 100755 features/bootchain-waitdev/data/lib/initrd/pre/bootchain/300-waitdev
 rename features/{bootchain-core => bootchain-waitdev}/data/lib/uevent/filters/bootchain-waitdev (100%)
 create mode 100644 features/bootchain-waitdev/rules.mk

diff --git a/features/bootchain-core/README.md b/features/bootchain-core/README.md
index 1844f88..0ccacd9 100644
--- a/features/bootchain-core/README.md
+++ b/features/bootchain-core/README.md
@@ -45,6 +45,11 @@ us to optimize fill in `initramfs` only which we are need.
   earlier one the completed step. So it's not a pipeline in its purest
   form, but rather a chain loading steps, the sequence of actions performed.
 
+## Difference from the original pipeline
+
+- Modularity: loading methods are initially separated from the common
+  code and daemon.
+
 ## External elements of the bootchain (steps-scripts)
 
 - `mountfs` - mounts a file or device from the result of the previous or other
diff --git a/features/bootchain-core/config.mk b/features/bootchain-core/config.mk
index 33e66ed..c87bad2 100644
--- a/features/bootchain-core/config.mk
+++ b/features/bootchain-core/config.mk
@@ -1,8 +1,5 @@
-$(call feature-requires,depmod-image add-udev-rules)
+$(call feature-requires,depmod-image)
 
 BOOTCHAIN_CORE_DATADIR = $(FEATURESDIR)/bootchain-core/data
 
-BOOTCHAIN_CORE_RULES = \
-	*-cdrom_id.rules
-
 BOOTCHAIN_CORE_MODULES = isofs squashfs overlay
diff --git a/features/bootchain-core/data/etc/initrd/cmdline.d/bootchain-core b/features/bootchain-core/data/etc/initrd/cmdline.d/bootchain-core
index 8af3a20..1b1198c 100644
--- a/features/bootchain-core/data/etc/initrd/cmdline.d/bootchain-core
+++ b/features/bootchain-core/data/etc/initrd/cmdline.d/bootchain-core
@@ -1,6 +1,4 @@
 register_parameter string BOOTCHAIN
 register_alias BOOTCHAIN PIPELINE
-register_array string GETIMAGE
 register_array string MOUNTFS
 register_array string OVERLAYFS
-register_array string WAITDEV
diff --git a/features/bootchain-core/data/etc/rc.d/init.d/bootchain b/features/bootchain-core/data/etc/rc.d/init.d/bootchain
index 1be6d39..b7bd808 100755
--- a/features/bootchain-core/data/etc/rc.d/init.d/bootchain
+++ b/features/bootchain-core/data/etc/rc.d/init.d/bootchain
@@ -17,23 +17,9 @@ NAME=chaind
 PIDFILE="/var/run/$NAME.pid"
 ARGS="--lockfile $LOCKFILE --pidfile $PIDFILE --name $NAME --displayname $NAME"
 
-prepare() {
-	local dir i n
-
-	dir=/.initrd/bootchain/waitdev
-	mkdir -p -- "$dir"
-
-	i=0
-	while [ "$i" -lt "${WAITDEV:-0}" ]; do
-		touch "$dir/$i"
-		i=$(($i + 1))
-	done
-}
-
 start() {
 	RETVAL=0
 	if [ "${ROOT-}" = bootchain ] || [ "${ROOT-}" = pipeline ]; then
-		prepare
 		start_daemon --background $ARGS "$NAME"
 		RETVAL=$?
 	fi
@@ -43,7 +29,7 @@ start() {
 stop() {
 	stop_daemon $ARGS "$NAME"
 	RETVAL=$?
-	[ ! -f "$PIDFILE" ] || rm -f -- "$PIDFILE"
+	rm -f -- "$PIDFILE"
 	return $RETVAL
 }
 
diff --git a/features/bootchain-core/rules.mk b/features/bootchain-core/rules.mk
index 724a0b0..843f235 100644
--- a/features/bootchain-core/rules.mk
+++ b/features/bootchain-core/rules.mk
@@ -1,4 +1,3 @@
 MODULES_TRY_ADD += $(BOOTCHAIN_CORE_MODULES)
 
-PUT_UDEV_RULES += $(BOOTCHAIN_CORE_RULES)
 PUT_FEATURE_DIRS += $(BOOTCHAIN_CORE_DATADIR)
diff --git a/features/bootchain-getimage/README.md b/features/bootchain-getimage/README.md
new file mode 100644
index 0000000..042e8ff
--- /dev/null
+++ b/features/bootchain-getimage/README.md
@@ -0,0 +1,24 @@
+# Feature: bootchain-getimage
+
+This is not a standalone feature. This is an add-on to the bootchain-core
+feature. It allows to get a remote image and mount it. This is useful for
+network boot.
+
+## Chain elements
+
+- `getimage` receives and mounts the remote image.
+
+## Boot parameters
+
+- `getimage` specifies an URL to fetch and mount.
+
+This parameter can be specified more than once depending on how many times
+a corresponding element is mentioned in the `bootchain`.
+
+## Example
+
+Cmdline: root=bootchain bootchain=getimage,mountfs,overlayfs,rootfs getimage=http://ftp.altlinux.org/pub/people/mike/iso/misc/vi-20140918-i586.iso mountfs=rescue
+
+Following these parameters, the bootchain downloads the "vi-20140918-i586.iso"
+image, mount it as a loop, make it writable using overlayfs and will try to
+boot from it.
diff --git a/features/bootchain-getimage/config.mk b/features/bootchain-getimage/config.mk
new file mode 100644
index 0000000..498196e
--- /dev/null
+++ b/features/bootchain-getimage/config.mk
@@ -0,0 +1,5 @@
+$(call feature-requires,bootchain-core)
+
+BOOTCHAIN_GETIMAGE_DATADIR = $(FEATURESDIR)/bootchain-getimage/data
+
+BOOTCHAIN_GETIMAGE_PROGS = wget
diff --git a/features/bootchain-getimage/data/etc/initrd/cmdline.d/bootchain-getimage b/features/bootchain-getimage/data/etc/initrd/cmdline.d/bootchain-getimage
new file mode 100644
index 0000000..675f96d
--- /dev/null
+++ b/features/bootchain-getimage/data/etc/initrd/cmdline.d/bootchain-getimage
@@ -0,0 +1 @@
+register_array string GETIMAGE
diff --git a/features/bootchain-core/data/lib/bootchain/getimage b/features/bootchain-getimage/data/lib/bootchain/getimage
similarity index 100%
rename from features/bootchain-core/data/lib/bootchain/getimage
rename to features/bootchain-getimage/data/lib/bootchain/getimage
diff --git a/features/bootchain-getimage/rules.mk b/features/bootchain-getimage/rules.mk
new file mode 100644
index 0000000..27fe98f
--- /dev/null
+++ b/features/bootchain-getimage/rules.mk
@@ -0,0 +1,2 @@
+PUT_FEATURE_DIRS += $(BOOTCHAIN_GETIMAGE_DATADIR)
+PUT_FEATURE_PROGS += $(BOOTCHAIN_GETIMAGE_PROGS)
diff --git a/features/bootchain-waitdev/README.md b/features/bootchain-waitdev/README.md
new file mode 100644
index 0000000..bdf736e
--- /dev/null
+++ b/features/bootchain-waitdev/README.md
@@ -0,0 +1,22 @@
+# Feature: bootchain-waitdev
+
+This is not a standalone feature. This is an add-on to the bootchain-core
+feature. It allows to wait a specified block or character special devices.
+
+## Chain elements
+
+- `waitdev` waits for the local device to appear.
+
+## Boot parameters
+
+- `waitdev` describes the local device to wait. The format of this parameter is
+   the same as `root=`. This parameter can be specified more than once depending
+   on how many times a corresponding element is mentioned in the `bootchain`.
+
+## Example
+
+Cmdline: root=bootchain bootchain=waitdev,mountfs,mountfs,overlayfs,rootfs waitdev=LABEL=ALT_regular-rescue/x86_64 mountfs=dev mountfs=rescue
+
+Following these parameters, the bootchain wait local disk drive labeled as
+"ALT_regular-rescue/x86_64", mount it, mount squash file "rescue" as a loop
+from it, make final rootfs writable using overlayfs and will try to boot from it.
diff --git a/features/bootchain-waitdev/config.mk b/features/bootchain-waitdev/config.mk
new file mode 100644
index 0000000..38368e9
--- /dev/null
+++ b/features/bootchain-waitdev/config.mk
@@ -0,0 +1,6 @@
+$(call feature-requires,bootchain-core add-udev-rules)
+
+BOOTCHAIN_WAITDEV_DATADIR = $(FEATURESDIR)/bootchain-waitdev/data
+
+BOOTCHAIN_WAITDEV_RULES = \
+	*-cdrom_id.rules
diff --git a/features/bootchain-waitdev/data/etc/initrd/cmdline.d/bootchain-waitdev b/features/bootchain-waitdev/data/etc/initrd/cmdline.d/bootchain-waitdev
new file mode 100644
index 0000000..3544c25
--- /dev/null
+++ b/features/bootchain-waitdev/data/etc/initrd/cmdline.d/bootchain-waitdev
@@ -0,0 +1 @@
+register_array string WAITDEV
diff --git a/features/bootchain-core/data/etc/udev/rules.d/50-bootchain-waitdev.rules b/features/bootchain-waitdev/data/etc/udev/rules.d/50-bootchain-waitdev.rules
similarity index 100%
rename from features/bootchain-core/data/etc/udev/rules.d/50-bootchain-waitdev.rules
rename to features/bootchain-waitdev/data/etc/udev/rules.d/50-bootchain-waitdev.rules
diff --git a/features/bootchain-core/data/lib/bootchain/waitdev b/features/bootchain-waitdev/data/lib/bootchain/waitdev
similarity index 100%
rename from features/bootchain-core/data/lib/bootchain/waitdev
rename to features/bootchain-waitdev/data/lib/bootchain/waitdev
diff --git a/features/bootchain-waitdev/data/lib/initrd/pre/bootchain/300-waitdev b/features/bootchain-waitdev/data/lib/initrd/pre/bootchain/300-waitdev
new file mode 100755
index 0000000..3642722
--- /dev/null
+++ b/features/bootchain-waitdev/data/lib/initrd/pre/bootchain/300-waitdev
@@ -0,0 +1,12 @@
+#!/bin/bash -efu
+
+. /.initrd/initenv
+
+dir=/.initrd/bootchain/waitdev
+mkdir -p -- "$dir"
+
+i=0
+while [ "$i" -lt "${WAITDEV:-0}" ]; do
+	touch "$dir/$i"
+	i=$((1 + $i))
+done
diff --git a/features/bootchain-core/data/lib/uevent/filters/bootchain-waitdev b/features/bootchain-waitdev/data/lib/uevent/filters/bootchain-waitdev
similarity index 100%
rename from features/bootchain-core/data/lib/uevent/filters/bootchain-waitdev
rename to features/bootchain-waitdev/data/lib/uevent/filters/bootchain-waitdev
diff --git a/features/bootchain-waitdev/rules.mk b/features/bootchain-waitdev/rules.mk
new file mode 100644
index 0000000..56fe21c
--- /dev/null
+++ b/features/bootchain-waitdev/rules.mk
@@ -0,0 +1,2 @@
+PUT_UDEV_RULES += $(BOOTCHAIN_WAITDEV_RULES)
+PUT_FEATURE_DIRS += $(BOOTCHAIN_WAITDEV_DATADIR)
diff --git a/features/pipeline/config.mk b/features/pipeline/config.mk
index 3ff29ac..7f9dfb4 100644
--- a/features/pipeline/config.mk
+++ b/features/pipeline/config.mk
@@ -1 +1 @@
-$(call feature-requires,bootchain-core)
+$(call feature-requires,bootchain-waitdev bootchain-getimage)
-- 
2.24.1



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-10-24 17:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-24 17:20 [make-initrd] [PATCH v6 04/22] bootchain: separate getimage and waitdev features Leonid Krivoshein

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