| 1 | #!/bin/sh -e |
| 2 | |
| 3 | PREREQS="" |
| 4 | |
| 5 | prereqs() { echo "$PREREQS"; } |
| 6 | |
| 7 | case "$1" in |
| 8 | prereqs) |
| 9 | prereqs |
| 10 | exit 0 |
| 11 | ;; |
| 12 | esac |
| 13 | |
| 14 | . /usr/share/initramfs-tools/hook-functions |
| 15 | |
| 16 | mkdir -p "$DESTDIR/usr/lib/systemd" |
| 17 | copy_exec /usr/lib/systemd/systemd-udevd /usr/lib/systemd |
| 18 | copy_exec /usr/bin/udevadm /usr/bin |
| 19 | # libkmod is loaded via dlopen() since v256 so pull it in manually |
| 20 | for library in /usr/lib/*/libkmod.so.*; do |
| 21 | if [ -f "${library}" ]; then |
| 22 | copy_exec "${library}" |
| 23 | fi |
| 24 | done |
| 25 | |
| 26 | if [ -e /etc/udev/udev.conf ]; then |
| 27 | mkdir -p "$DESTDIR/etc/udev" |
| 28 | cp -p /etc/udev/udev.conf "$DESTDIR/etc/udev/" |
| 29 | fi |
| 30 | |
| 31 | # copy hwdb.bin |
| 32 | if [ -e /usr/lib/udev/hwdb.bin ]; then |
| 33 | mkdir -p "$DESTDIR/usr/lib/udev" |
| 34 | cp -p /usr/lib/udev/hwdb.bin "$DESTDIR/usr/lib/udev/hwdb.bin" |
| 35 | fi |
| 36 | |
| 37 | # copy .link files containing interface naming definitions |
| 38 | mkdir -p "$DESTDIR/usr/lib/systemd/network/" |
| 39 | find -L /usr/lib/systemd/network -name '*.link*' -execdir cp -r -pt "$DESTDIR/usr/lib/systemd/network/" '{}' + |
| 40 | if [ -d /usr/local/lib/systemd/network ]; then |
| 41 | find -L /usr/local/lib/systemd/network -name '*.link*' -execdir cp -r -pt "$DESTDIR/usr/lib/systemd/network/" '{}' + |
| 42 | fi |
| 43 | if [ -d /etc/systemd/network ]; then |
| 44 | find -L /etc/systemd/network -name '*.link*' -execdir cp -r -pt "$DESTDIR/usr/lib/systemd/network/" '{}' + |
| 45 | fi |
| 46 | |
| 47 | mkdir -p "$DESTDIR/usr/lib/udev/rules.d/" |
| 48 | for rules in 50-firmware.rules 50-udev-default.rules \ |
| 49 | 60-block.rules 60-persistent-storage.rules \ |
| 50 | 61-persistent-storage-android.rules 71-seat.rules \ |
| 51 | 73-special-net-names.rules 75-net-description.rules \ |
| 52 | 80-net-setup-link.rules 80-drivers.rules; do |
| 53 | if [ -e /etc/udev/rules.d/$rules ]; then |
| 54 | cp -p /etc/udev/rules.d/$rules "$DESTDIR/usr/lib/udev/rules.d/" |
| 55 | elif [ -e /usr/lib/udev/rules.d/$rules ]; then |
| 56 | cp -p /usr/lib/udev/rules.d/$rules "$DESTDIR/usr/lib/udev/rules.d/" |
| 57 | fi |
| 58 | done |
| 59 | |
| 60 | # See if chzdev can filter out generated rules, per LP: #2044104 |
| 61 | ZDEV_FILTERING=0 |
| 62 | if [ -e /usr/sbin/chzdev ] && \ |
| 63 | dpkg --compare-versions "$(dpkg-query -f '${Version}' -W s390-tools 2> /dev/null)" '>=' '2.33.0'; |
| 64 | then |
| 65 | ZDEV_FILTERING=1 |
| 66 | fi |
| 67 | |
| 68 | # now copy all custom udev rules which don't have an equivalent in /usr/lib (e. g. |
| 69 | # 70-persistent-net.rules or similar); They might contain network names or |
| 70 | # other bits which are relevant for the initramfs. |
| 71 | for rules in /etc/udev/rules.d/*.rules; do |
| 72 | if [ ! -e "$rules" ]; then |
| 73 | continue |
| 74 | fi |
| 75 | |
| 76 | # Skip rules generated by chzdev as they are handled by its own hook. |
| 77 | # See LP: #2044104 |
| 78 | if [ $ZDEV_FILTERING -eq 1 ] && /usr/sbin/chzdev --is-owner "$rules"; then |
| 79 | # only skip/continue if rule is not configured as zdev_early (=0), |
| 80 | # but copy if zdev_early=1 or if zdev_early is not specified at all |
| 81 | if [ $(grep "ENV{zdev_early}=\"0\"" "$rules") ]; then |
| 82 | continue; |
| 83 | fi |
| 84 | fi |
| 85 | |
| 86 | if [ ! -e "/usr/lib/${rules#/etc/}" ]; then |
| 87 | cp -p "$rules" "$DESTDIR/usr/lib/udev/rules.d/" |
| 88 | fi |
| 89 | done |
| 90 | |
| 91 | for program in ata_id scsi_id; do |
| 92 | copy_exec /usr/lib/udev/$program /usr/lib/udev |
| 93 | done |
| 94 | copy_exec /sbin/blkid /sbin |