installer.kmdr, installer.sh: code changed to use udisks instead of hal

This commit is contained in:
Silvan Calarco 2011-09-04 22:02:43 +02:00
parent 704bff28e2
commit 670a071a66
2 changed files with 359 additions and 382 deletions

View File

@ -334,30 +334,6 @@ Released under the terms of the GNU GPL v3 license</string>
<string>This program will install openmamba on this computer.</string>
</property>
</widget>
<widget class="Label">
<property name="name">
<cstring>Label18_2</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>220</y>
<width>560</width>
<height>60</height>
</rect>
</property>
<property name="text">
<string>If you have problems, suggestions or would like to contribute to the development of openmamba please consult the forums and maling lists available at &lt;a href="http://www.openmamba.org"&gt;www.openmamba.org&lt;/a&gt;.</string>
</property>
<property name="alignment">
<set>WordBreak|AlignVCenter</set>
</property>
<property name="associations" stdset="0">
<stringlist>
<string></string>
</stringlist>
</property>
</widget>
<widget class="GroupBox">
<property name="name">
<cstring>GroupBox4</cstring>
@ -399,26 +375,6 @@ Released under the terms of the GNU GPL v3 license</string>
</stringlist>
</property>
</widget>
<widget class="Label">
<property name="name">
<cstring>integrityCheckLabel</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>540</width>
<height>70</height>
</rect>
</property>
<property name="text">
<string>Please wait some time while the installation medium is checked for data integrity.
Press the skip button only if you have previously checked the medium on this computer.</string>
</property>
<property name="alignment">
<set>WordBreak|AlignVCenter</set>
</property>
</widget>
<widget class="ExecButton">
<property name="name">
<cstring>skipButton</cstring>
@ -445,6 +401,26 @@ killall md5progress.sh
</stringlist>
</property>
</widget>
<widget class="Label">
<property name="name">
<cstring>integrityCheckLabel</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>540</width>
<height>70</height>
</rect>
</property>
<property name="text">
<string>Please wait some time while the installation medium is checked for data integrity.
Press the skip button only if you have previously checked the medium on this computer.</string>
</property>
<property name="alignment">
<set>WordBreak|AlignVCenter</set>
</property>
</widget>
<widget class="ScriptObject">
<property name="name">
<cstring>launchMD5script</cstring>
@ -464,6 +440,30 @@ killall md5progress.sh
</property>
</widget>
</widget>
<widget class="Label">
<property name="name">
<cstring>Label18_2</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>220</y>
<width>560</width>
<height>60</height>
</rect>
</property>
<property name="text">
<string>If you have problems, suggestions or would like to contribute to the development of openmamba please consult the forums and maling lists available at &lt;a href="http://www.openmamba.org"&gt;www.openmamba.org&lt;/a&gt;.</string>
</property>
<property name="alignment">
<set>WordBreak|AlignVCenter</set>
</property>
<property name="associations" stdset="0">
<stringlist>
<string></string>
</stringlist>
</property>
</widget>
</widget>
<widget class="QWidget">
<property name="name">
@ -1293,6 +1293,52 @@ dcop @dcopid KommanderIf setBusyCursor false
<set>WordBreak|AlignTop|AlignHCenter</set>
</property>
</widget>
<widget class="CheckBox">
<property name="name">
<cstring>removablebox</cstring>
</property>
<property name="geometry">
<rect>
<x>300</x>
<y>20</y>
<width>270</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Show removab&amp;le devices</string>
</property>
<property name="associations" stdset="0">
<stringlist>
<string></string>
<string></string>
<string></string>
</stringlist>
</property>
</widget>
<widget class="CheckBox">
<property name="name">
<cstring>swapcheckbox</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>280</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>I&amp;gnore SWAP partition check</string>
</property>
<property name="associations" stdset="0">
<stringlist>
<string></string>
<string></string>
<string></string>
</stringlist>
</property>
</widget>
<widget class="Label">
<property name="name">
<cstring>installhint</cstring>
@ -1342,52 +1388,6 @@ dcop @dcopid KommanderIf setBusyCursor false
</stringlist>
</property>
</widget>
<widget class="CheckBox">
<property name="name">
<cstring>removablebox</cstring>
</property>
<property name="geometry">
<rect>
<x>300</x>
<y>20</y>
<width>270</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Show removab&amp;le devices</string>
</property>
<property name="associations" stdset="0">
<stringlist>
<string></string>
<string></string>
<string></string>
</stringlist>
</property>
</widget>
<widget class="CheckBox">
<property name="name">
<cstring>swapcheckbox</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>280</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>I&amp;gnore SWAP partition check</string>
</property>
<property name="associations" stdset="0">
<stringlist>
<string></string>
<string></string>
<string></string>
</stringlist>
</property>
</widget>
</widget>
<widget class="CheckBox">
<property name="name">
@ -1405,28 +1405,6 @@ dcop @dcopid KommanderIf setBusyCursor false
<string></string>
</property>
</widget>
<widget class="Label">
<property name="name">
<cstring>swapsizelabel</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>70</y>
<width>410</width>
<height>60</height>
</rect>
</property>
<property name="text">
<string></string>
</property>
<property name="textFormat">
<enum>RichText</enum>
</property>
<property name="alignment">
<set>WordBreak|AlignVCenter</set>
</property>
</widget>
<widget class="Label">
<property name="name">
<cstring>Label21_2_3</cstring>
@ -1451,6 +1429,28 @@ dcop @dcopid KommanderIf setBusyCursor false
<set>AlignCenter</set>
</property>
</widget>
<widget class="Label">
<property name="name">
<cstring>swapsizelabel</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>70</y>
<width>410</width>
<height>60</height>
</rect>
</property>
<property name="text">
<string></string>
</property>
<property name="textFormat">
<enum>RichText</enum>
</property>
<property name="alignment">
<set>WordBreak|AlignVCenter</set>
</property>
</widget>
<widget class="ScriptObject">
<property name="name">
<cstring>scandisks</cstring>
@ -1468,7 +1468,11 @@ dcop @dcopid KommanderIf setBusyCursor false
<string>@partitionslabel.clear
@BackBox.setChecked(true)
@execBegin
storages=`hal-find-by-capability --capability storage`
function get_udisks_key() {
LANG=C udisks --show-info $1 | grep " $2:" | head -n1 | sed "s|[[:space:]]*$2:[[:space:]]*\(.*\)|\1|"
}
devices=`udisks --enumerate-device-files | grep -v /dev/disk`
partlabel=
linuxok=
swapok=
@ -1483,59 +1487,58 @@ fi
systemrequired=5120
dcop @dcopid KommanderIf setText swapsizelabel "@i18n("In order to install openmamba you need on your fixed disk(s):&lt;br&gt;- a Linux type partition with at least $systemrequired MBytes&lt;br&gt;- a SWAP type partition with at least $swaprequired MBytes")"
for s in $storages; do
diskdevice=`hal-get-property --udi $s --key block.device`
vendor=`hal-get-property --udi $s --key info.vendor`
product=`hal-get-property --udi $s --key info.product`
hotpluggable=`hal-get-property --udi $s --key storage.hotpluggable` || hotpluggable="false"
partscheme=`hal-get-property --udi $s --key storage.partitioning_scheme`
[ "$partscheme" ] || continue
disksize=`hal-get-property --udi $s --key storage.size`
disksize=`expr $disksize / 1024 / 1024 / 1024`
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 ] &amp;&amp; continue
partscheme=`get_udisks_key $d scheme`
[ "$partscheme" ] || continue
disksize=`get_udisks_key $d size`
disksize=`expr $disksize / 1024 / 1024 / 1024`
volumes=`ls -d $native_path/${diskdevice}* 2&gt;/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`
parttype=`get_udisks_key $device usage`
[ "$parttype" ] || parttype="unknown"
fstype=`get_udisks_key $device type`
[ "$fstype" ] || fstype="unformatted"
add_info=""
[ "$is_system_internal" = "1" ] || add_info=",removable"
[ "$volsize" -gt "0" ] || continue
volumes=`hal-find-by-property --key info.parent --string $s`
thisdisk=
[ "$hotpluggable" = "true" -a @removablebox.checked == 0 ] &amp;&amp; continue
for udi in $volumes; do
device=`hal-get-property --udi $udi --key block.device`
blocksize=`hal-get-property --udi $udi --key volume.block_size`
numblocks=`hal-get-property --udi $udi --key volume.num_blocks`
volsize=`expr $blocksize \* $numblocks / 1024 / 1024`
volname=`hal-get-property --udi $udi --key volume.label`
[ "$volname" ] || volname=""
parttype=`hal-get-property --udi $udi --key volume.partition.type`
[ "$parttype" ] || parttype="unknown"
fstype=`hal-get-property --udi $udi --key volume.fstype`
[ "$fstype" ] || fstype="unformatted"
add_info=""
[ "$hotpluggable" = "true" ] &amp;&amp; {
add_info=",removable"
}
[ "$volsize" -gt "0" ] || continue
case "$parttype" in
0x82) fstype="swap" ;;
0x83) fstype="linux" ;;
esac
thispart="&lt;tr&gt;&lt;td width=50&gt;${device:5:5}&lt;/td&gt;&lt;td width=100&gt;$fstype&lt;/td&gt;&lt;td width=130&gt;$volname&lt;/td&gt;&lt;td align=right&gt;$volsize MB&lt;/td&gt;"
case "$fstype" in
thispart="&lt;tr&gt;&lt;td width=50&gt;${device:5:5}&lt;/td&gt;&lt;td width=100&gt;$fstype&lt;/td&gt;&lt;td width=130&gt;$volname&lt;/td&gt;&lt;td align=right&gt;$volsize MB&lt;/td&gt;"
case "$fstype" in
swap) if [ $swaprequired -le $volsize ]; then
swapok=$udi
swapok=1
thispart="$thispart&lt;td&gt;&lt;b&gt;@i18n("OK for swap")&lt;/b&gt;&lt;/td&gt;"
fi
fi
;;
linux|ext2|ext3|ext4|reiserfs|reiser4)
if [ $systemrequired -le $volsize ]; then
linuxok=$udi;
linuxok=1
thispart="$thispart&lt;td&gt;&lt;b&gt;@i18n("OK for system")&lt;/b&gt;&lt;/td&gt;"
fi
;;
*) thispart="$thispart&lt;td&gt;&lt;/td&gt;"
;;
esac
thisdisk="${thispart}${thisdisk}"
done
partlabel="&lt;b&gt;@i18n(Disk) $vendor $product $disksize GB (${diskdevice:5:5})&lt;/b&gt;:&lt;br&gt;&lt;br&gt;&lt;table cellspacing=0 cellpadding=0&gt;&lt;tr&gt;${thisdisk}&lt;/tr&gt;&lt;/table&gt;${partlabel}"
esac
thisdisk="${thispart}${thisdisk}"
done
partlabel="&lt;b&gt;@i18n("Disk") $vendor $product $disksize GB (${diskdevice})&lt;/b&gt;:&lt;br&gt;&lt;br&gt;&lt;table cellspacing=0 cellpadding=0&gt;&lt;tr&gt;${thisdisk}&lt;/tr&gt;&lt;/table&gt;${partlabel}"
done
dcop @dcopid KommanderIf setText partitionslabel "$partlabel"
if [ @swapcheckbox.checked = 1 ]; then
swapok="1"
@ -1552,48 +1555,6 @@ else
fi
dcop @dcopid KommanderIf setText installhint "$insthint"
@execEnd
</string>
</stringlist>
</property>
</widget>
<widget class="ScriptObject">
<property name="name">
<cstring>RunPartTool</cstring>
</property>
<property name="geometry">
<rect>
<x>550</x>
<y>40</y>
<width>32</width>
<height>32</height>
</rect>
</property>
<property name="associations" stdset="0">
<stringlist>
<string>@exec("dcop kded kded unloadModule medianotifier")
@execBegin
volumes=`hal-find-by-capability --capability volume`
for v in $volumes; do
mountpoint=`hal-get-property --udi $v --key volume.mount_point`
[ "$mountpoint" ] &amp;&amp; umount $mountpoint
done
/sbin/swapoff -a
@execEnd
@PartitionBox.setEnabled(false)
@BootloaderBox.setEnabled(false)
@Message.info("&lt;b&gt;
@i18n("Hint: in order to install openmamba you should create:")
&lt;/b&gt;&lt;br&gt;&lt;ul&gt;
&lt;li&gt;@i18n("a Linux partition (type ext2,ext3,ext4 or reiserfs)")
&lt;li&gt;@i18n("a Linux SWAP partition")
&lt;/ul&gt;
@i18n("Press OK to launch the disk partitioning tool.")
",@i18n("Hint for partitioning"))
@exec(/usr/sbin/gparted)
@scanDevices.execute()
@exec("dcop kded kded loadModule medianotifier")
@PartitionBox.setEnabled(true)
@BootloaderBox.setEnabled(true)
</string>
</stringlist>
</property>
@ -1619,12 +1580,18 @@ done
@scandisks.execute()
@rebootneededbox.setChecked(false)
@execBegin
storages=`hal-find-by-capability --capability storage`
for s in $storages; do
partscheme=`hal-get-property --udi $s --key storage.partitioning_scheme`
hotpluggable=`hal-get-property --udi $s --key storage.hotpluggable` || hotpluggable="false"
[ "$hotpluggable" = "true" -a @removablebox.checked == 0 ] &amp;&amp; continue
[ "$partscheme" = "none" ] &amp;&amp; dcop @dcopid KommanderIf setChecked rebootneededbox true
function get_udisks_key() {
LANG=C udisks --show-info $1 | grep " $2:" | head -n1 | sed "s|[[:space:]]*$2:[[:space:]]*\(.*\)|\1|"
}
devices=`udisks --enumerate-device-files | grep -v /dev/disk | sort -n -r`
for device in $devices; do
native_path=`get_udisks_key $device native-path`
[ -e $native_path/partition ] &amp;&amp; continue
partscheme=`get_udisks_key $device scheme`
is_system_internal=`get_udisks_key $device "system internal"`
[ "$is_system_internal" != "1" -a @removablebox.checked == 0 ] &amp;&amp; continue
[ "$partscheme" = "none" -o "$partscheme" = "" ] &amp;&amp; dcop @dcopid KommanderIf setChecked rebootneededbox true
done
@execEnd
@setGlobal("rebootquest","0")
@ -1638,6 +1605,52 @@ else
dcop ksmserver ksmserver logout 0 1 1
fi
@endif
</string>
</stringlist>
</property>
</widget>
<widget class="ScriptObject">
<property name="name">
<cstring>RunPartTool</cstring>
</property>
<property name="geometry">
<rect>
<x>550</x>
<y>40</y>
<width>32</width>
<height>32</height>
</rect>
</property>
<property name="associations" stdset="0">
<stringlist>
<string>@exec("dcop kded kded unloadModule medianotifier")
@execBegin
function get_udisks_key() {
LANG=C udisks --show-info $1 | grep " $2:" | head -n1 | sed "s|[[:space:]]*$2:[[:space:]]*\(.*\)|\1|"
}
volumes=`udisks --enumerate-device-files | grep -v /dev/disk`
for v in $volumes; do
native_path=`get_udisks_key $v native-path`
[ ! -e $native_path/partition ] || continue
udisks --unmount $v
done
/sbin/swapoff -a
@execEnd
@PartitionBox.setEnabled(false)
@BootloaderBox.setEnabled(false)
@Message.info("&lt;b&gt;
@i18n("Hint: in order to install openmamba you should create:")
&lt;/b&gt;&lt;br&gt;&lt;ul&gt;
&lt;li&gt;@i18n("a Linux partition (type ext2,ext3,ext4 or reiserfs)")
&lt;li&gt;@i18n("a Linux SWAP partition")
&lt;/ul&gt;
@i18n("Press OK to launch the disk partitioning tool.")
",@i18n("Hint for partitioning"))
@exec(/usr/sbin/gparted)
@scanDevices.execute()
@exec("dcop kded kded loadModule medianotifier")
@PartitionBox.setEnabled(true)
@BootloaderBox.setEnabled(true)
</string>
</stringlist>
</property>
@ -2074,62 +2087,6 @@ fi
</hbox>
</widget>
</widget>
<widget class="ScriptObject">
<property name="name">
<cstring>setlabel</cstring>
</property>
<property name="geometry">
<rect>
<x>540</x>
<y>40</y>
<width>32</width>
<height>32</height>
</rect>
</property>
<property name="populationText">
<string></string>
</property>
<property name="associations" stdset="0">
<stringlist>
<string>@execBegin
@if (@devicesbox.currentItem &gt;= 0)
currdev=@String.section(@devicesbox.item(@devicesbox.currentItem)," ",0)
@showdevice.setText(@devicesbox.item(@devicesbox.currentItem))
@dcop(@dcopid, KommanderIf, enableWidget(QString,bool), next, true)
@BackBox.setChecked(true)
parent_udi=`hal-find-by-property --key block.device --string /dev/$currdev`
# detect linux driver
unset linux_driver
while [ ! "$linux_driver" -a "$parent_udi" != "/org/freedesktop/Hal/devices/computer" ]; do
parent_udi=`hal-get-property --udi $parent_udi --key info.parent 2&gt;/dev/null`
[ "`hal-get-property --udi $parent_udi --key info.subsystem 2&gt;/dev/null`" = "pci" ] &amp;&amp; linux_driver=`hal-get-property --udi $parent_udi --key info.linux.driver 2&gt;/dev/null`
done
[ "$linux_driver" ] || linux_driver="undetected"
dcop @dcopid KommanderIf setText driverlabel $linux_driver
#
# set MBR combo box
#
dcop @dcopid KommanderIf "clear(QString)" mbrbox
storages=`hal-find-by-capability --capability storage`
dcop @dcopid KommanderIf "addListItem(QString,QString,int)" mbrbox "$currdev (@i18n("System partition"))" 0
for udi in $storages; do
device=`hal-get-property --udi $udi --key block.device`
hotpluggable=`hal-get-property --udi $udi --key storage.hotpluggable` || hotpluggable="false"
partscheme=`hal-get-property --udi $udi --key storage.partitioning_scheme`
if [ "$hotpluggable" == "false" -o "@removablebox.checked" == "1" ]; then
[ "$partscheme" == "mbr" ] &amp;&amp; \
dcop @dcopid KommanderIf "addListItem(QString,QString,int)" mbrbox "${device:5:5} (master boot record)" 0
fi
done
dcop @dcopid KommanderIf "setCurrentItem(int)" 0
@endif
@execEnd
@setBootableCheckbox.execute()</string>
</stringlist>
</property>
</widget>
<widget class="ScriptObject">
<property name="name">
<cstring>scanDevices</cstring>
@ -2148,39 +2105,43 @@ fi
@BackBox.setChecked(true)
@NextBox.setChecked(false)
@execBegin
function get_udisks_key() {
LANG=C udisks --show-info $1 | grep " $2:" | head -n1 | sed "s|[[:space:]]*$2:[[:space:]]*\(.*\)|\1|"
}
rpm -q openmamba-devel &amp;&amp; {
dcop @dcopid KommanderIf "setEnabled(QString,bool)" stablebox true
dcop @dcopid KommanderIf "setEnabled(QString,bool)" stablelabel true
}
volumes=`hal-find-by-capability --capability volume`
devices=`udisks --enumerate-device-files | grep -v /dev/disk | sort -n -r`
partlabel=
for udi in $volumes; do
device=`hal-get-property --udi $udi --key block.device`
parent_udi=`hal-get-property --udi $udi --key block.storage_device`
hotpluggable=`hal-get-property --udi $parent_udi --key storage.hotpluggable` || hotpluggable="false"
blocksize=`hal-get-property --udi $udi --key volume.block_size`
numblocks=`hal-get-property --udi $udi --key volume.num_blocks`
volsize=`expr $blocksize \* $numblocks / 1024 / 1024`
volname=`hal-get-property --udi $udi --key volume.label`
for device in $devices; do
native_path=`get_udisks_key $device native-path`
[ -e $native_path/partition ] || continue
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`
[ "$volname" ] || volname="unnamed"
parttype=`hal-get-property --udi $udi --key volume.partition.type`
parttype=`get_udisks_key $device usage`
[ "$parttype" ] || parttype="unknown"
partscheme=`hal-get-property --udi $udi --key volume.partition.scheme`
partscheme=`get_udisks_key $device scheme`
[ "$partscheme" ] || partscheme="unknown"
fstype=`hal-get-property --udi $udi --key volume.fstype`
fstype=`get_udisks_key $device type`
[ "$fstype" ] || fstype="unformatted"
add_info=""
[ "$hotpluggable" = "true" ] &amp;&amp; {
[ "$is_system_internal" = "1" ] || {
add_info=",removable"
[ @removablebox.checked == 1 ] || continue
}
if [ "$partscheme" == "mbr" -o "$partscheme" == "embr" ]; then
partlabel="$partlabel&lt;br&gt;${device:5:5} $fstype $volname $volsize MB"
case "$parttype" in
0x82) ;;
0x83) dcop @dcopid KommanderIf "addListItem(QString,QString,int)" devicesbox "${device:5:5} ($fstype,$volname,$volsize MB${add_info})" 0 ;;
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 ;;
*) ;;
esac
elif [ "$partscheme" == "gpt" -o "$partscheme" == "unknown" -a $volsize -gt 0 ]; then
@ -2204,6 +2165,57 @@ done
</stringlist>
</property>
</widget>
<widget class="ScriptObject">
<property name="name">
<cstring>setlabel</cstring>
</property>
<property name="geometry">
<rect>
<x>540</x>
<y>40</y>
<width>32</width>
<height>32</height>
</rect>
</property>
<property name="populationText">
<string></string>
</property>
<property name="associations" stdset="0">
<stringlist>
<string>@execBegin
function get_udisks_key() {
LANG=C udisks --show-info $1 | grep " $2:" | head -n1 | sed "s|[[:space:]]*$2:[[:space:]]*\(.*\)|\1|"
}
@if (@devicesbox.currentItem &gt;= 0)
currdev=@String.section(@devicesbox.item(@devicesbox.currentItem)," ",0)
@showdevice.setText(@devicesbox.item(@devicesbox.currentItem))
@dcop(@dcopid, KommanderIf, enableWidget(QString,bool), next, true)
@BackBox.setChecked(true)
#
# set MBR combo box
#
dcop @dcopid KommanderIf "clear(QString)" mbrbox
devices=`udisks --enumerate-device-files | grep -v /dev/disk`
dcop @dcopid KommanderIf "addListItem(QString,QString,int)" mbrbox "$currdev (@i18n("System partition"))" 0
for device in $devices; do
native_path=`get_udisks_key $device native-path`
[ -e $native_path/partition ] &amp;&amp; continue
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" ] &amp;&amp; \
dcop @dcopid KommanderIf "addListItem(QString,QString,int)" mbrbox "${device:5:5} (master boot record)" 0
fi
done
dcop @dcopid KommanderIf "setCurrentItem(int)" 0
@endif
@execEnd
@setBootableCheckbox.execute()</string>
</stringlist>
</property>
</widget>
</widget>
<widget class="QWidget">
<property name="name">
@ -2586,6 +2598,30 @@ done
</property>
</widget>
</widget>
<widget class="Label">
<property name="name">
<cstring>Label21_2_4</cstring>
</property>
<property name="geometry">
<rect>
<x>80</x>
<y>10</y>
<width>470</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>Choose user data partition (home)</string>
</property>
<property name="alignment">
<set>AlignCenter</set>
</property>
</widget>
<widget class="ScriptObject">
<property name="name">
<cstring>setlabel_2</cstring>
@ -2618,7 +2654,6 @@ done
fi
@dcop(@dcopid, KommanderIf, enableWidget(QString,bool), next, true)
@BackBox.setChecked(true)
parent_udi=`hal-find-by-property --key block.device --string /dev/$currdev`
dcop @dcopid KommanderIf "setCurrentItem(int)" 0
@endif
@execEnd
@ -2644,42 +2679,45 @@ done
@BackBox.setChecked(true)
@NextBox.setChecked(true)
@execBegin
volumes=`hal-find-by-capability --capability volume`
function get_udisks_key() {
LANG=C udisks --show-info $1 | grep " $2:" | head -n1 | sed "s|[[:space:]]*$2:[[:space:]]*\(.*\)|\1|"
}
devices=`udisks --enumerate-device-files | grep -v /dev/disk | sort -n -r`
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 udi in $volumes; do
device=`hal-get-property --udi $udi --key block.device`
for device in $devices; do
[ "${device:5:5}" = "$installdevice" ] &amp;&amp; continue
parent_udi=`hal-get-property --udi $udi --key block.storage_device`
hotpluggable=`hal-get-property --udi $parent_udi --key storage.hotpluggable` || hotpluggable="false"
blocksize=`hal-get-property --udi $udi --key volume.block_size`
numblocks=`hal-get-property --udi $udi --key volume.num_blocks`
volsize=`expr $blocksize \* $numblocks / 1024 / 1024`
volname=`hal-get-property --udi $udi --key volume.label`
native_path=`get_udisks_key $device native-path`
[ -e $native_path/partition ] || continue
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`
[ "$volname" ] || volname="unnamed"
parttype=`hal-get-property --udi $udi --key volume.partition.type`
parttype=`get_udisks_key $device usage`
[ "$parttype" ] || parttype="unknown"
partscheme=`hal-get-property --udi $udi --key volume.partition.scheme`
partscheme=`get_udisks_key $device scheme`
[ "$partscheme" ] || partscheme="unknown"
fstype=`hal-get-property --udi $udi --key volume.fstype`
fstype=`get_udisks_key $device type`
[ "$fstype" ] || fstype="unformatted"
add_info=""
[ "$hotpluggable" = "true" ] &amp;&amp; {
[ "$is_system_internal" = "1" ] || {
add_info=",removable"
[ @removablebox.checked == 1 ] || continue
}
if [ "$partscheme" == "mbr" -o "$partscheme" == "embr" ]; then
partlabel="$partlabel&lt;br&gt;${device:5:5} $fstype $volname $volsize MB"
case "$parttype" in
0x82) ;;
0x83) dcop @dcopid KommanderIf "addListItem(QString,QString,int)" devicesbox_2 "${device:5:5} ($fstype,$volname,$volsize MB${add_info})" 1 ;;
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 ;;
*) ;;
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 ;;
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 ;;
*) ;;
esac
fi
@ -2689,30 +2727,6 @@ done
</stringlist>
</property>
</widget>
<widget class="Label">
<property name="name">
<cstring>Label21_2_4</cstring>
</property>
<property name="geometry">
<rect>
<x>80</x>
<y>10</y>
<width>470</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>Choose user data partition (home)</string>
</property>
<property name="alignment">
<set>AlignCenter</set>
</property>
</widget>
</widget>
<widget class="QWidget">
<property name="name">
@ -2998,41 +3012,41 @@ fi
@chainloadbox.clear
@setBootableCheckbox.execute()
@execBegin
function get_udisks_key() {
LANG=C udisks --show-info $1 | grep " $2:" | head -n1 | sed "s|[[:space:]]*$2:[[:space:]]*\(.*\)|\1|"
}
conffile=~/.installer.conf
[ -e $conffile ] &amp;&amp; mv ${conffile} ${conffile}~
installdevice=@String.section(@devicesbox.item(@devicesbox.currentItem)," ",0)
volumes=`hal-find-by-capability --capability volume`
devices=`udisks --enumerate-device-files | grep -v /dev/disk | sort -n -r`
partlabel=
for udi in $volumes; do
device=`hal-get-property --udi $udi --key block.device`
for device in $devices; do
[ "${device:5:5}" = "$installdevice" ] &amp;&amp; continue
parent_udi=`hal-get-property --udi $udi --key block.storage_device`
hotpluggable=`hal-get-property --udi $parent_udi --key storage.hotpluggable` || hotpluggable="false"
blocksize=`hal-get-property --udi $udi --key volume.block_size`
numblocks=`hal-get-property --udi $udi --key volume.num_blocks`
volsize=`expr $blocksize \* $numblocks / 1024 / 1024`
[ $volsize = 0 ] &amp;&amp; continue
volname=`hal-get-property --udi $udi --key volume.label`
mount_point=`hal-get-property --udi $udi --key volume.mount_point`
native_path=`get_udisks_key $device native-path`
[ -e $native_path/partition ] || continue
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`
[ "$volname" ] || volname="unnamed"
parttype=`hal-get-property --udi $udi --key volume.partition.type`
parttype=`get_udisks_key $device usage`
[ "$parttype" ] || parttype="unknown"
partscheme=`hal-get-property --udi $udi --key volume.partition.scheme`
partscheme=`get_udisks_key $device scheme`
[ "$partscheme" ] || partscheme="unknown"
fstype=`hal-get-property --udi $udi --key volume.fstype`
fstype=`get_udisks_key $device type`
[ "$fstype" ] || fstype="unformatted"
add_info=""
[ "$hotpluggable" = "true" ] &amp;&amp; {
[ "$is_system_internal" = "1" ] || {
add_info=",removable"
[ @removablebox.checked == 1 ] || continue
}
if [ "$partscheme" == "mbr" -o "$partscheme" == "embr" ]; then
partlabel="$partlabel&lt;br&gt;${device:5:5} $fstype $volname $volsize MB"
case "$parttype" in
0x82) ;;
0x83) ;;
case "$fstype" in
swap|iso9660|unformatted) ;;
ext2|ext3|ext4|reiserfs|reiser4) ;;
*) dcop @dcopid KommanderIf "addListItem(QString,QString,int)" chainloadbox "${device:5:5} ($fstype,$volname,$volsize MB${add_info})" 0
dcop @dcopid KommanderIf "setSelection" chainloadbox "${device:5:5} ($fstype,$volname,$volsize MB${add_info})"
;;

View File

@ -85,29 +85,8 @@ Installation time: $TIME_ELAPSED minutes"
done
}
# function dev2gdev()
# convert the device name to the string used by grub
# using the file /boot/grub/device.map
# note: in case of error the null string is returned
# args:
# $1: the name of the device
# example:
# /dev/hda3 --> (hd0,2)
# /dev/sdb1 --> (hd1,0)
function dev2gdev() {
local devname=$1
local disk=${devname:0:8} \
part=${devname:8:2}
[ ${part:-0} -lt 1 ] && echo -n ""
cat $MOUNTPOINT/boot/grub/device.map | \
while read tok1 tok2; do
if [ "$tok2" = "$disk" ]; then
echo -n "${tok1/)/},$(($part)))"
fi
done
function get_udisks_key() {
LANG=C udisks --show-info $1 | grep " $2:" | head -n1 | sed "s|[[:space:]]*$2:[[:space:]]*\(.*\)|\1|"
}
[ "$1" = "-y" ] || {
@ -117,23 +96,6 @@ function dev2gdev() {
exit 0
}
function find_driver_for_udi() {
local found_driver parent_udi
parent_udi=$1
while [ ! "$found_driver" -a "$parent_udi" != "/org/freedesktop/Hal/devices/computer" ]; do
parent_udi=`hal-get-property --udi $parent_udi --key info.parent 2>/dev/null`
[ "`hal-get-property --udi $parent_udi --key info.subsystem 2>/dev/null`" = "pci" ] &&
found_driver=`hal-get-property --udi $parent_udi --key info.linux.driver 2>/dev/null`
done
if [ "$found_driver" ]; then
echo $found_driver
return 0
else
return 1
fi
}
DCOPID=$2
echo $"\
@ -212,15 +174,16 @@ tempfile=`tempfile 2>/dev/null`
mapfile=`tempfile 2>/dev/null`
# generate current volumes sorted list with driver information
storages=`hal-find-by-capability --capability storage`
devices=`udisks --enumerate-device-files | grep -v /dev/disk`
for s in $storages; do
device=`hal-get-property --udi $s --key block.device`
linux_driver=`find_driver_for_udi $s`
hotpluggable=`hal-get-property --udi $s --key storage.hotpluggable` || hotpluggable="false"
native_path=`get_udisks_key $device native-path`
[ -e $native_path/partition ] && continue
is_system_internal=`get_udisks_key $device "system internal"`
#linux_driver=`find_driver_for_udi $s`
[ "${device:5:2}" = "sd" -o "${device:5:2}" = "hd" ] && \
echo "${device:0:8} $linux_driver" >> $tempfile
echo "${device:0:8}" >> $tempfile
if [ "$INSTALL_BOOTLOADER_DEVICE" = "$device" ]; then
INSTALL_BOOTLOADER_DEVICE_HOTPLUGGABLE=$hotpluggable
INSTALL_BOOTLOADER_DEVICE_INTERNAL=$is_system_internal
fi
done
# sort
@ -462,7 +425,7 @@ if [ "$INSTALL_BOOTLOADER_DEVICE" ]; then
fi
done
echo "GRUB_INSTALL_DEVICE=$INSTALL_BOOTLOADER_DEVICE_BYID" >> $MOUNTPOINT/etc/sysconfig/grub
if [ "$INSTALL_BOOTLOADER_DEVICE_HOTPLUGGABLE" = "true" ]; then
if [ "$INSTALL_BOOTLOADER_DEVICE_INTERNAL" != "1" ]; then
echo $"Installing grub bootloader on removable device $INSTALL_BOOTLOADER_DEVICE"
echo "(hd0) $INSTALL_BOOTLOADER_DEVICE" > $MOUNTPOINT/boot/grub/device.map
grub-install $INSTALL_BOOTLOADER_DEVICE --root-directory=$MOUNTPOINT --no-floppy --force