From b3ceb3d9fff69b33b8665a0137f5177f72c45cc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Thu, 16 Dec 2021 14:35:17 +0100 Subject: [PATCH 1/6] kernel-install: 50-depmod: port to /bin/sh --- src/kernel-install/50-depmod.install | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/kernel-install/50-depmod.install b/src/kernel-install/50-depmod.install index 2fd959865f2..aa1f6b8e0ef 100644 --- a/src/kernel-install/50-depmod.install +++ b/src/kernel-install/50-depmod.install @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh # SPDX-License-Identifier: LGPL-2.1-or-later @@ -20,23 +20,25 @@ COMMAND="$1" KERNEL_VERSION="$2" -ENTRY_DIR_ABS="$3" -KERNEL_IMAGE="$4" -INITRD_OPTIONS_START="5" - -[[ $KERNEL_VERSION ]] || exit 1 case "$COMMAND" in add) - [[ -d "/lib/modules/${KERNEL_VERSION}/kernel" ]] || exit 0 - [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \ - echo "Running depmod -a ${KERNEL_VERSION}" - exec depmod -a "${KERNEL_VERSION}" + [ -d "/lib/modules/$KERNEL_VERSION/kernel" ] || exit 0 + [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "+depmod -a $KERNEL_VERSION" + exec depmod -a "$KERNEL_VERSION" ;; remove) - [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \ - echo "Removing /lib/modules/${KERNEL_VERSION}/modules.dep and associated files" - exec rm -f /lib/modules/"${KERNEL_VERSION}"/modules.{alias{,.bin},builtin.bin,dep{,.bin},devname,softdep,symbols{,.bin}} + [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "Removing /lib/modules/$KERNEL_VERSION/modules.dep and associated files" + exec rm -f \ + "/lib/modules/$KERNEL_VERSION/modules.alias" \ + "/lib/modules/$KERNEL_VERSION/modules.alias.bin" \ + "/lib/modules/$KERNEL_VERSION/modules.builtin.bin" \ + "/lib/modules/$KERNEL_VERSION/modules.dep" \ + "/lib/modules/$KERNEL_VERSION/modules.dep.bin" \ + "/lib/modules/$KERNEL_VERSION/modules.devname" \ + "/lib/modules/$KERNEL_VERSION/modules.softdep" \ + "/lib/modules/$KERNEL_VERSION/modules.symbols" \ + "/lib/modules/$KERNEL_VERSION/modules.symbols.bin" ;; *) exit 0 From 662f45e3ea9f6e933234b81bec532d584bda6ead Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Thu, 16 Dec 2021 14:35:33 +0100 Subject: [PATCH 2/6] kernel-install: 90-loaderentry: port to /bin/sh Also, forward the rm -f exit code on removal instead of swallowing it --- src/kernel-install/90-loaderentry.install | 108 +++++++++------------- 1 file changed, 44 insertions(+), 64 deletions(-) diff --git a/src/kernel-install/90-loaderentry.install b/src/kernel-install/90-loaderentry.install index 044eced3f01..35324e69a99 100644 --- a/src/kernel-install/90-loaderentry.install +++ b/src/kernel-install/90-loaderentry.install @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh # SPDX-License-Identifier: LGPL-2.1-or-later @@ -22,68 +22,53 @@ COMMAND="$1" KERNEL_VERSION="$2" ENTRY_DIR_ABS="$3" KERNEL_IMAGE="$4" -INITRD_OPTIONS_START="5" +INITRD_OPTIONS_SHIFT=4 -if ! [[ $KERNEL_INSTALL_MACHINE_ID ]]; then - exit 0 -fi - -if [ "$KERNEL_INSTALL_LAYOUT" != "bls" ]; then - exit 0 -fi +[ "$KERNEL_INSTALL_LAYOUT" = "bls" ] || exit 0 MACHINE_ID="$KERNEL_INSTALL_MACHINE_ID" BOOT_ROOT="$KERNEL_INSTALL_BOOT_ROOT" BOOT_MNT="$(stat -c %m "$BOOT_ROOT")" -if [[ "$BOOT_MNT" == '/' ]]; then +if [ "$BOOT_MNT" = '/' ]; then ENTRY_DIR="$ENTRY_DIR_ABS" else ENTRY_DIR="${ENTRY_DIR_ABS#$BOOT_MNT}" fi -if [[ $COMMAND == remove ]]; then - rm -f "$BOOT_ROOT/loader/entries/$MACHINE_ID-$KERNEL_VERSION.conf" - rm -f "$BOOT_ROOT/loader/entries/$MACHINE_ID-$KERNEL_VERSION+"*".conf" - exit 0 -fi +case "$COMMAND" in + remove) + exec rm -f \ + "$BOOT_ROOT/loader/entries/$MACHINE_ID-$KERNEL_VERSION.conf" \ + "$BOOT_ROOT/loader/entries/$MACHINE_ID-$KERNEL_VERSION+"*".conf" + ;; + add) + ;; + *) + exit 1 + ;; +esac -if ! [[ $COMMAND == add ]]; then - exit 1 -fi - -if ! [[ $KERNEL_IMAGE ]]; then - exit 1 -fi - -if [[ -f /etc/os-release ]]; then +if [ -r /etc/os-release ]; then . /etc/os-release -elif [[ -f /usr/lib/os-release ]]; then +elif [ -r /usr/lib/os-release ]; then . /usr/lib/os-release fi -if ! [[ $PRETTY_NAME ]]; then - PRETTY_NAME="Linux $KERNEL_VERSION" -fi +[ -n "$PRETTY_NAME" ] || PRETTY_NAME="Linux $KERNEL_VERSION" -if [[ -f /etc/kernel/cmdline ]]; then - read -r -d '' -a BOOT_OPTIONS < /etc/kernel/cmdline -elif [[ -f /usr/lib/kernel/cmdline ]]; then - read -r -d '' -a BOOT_OPTIONS < /usr/lib/kernel/cmdline +if [ -r /etc/kernel/cmdline ]; then + BOOT_OPTIONS="$(tr -s "$IFS" ' ' &2 exit 1 fi @@ -106,43 +91,38 @@ install -g root -o root -m 0644 "$KERNEL_IMAGE" "$ENTRY_DIR_ABS/linux" || { exit 1 } -INITRD_OPTIONS=( "${@:${INITRD_OPTIONS_START}}" ) +shift "$INITRD_OPTIONS_SHIFT" +for initrd; do + [ -f "$initrd" ] || continue -for initrd in "${INITRD_OPTIONS[@]}"; do - if [[ -f "${initrd}" ]]; then - initrd_basename="$(basename ${initrd})" - [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \ - echo "Installing $ENTRY_DIR_ABS/${initrd_basename}" - install -g root -o root -m 0644 "${initrd}" "$ENTRY_DIR_ABS/${initrd_basename}" || { - echo "Could not copy '${initrd}' to '$ENTRY_DIR_ABS/${initrd_basename}'." >&2 - exit 1 - } - fi + initrd_basename="${initrd##*/}" + [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "Installing $ENTRY_DIR_ABS/$initrd_basename" + install -g root -o root -m 0644 "$initrd" "$ENTRY_DIR_ABS/$initrd_basename" || { + echo "Could not copy '$initrd' to '$ENTRY_DIR_ABS/$initrd_basename'." >&2 + exit 1 + } done -# If no initrd option is supplied, fall back to "initrd" which is -# the name used by dracut when generating it in its kernel-install hook -[[ ${#INITRD_OPTIONS[@]} == 0 ]] && INITRD_OPTIONS=( initrd ) - mkdir -p "${LOADER_ENTRY%/*}" || { echo "Could not create loader entry directory '${LOADER_ENTRY%/*}'." >&2 exit 1 } -[ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \ - echo "Creating $LOADER_ENTRY" +# Try "initrd", generated by dracut in its kernel-install hook, if no initrds were supplied +[ $# -eq 0 ] && set -- "initrd" + +[ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "Creating $LOADER_ENTRY" { echo "title $PRETTY_NAME" echo "version $KERNEL_VERSION" echo "machine-id $MACHINE_ID" - echo "options ${BOOT_OPTIONS[*]}" + echo "options $BOOT_OPTIONS" echo "linux $ENTRY_DIR/linux" - for initrd in "${INITRD_OPTIONS[@]}"; do - [[ -f $ENTRY_DIR_ABS/$(basename ${initrd}) ]] && \ - echo "initrd $ENTRY_DIR/$(basename ${initrd})" + for initrd; do + [ -f "$ENTRY_DIR_ABS/${initrd##*/}" ] && echo "initrd $ENTRY_DIR/${initrd##*/}" done : -} > "$LOADER_ENTRY" || { +} >"$LOADER_ENTRY" || { echo "Could not create loader entry '$LOADER_ENTRY'." >&2 exit 1 } From 0bb1cb1fce5ebf307501dec1679e37f0c0157be9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Thu, 16 Dec 2021 14:37:53 +0100 Subject: [PATCH 3/6] kernel-install: fix shellcheck --- src/kernel-install/kernel-install | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/kernel-install/kernel-install b/src/kernel-install/kernel-install index b358b03b2ff..f6da0cf7a82 100755 --- a/src/kernel-install/kernel-install +++ b/src/kernel-install/kernel-install @@ -26,8 +26,8 @@ usage() echo " $0 [OPTIONS...] add KERNEL-VERSION KERNEL-IMAGE [INITRD-FILE ...]" echo " $0 [OPTIONS...] remove KERNEL-VERSION" echo "Options:" - echo " -h,--help Print this help" - echo " -v,--verbose Increase verbosity" + echo " -h, --help Print this help" + echo " -v, --verbose Increase verbosity" } dropindirs_sort() @@ -58,15 +58,15 @@ dropindirs_sort() export LC_COLLATE=C -for i in "$@"; do - if [ "$i" == "--help" -o "$i" == "-h" ]; then +for i; do + if [ "$i" = "--help" ] || [ "$i" = "-h" ]; then usage exit 0 fi done KERNEL_INSTALL_VERBOSE=0 -if [ "$1" == "--verbose" -o "$1" == "-v" ]; then +if [ "$1" = "--verbose" ] || [ "$1" = "-v" ]; then shift KERNEL_INSTALL_VERBOSE=1 fi @@ -185,13 +185,13 @@ case $COMMAND in for f in "${PLUGINS[@]}"; do if [[ -x $f ]]; then [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \ - echo "+$f add $KERNEL_VERSION $ENTRY_DIR_ABS $KERNEL_IMAGE ${INITRD_OPTIONS[@]}" + echo "+$f add $KERNEL_VERSION $ENTRY_DIR_ABS $KERNEL_IMAGE ${INITRD_OPTIONS[*]}" "$f" add "$KERNEL_VERSION" "$ENTRY_DIR_ABS" "$KERNEL_IMAGE" "${INITRD_OPTIONS[@]}" x=$? - if [[ $x == $SKIP_REMAINING ]]; then + if [ $x -eq "$SKIP_REMAINING" ]; then break fi - ((ret+=$x)) + ((ret+=x)) fi done ;; @@ -203,10 +203,10 @@ case $COMMAND in echo "+$f remove $KERNEL_VERSION $ENTRY_DIR_ABS" "$f" remove "$KERNEL_VERSION" "$ENTRY_DIR_ABS" x=$? - if [[ $x == $SKIP_REMAINING ]]; then + if [ $x -eq "$SKIP_REMAINING" ]; then break fi - ((ret+=$x)) + ((ret+=x)) fi done @@ -222,4 +222,4 @@ case $COMMAND in ;; esac -exit $ret +exit "$ret" From 76b1274a5cb54acaa4a0f0c2e570d751f9067c06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Thu, 16 Dec 2021 15:06:06 +0100 Subject: [PATCH 4/6] kernel-install: port to /bin/sh --- src/kernel-install/kernel-install | 107 ++++++++++++------------------ 1 file changed, 42 insertions(+), 65 deletions(-) diff --git a/src/kernel-install/kernel-install b/src/kernel-install/kernel-install index f6da0cf7a82..2e8f382d5fe 100755 --- a/src/kernel-install/kernel-install +++ b/src/kernel-install/kernel-install @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh # SPDX-License-Identifier: LGPL-2.1-or-later @@ -18,7 +18,7 @@ # You should have received a copy of the GNU Lesser General Public License # along with systemd; If not, see . -SKIP_REMAINING=77 +skip_remaining=77 usage() { @@ -32,24 +32,17 @@ usage() dropindirs_sort() { - local suffix=$1; shift - local -a files - local f d i + suffix="$1" + shift - readarray -t files <<<"$( - for d in "$@"; do - for i in "$d/"*"$suffix"; do - if [[ -e "$i" ]]; then - echo "${i##*/}" - fi - done - done | sort -Vu - )" - - for f in "${files[@]}"; do - for d in "$@"; do - if [[ -e "$d/$f" ]]; then - echo "$d/$f" + for d; do + for i in "$d/"*"$suffix"; do + [ -e "$i" ] && echo "${i##*/}" + done + done | sort -Vu | while read -r f; do + for d; do + if [ -e "$d/$f" ]; then + [ -x "$d/$f" ] && echo "$d/$f" continue 2 fi done @@ -65,27 +58,25 @@ for i; do fi done -KERNEL_INSTALL_VERBOSE=0 +export KERNEL_INSTALL_VERBOSE=0 if [ "$1" = "--verbose" ] || [ "$1" = "-v" ]; then shift KERNEL_INSTALL_VERBOSE=1 fi -export KERNEL_INSTALL_VERBOSE -if [[ "${0##*/}" == 'installkernel' ]]; then - COMMAND='add' - # make install doesn't pass any parameter wrt initrd handling - INITRD_OPTIONS=() +if [ "${0##*/}" = "installkernel" ]; then + COMMAND=add + # make install doesn't pass any initrds else COMMAND="$1" - shift - INITRD_OPTIONS=( "${@:3}" ) + [ $# -ge 1 ] && shift fi KERNEL_VERSION="$1" KERNEL_IMAGE="$2" +[ $# -ge 2 ] && shift 2 -if [[ ! $COMMAND ]] || [[ ! $KERNEL_VERSION ]]; then +if [ -z "$COMMAND" ] || [ -z "$KERNEL_VERSION" ]; then echo "Not enough arguments" >&2 exit 1 fi @@ -99,12 +90,11 @@ fi # Prefer to use an existing machine ID from /etc/machine-info or /etc/machine-id. If we're using the machine # ID /etc/machine-id, try to persist it in /etc/machine-info. If no machine ID is found, try to generate # a new machine ID in /etc/machine-info. If that fails, use "Default". - -[ -z "$MACHINE_ID" ] && [ -f /etc/machine-info ] && source /etc/machine-info && MACHINE_ID="$KERNEL_INSTALL_MACHINE_ID" -[ -z "$MACHINE_ID" ] && [ -f /etc/machine-id ] && read -r MACHINE_ID >/etc/machine-info +[ -z "$MACHINE_ID" ] && [ -r /etc/machine-info ] && . /etc/machine-info && MACHINE_ID="$KERNEL_INSTALL_MACHINE_ID" +[ -z "$MACHINE_ID" ] && [ -r /etc/machine-id ] && read -r MACHINE_ID >/etc/machine-info [ -z "$MACHINE_ID" ] && NEW_MACHINE_ID="$(systemd-id128 new)" && echo "KERNEL_INSTALL_MACHINE_ID=$NEW_MACHINE_ID" >>/etc/machine-info -[ -z "$MACHINE_ID" ] && [ -f /etc/machine-info ] && source /etc/machine-info && MACHINE_ID="$KERNEL_INSTALL_MACHINE_ID" +[ -z "$MACHINE_ID" ] && [ -r /etc/machine-info ] && . /etc/machine-info && MACHINE_ID="$KERNEL_INSTALL_MACHINE_ID" [ -z "$MACHINE_ID" ] && MACHINE_ID="Default" [ -z "$BOOT_ROOT" ] && for suff in "$MACHINE_ID" "loader/entries"; do @@ -125,11 +115,6 @@ done [ -z "$BOOT_ROOT" ] && BOOT_ROOT="/boot" -ENTRY_DIR_ABS="$BOOT_ROOT/$MACHINE_ID/$KERNEL_VERSION" - -export KERNEL_INSTALL_MACHINE_ID="$MACHINE_ID" -export KERNEL_INSTALL_BOOT_ROOT="$BOOT_ROOT" - if [ -z "$layout" ]; then # Administrative decision: if not present, some scripts generate into /boot. if [ -d "$BOOT_ROOT/$MACHINE_ID" ]; then @@ -152,21 +137,23 @@ MAKE_ENTRY_DIR_ABS=$? ret=0 -readarray -t PLUGINS <<<"$( +PLUGINS="$( dropindirs_sort ".install" \ "/etc/kernel/install.d" \ "/usr/lib/kernel/install.d" )" +IFS=" +" -case $COMMAND in +case "$COMMAND" in add) - if [[ ! "$KERNEL_IMAGE" ]]; then + if [ -z "$KERNEL_IMAGE" ]; then echo "Command 'add' requires an argument" >&2 exit 1 fi - if [[ ! -f "$KERNEL_IMAGE" ]]; then - echo "Kernel image argument ${KERNEL_IMAGE} not a file" >&2 + if ! [ -f "$KERNEL_IMAGE" ]; then + echo "Kernel image argument $KERNEL_IMAGE not a file" >&2 exit 1 fi @@ -182,32 +169,22 @@ case $COMMAND in fi fi - for f in "${PLUGINS[@]}"; do - if [[ -x $f ]]; then - [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \ - echo "+$f add $KERNEL_VERSION $ENTRY_DIR_ABS $KERNEL_IMAGE ${INITRD_OPTIONS[*]}" - "$f" add "$KERNEL_VERSION" "$ENTRY_DIR_ABS" "$KERNEL_IMAGE" "${INITRD_OPTIONS[@]}" - x=$? - if [ $x -eq "$SKIP_REMAINING" ]; then - break - fi - ((ret+=x)) - fi + for f in $PLUGINS; do + [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "+$f add $KERNEL_VERSION $ENTRY_DIR_ABS $KERNEL_IMAGE $*" + "$f" add "$KERNEL_VERSION" "$ENTRY_DIR_ABS" "$KERNEL_IMAGE" "$@" + err=$? + [ $err -eq $skip_remaining ] && break + ret=$(( ret + err )) done ;; remove) - for f in "${PLUGINS[@]}"; do - if [[ -x $f ]]; then - [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \ - echo "+$f remove $KERNEL_VERSION $ENTRY_DIR_ABS" - "$f" remove "$KERNEL_VERSION" "$ENTRY_DIR_ABS" - x=$? - if [ $x -eq "$SKIP_REMAINING" ]; then - break - fi - ((ret+=x)) - fi + for f in $PLUGINS; do + [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "+$f remove $KERNEL_VERSION $ENTRY_DIR_ABS" + "$f" remove "$KERNEL_VERSION" "$ENTRY_DIR_ABS" + err=$? + [ $err -eq $skip_remaining ] && break + ret=$(( ret + err )) done if [ "$MAKE_ENTRY_DIR_ABS" -eq 0 ]; then From 742561efbe938c45936f2e4f5d81b3ff6b352882 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Fri, 17 Dec 2021 19:51:12 +0100 Subject: [PATCH 5/6] kernel-install: 90-loaderentry: error out on nonexistent initrds instead of swallowing them quietly --- src/kernel-install/90-loaderentry.install | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/kernel-install/90-loaderentry.install b/src/kernel-install/90-loaderentry.install index 35324e69a99..e588e72bf9c 100644 --- a/src/kernel-install/90-loaderentry.install +++ b/src/kernel-install/90-loaderentry.install @@ -93,7 +93,10 @@ install -g root -o root -m 0644 "$KERNEL_IMAGE" "$ENTRY_DIR_ABS/linux" || { shift "$INITRD_OPTIONS_SHIFT" for initrd; do - [ -f "$initrd" ] || continue + [ -f "$initrd" ] || { + echo "Initrd '$initrd' not a file." >&2 + exit 1 + } initrd_basename="${initrd##*/}" [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "Installing $ENTRY_DIR_ABS/$initrd_basename" @@ -108,9 +111,6 @@ mkdir -p "${LOADER_ENTRY%/*}" || { exit 1 } -# Try "initrd", generated by dracut in its kernel-install hook, if no initrds were supplied -[ $# -eq 0 ] && set -- "initrd" - [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "Creating $LOADER_ENTRY" { echo "title $PRETTY_NAME" @@ -119,8 +119,10 @@ mkdir -p "${LOADER_ENTRY%/*}" || { echo "options $BOOT_OPTIONS" echo "linux $ENTRY_DIR/linux" for initrd; do - [ -f "$ENTRY_DIR_ABS/${initrd##*/}" ] && echo "initrd $ENTRY_DIR/${initrd##*/}" + echo "initrd $ENTRY_DIR/${initrd##*/}" done + # Try "initrd", generated by dracut in its kernel-install hook, if no initrds were supplied + [ $# -eq 0 ] && [ -f "$ENTRY_DIR_ABS/initrd" ] && echo "initrd $ENTRY_DIR/initrd" : } >"$LOADER_ENTRY" || { echo "Could not create loader entry '$LOADER_ENTRY'." >&2 From af319a4b14bd05cd4c8460487f2c6d7a31b35640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Mon, 20 Dec 2021 14:57:39 +0100 Subject: [PATCH 6/6] kernel-install: don't pull out KERNEL_IMAGE It's part of the pack directly passed to scripts on add and ignored on remove --- src/kernel-install/kernel-install | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/kernel-install/kernel-install b/src/kernel-install/kernel-install index 2e8f382d5fe..097d6557f29 100755 --- a/src/kernel-install/kernel-install +++ b/src/kernel-install/kernel-install @@ -72,15 +72,14 @@ else [ $# -ge 1 ] && shift fi -KERNEL_VERSION="$1" -KERNEL_IMAGE="$2" -[ $# -ge 2 ] && shift 2 - -if [ -z "$COMMAND" ] || [ -z "$KERNEL_VERSION" ]; then +if [ $# -lt 1 ]; then echo "Not enough arguments" >&2 exit 1 fi +KERNEL_VERSION="$1" +shift + if [ -r "/etc/kernel/install.conf" ]; then . /etc/kernel/install.conf elif [ -r "/usr/lib/kernel/install.conf" ]; then @@ -147,13 +146,13 @@ IFS=" case "$COMMAND" in add) - if [ -z "$KERNEL_IMAGE" ]; then - echo "Command 'add' requires an argument" >&2 + if [ $# -lt 1 ]; then + echo "Command 'add' requires a kernel image" >&2 exit 1 fi - if ! [ -f "$KERNEL_IMAGE" ]; then - echo "Kernel image argument $KERNEL_IMAGE not a file" >&2 + if ! [ -f "$1" ]; then + echo "Kernel image argument $1 not a file" >&2 exit 1 fi @@ -170,8 +169,8 @@ case "$COMMAND" in fi for f in $PLUGINS; do - [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "+$f add $KERNEL_VERSION $ENTRY_DIR_ABS $KERNEL_IMAGE $*" - "$f" add "$KERNEL_VERSION" "$ENTRY_DIR_ABS" "$KERNEL_IMAGE" "$@" + [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "+$f add $KERNEL_VERSION $ENTRY_DIR_ABS $*" + "$f" add "$KERNEL_VERSION" "$ENTRY_DIR_ABS" "$@" err=$? [ $err -eq $skip_remaining ] && break ret=$(( ret + err ))