From 075f6d07c6c6eaf0803a0d04babfcf09c4e260e6 Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Wed, 30 Mar 2022 06:07:03 +0200 Subject: mbuto: Make NODES and LINKS simple lists Instead of having one device node per line, use commas to separate attributes, if given. Take links as pairs of tokens, instead of requiring one line for each. This makes command-line overrides actually usable without the need to resort to printf(1) tricks. Signed-off-by: Stefano Brivio --- mbuto | 53 +++++++++++++++++------------------------------------ 1 file changed, 17 insertions(+), 36 deletions(-) diff --git a/mbuto b/mbuto index 99b0e2d..7284ee9 100755 --- a/mbuto +++ b/mbuto @@ -35,16 +35,8 @@ LIBS_DLOPEN="${LIBS_DLOPEN:- # Kernel modules: see profile_base(). -# Device nodes, one per line, NAME TYPE MAJOR MINOR supported, copied otherwise -NODES="${NODES:- - console - kmsg - null - ptmx - random - urandom - zero -}" +# Device nodes, NAME,TYPE,MAJOR,MINOR supported, copied otherwise +NODES="${NODES:-console kmsg null ptmx random urandom zero}" # Empty directories to create DIRS="${DIRS:-/proc /sys}" @@ -80,7 +72,7 @@ profile_base() { # Programs sourced with linked libraries, alternatives with commas PROGS="${PROGS:-ash,dash,bash mount mkdir ln}" - # Links: installed target program, then link name, one per line + # Links: installed target program, then link name LINKS="${LINKS:- ash,dash,bash /bin/sh ash,dash,bash /init}" @@ -108,9 +100,7 @@ profile_bash() { KMODS="${KMODS:-virtio_net virtio_pci}" - NODES="${NODES} - tty - ttyS0" + NODES="${NODES} tty ttyS0" OUTPUT="__INITRD__ " @@ -178,12 +168,9 @@ profile_passt() { ash,dash,bash /bin/sh ash,dash,bash /usr/bin/bash}" - NODES="${NODES} - tty - ttyS0" + NODES="${NODES} tty ttyS0" - DIRS="${DIRS} - /tmp" + DIRS="${DIRS} /tmp" COPIES="${COPIES} /etc/udhcpc/default.script @@ -509,8 +496,8 @@ libs_copy() { # prog_link() - Link from $LINKS to sourced program from $PROGS # $1: Program name from $PROGS # $2: Target on working directory $wd -# $3: First token of line from $LINKS, skip if not matching -# $4: Link name, second token from $LINKS line +# $3: Even-numbered token from $LINKS, skip if not matching +# $4: Link name, next token from $LINKS prog_link() { [ "${1}" != "${3}" ] && return "${MKDIR}" -p "$("${DIRNAME}" "${wd}${4}")" @@ -541,15 +528,13 @@ prog_add() { "${MKDIR}" -p "${__bindir}" "${CP}" --preserve=all "${__bin}" "${__bindir}" - IFS=' -' + __target= for __l in ${LINKS}; do - IFS=' ' + [ -z "${__target}" ] && __target="${__l}" && continue + prog_link "${1}" \ "${__bindir##${wd}}/$("${BASENAME}" "${__bin}")" \ - ${__l} - IFS=' -' + "${__target}" "${__l}" done IFS=' @@ -746,15 +731,11 @@ build() { done kmod_post - IFS=' -' for __n in ${NODES}; do - IFS=' ' + IFS=',' node_add ${__n} - IFS=' -' + unset IFS done - unset IFS for __c in ${COPIES}; do "${CP}" --parent -a "${__c}" "${wd}" @@ -891,10 +872,10 @@ usage() { echo " KMODS" echo " base kernel modules" echo " NODES" - echo " device nodes, one per line. Copied from host if just" - echo " name is given, created if 'NAME TYPE MAJOR MINOR'" + echo " device nodes, copied from host if just name is given, " + echo " created if NAME,TYPE,MAJOR,MINOR" echo " LINKS" - echo " link to programs by name, one per line, in the form" + echo " link to programs by name, pairs of" echo " PROGRAM PATH" echo " DIRS" echo " list of initial set of empty directories" -- cgit v1.2.3