Magellan Linux

Diff of /trunk/installer-simple/functions/hwdetection.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2486 by niro, Wed Jan 8 09:15:14 2014 UTC revision 2487 by niro, Wed Jan 8 12:11:44 2014 UTC
# Line 11  hwinfo() Line 11  hwinfo()
11   yes|y|true|1) use_sudo=sudo ;;   yes|y|true|1) use_sudo=sudo ;;
12   esac   esac
13    
14   ${use_sudo} /usr/sbin/hwinfo $@   LC_ALL=C ${use_sudo} /usr/sbin/hwinfo $@
15  }  }
16    
17  # get_hwinfo $hw_item  # get_hwinfo $hw_item
# Line 165  get_blkid_information() Line 165  get_blkid_information()
165   local variable="$2"   local variable="$2"
166   local method   local method
167    
168     local use_sudo=""
169     case ${SUDO} in
170     yes|y|true|1) use_sudo=sudo ;;
171     esac
172    
173   case $1 in   case $1 in
174   --uuid|-u) shift; method="-U"; partition="$1"; variable="$2" ;;   --uuid|-u) shift; method="-U"; partition="$1"; variable="$2" ;;
175   --label|-l) shift; method="-L"; partition="$1"; variable="$2" ;;   --label|-l) shift; method="-L"; partition="$1"; variable="$2" ;;
# Line 182  get_blkid_information() Line 187  get_blkid_information()
187   return 1   return 1
188   fi   fi
189    
190   blkid -o value -s "${variable}" "${method}" "${partition}"   LC_ALL=C ${use_sudo} blkid -o value -s "${variable}" "${method}" "${partition}"
191  }  }
192    
193  get_fstype()  get_fstype()
# Line 215  get_uuid() Line 220  get_uuid()
220   get_blkid_information ${partition} UUID   get_blkid_information ${partition} UUID
221  }  }
222    
 # create_initrd {/path/to/initrd kernelversion </path/to/config>}  
 # 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=<xres>x<yres>[-<bpp>][@<refresh>] scroll=<ywrap|ypan|redraw> ...  
 #  
 # 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}  
 }  
   
223  is_mounted()  is_mounted()
224  {  {
225   local item   local item
# Line 349  iface_has_link() Line 254  iface_has_link()
254   [[ $(cat ${interface}/carrier) = 1 ]] || return 1   [[ $(cat ${interface}/carrier) = 1 ]] || return 1
255  }  }
256    
257  hdd_size_below_256mb()  # device_minimum_size [drive] [size-in-mb]
258    device_minimum_size()
259  {  {
260   local hdd="$1"   local device="$1"
261     local minimum_size="$2"
262   local size   local size
  local retval  
  [[ -z ${hdd} ]] && dialog_die "Error: get_hdd_size() no \$hdd given!"  
263    
264   size=$(fdisk -l ${hdd} | grep "Disk.*${hdd}" | sed 's:.*,\ \(.*\)\ byte.*:\1:')   local use_sudo=""
265   if [[ ${size} -le 257000000 ]]   case ${SUDO} in
266   then   yes|y|true|1) use_sudo=sudo ;;
267   retval="0"   esac
268   else  
269   retval="1"   [[ -z ${device} ]] && dialog_die "Error: device_minimum_size() no \$device given!"
270   fi   [[ -z ${minimum_size} ]] && dialog_die "Error: device_minimum_size() no \$minium_size given!"
271    
272   return "${retval}"   # convert to bytes
273     minimum_size=$(( ${minimum_size}*1024*1024 ))
274    
275     size=$(LC_ALL=C ${use_sudo} fdisk -l ${device} | grep "Disk.*${device}" | sed 's:.*,\ \(.*\)\ byte.*:\1:')
276     [[ ${size} -ge ${minimum_size} ]] || return 1
277    
278     return 0
279  }  }
280    
281  chrooted()  chrooted()
282  {  {
283   local cmd="$@"   local cmd="$@"
284    
285     local use_sudo=""
286     case ${SUDO} in
287     yes|y|true|1) use_sudo=sudo ;;
288     esac
289    
290   is_mounted --location ${INSTALLROOT}/sys || mount -t sysfs sysfs ${INSTALLROOT}/sys   is_mounted --location ${INSTALLROOT}/sys || mount -t sysfs sysfs ${INSTALLROOT}/sys
291   is_mounted --location ${INSTALLROOT}/proc || mount -t proc proc ${INSTALLROOT}/proc   is_mounted --location ${INSTALLROOT}/proc || mount -t proc proc ${INSTALLROOT}/proc
292   is_mounted --location ${INSTALLROOT}/dev || mount -o bind /dev ${INSTALLROOT}/dev   is_mounted --location ${INSTALLROOT}/dev || mount -o bind /dev ${INSTALLROOT}/dev
293    
294   chroot ${INSTALLROOT} ${cmd}   LC_ALL=C ${use_sudo} chroot ${INSTALLROOT} ${cmd}
295    
296   is_mounted --location ${INSTALLROOT}/dev && umount ${INSTALLROOT}/dev   is_mounted --location ${INSTALLROOT}/dev && umount ${INSTALLROOT}/dev
297   is_mounted --location ${INSTALLROOT}/proc && umount ${INSTALLROOT}/proc   is_mounted --location ${INSTALLROOT}/proc && umount ${INSTALLROOT}/proc

Legend:
Removed from v.2486  
changed lines
  Added in v.2487