From: Leonid Krivoshein <klark.devel@gmail.com> To: make-initrd@lists.altlinux.org Subject: [make-initrd] [PATCH v1 33/41] fork pipeline: bootchain-loop: primary changes Date: Fri, 24 Sep 2021 18:58:58 +0300 Message-ID: <a900dd6f-d95f-369c-748a-0ad87b67e0d5@gmail.com> (raw) --- .../bootchain-core/data/sbin/bootchain-loop | 100 +++++++++++++----- 1 file changed, 71 insertions(+), 29 deletions(-) diff --git a/make-initrd/features/bootchain-core/data/sbin/bootchain-loop b/make-initrd/features/bootchain-core/data/sbin/bootchain-loop index 0b9fdd3..70a5bf6 100755 --- a/make-initrd/features/bootchain-core/data/sbin/bootchain-loop +++ b/make-initrd/features/bootchain-core/data/sbin/bootchain-loop @@ -2,53 +2,95 @@ . bootchain-sh-functions -stepnum=0 +stepnum="${stepnum:-0}" chainsteps="${chainsteps-}" -datadir= -destdir= +prevdir="${prevdir-}" + +debug() +{ + [ -z "$BC_DEBUG" ] || + message "$*" +} + + +rc=0 while [ -n "$chainsteps" ]; do name="${chainsteps%%,*}" exe="$handlerdir/$name" if [ -x "$exe" ]; then - eval "callnum=\"\${callnum_$name:-0}\"" - - datadir="$mntdir/src/pipe$stepnum" - destdir="$mntdir/dst/pipe$stepnum" + assign "callnum" "\${callnum_$name:-0}" + datadir="$mntdir/src/step$stepnum" + destdir="$mntdir/dst/step$stepnum" - [ "$stepnum" != 0 ] || - prevdir="" + run mkdir -p -- "$datadir" "$destdir" - mkdir -p -- "$datadir" "$destdir" - - if ! mountpoint -q "$destdir"; then + if mountpoint -q -- "$destdir" || + [ -s "$destdir/DEVNAME" ] || + [ -b "$destdir/dev" ] || + [ -c "$destdir/dev" ] + then + message "[$callnum] Handler: $exe skipped" + else message "[$callnum] Handler: $exe" export name callnum datadir destdir prevdir - rc=0 - "$exe" || rc=$? - - if [ "$rc" != 0 ]; then - [ "$rc" != 2 ] || + for try in 1 2 3 4 5; do + [ -z "$BC_DEBUG" ] || + run "$handlerdir/debug" ||: + rc=0 + run "$exe" || + rc=$? + [ "$rc" != 0 ] || break - message "[$callnum] Handler failed (rc=$rc)" - sleep 1 - continue - fi - else - message "[$callnum] Handler: $exe skipped" + [ "$rc" != 2 ] || [ -z "$pipeline_mode" ] || + break 2 + message "[$callnum] Handler failed (rc=$rc, try=$try)" + [ ! -f "$BC_PASSED/$PROG" ] || + break 2 + sleep 2 + done + + [ -r "$BC_NEXTCHAIN" ] || + run touch "$BC_PASSED/$name" + [ ! -f "$BC_PASSED/$PROG" ] || + break + [ "$rc" = 0 ] || + break fi - prevdir="$destdir" + if [ ! -r "$BC_NEXTCHAIN" ]; then + callnum=$((1 + $callnum)) + assign "callnum_$name" "\$callnum" + eval "export callnum_$name" + fi - callnum=$(($callnum + 1)) - eval "callnum_$name=\"\$callnum\"" + stepnum=$((1 + $stepnum)) + prevdir="$(readlink-e "$destdir" 2>/dev/null ||:)" fi - chainsteps="${chainsteps#$name}" - chainsteps="${chainsteps#,}" + if [ ! -r "$BC_NEXTCHAIN" ]; then + chainsteps="${chainsteps#$name}" + chainsteps="${chainsteps#,}" + else + debug "chain will be reloaded by $BC_NEXTCHAIN:" + fdump "$BC_NEXTCHAIN" + . "$BC_NEXTCHAIN" + run rm -f -- "$BC_NEXTCHAIN" + fi - stepnum=$(($stepnum + 1)) + debug "remaining steps: $chainsteps" done + +[ -z "$chainsteps" ] || + message "remaining steps after breaking loop: $chainsteps" + +if [ "$rc" = 2 ] && [ -n "$pipeline_mode" ]; then + debug "finishing in pipeline mode" +elif [ "$rc" = 0 ] && [ -f "$BC_PASSED/$PROG" ]; then + debug "finishing in bootchain mode" +else + fatal "daemon terminated incorrectly (rc=$rc)" +fi -- 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=a900dd6f-d95f-369c-748a-0ad87b67e0d5@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