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 <http://www.gnu.org/licenses/>.
20
21COMMAND="$1"
22KERNEL_VERSION="$2"
23
24case "$COMMAND" in
25    add)
26        [ -d "/lib/modules/$KERNEL_VERSION/kernel" ] || exit 0
27        [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "+depmod -a $KERNEL_VERSION"
28        exec depmod -a "$KERNEL_VERSION"
29        ;;
30    remove)
31        [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \
32            echo "Removing /lib/modules/${KERNEL_VERSION}/modules.dep and associated files"
33        exec rm -f \
34            "/lib/modules/$KERNEL_VERSION/modules.alias" \
35            "/lib/modules/$KERNEL_VERSION/modules.alias.bin" \
36            "/lib/modules/$KERNEL_VERSION/modules.builtin.bin" \
37            "/lib/modules/$KERNEL_VERSION/modules.builtin.alias.bin" \
38            "/lib/modules/$KERNEL_VERSION/modules.dep" \
39            "/lib/modules/$KERNEL_VERSION/modules.dep.bin" \
40            "/lib/modules/$KERNEL_VERSION/modules.devname" \
41            "/lib/modules/$KERNEL_VERSION/modules.softdep" \
42            "/lib/modules/$KERNEL_VERSION/modules.symbols" \
43            "/lib/modules/$KERNEL_VERSION/modules.symbols.bin"
44        ;;
45    *)
46        exit 0
47esac
48