slitaz-tools rev 733

tazinst: improved ms-windows detection
author Dominique Corbex <domcox@slitaz.org>
date Thu Apr 19 08:42:38 2012 +0200 (2012-04-19)
parents fb636ac549ab
children e436b1a8acad
files installer/tazinst
line diff
     1.1 --- a/installer/tazinst	Thu Apr 12 11:03:44 2012 +0200
     1.2 +++ b/installer/tazinst	Thu Apr 19 08:42:38 2012 +0200
     1.3 @@ -20,7 +20,7 @@
     1.4  # 7: Another instance is running
     1.5  # 8: Internal error
     1.6  
     1.7 -VERSION=3.32
     1.8 +VERSION=3.33
     1.9  
    1.10  # Internationalization
    1.11  . /usr/bin/gettext.sh
    1.12 @@ -774,20 +774,39 @@
    1.13  	debug "Searching for Windows"
    1.14  	if [ "$TGT_WINBOOT" == "auto" ];then
    1.15  		WINBOOT=$(fdisk -l | awk '
    1.16 -BEGIN{disk=-1,	found=-1,	winboot=""}
    1.17 +BEGIN{
    1.18 +	disk=-1
    1.19 +	found=0 
    1.20 +	winboot=""}
    1.21  {
    1.22 -	# Counting disk
    1.23 -	if ($1=="Disk"){disk++, part=-1}
    1.24 -	# Counting partition
    1.25 -	if (substr($1,1,4)=="/dev"){part++}
    1.26 -	# Read partition Id
    1.27 - 	if ($2=="*"){Id=$6}	else {Id=$5}
    1.28 -	# Detect Windows type
    1.29 -	if (Id=="7" || Id=="b"){
    1.30 -		if (found){
    1.31 -			# record 1st Windows partition found
    1.32 -			winboot=sprintf("hd%d,%d",disk,part),found++}
    1.33 +	# Count disks
    1.34 +	if ($1=="Disk"){
    1.35 +		disk++
    1.36 +		part=-1
    1.37 +		dev=substr($2,6,3)
    1.38 +		# get removable status
    1.39 +		file="/sys/block/"dev"/removable"
    1.40 +		"cat " file | getline removable
    1.41 +		close("cat ")
    1.42 +}
    1.43 +	# Count partitions
    1.44 +	if (substr($1,1,4)=="/dev"){
    1.45 +		# List fixed drives only
    1.46 +		if (removable==0){
    1.47 +			part++
    1.48 +			# Read partition Id
    1.49 +	 		if ($2=="*"){Id=$6} else {Id=""}
    1.50 +			# Detect Windows Partition Type: 7,b,c,e,f
    1.51 +			WPT="[7bcef]"
    1.52 +			if (Id ~ WPT){
    1.53 +				found++
    1.54 +				# record 1st Windows partition found
    1.55 +				if (found==1){
    1.56 +					winboot=sprintf("hd%d,%d",disk,part)
    1.57 +				}
    1.58 +			}
    1.59  		}
    1.60 +	}
    1.61  }
    1.62  END{printf "%s", winboot}')
    1.63  		if [ -z "$WINBOOT" ]; then