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 01/22] separate new feature of bootchain-core from pipeline 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:19:57 -0000 X-List-Received-Date: Sun, 24 Oct 2021 17:19:57 -0000 Message-ID: <20211024171957.oLIWp2BLEN1d9iPyx1rFjVJmbbYgE2eRfErYIwBKAEc@z> Archived-At: List-Archive: Pipeline live as an add-in over bootchain-core for backward compatibility with already existing solutions. For bootchain-core it is planned to implement a number of new features to cover the tasks of bootloading the installer and live systems. Signed-off-by: Leonid Krivoshein --- features/bootchain-core/README.md | 82 +++++++++++++++++++ features/bootchain-core/config.mk | 8 ++ .../data/etc/initrd/cmdline.d/bootchain-core} | 3 +- .../data/etc/rc.d/init.d/bootchain} | 8 +- .../udev/rules.d/50-bootchain-waitdev.rules} | 2 +- .../data/lib/bootchain}/getimage | 2 +- .../data/lib/bootchain}/mountfs | 2 +- .../data/lib/bootchain}/overlayfs | 2 +- .../data/lib/bootchain}/rootfs | 2 +- .../data/lib/bootchain}/waitdev | 4 +- .../data/lib/initrd/cmdline.d/bootchain | 6 ++ .../data/lib/initrd/cmdline.d/pipeline | 2 +- .../lib/uevent/filters/bootchain-waitdev} | 4 +- .../data/sbin/bootchain-sh-functions} | 12 +-- .../data/sbin/chaind} | 22 ++--- features/bootchain-core/rules.mk | 4 + features/pipeline/config.mk | 9 +- features/pipeline/rules.mk | 6 -- 18 files changed, 134 insertions(+), 46 deletions(-) create mode 100644 features/bootchain-core/README.md create mode 100644 features/bootchain-core/config.mk rename features/{pipeline/data/etc/initrd/cmdline.d/pipeline => bootchain-core/data/etc/initrd/cmdline.d/bootchain-core} (63%) rename features/{pipeline/data/etc/rc.d/init.d/pipeline => bootchain-core/data/etc/rc.d/init.d/bootchain} (83%) rename features/{pipeline/data/etc/udev/rules.d/50-pipeline-waitdev.rules => bootchain-core/data/etc/udev/rules.d/50-bootchain-waitdev.rules} (77%) rename features/{pipeline/data/lib/pipeline => bootchain-core/data/lib/bootchain}/getimage (93%) rename features/{pipeline/data/lib/pipeline => bootchain-core/data/lib/bootchain}/mountfs (91%) rename features/{pipeline/data/lib/pipeline => bootchain-core/data/lib/bootchain}/overlayfs (95%) rename features/{pipeline/data/lib/pipeline => bootchain-core/data/lib/bootchain}/rootfs (86%) rename features/{pipeline/data/lib/pipeline => bootchain-core/data/lib/bootchain}/waitdev (83%) create mode 100755 features/bootchain-core/data/lib/initrd/cmdline.d/bootchain rename features/{pipeline => bootchain-core}/data/lib/initrd/cmdline.d/pipeline (64%) rename features/{pipeline/data/lib/uevent/filters/pipeline-waitdev => bootchain-core/data/lib/uevent/filters/bootchain-waitdev} (77%) rename features/{pipeline/data/sbin/pipeline-sh-functions => bootchain-core/data/sbin/bootchain-sh-functions} (70%) rename features/{pipeline/data/sbin/pipelined => bootchain-core/data/sbin/chaind} (78%) create mode 100644 features/bootchain-core/rules.mk diff --git a/features/bootchain-core/README.md b/features/bootchain-core/README.md new file mode 100644 index 0000000..ce2bf98 --- /dev/null +++ b/features/bootchain-core/README.md @@ -0,0 +1,82 @@ +# Feature: bootchain-core + +`bootchain-core` - it's a fork and further development the original +feature of `pipeline`. This feature allow us to consistently setup +steps-scripts one by one. For details about `pipeline` you can see +in ../features/pipeline/README.md. + +In fork process `pipeline` was divided by three parts: + +- `bootchain-core` - the main functional of feature `pipeline`, common + API and daemon. +- `bootchain-getimage` - method to networking boot from ISO-image with + the wget utility. +- `bootchain-waitdev` - method to boot from specified local media. + +The future work with `bootchain` allowed us to create a few modules. +They are expected to be upstream soon. This divide on modules allow +us to optimize fill in `initramfs` only which we are need. + +## Main components of bootchain-core + +- `/sbin/bootchain-sh-functions` - common API and evolution + of `pipeline-sh-functions`. +- `/sbin/chaind` - daemon, evolution of `pipelined`. +- `/etc/rc.d/init.d/bootchain` - sysvinit start script. + +## Reasons of making fork and rename pipeline + +- A set of `bootchain` modules was developed in order to create a + replacement in stage1 programs `propagator`, fully integrated into + the run-time `make-initrd`. In the original version, the `pipeline` + feature did not satisfy this need. At an early stage of development, + it was not yet known what functionality `bootchain` would eventually + have, how far it would go from the fork and be able to whether to be + fully compatible with it. +- For some time, the development of `bootchain` was carried out independently + of the main project `make-initrd`. To build and test bootable disks with + `make-initrd` and `bootchain` so that `bootchain` does not depend on + `make-initrd` versions, so that not intersect with the `pipeline` features + built into the `make-initrd` and so as not to interfere the author of + `make-initrd`, the `pipeline` feature had to be copied under a different + name, giving it a more appropriate name at the same time. +- The result of the completed step is not always used next. Steps-scripts + they can use the results not only of the previous one, but also of any + 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. + +## External elements of the bootchain (steps-scripts) + +- `mountfs` - mounts a file or device from the result of the previous or other + specified step. +- `overlayfs` - combines one or more elements of the boot chain using overlayfs. +- `rootfs` - forces the daemon to use the result of the previous element as the + found root of stage 2. + +## Boot parameters + +- `bootchain=name1[,name2][,name3]` - defines the initial state of the boot + chains, i.e. the steps that the daemon must go through one by one. These can + be both built-in pseudo-steps and real scripts of the actions performed. The + names these steps are listed separated by commas. +- `pipeline=name1[,name2][,name3]` - alias for `bootchain=...`. +- `mountfs=target` - specifies the file or device to be mounted. +- `overlayfs=list` - defines the list of elements to combine. + +## bootchain-sh-functions API + +- check_parameter() - checks that the required parameter is not empty, otherwise + it exits via fatal(). +- get_parameter() - outputs the value of the parameter of the current step by + the index $callnum. +- resolve_target() - output the path to a file, directory or device, depending + on from the parameter. +- run() - run an external command. + +## Example + +Cmdline: root=pipeline pipeline=getimage,mountfs,overlayfs,rootfs getimage=http://ftp.altlinux.org/pub/people/mike/iso/misc/vi-20140918-i586.iso mountfs=rescue + +Following these parameters, the daemon loads the image "vi-20140918-i586.iso", +mounts it via the loop device, mounts the "rescue" file from it as squashfs of +the root system, makes it writable using overlayfs and tries to boot from it. diff --git a/features/bootchain-core/config.mk b/features/bootchain-core/config.mk new file mode 100644 index 0000000..33e66ed --- /dev/null +++ b/features/bootchain-core/config.mk @@ -0,0 +1,8 @@ +$(call feature-requires,depmod-image add-udev-rules) + +BOOTCHAIN_CORE_DATADIR = $(FEATURESDIR)/bootchain-core/data + +BOOTCHAIN_CORE_RULES = \ + *-cdrom_id.rules + +BOOTCHAIN_CORE_MODULES = isofs squashfs overlay diff --git a/features/pipeline/data/etc/initrd/cmdline.d/pipeline b/features/bootchain-core/data/etc/initrd/cmdline.d/bootchain-core similarity index 63% rename from features/pipeline/data/etc/initrd/cmdline.d/pipeline rename to features/bootchain-core/data/etc/initrd/cmdline.d/bootchain-core index 4200d57..8af3a20 100644 --- a/features/pipeline/data/etc/initrd/cmdline.d/pipeline +++ b/features/bootchain-core/data/etc/initrd/cmdline.d/bootchain-core @@ -1,4 +1,5 @@ -register_parameter string PIPELINE +register_parameter string BOOTCHAIN +register_alias BOOTCHAIN PIPELINE register_array string GETIMAGE register_array string MOUNTFS register_array string OVERLAYFS diff --git a/features/pipeline/data/etc/rc.d/init.d/pipeline b/features/bootchain-core/data/etc/rc.d/init.d/bootchain similarity index 83% rename from features/pipeline/data/etc/rc.d/init.d/pipeline rename to features/bootchain-core/data/etc/rc.d/init.d/bootchain index 89d9de5..1be6d39 100755 --- a/features/pipeline/data/etc/rc.d/init.d/pipeline +++ b/features/bootchain-core/data/etc/rc.d/init.d/bootchain @@ -1,6 +1,6 @@ #!/bin/bash ### BEGIN INIT INFO -# Provides: pipeline +# Provides: bootchain # Required-Start: uevent udev # Should-Start: # Required-Stop: @@ -13,14 +13,14 @@ . /.initrd/initenv . /etc/init.d/template -NAME=pipelined +NAME=chaind PIDFILE="/var/run/$NAME.pid" ARGS="--lockfile $LOCKFILE --pidfile $PIDFILE --name $NAME --displayname $NAME" prepare() { local dir i n - dir=/.initrd/pipeline/waitdev + dir=/.initrd/bootchain/waitdev mkdir -p -- "$dir" i=0 @@ -32,7 +32,7 @@ prepare() { start() { RETVAL=0 - if [ "${ROOT-}" = pipeline ]; then + if [ "${ROOT-}" = bootchain ] || [ "${ROOT-}" = pipeline ]; then prepare start_daemon --background $ARGS "$NAME" RETVAL=$? diff --git a/features/pipeline/data/etc/udev/rules.d/50-pipeline-waitdev.rules b/features/bootchain-core/data/etc/udev/rules.d/50-bootchain-waitdev.rules similarity index 77% rename from features/pipeline/data/etc/udev/rules.d/50-pipeline-waitdev.rules rename to features/bootchain-core/data/etc/udev/rules.d/50-bootchain-waitdev.rules index e473deb..e4b8616 100644 --- a/features/pipeline/data/etc/udev/rules.d/50-pipeline-waitdev.rules +++ b/features/bootchain-core/data/etc/udev/rules.d/50-bootchain-waitdev.rules @@ -1 +1 @@ -SUBSYSTEM=="block", ACTION!="remove", RUN+="/lib/uevent/filters/pipeline-waitdev" +SUBSYSTEM=="block", ACTION!="remove", RUN+="/lib/uevent/filters/bootchain-waitdev" diff --git a/features/pipeline/data/lib/pipeline/getimage b/features/bootchain-core/data/lib/bootchain/getimage similarity index 93% rename from features/pipeline/data/lib/pipeline/getimage rename to features/bootchain-core/data/lib/bootchain/getimage index 409ad14..1f141ac 100755 --- a/features/pipeline/data/lib/pipeline/getimage +++ b/features/bootchain-core/data/lib/bootchain/getimage @@ -1,6 +1,6 @@ #!/bin/bash -efu -. pipeline-sh-functions +. bootchain-sh-functions check_parameter GETIMAGE url="$(get_parameter GETIMAGE)" diff --git a/features/pipeline/data/lib/pipeline/mountfs b/features/bootchain-core/data/lib/bootchain/mountfs similarity index 91% rename from features/pipeline/data/lib/pipeline/mountfs rename to features/bootchain-core/data/lib/bootchain/mountfs index d15ae91..45ffa68 100755 --- a/features/pipeline/data/lib/pipeline/mountfs +++ b/features/bootchain-core/data/lib/bootchain/mountfs @@ -1,6 +1,6 @@ #!/bin/bash -efu -. pipeline-sh-functions +. bootchain-sh-functions check_parameter MOUNTFS param="$(get_parameter MOUNTFS)" diff --git a/features/pipeline/data/lib/pipeline/overlayfs b/features/bootchain-core/data/lib/bootchain/overlayfs similarity index 95% rename from features/pipeline/data/lib/pipeline/overlayfs rename to features/bootchain-core/data/lib/bootchain/overlayfs index 23b869b..58261cc 100755 --- a/features/pipeline/data/lib/pipeline/overlayfs +++ b/features/bootchain-core/data/lib/bootchain/overlayfs @@ -1,6 +1,6 @@ #!/bin/bash -efu -. pipeline-sh-functions +. bootchain-sh-functions target="$(get_parameter OVERLAYFS)" diff --git a/features/pipeline/data/lib/pipeline/rootfs b/features/bootchain-core/data/lib/bootchain/rootfs similarity index 86% rename from features/pipeline/data/lib/pipeline/rootfs rename to features/bootchain-core/data/lib/bootchain/rootfs index e4b2ca9..6ac64a6 100755 --- a/features/pipeline/data/lib/pipeline/rootfs +++ b/features/bootchain-core/data/lib/bootchain/rootfs @@ -1,6 +1,6 @@ #!/bin/bash -efu -. pipeline-sh-functions +. bootchain-sh-functions [ -n "$prevdir" ] || fatal "no previous step to use as rootfs" diff --git a/features/pipeline/data/lib/pipeline/waitdev b/features/bootchain-core/data/lib/bootchain/waitdev similarity index 83% rename from features/pipeline/data/lib/pipeline/waitdev rename to features/bootchain-core/data/lib/bootchain/waitdev index f818cc5..74af6ea 100755 --- a/features/pipeline/data/lib/pipeline/waitdev +++ b/features/bootchain-core/data/lib/bootchain/waitdev @@ -1,12 +1,12 @@ #!/bin/bash -efu -. pipeline-sh-functions +. bootchain-sh-functions check_parameter WAITDEV devspec="$(get_parameter WAITDEV)" while [ -n "$devspec" ]; do - envfile="/.initrd/pipeline/waitdev/$callnum" + envfile="/.initrd/bootchain/waitdev/$callnum" if [ -s "$envfile" ]; then devfile= diff --git a/features/bootchain-core/data/lib/initrd/cmdline.d/bootchain b/features/bootchain-core/data/lib/initrd/cmdline.d/bootchain new file mode 100755 index 0000000..b692f6d --- /dev/null +++ b/features/bootchain-core/data/lib/initrd/cmdline.d/bootchain @@ -0,0 +1,6 @@ +#!/bin/bash -efu + +. /.initrd/initenv + +[ "${ROOT-}" != bootchain ] || + echo bootchain > /etc/initrd/method diff --git a/features/pipeline/data/lib/initrd/cmdline.d/pipeline b/features/bootchain-core/data/lib/initrd/cmdline.d/pipeline similarity index 64% rename from features/pipeline/data/lib/initrd/cmdline.d/pipeline rename to features/bootchain-core/data/lib/initrd/cmdline.d/pipeline index ac65b68..21b164c 100755 --- a/features/pipeline/data/lib/initrd/cmdline.d/pipeline +++ b/features/bootchain-core/data/lib/initrd/cmdline.d/pipeline @@ -3,4 +3,4 @@ . /.initrd/initenv [ "${ROOT-}" != pipeline ] || - echo pipeline > /etc/initrd/method + echo bootchain > /etc/initrd/method diff --git a/features/pipeline/data/lib/uevent/filters/pipeline-waitdev b/features/bootchain-core/data/lib/uevent/filters/bootchain-waitdev similarity index 77% rename from features/pipeline/data/lib/uevent/filters/pipeline-waitdev rename to features/bootchain-core/data/lib/uevent/filters/bootchain-waitdev index d975006..272aee7 100755 --- a/features/pipeline/data/lib/uevent/filters/pipeline-waitdev +++ b/features/bootchain-core/data/lib/uevent/filters/bootchain-waitdev @@ -3,8 +3,8 @@ . /.initrd/initenv . initrd-sh-functions -mkdir -p -- /.initrd/pipeline/waitdev -cd /.initrd/pipeline/waitdev +mkdir -p -- /.initrd/bootchain/waitdev +cd /.initrd/bootchain/waitdev/ i=0 while [ "$i" -lt "${WAITDEV:-0}" ]; do diff --git a/features/pipeline/data/sbin/pipeline-sh-functions b/features/bootchain-core/data/sbin/bootchain-sh-functions similarity index 70% rename from features/pipeline/data/sbin/pipeline-sh-functions rename to features/bootchain-core/data/sbin/bootchain-sh-functions index 662d069..fa6201f 100644 --- a/features/pipeline/data/sbin/pipeline-sh-functions +++ b/features/bootchain-core/data/sbin/bootchain-sh-functions @@ -1,13 +1,13 @@ #!/bin/bash -efu -if [ -z "${__pipeline_sh_functions-}" ]; then -__pipeline_sh_functions=1 +if [ -z "${__bootchain_sh_functions-}" ]; then +__bootchain_sh_functions=1 . /.initrd/initenv . shell-signal -handlerdir="/lib/pipeline" -mntdir="/dev/pipeline" +handlerdir=/lib/bootchain +[ "${ROOT-}" = pipeline ] && mntdir=/dev/pipeline || mntdir=/dev/bootchain check_parameter() { @@ -29,7 +29,7 @@ resolve_target() '') ;; pipe[0-9]|pipe[0-9][0-9]|pipe[0-9][0-9][0-9]) - target="$mntdir/dst/$target" + target="$mntdir/dst/step${target:4}" ;; *) if [ -z "${prevdir-}" ]; then @@ -48,4 +48,4 @@ run() "$@" } -fi # __pipeline_sh_functions +fi # __bootchain_sh_functions diff --git a/features/pipeline/data/sbin/pipelined b/features/bootchain-core/data/sbin/chaind similarity index 78% rename from features/pipeline/data/sbin/pipelined rename to features/bootchain-core/data/sbin/chaind index 1d30061..d401101 100755 --- a/features/pipeline/data/sbin/pipelined +++ b/features/bootchain-core/data/sbin/chaind @@ -21,7 +21,7 @@ exit_handler() set_cleanup_handler exit_handler echo "$$" >"$pidfile" -. pipeline-sh-functions +. bootchain-sh-functions [ "${RDLOG-}" != 'console' ] || @@ -35,22 +35,22 @@ mkdir -p -- "$mntdir" mountpoint -q "$mntdir" || mount -t tmpfs tmpfs "$mntdir" ||: -pipenum=0 -pipe="$PIPELINE" +stepnum=0 +chainsteps="$BOOTCHAIN" datadir= destdir= -while [ -n "$pipe" ]; do - name="${pipe%%,*}" +while [ -n "$chainsteps" ]; do + name="${chainsteps%%,*}" exe="$handlerdir/$name" if [ -x "$exe" ]; then eval "callnum=\"\${callnum_$name:-0}\"" - datadir="$mntdir/src/pipe$pipenum" - destdir="$mntdir/dst/pipe$pipenum" + datadir="$mntdir/src/step$stepnum" + destdir="$mntdir/dst/step$stepnum" - [ "$pipenum" != 0 ] || + [ "$stepnum" != 0 ] || prevdir="" mkdir -p -- "$datadir" "$destdir" @@ -80,8 +80,8 @@ while [ -n "$pipe" ]; do eval "callnum_$name=\"\$callnum\"" fi - pipe="${pipe#$name}" - pipe="${pipe#,}" + chainsteps="${chainsteps#$name}" + chainsteps="${chainsteps#,}" - pipenum=$(($pipenum + 1)) + stepnum=$(($stepnum + 1)) done diff --git a/features/bootchain-core/rules.mk b/features/bootchain-core/rules.mk new file mode 100644 index 0000000..724a0b0 --- /dev/null +++ b/features/bootchain-core/rules.mk @@ -0,0 +1,4 @@ +MODULES_TRY_ADD += $(BOOTCHAIN_CORE_MODULES) + +PUT_UDEV_RULES += $(BOOTCHAIN_CORE_RULES) +PUT_FEATURE_DIRS += $(BOOTCHAIN_CORE_DATADIR) diff --git a/features/pipeline/config.mk b/features/pipeline/config.mk index 9172528..3ff29ac 100644 --- a/features/pipeline/config.mk +++ b/features/pipeline/config.mk @@ -1,8 +1 @@ -$(call feature-requires,depmod-image add-udev-rules) - -PIPELINE_DATADIR = $(FEATURESDIR)/pipeline/data - -PIPELINE_RULES = \ - *-cdrom_id.rules - -PIPELINE_MODULES = isofs squashfs overlay +$(call feature-requires,bootchain-core) diff --git a/features/pipeline/rules.mk b/features/pipeline/rules.mk index 3ccd260..e69de29 100644 --- a/features/pipeline/rules.mk +++ b/features/pipeline/rules.mk @@ -1,6 +0,0 @@ -MODULES_TRY_ADD += $(PIPELINE_MODULES) - -PUT_UDEV_RULES += $(PIPELINE_RULES) - -PUT_FEATURE_DIRS += $(PIPELINE_DATADIR) -PUT_FEATURE_FILES += $(PIPELINE_FILES) -- 2.24.1