--- trunk/installer/hwdetection.sh 2008/09/24 10:14:59 768 +++ trunk/installer/hwdetection.sh 2008/09/24 10:15:46 769 @@ -1,5 +1,5 @@ #!/bin/bash -# $Header: /home/cvsd/magellan-cvs/magellan-src/installer/hwdetection.sh,v 1.8 2008-09-22 22:06:46 niro Exp $ +# $Header: /home/cvsd/magellan-cvs/magellan-src/installer/hwdetection.sh,v 1.9 2008-09-24 10:15:46 niro Exp $ ## hwdetection, needs >= sys-apps/hwinfo @@ -139,19 +139,45 @@ # default config path is /etc/conf.d/mkinitrd create_initrd() { - local initrd="$1" - local kernel="$2" - local config="$3" + local initrd + local kernel + local config + local chroot + #local root local modules + # very basic getops + for i in $* + do + case $1 in + #--root|-r) shift; root="$1" ;; + --initrd|-i) shift; initrd="$1" ;; + --config|-c) shift; config="$1" ;; + --kernelversion|-v) shift; kernel="$1" ;; + esac + shift + done + [[ -z ${initrd} ]] && initrd="/boot/initrd-$(uname -r).img" [[ -z ${kernel} ]] && kernel="$(uname -r)" [[ -z ${config} ]] && config="/etc/conf.d/mkinitrd" + if [[ ! -z ${INSTALL_ROOT} ]] + then + config="${INSTALL_ROOT}/${config}" + chroot="chrooted" + fi + # get various modules needed to boot - modules="${modules} $(get_driver_modules disk)" - modules="${modules} $(get_driver_modules scsi)" - modules="${modules} $(get_driver_modules cdrom)" + modules="$(get_driver_modules disk)" + modules+=" $(get_driver_modules scsi)" + modules+=" $(get_driver_modules cdrom)" + + # check for special ide_disk drivers (ata support) + if [[ ! -z $(echo ${modules} | grep ide_disk) ]] + then + modules+=" $(grep ide_disk /proc/modules | cut -d' ' -f4 | sed '/-/d;s:,:\ :g')" + fi # remove all duplicate modules modules="$(remove_duplicates ${modules})" @@ -161,7 +187,22 @@ echo "MODULES=\"${modules}\"" >> ${config} echo "IMAGE_TYPE=\"initramfs\"" >> ${config} - mkinitrd -f ${initrd} ${kernel} + ${chroot} mkinitrd -f ${initrd} ${kernel} +} + +chrooted() +{ + local cmd="$@" + + mount -t sysfs sysfs ${INSTALL_ROOT}/sys + mount -t proc proc ${INSTALL_ROOT}/proc + mount -o bind /dev ${INSTALL_ROOT}/dev + + chroot ${INSTALL_ROOT} ${cmd} + + umount ${INSTALL_ROOT}/dev + umount ${INSTALL_ROOT}/proc + umount ${INSTALL_ROOT}/sys } # special: memory (size), floppy (modprobe floppy), smp (support y/n)