--- trunk/installer-simple/functions/hwdetection.sh 2014/01/08 09:15:14 2476 +++ trunk/installer-simple/functions/hwdetection.sh 2014/01/08 12:11:44 2487 @@ -11,7 +11,7 @@ yes|y|true|1) use_sudo=sudo ;; esac - ${use_sudo} /usr/sbin/hwinfo $@ + LC_ALL=C ${use_sudo} /usr/sbin/hwinfo $@ } # get_hwinfo $hw_item @@ -165,6 +165,11 @@ local variable="$2" local method + local use_sudo="" + case ${SUDO} in + yes|y|true|1) use_sudo=sudo ;; + esac + case $1 in --uuid|-u) shift; method="-U"; partition="$1"; variable="$2" ;; --label|-l) shift; method="-L"; partition="$1"; variable="$2" ;; @@ -182,7 +187,7 @@ return 1 fi - blkid -o value -s "${variable}" "${method}" "${partition}" + LC_ALL=C ${use_sudo} blkid -o value -s "${variable}" "${method}" "${partition}" } get_fstype() @@ -215,106 +220,6 @@ get_blkid_information ${partition} UUID } -# create_initrd {/path/to/initrd kernelversion } -# when nothing given then /boot/initrd-$(uname -r).img $(uname -r) will be used -# default config path is /etc/conf.d/mkinitrd -create_initrd() -{ - local initrd - local kernel - local config - local chroot - #local root - local modules - # enabled framebuffer modules as default - local framebuffer=1 - local uvesafb_config="/etc/modprobe.d/uvesafb.conf" - - # very basic getops - for i in $* - do - case $1 in - --initrd|-i) shift; initrd="$1" ;; - --config|-c) shift; config="$1" ;; - --kernelversion|-v) shift; kernel="$1" ;; - --nofb) shift; framebuffer=0 - 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}" - uvesafb_config="${INSTALL_ROOT}/${uvesafb_config}" - chroot="chrooted" - fi - - # get various modules needed to boot - 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 - - # check for usb-storage and add usb host drivers - if [[ ! -z $(echo ${modules} | grep usb[_-]storage) ]] - then - # add usb1, usb1.1, usb2 and ubs3 hosts - modules+=" uhci-hcd ohci-hcd ehci-hcd xhci-hcd" - fi - - # add some generic modules - modules+=" sg_mod sg loop sr_mod sd_mod ide-cd ide-cd_mod ide-disk" - - # add generic framebuffer modules - if [[ ${framebuffer} = 1 ]] - then - modules+=" uvesafb" - - # setup modprobe conf too - [[ ! -d $(dirname ${uvesafb_config}) ]] && install -d $(dirname ${uvesafb_config}) - cat > ${uvesafb_config} << EOF -# This file sets the parameters for uvesafb module. -# The following format should be used: -# options uvesafb mode_option=x[-][@] scroll= ... -# -# For more details see: -# http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/fb/uvesafb.txt -# -EOF - # fix a issues with virtualbox and 'ywrap' - if [[ ! -z $(hwinfo --bios | grep -i virtualbox) ]] - then - # use redraw on virtualbox - echo "options uvesafb mode_option=1024x768-32@60 scroll=redraw" >> ${uvesafb_config} - else - # default config 1024x768 and 60 HZ - echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" >> ${uvesafb_config} - fi - fi - - # remove all duplicate modules - modules="$(remove_duplicates ${modules})" - - # hotfix for usb-storage - modules="${modules/usb_storage/usb-storage}" - - # create the config and an initrd - echo "# autogenerated config file" > ${config} - echo "MODULES=\"${modules}\"" >> ${config} - echo "IMAGE_TYPE=\"initramfs\"" >> ${config} - - ${chroot} mkinitrd -f ${initrd} ${kernel} -} - is_mounted() { local item @@ -349,33 +254,44 @@ [[ $(cat ${interface}/carrier) = 1 ]] || return 1 } -hdd_size_below_256mb() +# device_minimum_size [drive] [size-in-mb] +device_minimum_size() { - local hdd="$1" + local device="$1" + local minimum_size="$2" local size - local retval - [[ -z ${hdd} ]] && dialog_die "Error: get_hdd_size() no \$hdd given!" - size=$(fdisk -l ${hdd} | grep "Disk.*${hdd}" | sed 's:.*,\ \(.*\)\ byte.*:\1:') - if [[ ${size} -le 257000000 ]] - then - retval="0" - else - retval="1" - fi + local use_sudo="" + case ${SUDO} in + yes|y|true|1) use_sudo=sudo ;; + esac + + [[ -z ${device} ]] && dialog_die "Error: device_minimum_size() no \$device given!" + [[ -z ${minimum_size} ]] && dialog_die "Error: device_minimum_size() no \$minium_size given!" - return "${retval}" + # convert to bytes + minimum_size=$(( ${minimum_size}*1024*1024 )) + + size=$(LC_ALL=C ${use_sudo} fdisk -l ${device} | grep "Disk.*${device}" | sed 's:.*,\ \(.*\)\ byte.*:\1:') + [[ ${size} -ge ${minimum_size} ]] || return 1 + + return 0 } chrooted() { local cmd="$@" + local use_sudo="" + case ${SUDO} in + yes|y|true|1) use_sudo=sudo ;; + esac + is_mounted --location ${INSTALLROOT}/sys || mount -t sysfs sysfs ${INSTALLROOT}/sys is_mounted --location ${INSTALLROOT}/proc || mount -t proc proc ${INSTALLROOT}/proc is_mounted --location ${INSTALLROOT}/dev || mount -o bind /dev ${INSTALLROOT}/dev - chroot ${INSTALLROOT} ${cmd} + LC_ALL=C ${use_sudo} chroot ${INSTALLROOT} ${cmd} is_mounted --location ${INSTALLROOT}/dev && umount ${INSTALLROOT}/dev is_mounted --location ${INSTALLROOT}/proc && umount ${INSTALLROOT}/proc