| 1 |
#!/bin/sh |
| 2 |
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- |
| 3 |
# ex: ts=8 sw=4 sts=4 et filetype=sh |
| 4 |
# SPDX-License-Identifier: LGPL-2.1-or-later |
| 5 |
# |
| 6 |
# This file is part of systemd. |
| 7 |
# |
| 8 |
# systemd is free software; you can redistribute it and/or modify it |
| 9 |
# under the terms of the GNU Lesser General Public License as published by |
| 10 |
# the Free Software Foundation; either version 2.1 of the License, or |
| 11 |
# (at your option) any later version. |
| 12 |
# |
| 13 |
# systemd is distributed in the hope that it will be useful, but |
| 14 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 |
# General Public License for more details. |
| 17 |
# |
| 18 |
# You should have received a copy of the GNU Lesser General Public License |
| 19 |
# along with systemd; If not, see <https://www.gnu.org/licenses/>. |
| 20 |
|
| 21 |
set -e |
| 22 |
|
| 23 |
COMMAND="${1:?}" |
| 24 |
KERNEL_VERSION="${2:?}" |
| 25 |
|
| 26 |
[ -w "/lib/modules" ] || exit 0 |
| 27 |
|
| 28 |
case "$COMMAND" in |
| 29 |
add) |
| 30 |
[ -d "/lib/modules/$KERNEL_VERSION/kernel" ] || exit 0 |
| 31 |
command -v depmod >/dev/null || exit 0 |
| 32 |
[ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "+depmod -a $KERNEL_VERSION" |
| 33 |
exec depmod -a "$KERNEL_VERSION" |
| 34 |
;; |
| 35 |
remove) |
| 36 |
if [ -n "$KERNEL_INSTALL_BOOT_ENTRY_TYPE" ] && [ -d "/lib/modules/$KERNEL_VERSION/kernel" ]; then |
| 37 |
[ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \ |
| 38 |
echo "Multiple entry types may exist, not removing modules.dep or associated files." |
| 39 |
exit 0 |
| 40 |
fi |
| 41 |
|
| 42 |
[ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \ |
| 43 |
echo "Removing /lib/modules/${KERNEL_VERSION}/modules.dep and associated files" |
| 44 |
exec rm -f \ |
| 45 |
"/lib/modules/$KERNEL_VERSION/modules.alias" \ |
| 46 |
"/lib/modules/$KERNEL_VERSION/modules.alias.bin" \ |
| 47 |
"/lib/modules/$KERNEL_VERSION/modules.builtin.bin" \ |
| 48 |
"/lib/modules/$KERNEL_VERSION/modules.builtin.alias.bin" \ |
| 49 |
"/lib/modules/$KERNEL_VERSION/modules.dep" \ |
| 50 |
"/lib/modules/$KERNEL_VERSION/modules.dep.bin" \ |
| 51 |
"/lib/modules/$KERNEL_VERSION/modules.devname" \ |
| 52 |
"/lib/modules/$KERNEL_VERSION/modules.softdep" \ |
| 53 |
"/lib/modules/$KERNEL_VERSION/modules.weakdep" \ |
| 54 |
"/lib/modules/$KERNEL_VERSION/modules.symbols" \ |
| 55 |
"/lib/modules/$KERNEL_VERSION/modules.symbols.bin" |
| 56 |
;; |
| 57 |
*) |
| 58 |
exit 0 |
| 59 |
;; |
| 60 |
esac |