File: kmod.initramfs-hook

package info (click to toggle)
kmod 34.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,864 kB
  • sloc: ansic: 16,990; makefile: 498; sh: 382; xml: 61; perl: 12
file content (34 lines) | stat: -rw-r--r-- 1,050 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh -e
# Copy the compatibility symlinks until initramfs-tools will be converted
# to use the kmod program.

if [ "$1" = "prereqs" ]; then exit 0; fi

. /usr/share/initramfs-tools/hook-functions

copy_exec /usr/bin/kmod
cp -aZ /usr/sbin/modprobe /usr/sbin/rmmod "$DESTDIR/usr/sbin/"

mkdir -p "$DESTDIR/usr/lib/modprobe.d/"
if [ "$(echo /usr/lib/modprobe.d/*)" != "/usr/lib/modprobe.d/*" ]; then
  cp -aZ /usr/lib/modprobe.d/* "$DESTDIR/usr/lib/modprobe.d/"
fi

kconfig_yes() {
  [ -e "/boot/config-$version" ] || return 1
  egrep -q "^$1=y$" "/boot/config-$version" || return 1
  return 0
}

# If CONFIG_MODULE_DECOMPRESS=n and compressed modules have been copied to
# the initramfs then also copy the library that kmod will use with dlopen(3)
# to uncompress them.
if ! kconfig_yes CONFIG_MODULE_DECOMPRESS; then
  if [ "$(find $DESTDIR/lib/modules/ -name "*.xz")" ]; then
	  copy_exec /usr/lib/*-linux-gnu/liblzma.so.5
  fi
  if [ "$(find $DESTDIR/lib/modules/ -name "*.zst")" ]; then
	  copy_exec /usr/lib/*-linux-gnu/libzstd.so.1
  fi
fi