installer.kmdr: preliminary LVM support

This commit is contained in:
Silvan Calarco 2014-06-25 17:04:14 +02:00
parent 16ea9baaf8
commit 0311bc8539

View File

@ -1598,26 +1598,44 @@ fi
dcop @dcopid KommanderIf setText swapsizelabel "@i18n("In order to install openmamba you need on your fixed disk(s):<br>- a Linux type partition with at least $systemrequired MBytes<br>- a SWAP type partition with at least $swaprequired MBytes")"
for d in $devices; do
diskdevice=${d/\/dev\/}
native_path=`get_udisks_key $d native-path`
[ ! -e $native_path/partition ] || continue
vendor=`get_udisks_key $d vendor`
product=`get_udisks_key $d model`
is_system_internal=`get_udisks_key $d "system internal"`
[ "$is_system_internal" != "1" -a @removablebox.checked == 0 ] && continue
partscheme=`get_udisks_key $d scheme`
[ "$partscheme" ] || continue
# lvm device?
lvm_vgname=`sudo pvdisplay $d 2>/dev/null | grep "VG Name" | sed "s|.*VG Name[[:space:]]*||"`
if [ "$lvm_vgname" ]; then
diskdevice=$lvm_vgname
native_path="/dev/$lvm_vgname"
lvm_lvnames=`ls -d $native_path/* | sort -n -r`
volumes=
for f in $lvm_lvnames; do
lvm_volume=`get_udisks_key $f "device-file" | sed "s|.*/||"`
volumes="$volumes $lvm_volume"
done
disktype="@i18n("LVM Group")"
else
diskdevice=${d/\/dev\/}
native_path=`get_udisks_key $d native-path`
[ ! -e $native_path/partition ] || continue
vendor=`get_udisks_key $d vendor`
product=`get_udisks_key $d model`
is_system_internal=`get_udisks_key $d "system internal"`
[ "$is_system_internal" != "1" -a @removablebox.checked == 0 ] && continue
partscheme=`get_udisks_key $d scheme`
[ "$partscheme" ] || continue
volumes=`ls -d $native_path/${diskdevice}* 2>/dev/null | sed "s|.*/||" | sort -n -r`
disktype="@i18n("Disk")"
fi
disksize=`get_udisks_key $d size`
disksize=`expr $disksize / 1024 / 1024 / 1024`
volumes=`ls -d $native_path/${diskdevice}* 2>/dev/null | sed "s|.*/||" | sort -n -r`
thisdisk=
for v in $volumes; do
device=/dev/$v
v_native_path=$native_path/$v
volsize=`get_udisks_key $device size`
volsize=`expr $volsize / 1024 / 1024`
volname=`get_udisks_key $device label`
if [ "${v:0:3}" = "dm-" ]; then
volname=`sudo dmsetup info $device | grep "^Name:" | sed "s|.*[[:space:]]||"`
else
volname=`get_udisks_key $device label`
fi
parttype=`get_udisks_key $device usage`
[ "$parttype" ] || parttype="unknown"
fstype=`get_udisks_key $device type`
@ -1626,7 +1644,7 @@ for d in $devices; do
[ "$is_system_internal" = "1" ] || add_info=",removable"
[ "$volsize" -gt "0" ] || continue
thispart="<tr><td width=50>${device:5:5}</td><td width=100>$fstype</td><td width=130>$volname</td><td align=right>$volsize MB</td>"
thispart="<tr><td width=80>$v</td><td width=100>$fstype</td><td width=130>$volname</td><td width=100 align=right>$volsize MB</td>"
case "$fstype" in
swap) if [ $swaprequired -le $volsize ]; then
@ -1634,7 +1652,7 @@ for d in $devices; do
thispart="$thispart<td><b>@i18n("OK for swap")</b></td>"
fi
;;
linux|ext2|ext3|ext4|reiserfs|reiser4)
unformatted|linux|ext2|ext3|ext4|reiserfs|reiser4)
if [ $systemrequired -le $volsize ]; then
linuxok=1
thispart="$thispart<td><b>@i18n("OK for system")</b></td>"
@ -1646,7 +1664,7 @@ for d in $devices; do
thisdisk="${thispart}${thisdisk}"
done
partlabel="<b>@i18n("Disk") $vendor $product $disksize GB (${diskdevice})</b>:<br><br><table cellspacing=0 cellpadding=0><tr>${thisdisk}</tr></table>${partlabel}"
partlabel="<b>$disktype $vendor $product $disksize GB (${diskdevice})</b>:<br><br><table cellspacing=0 cellpadding=0><tr>${thisdisk}</tr></table>${partlabel}"
done
dcop @dcopid KommanderIf setText partitionslabel "$partlabel"
@ -2134,13 +2152,20 @@ devices=`udisks --enumerate-device-files | grep -v /dev/disk | sort -n -r`
partlabel=
for device in $devices; do
native_path=`get_udisks_key $device native-path`
[ -e $native_path/partition ] || continue
if [ "${device:0:8}" != "/dev/dm-" ]; then
# not a lvm device
native_path=`get_udisks_key $device native-path`
[ -e $native_path/partition ] || continue
fi
is_system_internal=`get_udisks_key $device "system internal"`
volsize=`get_udisks_key $device size`
volsize=`expr $volsize / 1024 / 1024`
[ $systemrequired -le $volsize ] || continue
volname=`get_udisks_key $device label`
if [ "${device:5:3}" = "dm-" ]; then
volname=`sudo dmsetup info $device | grep "^Name:" | sed "s|.*[[:space:]]||"`
else
volname=`get_udisks_key $device label`
fi
[ "$volname" ] || volname="unnamed"
parttype=`get_udisks_key $device usage`
[ "$parttype" ] || parttype="unknown"
@ -2155,16 +2180,16 @@ for device in $devices; do
}
if [ "$partscheme" == "mbr" -o "$partscheme" == "embr" ]; then
partlabel="$partlabel<br>${device:5:5} $fstype $volname $volsize MB"
partlabel="$partlabel<br>${device:5} $fstype $volname $volsize MB"
case "$fstype" in
ext2|ext3|ext4|reiserfs|reiser4|unformatted)
dcop @dcopid KommanderIf "addListItem(QString,QString,int)" devicesbox "${device:5:5} ($fstype,$volname,$volsize MB${add_info})" 0 ;;
dcop @dcopid KommanderIf "addListItem(QString,QString,int)" devicesbox "${device:5} ($fstype,$volname,$volsize MB${add_info})" 0 ;;
*) ;;
esac
elif [ "$partscheme" == "gpt" -o "$partscheme" == "unknown" -a $volsize -gt 0 ]; then
case "$fstype" in
swap|iso9660) ;;
ext2|ext3|ext4|reiserfs|reiser4|unformatted) dcop @dcopid KommanderIf "addListItem(QString,QString,int)" devicesbox "${device:5:5} ($fstype,$volname,$volsize MB${add_info})" 0 ;;
ext2|ext3|ext4|reiserfs|reiser4|unformatted) dcop @dcopid KommanderIf "addListItem(QString,QString,int)" devicesbox "${device:5} ($fstype,$volname,$volsize MB${add_info})" 0 ;;
*) ;;
esac
fi
@ -2224,14 +2249,14 @@ function get_udisks_key_last() {
if [ -e $native_path/partition ]; then
partition_label=`get_udisks_key_last $device label`
if [ "${partition_label:0:3}" = "EFI" ]; then
dcop @dcopid KommanderIf "addListItem(QString,QString,int)" mbrbox "${device:5:5} (@i18n("EFI system partition"))" 0
dcop @dcopid KommanderIf "addListItem(QString,QString,int)" mbrbox "${device:5} (@i18n("EFI system partition"))" 0
fi
else
is_system_internal=`get_udisks_key $device "system internal"`
partscheme=`get_udisks_key $device scheme`
if [ "$is_system_internal" == "1" -o "@removablebox.checked" == "1" ]; then
[ "$partscheme" == "mbr" ] && \
dcop @dcopid KommanderIf "addListItem(QString,QString,int)" mbrbox "${device:5:5} (master boot record)" 0
dcop @dcopid KommanderIf "addListItem(QString,QString,int)" mbrbox "${device:5} (master boot record)" 0
fi
fi
done
@ -2669,13 +2694,19 @@ partlabel=
installdevice=@String.section(@devicesbox.item(@devicesbox.currentItem)," ",0)
dcop @dcopid KommanderIf "addListItem(QString,QString,int)" devicesbox_2 "@i18n("none (just use a single partition for system and home)")" 0
for device in $devices; do
[ "${device:5:5}" = "$installdevice" ] && continue
native_path=`get_udisks_key $device native-path`
[ -e $native_path/partition ] || continue
[ "${device:5}" = "$installdevice" ] && continue
if [ "${device:5:3}" != "dm-" ]; then
native_path=`get_udisks_key $device native-path`
[ -e $native_path/partition ] || continue
fi
is_system_internal=`get_udisks_key $device "system internal"`
volsize=`get_udisks_key $device size`
volsize=`expr $volsize / 1024 / 1024`
volname=`get_udisks_key $device label`
if [ "${device:5:3}" = "dm-" ]; then
volname=`sudo dmsetup info $device | grep "^Name:" | sed "s|.*[[:space:]]||"`
else
volname=`get_udisks_key $device label`
fi
[ $volsize -ge 512 ] || continue
[ "$volname" ] || volname="unnamed"
parttype=`get_udisks_key $device usage`
@ -2690,17 +2721,17 @@ for device in $devices; do
[ @removablebox.checked == 1 ] || continue
}
if [ "$partscheme" == "mbr" -o "$partscheme" == "embr" ]; then
partlabel="$partlabel<br>${device:5:5} $fstype $volname $volsize MB"
partlabel="$partlabel<br>${device:5} $fstype $volname $volsize MB"
case "$fstype" in
ext2|ext3|ext4|reiserfs|reiser4|unformatted)
dcop @dcopid KommanderIf "addListItem(QString,QString,int)" devicesbox_2 "${device:5:5} ($fstype,$volname,$volsize MB${add_info})" 1 ;;
dcop @dcopid KommanderIf "addListItem(QString,QString,int)" devicesbox_2 "${device:5} ($fstype,$volname,$volsize MB${add_info})" 1 ;;
*) ;;
esac
elif [ "$partscheme" == "gpt" -o "$partscheme" == "unknown" -a $volsize -gt 0 ]; then
case "$fstype" in
swap|iso9660) ;;
ext2|ext3|ext4|reiserfs|reiser4|unformatted)
dcop @dcopid KommanderIf "addListItem(QString,QString,int)" devicesbox_2 "${device:5:5} ($fstype,$volname,$volsize MB${add_info})" 1 ;;
dcop @dcopid KommanderIf "addListItem(QString,QString,int)" devicesbox_2 "${device:5} ($fstype,$volname,$volsize MB${add_info})" 1 ;;
*) ;;
esac
fi