for kdir in /lib/modules/*; do
[ -d $kdir ] || continue
kver=${kdir##*/}
- echo " $0 -f --initrdfs=rom $dir/initrd-$kver.gz $kver $verbose"
- done
+ echo " $0 -f --initrdfs=initramfs $dir/initrd-$kver.gz $kver $verbose"
+ done | sort -V
}
msg() {
return 0
fi
done
- debug "find_tool: did not found any of: $@"
+ debug "find_tool: did not find any of: $@"
return 1
}
inst "$@" $dest
- local lib libs=$(ldd "$@" | awk '/statically|linux-(gate|vdso)\.so/{next} NF == 2 {print $1} /=/{print $3}' | sort -u)
- for lib in $libs; do
- if [ ! -f "$DESTDIR/$_lib/${lib##*/}" ]; then
- inst_d /$_lib
- inst_exec $lib /$_lib
- fi
+ local obj lib libs
+ for obj in "$@"; do
+ case "$obj" in
+ /lib/ld-linux.so.2 | /lib64/ld-linux-x86-64.so.2)
+ continue
+ esac
+
+ libs=$(ldd "$obj" | awk '/statically|linux-(gate|vdso)\.so/{next} NF == 2 {print $1} /=/{print $3}' | sort -u)
+ for lib in $libs; do
+ if [ ! -f "$DESTDIR/$_lib/${lib##*/}" ]; then
+ inst_d /$_lib
+ inst_exec $lib /$_lib
+ fi
+ done
done
# hack for uclibc linked binaries requiring this fixed path
echo "$modprobe_conf_cache"
}
+# return options for MODULE
+# @param $1 module name
+modprobe_options() {
+ local module=$1
+ local options=$(modprobe_conf | awk -vmodule="$module" '{ if ($1 == "options" && $2 == module) { for(i=3;i<=NF;i++) printf("%s ",$i); }}')
+ echo ${options# }
+}
+
#
# defaults to modprobe -c if not told otherwise, this means include statements
# work from there.
if [ -n "$modulefile" ]; then
debug "Using $modulefile for modules config"
- modprobe_conf_cache=$(cat $modulefile)
+ modprobe_conf_cache=$(cat $modulefile | awk '!/^[\t ]*#/ { print }')
+
else
debug "Using modprobe -c to get modules config"
- modprobe_conf_cache=$(modprobe -c --set-version $kernel)
+ modprobe_conf_cache=$(modprobe -c --set-version $kernel | awk '!/^[\t ]*#/ { print }')
fi
}
fi
if [[ "$devpath" == /dev/cciss/* ]]; then
- find_module "cciss"
rootdev_add=/dev/cciss/
+
+ # load hpsa for future kernels, cciss for backwards compat
+ if [ "$kernel_version_long" -ge "003000000" ]; then
+ find_module "hpsa" "-cciss"
+ find_modules_scsi "$devpath"
+ else
+ find_module "cciss"
+ fi
+
return
fi
if [[ "$devpath" == /dev/ataraid/* ]]; then
find_modules_ide
find_module "ataraid"
- ataraidmodules=$(modprobe_conf | awk '/ataraid_hostadapter/ && ! /^[\t ]*#/ { print $3; }')
+ ataraidmodules=$(modprobe_conf | awk '/ataraid_hostadapter/ { print $3 }')
if [ -n "$ataraidmodules" ]; then
# FIXME: think about modules compiled in kernel
die "ataraid_hostadapter alias not defined in modprobe.conf! Please set it and run $PROGRAM again."
exit 0
EOF
chmod 755 "$DESTDIR/lib/firmware/firmware.sh"
+
+ # setup firmware loader agent
+ echo "echo -n "/lib/firmware/firmware.sh" > /proc/sys/kernel/hotplug" | add_linuxrc
fi
for firmware in $firmware_files; do
done
mount_sys
- echo "echo -n "/lib/firmware/firmware.sh" > /proc/sys/kernel/hotplug" | add_linuxrc
}
modules_install() {
# name of the module
local module=${modpath##*/}; module=${module%$modext}
- local options=$(modprobe_conf | awk -vmodule="$module" '{ if ($1 == "options" && $2 == module) { for(i=3;i<=NF;i++) printf("%s ",$i); }}' | xargs)
+ local options=$(modprobe_options "$module")
local genericname=$(echo $module | tr - _)
local usleep=$(eval echo \$MODULE_${genericname}_USLEEP)
local firmware=$(eval echo \$MODULE_${genericname}_FIRMWARE)
# parse 'root=xxx' kernel commandline
# We support passing root as hda3 /dev/hda3 0303 0x0303 and 303
add_linuxrc <<-'EOF'
- device=/dev/no_partition_found
+ device=
eval "$(busybox awk -v c="$ROOT" '
BEGIN {
num_pattern_short = "[0-9a-f][0-9a-f][0-9a-f]";
num_pattern = "[0-9a-f]" num_pattern_short;
dev_pattern = "[hms][a-z][a-z]([0-9])+";
- partition = "no_partition_found";
+ partition = "";
min = -1; maj = -1;
sub("^0x", "", c);
if (c ~ "^" num_pattern_short "$") sub("^", "0", c);
if (c ~ "^" num_pattern "$") {
- maj = sprintf("%s",substr(c,1,2));
- min = sprintf("%s",substr(c,3));
+ maj = sprintf("%d",substr(c,1,2));
+ min = sprintf("%d",substr(c,3));
}
if (c ~ "^\/dev\/" dev_pattern "$") sub("^/dev/","", c);
if (c ~ "^" dev_pattern "$") partition = c;
}
- $4 ~ partition { maj = $1; min = $2; }
- $1 ~ maj && $2 ~ min { partition = $4; }
+ partition && $4 == partition { maj = $1; min = $2; }
+ $1 == maj && $2 == min { partition = $4; }
END {
if (maj >= 0 && min >= 0) {
- printf("device=/dev/%s; maj=%s; min=%s;\n", partition, maj, min);
+ printf("maj=%s; min=%s;\n", maj, min);
+ }
+ if (partition) {
+ printf("device=/dev/%s;\n", partition);
}
}
' /proc/partitions)"
- if [ "$device" != '/dev/no_partition_found' -a ! -b $device ]; then
- mknod $device b $maj $min
- fi
- EOF
- add_linuxrc <<-EOF
- rootdev=$rootdev
- rootfs=$rootFs
- EOF
+ if [ -z "$device" ]; then
+ device=$ROOT
+ fi
- add_linuxrc <<-'EOF'
- if [ "$device" = '/dev/no_partition_found' ]; then
- device=$rootdev
+ if [ "$device" -a ! -b $device ]; then
+ mknod $device b $maj $min
fi
[ -n "$ROOTFSFLAGS" ] && ROOTFSFLAGS="-o $ROOTFSFLAGS"
- mount -t $rootfs -r $device $ROOTFSFLAGS /newroot || echo "Mount of rootfs failed."
- init="$(echo "$CMDLINE" | busybox awk '/init=\// { gsub(/.*init=/,NIL,$0); gsub(/ .*/,NIL,$0); print }')"
+ mount -t $ROOTFS -r $device $ROOTFSFLAGS /newroot || echo "Mount of rootfs failed."
+ init=$INIT
if [ -z "$init" -o ! -x "/newroot$init" ]; then
init=/sbin/init
fi
umount_all
busybox_applet switch_root
add_linuxrc <<-'EOF'
+ [ ! -e /newroot/dev/console ] && mknod -m 660 /newroot/dev/console c 5 1
exec switch_root /newroot $init ${1:+"$@"}
echo "Error! initramfs should not reach this place."
EOF
mount_proc
+add_linuxrc <<-EOF
+ # builtin defaults from geninitrd
+ ROOT=$rootdev
+ ROOTFS=$rootFs
+EOF
add_linuxrc <<-'EOF'
- read CMDLINE < /proc/cmdline; export CMDLINE
+ read CMDLINE < /proc/cmdline
for arg in $CMDLINE; do
if [ "${arg}" = "debuginitrd" ]; then
if [ "${arg##rootfsflags=}" != "${arg}" ]; then
ROOTFSFLAGS=${arg##rootfsflags=}
fi
+ if [ "${arg##init=}" != "${arg}" ]; then
+ INIT=${arg##init=}
+ fi
done
# make debugshell() invoke subshell if $DEBUGINITRD=sh
EOF
if is_yes "$RUN_SULOGIN_ON_ERR"; then
add_linuxrc <<-'EOF'
- echo "debug shell disabled by /etc/sysconfig/system:RUN_SULOGIN_ON_ERR setting"
+ echo "debug shell disabled by /etc/sysconfig/system: RUN_SULOGIN_ON_ERR setting"
EOF
else
add_linuxrc <<-'EOF'
initrd_gen_stop_udevd
initrd_gen_stop_uvesafb
+# clean up env
+add_linuxrc <<-'EOF'
+ ifs=$IFS
+ IFS="
+ "
+ for i in $(export -p); do
+ i=${i#declare -x } # ksh/bash
+ i=${i#export } # busybox
+
+ case "$i" in
+ *=*)
+ : ;;
+ *)
+ continue ;;
+ esac
+
+ i=${i%%=*}
+
+ [ -z "$i" ] && continue
+
+ case "$i" in
+ ROOT|PATH|HOME|TERM)
+ :
+ ;;
+ *)
+ unset $i
+ ;;
+ esac
+ done
+ IFS=$ifs
+EOF
+
if [ "$INITRDFS" = "initramfs" ]; then
initrd_gen_initramfs_switchroot
else
CONFIG_BLK_DEV_RAM_SIZE=$(ikconfig | awk -F= '/^CONFIG_BLK_DEV_RAM_SIZE/{print $2}')
if [ -z "$CONFIG_BLK_DEV_RAM_SIZE" ]; then
CONFIG_BLK_DEV_RAM_SIZE=4096
+ warn "No CONFIG_BLK_DEV_RAM_SIZE detected, fallback to $CONFIG_BLK_DEV_RAM_SIZE"
fi
if [ "$IMAGESIZE" -gt $CONFIG_BLK_DEV_RAM_SIZE ]; then