diff options
Diffstat (limited to 'source/a/mkinitrd/mkinitrd')
-rw-r--r-- | source/a/mkinitrd/mkinitrd | 143 |
1 files changed, 79 insertions, 64 deletions
diff --git a/source/a/mkinitrd/mkinitrd b/source/a/mkinitrd/mkinitrd index 7c2f7629f..6f4ff3c19 100644 --- a/source/a/mkinitrd/mkinitrd +++ b/source/a/mkinitrd/mkinitrd @@ -51,6 +51,8 @@ # Modified by Patrick Volkerding <volkerdi@slackware.com> 12 July 2017 # Add support for including Slackware and kernel versions in the # output filename. Thanks to SeB. +# Modified by Patrick Volkerding <volkerdi@slackware.com> 04 Feb 2019 +# Allow specifying more than one kernel version. MKINITRD_VERSION=1.4.11 @@ -148,8 +150,10 @@ EOF create_new_source_tree() { mkdir -p $SOURCE_TREE - # Make sure a kernel module directory exists: - mkdir -p $SOURCE_TREE/lib/modules/${KERNEL_VERSION} + # Make sure the kernel module directories exist: + for kver in $(echo ${KERNEL_VERSION} | tr ':' '\n') ; do + mkdir -p $SOURCE_TREE/lib/modules/${kver} + done # Add the initrd-tree skeleton: ( cd $SOURCE_TREE ; tar xzf /usr/share/mkinitrd/initrd-tree.tar.gz ) # Make sure we have any block devices that might be needed: @@ -445,10 +449,12 @@ if echo "$OUTPUT_IMAGE" | grep -qE "%KVER%|%SLACKVER%" ; then fi # If kernel modules are needed but the kernel version is absent, exit now: -if [ ! -d /lib/modules/$KERNEL_VERSION ]; then - echo "ERROR: No /lib/modules/$KERNEL_VERSION kernel modules tree found for kernel \"$KERNEL_VERSION\"" - exit 1 -fi +for kver in $(echo ${KERNEL_VERSION} | tr ':' '\n') ; do + if [ ! -d /lib/modules/$kver ]; then + echo "ERROR: No /lib/modules/$kver kernel modules tree found for kernel \"$kver\"" + exit 1 + fi +done # If clearing source tree was requested, do that first if [ "$CLEAR_TREE" = "1" ]; then @@ -644,10 +650,12 @@ if [ ! -z "$CRYPT" -o ! -z "$LVM" ]; then $SOURCE_TREE/lib/udev/rules.d/95-dm-initrd.rules fi -# Make module directory: -if [ ! -d $SOURCE_TREE/lib/modules/$KERNEL_VERSION ]; then - mkdir -p $SOURCE_TREE/lib/modules/$KERNEL_VERSION -fi +# Make module directories: +for kver in $(echo ${KERNEL_VERSION} | tr ':' '\n') ; do + if [ ! -d $SOURCE_TREE/lib/modules/$kver ]; then + mkdir -p $SOURCE_TREE/lib/modules/$kver + fi +done # Copy kmod/modprobe stuff to initrd: for i in kmod depmod insmod lsmod modinfo modprobe rmmod ; do @@ -656,8 +664,10 @@ for i in kmod depmod insmod lsmod modinfo modprobe rmmod ; do done # Make sure modules.builtin and modules.order are there (for kmod): -cp /lib/modules/$KERNEL_VERSION/modules.{builtin,order} \ - $SOURCE_TREE/lib/modules/$KERNEL_VERSION +for kver in $(echo ${KERNEL_VERSION} | tr ':' '\n') ; do + cp /lib/modules/$kver/modules.{builtin,order} \ + $SOURCE_TREE/lib/modules/$kver +done # If an executable $SOURCE_TREE/load_kernel_modules already exists, then # we assume you will want to load the kernel modules mentioned in there. @@ -699,67 +709,72 @@ if [ ! -z "$MODULE_LIST" ]; then INDEX=$(expr $INDEX - 1) # Don't include the null value fi - # Wrap everything in a while loop - i=0 - while [ $i -ne $INDEX ]; do - i=$(( $i + 1 )) - - # FULL_MOD is the module plus any arguments (if any) - # MODULE is the module name - # ARGS is any optional arguments to be passed to the kernel - FULL_MOD="$(echo "$MODULE_LIST" | cut -d ':' -f $i)" - MODULE="$(echo "$FULL_MOD" | cut -d ' ' -f 1 )" - # Test for arguments - if echo "$FULL_MOD" | grep ' ' > /dev/null; then - ARGS=" $(echo "$FULL_MOD" | cut -d ' ' -f 2- )" - else - unset ARGS - fi + # Repeat these tasks for all kernel versions support has been requested for: + for kver in $(echo ${KERNEL_VERSION} | tr ':' '\n') ; do + + # Wrap everything in a while loop + i=0 + while [ $i -ne $INDEX ]; do + i=$(( $i + 1 )) + + # FULL_MOD is the module plus any arguments (if any) + # MODULE is the module name + # ARGS is any optional arguments to be passed to the kernel + FULL_MOD="$(echo "$MODULE_LIST" | cut -d ':' -f $i)" + MODULE="$(echo "$FULL_MOD" | cut -d ' ' -f 1 )" + # Test for arguments + if echo "$FULL_MOD" | grep ' ' > /dev/null; then + ARGS=" $(echo "$FULL_MOD" | cut -d ' ' -f 2- )" + else + unset ARGS + fi - # Get MODULE deps and prepare modprobe lines - /sbin/modprobe --set-version $KERNEL_VERSION --show-depends --ignore-install $MODULE 2>/dev/null \ - | grep "^insmod " | cut -f 2 -d ' ' | while read SRCMOD; do + # Get MODULE deps and prepare modprobe lines + /sbin/modprobe --set-version $kver --show-depends --ignore-install $MODULE 2>/dev/null \ + | grep "^insmod " | cut -f 2 -d ' ' | while read SRCMOD; do - if ! grep -Eq " $(basename $SRCMOD .ko)(\.| |$)" $SOURCE_TREE/load_kernel_modules 2>/dev/null ; then - LINE="$(echo "modprobe -v $(basename ${SRCMOD%%.gz} .ko)" )" + if ! grep -Eq " $(basename $SRCMOD .ko)(\.| |$)" $SOURCE_TREE/load_kernel_modules 2>/dev/null ; then + LINE="$(echo "modprobe -v $(basename ${SRCMOD%%.gz} .ko)" )" - # Test to see if arguments should be passed - # Over-ride the previously defined LINE variable if so - if [ "$(basename $SRCMOD .ko)" = "$MODULE" ]; then - # SRCMOD and MODULE are same, ARGS can be passed - LINE="$LINE$ARGS" - fi + # Test to see if arguments should be passed + # Over-ride the previously defined LINE variable if so + if [ "$(basename $SRCMOD .ko)" = "$MODULE" ]; then + # SRCMOD and MODULE are same, ARGS can be passed + LINE="$LINE$ARGS" + fi - fi + fi - if ! grep -qx "$LINE" $SOURCE_TREE/load_kernel_modules ; then - echo "$LINE" >> $SOURCE_TREE/load_kernel_modules - fi + if ! grep -qx "$LINE" $SOURCE_TREE/load_kernel_modules ; then + echo "$LINE" >> $SOURCE_TREE/load_kernel_modules + fi - # Try to add the module to the initrd-tree. This should be done - # even if it exists there already as we may have changed compilers - # or otherwise caused the modules in the initrd-tree to need - # replacement. - if cp -a --parents $SRCMOD $SOURCE_TREE 2>/dev/null; then - echo "OK: $SRCMOD added." - # If a module needs firmware, copy that too - /sbin/modinfo -F firmware "$SRCMOD" | sed 's/^/\/lib\/firmware\//' | - while read SRCFW; do - if cp -a --parents "$SRCFW" $SOURCE_TREE 2>/dev/null; then - echo "OK: $SRCFW added." - else - echo "WARNING: Could not find firmware \"$SRCFW\"" - fi - done - else - echo "WARNING: Could not find module \"$SRCMOD\"" - fi + # Try to add the module to the initrd-tree. This should be done + # even if it exists there already as we may have changed compilers + # or otherwise caused the modules in the initrd-tree to need + # replacement. + if cp -a --parents $SRCMOD $SOURCE_TREE 2>/dev/null; then + echo "OK: $SRCMOD added." + # If a module needs firmware, copy that too + /sbin/modinfo -F firmware "$SRCMOD" | sed 's/^/\/lib\/firmware\//' | + while read SRCFW; do + if cp -a --parents "$SRCFW" $SOURCE_TREE 2>/dev/null; then + echo "OK: $SRCFW added." + else + echo "WARNING: Could not find firmware \"$SRCFW\"" + fi + done + else + echo "WARNING: Could not find module \"$SRCMOD\"" + fi + done done - done - # Pregenerate the module dependency information - /sbin/depmod -a -b $SOURCE_TREE ${KERNEL_VERSION} + # Pregenerate the module dependency information + /sbin/depmod -a -b $SOURCE_TREE $kver + + done # repeat for all kernel versions # Copy /{etc,lib}/modprobe.d/* if desired if [ ! -z $MODCONF ]; then |