]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
fix(net-lib): add a new dracut module called net-lib
authorLaszlo Gombos <laszlo.gombos@gmail.com>
Tue, 28 Feb 2023 19:59:13 +0000 (19:59 +0000)
committerNeal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>
Sun, 31 Mar 2024 18:32:28 +0000 (14:32 -0400)
13 files changed:
.github/labeler.yml
modules.d/35connman/module-setup.sh
modules.d/35network-legacy/module-setup.sh
modules.d/35network-manager/module-setup.sh
modules.d/40network/module-setup.sh
modules.d/40network/netroot.sh [deleted file]
modules.d/45net-lib/dhcp-root.sh [moved from modules.d/40network/dhcp-root.sh with 100% similarity]
modules.d/45net-lib/ifname-genrules.sh [moved from modules.d/40network/ifname-genrules.sh with 100% similarity]
modules.d/45net-lib/module-setup.sh [new file with mode: 0755]
modules.d/45net-lib/net-lib.sh [moved from modules.d/40network/net-lib.sh with 100% similarity]
modules.d/45net-lib/netroot.sh [moved from modules.d/35connman/netroot.sh with 100% similarity]
modules.d/95nfs/nfs-lib.sh
test/TEST-20-NFS/test.sh

index 5667c635714a1a911e535827c3a2b623fb636a69..b8146a099bafc5ee6791a901ed5c9c0a5943da89 100644 (file)
@@ -538,6 +538,10 @@ uefi-lib:
   - changed-files:
     - any-glob-to-any-file: 'modules.d/99uefi-lib/*'
 
+net-lib:
+  - changed-files:
+    - any-glob-to-any-file: 'modules.d/45net-lib/*'
+
 test:
   - changed-files:
     - any-glob-to-any-file: ['test/*', 'test/**/*', 'modules.d/80test*', 'modules.d/80test*/*']
