kernel-install: add --verbose

This makes it easier to see what is going on. Documentation for
--verbose and --help is added to the man page. Our plugins are updated
to also log a bit.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2019-03-07 20:49:30 +01:00
parent 7061e4ca00
commit 7054308a8d
4 changed files with 48 additions and 2 deletions

View File

@ -6,7 +6,8 @@
SPDX-License-Identifier: LGPL-2.1+
-->
<refentry id="kernel-install">
<refentry id="kernel-install"
xmlns:xi="http://www.w3.org/2001/XInclude">
<refentryinfo>
<title>kernel-install</title>
@ -27,6 +28,7 @@
<cmdsynopsis>
<command>kernel-install</command>
<arg choice="plain">COMMAND</arg>
<arg choice="opt" rep="repeat">OPTIONS</arg>
<arg choice="plain"><replaceable>KERNEL-VERSION</replaceable></arg>
<arg choice="plain"><replaceable>KERNEL-IMAGE</replaceable></arg>
<arg choice="opt" rep="repeat"><replaceable>INITRD-FILE</replaceable></arg>
@ -127,6 +129,29 @@
</refsect1>
<refsect1>
<title>Options</title>
<para>The following options are understood:</para>
<variablelist>
<varlistentry>
<term><option>-v</option></term>
<term><option>--verbose</option></term>
<listitem>
<para>Output additional information about operations being performed.</para>
</listitem>
</varlistentry>
<xi:include href="standard-options.xml" xpointer="help" />
</variablelist>
</refsect1>
<refsect1>
<title>Environment variables</title>
<para>If <option>--verbose</option> is used, <varname>$KERNEL_INSTALL_VERBOSE=1</varname> will be set for
the plugins. They may output additional logs in this case.</para>
</refsect1>
<refsect1>
<title>Exit status</title>
<para>If every executable returns 0 or 77, 0 is returned, and a non-zero failure code otherwise.</para>

View File

@ -13,9 +13,13 @@ INITRD_OPTIONS_START="5"
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}"
;;
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}}
;;
*)

View File

@ -88,6 +88,8 @@ INITRD_OPTIONS=( "${@:${INITRD_OPTIONS_START}}" )
for initrd in "${INITRD_OPTIONS[@]}"; do
if [[ -f "${initrd}" ]]; then
initrd_basename="$(basename ${initrd})"
[ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \
echo "Installing $BOOT_DIR_ABS/${initrd_basename}"
cp "${initrd}" "$BOOT_DIR_ABS/${initrd_basename}" &&
chown root:root "$BOOT_DIR_ABS/${initrd_basename}" &&
chmod 0644 "$BOOT_DIR_ABS/${initrd_basename}" || {
@ -106,6 +108,8 @@ mkdir -p "${LOADER_ENTRY%/*}" || {
exit 1
}
[ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \
echo "Creating $LOADER_ENTRY"
{
echo "title $PRETTY_NAME"
echo "version $KERNEL_VERSION"

View File

@ -5,7 +5,6 @@
#
# This file is part of systemd.
#
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
@ -63,6 +62,13 @@ for i in "$@"; do
fi
done
KERNEL_INSTALL_VERBOSE=0
if [ "$1" == "--verbose" -o "$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
@ -126,6 +132,8 @@ case $COMMAND in
for f in "${PLUGINS[@]}"; do
if [[ -x $f ]]; then
[ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \
echo "+$f add $KERNEL_VERSION $BOOT_DIR_ABS $KERNEL_IMAGE ${INITRD_OPTIONS[@]}"
"$f" add "$KERNEL_VERSION" "$BOOT_DIR_ABS" "$KERNEL_IMAGE" "${INITRD_OPTIONS[@]}"
x=$?
if [[ $x == $SKIP_REMAINING ]]; then
@ -148,6 +156,8 @@ case $COMMAND in
remove)
for f in "${PLUGINS[@]}"; do
if [[ -x $f ]]; then
[ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \
echo "+$f remove $KERNEL_VERSION $BOOT_DIR_ABS"
"$f" remove "$KERNEL_VERSION" "$BOOT_DIR_ABS"
x=$?
if [[ $x == $SKIP_REMAINING ]]; then
@ -158,6 +168,9 @@ case $COMMAND in
fi
done
[ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \
echo "Removing $BOOT_DIR_ABS"
rm -rf "$BOOT_DIR_ABS"
((ret+=$?))
;;