commit 3827df94d66c75873c53f0949960a294d7a7f88a Author: Leonid Krivoshein Date: Sun Sep 26 04:48:04 2021 +0300 fixed resolve_target(), reverse addressation added diff --git a/bootchain-core/data/bin/bootchain-sh-functions b/bootchain-core/data/bin/bootchain-sh-functions index 086d698..4f416d2 100644 --- a/bootchain-core/data/bin/bootchain-sh-functions +++ b/bootchain-core/data/bin/bootchain-sh-functions @@ -49,25 +49,33 @@ get_parameter() resolve_target() { local target="$1" + local where="${target%%/*}" + local n="${#where}" - case "${target%%/*}" in + target="${target:$n}" + + case "$where" in '') ;; pipe[0-9]|pipe[0-9][0-9]|pipe[0-9][0-9][0-9]) - target="$mntdir/dst/step${target:4}" + n="$(( ${basestep:-0} + ${where:4} ))" + [ ! -d "$mntdir/dst/step$n" ] && return 0 || + target="$mntdir/dst/step${n}${target}" ;; - step[0-9]|step[0-9][0-9]|step[0-9][0-9][0-9]) - target="$mntdir/dst/$target" + step-[1-9]|step-[1-9][0-9]|step-[1-9][0-9][0-9]) + n="$(( ${stepnum:-0} - ${where:5} ))" + [ "${basestep:-0}" -le "$n" ] && [ -d "$mntdir/dst/step$n" ] && + target="$mntdir/dst/step${n}${target}" || return 0 ;; *) if [ -z "${prevdir-}" ]; then - message "no previous step results to use with $PROG" + message "no previous step results to use with $name" return 0 fi - if [ "$target" = DEVNAME ] && [ -s "$prevdir/DEVNAME" ]; then - read -r target <"$prevdir/DEVNAME" ||: + if [ "$where" = DEVNAME ] && [ -s "$prevdir/DEVNAME" ]; then + read -r target <"$prevdir/DEVNAME" 2>/dev/null ||: else - target="$prevdir/${target#/}" + target="$prevdir/${where#/}${target}" fi ;; esac diff --git a/bootchain-core/data/sbin/bootchain-loop b/bootchain-core/data/sbin/bootchain-loop index 1cf00d3..59c2ac7 100755 --- a/bootchain-core/data/sbin/bootchain-loop +++ b/bootchain-core/data/sbin/bootchain-loop @@ -6,6 +6,7 @@ bcretry="${bcretry:-1}" stepnum="${stepnum:-0}" chainsteps="${chainsteps-}" prevdir="${prevdir-}" +basestep="$stepnum" BC_IM_supported= @@ -83,7 +84,8 @@ while [ -n "$chainsteps" ]; do else message "[$callnum] Handler: $exe" - export name callnum datadir destdir prevdir + export name callnum datadir destdir + export basestep stepnum prevdir for try in 1 2 3 4 5; do [ -z "$BC_DEBUG" ] || @@ -128,6 +130,7 @@ while [ -n "$chainsteps" ]; do debug "chain will be reloaded by $BC_NEXTCHAIN:" fdump "$BC_NEXTCHAIN" . "$BC_NEXTCHAIN" + basestep="$stepnum" run rm -f -- "$BC_NEXTCHAIN" fi