aboutgitcode
path: root/mbuto
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2022-03-30 06:07:03 +0200
committerStefano Brivio <sbrivio@redhat.com>2022-04-06 12:29:43 +0200
commit075f6d07c6c6eaf0803a0d04babfcf09c4e260e6 (patch)
tree0139b177a75c6b56f5e8d85b6c805e9af7140f09 /mbuto
parent6199e368f68dcc9faabb48277c9d014ea0a4f0db (diff)
downloadmbuto-075f6d07c6c6eaf0803a0d04babfcf09c4e260e6.tar
mbuto-075f6d07c6c6eaf0803a0d04babfcf09c4e260e6.tar.gz
mbuto-075f6d07c6c6eaf0803a0d04babfcf09c4e260e6.tar.bz2
mbuto-075f6d07c6c6eaf0803a0d04babfcf09c4e260e6.tar.lz
mbuto-075f6d07c6c6eaf0803a0d04babfcf09c4e260e6.tar.xz
mbuto-075f6d07c6c6eaf0803a0d04babfcf09c4e260e6.tar.zst
mbuto-075f6d07c6c6eaf0803a0d04babfcf09c4e260e6.zip
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 <sbrivio@redhat.com>
Diffstat (limited to 'mbuto')
-rwxr-xr-xmbuto53
1 files 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"