From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa.local.altlinux.org X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,MISSING_DATE,MISSING_MID, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 From: "Leonid Krivoshein" To: make-initrd@lists.altlinux.org Subject: [make-initrd] [PATCH v6 04/22] bootchain: separate getimage and waitdev features X-BeenThere: make-initrd@lists.altlinux.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: make-initrd@lists.altlinux.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Date: Sun, 24 Oct 2021 17:20:27 -0000 X-List-Received-Date: Sun, 24 Oct 2021 17:20:27 -0000 Message-ID: <20211024172027.jcMYY4R4V0Ibeg0OGxiiNXzLbRTSUosEZzvNk3gTD0M@z> Archived-At: List-Archive: Now bootchain-core will include only really basic functionality. Signed-off-by: Leonid Krivoshein --- 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