index 6502d307ed5c6cc989fdd2e5e966a4551d7f3651..61b6fa31294526501c9393ecab58d5188a27f382 100755 (executable)
@@ -10,7 +10,7 @@ check() {
 
 # called by dracut
 depends() {
-    echo dbus systemd bash
+    echo dbus systemd bash net-lib
     return 0
 }
 
@@ -25,7 +25,6 @@ install() {
     # in an emergency shell.
     inst_multiple ip sed grep
 
-    inst_script "$moddir/netroot.sh" "/sbin/netroot"
     inst connmand
     inst connmanctl
     inst connmand-wait-online
index 868ea8fc29eed1b1f4bc90e47e04da7eecd97f97..4aef11924c8ca9b066bc5691b62ac5dc78981940 100755 (executable)
@@ -10,6 +10,7 @@ check() {
 
 # called by dracut
 depends() {
+    echo net-lib
     return 0
 }
 
index d9a244a3f07689db10bdd594b9dfce97a411207b..befa04e2731009908ea16dc05b378ff514b6746a 100755 (executable)
@@ -10,7 +10,7 @@ check() {
 
 # called by dracut
 depends() {
-    echo dbus bash
+    echo dbus bash net-lib
     return 0
 }
 
index 4c77ff3292eec890ed03d667393bb9f0c5bcc004..970c252baf2c487e4ed075794159d50f391f7059 100755 (executable)
@@ -27,22 +27,6 @@ depends() {
             network_handler="network-legacy"
         fi
     fi
-    echo "kernel-network-modules $network_handler"
+    echo "net-lib kernel-network-modules $network_handler"
     return 0
 }
-
-# called by dracut
-installkernel() {
-    return 0
-}
-
-# called by dracut
-install() {
-    inst_script "$moddir/netroot.sh" "/sbin/netroot"
-    inst_simple "$moddir/net-lib.sh" "/lib/net-lib.sh"
-    inst_hook pre-udev 50 "$moddir/ifname-genrules.sh"
-    inst_hook cmdline 91 "$moddir/dhcp-root.sh"
-    inst_multiple ip sed awk grep pgrep tr
-    inst_multiple -o arping arping2
-    dracut_need_initqueue
-}
diff --git a/modules.d/40network/netroot.sh b/modules.d/40network/netroot.sh
deleted file mode 100755 (executable)
index 8f97774..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-#!/bin/sh
-
-PATH=/usr/sbin:/usr/bin:/sbin:/bin
-command -v getarg > /dev/null || . /lib/dracut-lib.sh
-command -v setup_net > /dev/null || . /lib/net-lib.sh
-
-# Huh? Empty $1?
-[ -z "$1" ] && exit 1
-
-# [ ! -z $2 ] means this is for manually bringing up network
-# instead of real netroot; If It's called without $2, then there's
-# no sense in doing something if no (net)root info is available
-# or root is already there
-[ -d "$NEWROOT"/proc ] && exit 0
-
-if [ -z "$netroot" ]; then
-    netroot=$(getarg netroot=)
-fi
-
-[ -z "$netroot" ] && exit 1
-
-# Set or override primary interface
-netif=$1
-[ -e "/tmp/net.bootdev" ] && read -r netif < /tmp/net.bootdev
-
-case "$netif" in
-    ??:??:??:??:??:??) # MAC address
-        for i in /sys/class/net/*/address; do
-            read -r mac < "$i"
-            if [ "$mac" = "$netif" ]; then
-                i=${i%/address}
-                netif=${i##*/}
-                break
-            fi
-        done ;;
-esac
-
-# Figure out the handler for root=dhcp by recalling all netroot cmdline
-# handlers when this is not called from manually network bringing up.
-if [ -z "$2" ]; then
-    if getarg "root=dhcp" || getarg "netroot=dhcp" || getarg "root=dhcp6" || getarg "netroot=dhcp6"; then
-        # Load dhcp options
-        # shellcheck disable=SC1090
-        [ -e /tmp/dhclient."$netif".dhcpopts ] && . /tmp/dhclient."$netif".dhcpopts
-
-        # If we have a specific bootdev with no dhcpoptions or empty root-path,
-        # we die. Otherwise we just warn
-        if [ -z "$new_root_path" ]; then
-            [ -n "$BOOTDEV" ] && die "No dhcp root-path received for '$BOOTDEV'"
-            warn "No dhcp root-path received for '$netif' trying other interfaces if available"
-            exit 1
-        fi
-
-        rm -f -- "$hookdir"/initqueue/finished/dhcp.sh
-
-        # Set netroot to new_root_path, so cmdline parsers don't call
-        netroot=$new_root_path
-
-        # FIXME!
-        unset rootok
-        for f in "$hookdir"/cmdline/90*.sh; do
-            # shellcheck disable=SC1090
-            [ -f "$f" ] && . "$f"
-        done
-    else
-        rootok="1"
-    fi
-
-    # Check: do we really know how to handle (net)root?
-    if [ -z "$root" ]; then
-        root=$(getarg root=)
-    fi
-    [ -z "$root" ] && die "No or empty root= argument"
-    [ -z "$rootok" ] && die "Don't know how to handle 'root=$root'"
-
-    handler=${netroot%%:*}
-    handler=${handler%%4}
-    handler=$(command -v "${handler}"root)
-    if [ -z "$netroot" ] || [ ! -e "$handler" ]; then
-        die "No handler for netroot type '$netroot'"
-    fi
-fi
-
-# Source netroot hooks before we start the handler
-source_hook netroot "$netif"
-
-# Run the handler; don't store the root, it may change from device to device
-# XXX other variables to export?
-[ -n "$handler" ] && "$handler" "$netif" "$netroot" "$NEWROOT"
-save_netinfo "$netif"
-
-exit 0
diff --git a/modules.d/45net-lib/module-setup.sh b/modules.d/45net-lib/module-setup.sh
new file mode 100755 (executable)
index 0000000..8053aa6
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+check() {
+    return 255
+}
+
+depends() {
+    echo base
+    return 0
+}
+
+install() {
+    inst_script "$moddir/netroot.sh" "/sbin/netroot"
+    inst_simple "$moddir/net-lib.sh" "/lib/net-lib.sh"
+    inst_hook pre-udev 50 "$moddir/ifname-genrules.sh"
+    inst_hook cmdline 91 "$moddir/dhcp-root.sh"
+    inst_multiple ip sed awk grep pgrep tr
+    inst_multiple -o arping arping2
+    dracut_need_initqueue
+}
index f00067124e73382fd7ee6572d9f5d1f35ed188bb..7896da9c028b1c71536ba31a46000c886bff610a 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
-. /lib/net-lib.sh
+type get_ip > /dev/null 2>&1 || . /lib/net-lib.sh
 
 # TODO: make these things not pollute the calling namespace
 
index b7cca75b1b9bd7cd87403da2660bd238af555ffc..cfec348aedceb99ac857e85a9a5db3a2efcdaf09 100755 (executable)
@@ -318,7 +318,7 @@ test_setup() {
         inst_simple "${PKGLIBDIR}/modules.d/99base/dracut-lib.sh" "/lib/dracut-lib.sh"
         inst_simple "${PKGLIBDIR}/modules.d/99base/dracut-dev-lib.sh" "/lib/dracut-dev-lib.sh"
         inst_simple "${PKGLIBDIR}/modules.d/45url-lib/url-lib.sh" "/lib/url-lib.sh"
-        inst_simple "${PKGLIBDIR}/modules.d/40network/net-lib.sh" "/lib/net-lib.sh"
+        inst_simple "${PKGLIBDIR}/modules.d/45net-lib/net-lib.sh" "/lib/net-lib.sh"
         inst_simple "${PKGLIBDIR}/modules.d/95nfs/nfs-lib.sh" "/lib/nfs-lib.sh"
         inst_binary "${PKGLIBDIR}/dracut-util" "/usr/bin/dracut-util"
         ln -s dracut-util "${initdir}/usr/bin/dracut-getarg"