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> <string>This program will install openmamba on this computer.</string>
</property> </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 class="GroupBox"> <widget class="GroupBox">
<property name="name"> <property name="name">
<cstring>GroupBox4</cstring> <cstring>GroupBox4</cstring>
@ -399,26 +375,6 @@ Released under the terms of the GNU GPL v3 license</string>
</stringlist> </stringlist>
</property> </property>
</widget> </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"> <widget class="ExecButton">
<property name="name"> <property name="name">
<cstring>skipButton</cstring> <cstring>skipButton</cstring>
@ -445,6 +401,26 @@ killall md5progress.sh
</stringlist> </stringlist>
</property> </property>
</widget> </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"> <widget class="ScriptObject">
<property name="name"> <property name="name">
<cstring>launchMD5script</cstring> <cstring>launchMD5script</cstring>
@ -464,6 +440,30 @@ killall md5progress.sh
</property> </property>
</widget> </widget>
</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>
<widget class="QWidget"> <widget class="QWidget">
<property name="name"> <property name="name">
@ -1293,6 +1293,52 @@ dcop @dcopid KommanderIf setBusyCursor false
<set>WordBreak|AlignTop|AlignHCenter</set> <set>WordBreak|AlignTop|AlignHCenter</set>
</property> </property>
</widget> </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"> <widget class="Label">
<property name="name"> <property name="name">
<cstring>installhint</cstring> <cstring>installhint</cstring>
@ -1342,52 +1388,6 @@ dcop @dcopid KommanderIf setBusyCursor false
</stringlist> </stringlist>
</property> </property>
</widget> </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>
<widget class="CheckBox"> <widget class="CheckBox">
<property name="name"> <property name="name">
@ -1405,28 +1405,6 @@ dcop @dcopid KommanderIf setBusyCursor false
<string></string> <string></string>
</property> </property>
</widget> </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"> <widget class="Label">
<property name="name"> <property name="name">
<cstring>Label21_2_3</cstring> <cstring>Label21_2_3</cstring>
@ -1451,6 +1429,28 @@ dcop @dcopid KommanderIf setBusyCursor false
<set>AlignCenter</set> <set>AlignCenter</set>
</property> </property>
</widget> </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"> <widget class="ScriptObject">
<property name="name"> <property name="name">
<cstring>scandisks</cstring> <cstring>scandisks</cstring>
@ -1468,7 +1468,11 @@ dcop @dcopid KommanderIf setBusyCursor false
<string>@partitionslabel.clear <string>@partitionslabel.clear
@BackBox.setChecked(true) @BackBox.setChecked(true)
@execBegin @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= partlabel=
linuxok= linuxok=
swapok= swapok=
@ -1483,59 +1487,58 @@ fi
systemrequired=5120 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")" 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 for d in $devices; do
diskdevice=`hal-get-property --udi $s --key block.device` diskdevice=${d/\/dev\/}
vendor=`hal-get-property --udi $s --key info.vendor` native_path=`get_udisks_key $d native-path`
product=`hal-get-property --udi $s --key info.product` [ ! -e $native_path/partition ] || continue
hotpluggable=`hal-get-property --udi $s --key storage.hotpluggable` || hotpluggable="false" vendor=`get_udisks_key $d vendor`
partscheme=`hal-get-property --udi $s --key storage.partitioning_scheme` product=`get_udisks_key $d model`
[ "$partscheme" ] || continue is_system_internal=`get_udisks_key $d "system internal"`
disksize=`hal-get-property --udi $s --key storage.size` [ "$is_system_internal" != "1" -a @removablebox.checked == 0 ] &amp;&amp; continue
disksize=`expr $disksize / 1024 / 1024 / 1024` 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=
volumes=`hal-find-by-property --key info.parent --string $s` for v in $volumes; do
thisdisk= device=/dev/$v
[ "$hotpluggable" = "true" -a @removablebox.checked == 0 ] &amp;&amp; continue v_native_path=$native_path/$v
for udi in $volumes; do volsize=`get_udisks_key $device size`
device=`hal-get-property --udi $udi --key block.device` volsize=`expr $volsize / 1024 / 1024`
blocksize=`hal-get-property --udi $udi --key volume.block_size` volname=`get_udisks_key $device label`
numblocks=`hal-get-property --udi $udi --key volume.num_blocks` parttype=`get_udisks_key $device usage`
volsize=`expr $blocksize \* $numblocks / 1024 / 1024` [ "$parttype" ] || parttype="unknown"
volname=`hal-get-property --udi $udi --key volume.label` fstype=`get_udisks_key $device type`
[ "$volname" ] || volname="" [ "$fstype" ] || fstype="unformatted"
parttype=`hal-get-property --udi $udi --key volume.partition.type` add_info=""
[ "$parttype" ] || parttype="unknown" [ "$is_system_internal" = "1" ] || add_info=",removable"
fstype=`hal-get-property --udi $udi --key volume.fstype` [ "$volsize" -gt "0" ] || continue
[ "$fstype" ] || fstype="unformatted"
add_info="" 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;"
[ "$hotpluggable" = "true" ] &amp;&amp; {
add_info=",removable" case "$fstype" in
}
[ "$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
swap) if [ $swaprequired -le $volsize ]; then 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;" 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) linux|ext2|ext3|ext4|reiserfs|reiser4)
if [ $systemrequired -le $volsize ]; then 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;" thispart="$thispart&lt;td&gt;&lt;b&gt;@i18n("OK for system")&lt;/b&gt;&lt;/td&gt;"
fi fi
;; ;;
*) thispart="$thispart&lt;td&gt;&lt;/td&gt;" *) thispart="$thispart&lt;td&gt;&lt;/td&gt;"
;; ;;
esac esac
thisdisk="${thispart}${thisdisk}" 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}" 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 done
dcop @dcopid KommanderIf setText partitionslabel "$partlabel" dcop @dcopid KommanderIf setText partitionslabel "$partlabel"
if [ @swapcheckbox.checked = 1 ]; then if [ @swapcheckbox.checked = 1 ]; then
swapok="1" swapok="1"
@ -1552,48 +1555,6 @@ else
fi fi
dcop @dcopid KommanderIf setText installhint "$insthint" dcop @dcopid KommanderIf setText installhint "$insthint"
@execEnd @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> </string>
</stringlist> </stringlist>
</property> </property>
@ -1619,12 +1580,18 @@ done
@scandisks.execute() @scandisks.execute()
@rebootneededbox.setChecked(false) @rebootneededbox.setChecked(false)
@execBegin @execBegin
storages=`hal-find-by-capability --capability storage` function get_udisks_key() {
for s in $storages; do LANG=C udisks --show-info $1 | grep " $2:" | head -n1 | sed "s|[[:space:]]*$2:[[:space:]]*\(.*\)|\1|"
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 devices=`udisks --enumerate-device-files | grep -v /dev/disk | sort -n -r`
[ "$partscheme" = "none" ] &amp;&amp; dcop @dcopid KommanderIf setChecked rebootneededbox true 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 done
@execEnd @execEnd
@setGlobal("rebootquest","0") @setGlobal("rebootquest","0")
@ -1638,6 +1605,52 @@ else
dcop ksmserver ksmserver logout 0 1 1 dcop ksmserver ksmserver logout 0 1 1
fi fi
@endif @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> </string>
</stringlist> </stringlist>
</property> </property>
@ -2074,62 +2087,6 @@ fi
</hbox> </hbox>
</widget> </widget>
</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"> <widget class="ScriptObject">
<property name="name"> <property name="name">
<cstring>scanDevices</cstring> <cstring>scanDevices</cstring>
@ -2148,39 +2105,43 @@ fi
@BackBox.setChecked(true) @BackBox.setChecked(true)
@NextBox.setChecked(false) @NextBox.setChecked(false)
@execBegin @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; { rpm -q openmamba-devel &amp;&amp; {
dcop @dcopid KommanderIf "setEnabled(QString,bool)" stablebox true dcop @dcopid KommanderIf "setEnabled(QString,bool)" stablebox true
dcop @dcopid KommanderIf "setEnabled(QString,bool)" stablelabel 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= partlabel=
for udi in $volumes; do for device in $devices; do
device=`hal-get-property --udi $udi --key block.device` native_path=`get_udisks_key $device native-path`
parent_udi=`hal-get-property --udi $udi --key block.storage_device` [ -e $native_path/partition ] || continue
hotpluggable=`hal-get-property --udi $parent_udi --key storage.hotpluggable` || hotpluggable="false" is_system_internal=`get_udisks_key $device "system internal"`
blocksize=`hal-get-property --udi $udi --key volume.block_size` volsize=`get_udisks_key $device size`
numblocks=`hal-get-property --udi $udi --key volume.num_blocks` volsize=`expr $volsize / 1024 / 1024`
volsize=`expr $blocksize \* $numblocks / 1024 / 1024` volname=`get_udisks_key $device label`
volname=`hal-get-property --udi $udi --key volume.label`
[ "$volname" ] || volname="unnamed" [ "$volname" ] || volname="unnamed"
parttype=`hal-get-property --udi $udi --key volume.partition.type` parttype=`get_udisks_key $device usage`
[ "$parttype" ] || parttype="unknown" [ "$parttype" ] || parttype="unknown"
partscheme=`hal-get-property --udi $udi --key volume.partition.scheme` partscheme=`get_udisks_key $device scheme`
[ "$partscheme" ] || partscheme="unknown" [ "$partscheme" ] || partscheme="unknown"
fstype=`hal-get-property --udi $udi --key volume.fstype` fstype=`get_udisks_key $device type`
[ "$fstype" ] || fstype="unformatted" [ "$fstype" ] || fstype="unformatted"
add_info="" add_info=""
[ "$hotpluggable" = "true" ] &amp;&amp; { [ "$is_system_internal" = "1" ] || {
add_info=",removable" add_info=",removable"
[ @removablebox.checked == 1 ] || continue [ @removablebox.checked == 1 ] || continue
} }
if [ "$partscheme" == "mbr" -o "$partscheme" == "embr" ]; then if [ "$partscheme" == "mbr" -o "$partscheme" == "embr" ]; then
partlabel="$partlabel&lt;br&gt;${device:5:5} $fstype $volname $volsize MB" partlabel="$partlabel&lt;br&gt;${device:5:5} $fstype $volname $volsize MB"
case "$parttype" in case "$fstype" in
0x82) ;; ext2|ext3|ext4|reiserfs|reiser4|unformatted)
0x83) 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:5} ($fstype,$volname,$volsize MB${add_info})" 0 ;;
*) ;; *) ;;
esac esac
elif [ "$partscheme" == "gpt" -o "$partscheme" == "unknown" -a $volsize -gt 0 ]; then elif [ "$partscheme" == "gpt" -o "$partscheme" == "unknown" -a $volsize -gt 0 ]; then
@ -2204,6 +2165,57 @@ done
</stringlist> </stringlist>
</property> </property>
</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
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>
<widget class="QWidget"> <widget class="QWidget">
<property name="name"> <property name="name">
@ -2586,6 +2598,30 @@ done
</property> </property>
</widget> </widget>
</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"> <widget class="ScriptObject">
<property name="name"> <property name="name">
<cstring>setlabel_2</cstring> <cstring>setlabel_2</cstring>
@ -2618,7 +2654,6 @@ done
fi fi
@dcop(@dcopid, KommanderIf, enableWidget(QString,bool), next, true) @dcop(@dcopid, KommanderIf, enableWidget(QString,bool), next, true)
@BackBox.setChecked(true) @BackBox.setChecked(true)
parent_udi=`hal-find-by-property --key block.device --string /dev/$currdev`
dcop @dcopid KommanderIf "setCurrentItem(int)" 0 dcop @dcopid KommanderIf "setCurrentItem(int)" 0
@endif @endif
@execEnd @execEnd
@ -2644,42 +2679,45 @@ done
@BackBox.setChecked(true) @BackBox.setChecked(true)
@NextBox.setChecked(true) @NextBox.setChecked(true)
@execBegin @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= partlabel=
installdevice=@String.section(@devicesbox.item(@devicesbox.currentItem)," ",0) 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 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 for device in $devices; do
device=`hal-get-property --udi $udi --key block.device`
[ "${device:5:5}" = "$installdevice" ] &amp;&amp; continue [ "${device:5:5}" = "$installdevice" ] &amp;&amp; continue
parent_udi=`hal-get-property --udi $udi --key block.storage_device` native_path=`get_udisks_key $device native-path`
hotpluggable=`hal-get-property --udi $parent_udi --key storage.hotpluggable` || hotpluggable="false" [ -e $native_path/partition ] || continue
blocksize=`hal-get-property --udi $udi --key volume.block_size` is_system_internal=`get_udisks_key $device "system internal"`
numblocks=`hal-get-property --udi $udi --key volume.num_blocks` volsize=`get_udisks_key $device size`
volsize=`expr $blocksize \* $numblocks / 1024 / 1024` volsize=`expr $volsize / 1024 / 1024`
volname=`hal-get-property --udi $udi --key volume.label` volname=`get_udisks_key $device label`
[ "$volname" ] || volname="unnamed" [ "$volname" ] || volname="unnamed"
parttype=`hal-get-property --udi $udi --key volume.partition.type` parttype=`get_udisks_key $device usage`
[ "$parttype" ] || parttype="unknown" [ "$parttype" ] || parttype="unknown"
partscheme=`hal-get-property --udi $udi --key volume.partition.scheme` partscheme=`get_udisks_key $device scheme`
[ "$partscheme" ] || partscheme="unknown" [ "$partscheme" ] || partscheme="unknown"
fstype=`hal-get-property --udi $udi --key volume.fstype` fstype=`get_udisks_key $device type`
[ "$fstype" ] || fstype="unformatted" [ "$fstype" ] || fstype="unformatted"
add_info="" add_info=""
[ "$hotpluggable" = "true" ] &amp;&amp; { [ "$is_system_internal" = "1" ] || {
add_info=",removable" add_info=",removable"
[ @removablebox.checked == 1 ] || continue [ @removablebox.checked == 1 ] || continue
} }
if [ "$partscheme" == "mbr" -o "$partscheme" == "embr" ]; then if [ "$partscheme" == "mbr" -o "$partscheme" == "embr" ]; then
partlabel="$partlabel&lt;br&gt;${device:5:5} $fstype $volname $volsize MB" partlabel="$partlabel&lt;br&gt;${device:5:5} $fstype $volname $volsize MB"
case "$parttype" in case "$fstype" in
0x82) ;; ext2|ext3|ext4|reiserfs|reiser4|unformatted)
0x83) 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:5} ($fstype,$volname,$volsize MB${add_info})" 1 ;;
*) ;; *) ;;
esac esac
elif [ "$partscheme" == "gpt" -o "$partscheme" == "unknown" -a $volsize -gt 0 ]; then elif [ "$partscheme" == "gpt" -o "$partscheme" == "unknown" -a $volsize -gt 0 ]; then
case "$fstype" in case "$fstype" in
swap|iso9660) ;; 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 esac
fi fi
@ -2689,30 +2727,6 @@ done
</stringlist> </stringlist>
</property> </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> </widget>
<widget class="QWidget"> <widget class="QWidget">
<property name="name"> <property name="name">
@ -2998,41 +3012,41 @@ fi
@chainloadbox.clear @chainloadbox.clear
@setBootableCheckbox.execute() @setBootableCheckbox.execute()
@execBegin @execBegin
function get_udisks_key() {
LANG=C udisks --show-info $1 | grep " $2:" | head -n1 | sed "s|[[:space:]]*$2:[[:space:]]*\(.*\)|\1|"
}
conffile=~/.installer.conf conffile=~/.installer.conf
[ -e $conffile ] &amp;&amp; mv ${conffile} ${conffile}~ [ -e $conffile ] &amp;&amp; mv ${conffile} ${conffile}~
installdevice=@String.section(@devicesbox.item(@devicesbox.currentItem)," ",0) 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= partlabel=
for udi in $volumes; do for device in $devices; do
device=`hal-get-property --udi $udi --key block.device`
[ "${device:5:5}" = "$installdevice" ] &amp;&amp; continue [ "${device:5:5}" = "$installdevice" ] &amp;&amp; continue
parent_udi=`hal-get-property --udi $udi --key block.storage_device` native_path=`get_udisks_key $device native-path`
hotpluggable=`hal-get-property --udi $parent_udi --key storage.hotpluggable` || hotpluggable="false" [ -e $native_path/partition ] || continue
blocksize=`hal-get-property --udi $udi --key volume.block_size` is_system_internal=`get_udisks_key $device "system internal"`
numblocks=`hal-get-property --udi $udi --key volume.num_blocks` volsize=`get_udisks_key $device size`
volsize=`expr $blocksize \* $numblocks / 1024 / 1024` volsize=`expr $volsize / 1024 / 1024`
[ $volsize = 0 ] &amp;&amp; continue volname=`get_udisks_key $device label`
volname=`hal-get-property --udi $udi --key volume.label`
mount_point=`hal-get-property --udi $udi --key volume.mount_point`
[ "$volname" ] || volname="unnamed" [ "$volname" ] || volname="unnamed"
parttype=`hal-get-property --udi $udi --key volume.partition.type` parttype=`get_udisks_key $device usage`
[ "$parttype" ] || parttype="unknown" [ "$parttype" ] || parttype="unknown"
partscheme=`hal-get-property --udi $udi --key volume.partition.scheme` partscheme=`get_udisks_key $device scheme`
[ "$partscheme" ] || partscheme="unknown" [ "$partscheme" ] || partscheme="unknown"
fstype=`hal-get-property --udi $udi --key volume.fstype` fstype=`get_udisks_key $device type`
[ "$fstype" ] || fstype="unformatted" [ "$fstype" ] || fstype="unformatted"
add_info="" add_info=""
[ "$hotpluggable" = "true" ] &amp;&amp; { [ "$is_system_internal" = "1" ] || {
add_info=",removable" add_info=",removable"
[ @removablebox.checked == 1 ] || continue [ @removablebox.checked == 1 ] || continue
} }
if [ "$partscheme" == "mbr" -o "$partscheme" == "embr" ]; then if [ "$partscheme" == "mbr" -o "$partscheme" == "embr" ]; then
partlabel="$partlabel&lt;br&gt;${device:5:5} $fstype $volname $volsize MB" partlabel="$partlabel&lt;br&gt;${device:5:5} $fstype $volname $volsize MB"
case "$parttype" in case "$fstype" in
0x82) ;; swap|iso9660|unformatted) ;;
0x83) ;; 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 "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})" 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 done
} }
# function dev2gdev() function get_udisks_key() {
# convert the device name to the string used by grub LANG=C udisks --show-info $1 | grep " $2:" | head -n1 | sed "s|[[:space:]]*$2:[[:space:]]*\(.*\)|\1|"
# 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
} }
[ "$1" = "-y" ] || { [ "$1" = "-y" ] || {
@ -117,23 +96,6 @@ function dev2gdev() {
exit 0 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 DCOPID=$2
echo $"\ echo $"\
@ -212,15 +174,16 @@ tempfile=`tempfile 2>/dev/null`
mapfile=`tempfile 2>/dev/null` mapfile=`tempfile 2>/dev/null`
# generate current volumes sorted list with driver information # 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 for s in $storages; do
device=`hal-get-property --udi $s --key block.device` native_path=`get_udisks_key $device native-path`
linux_driver=`find_driver_for_udi $s` [ -e $native_path/partition ] && continue
hotpluggable=`hal-get-property --udi $s --key storage.hotpluggable` || hotpluggable="false" 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" ] && \ [ "${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 if [ "$INSTALL_BOOTLOADER_DEVICE" = "$device" ]; then
INSTALL_BOOTLOADER_DEVICE_HOTPLUGGABLE=$hotpluggable INSTALL_BOOTLOADER_DEVICE_INTERNAL=$is_system_internal
fi fi
done done
# sort # sort
@ -462,7 +425,7 @@ if [ "$INSTALL_BOOTLOADER_DEVICE" ]; then
fi fi
done done
echo "GRUB_INSTALL_DEVICE=$INSTALL_BOOTLOADER_DEVICE_BYID" >> $MOUNTPOINT/etc/sysconfig/grub 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 $"Installing grub bootloader on removable device $INSTALL_BOOTLOADER_DEVICE"
echo "(hd0) $INSTALL_BOOTLOADER_DEVICE" > $MOUNTPOINT/boot/grub/device.map echo "(hd0) $INSTALL_BOOTLOADER_DEVICE" > $MOUNTPOINT/boot/grub/device.map
grub-install $INSTALL_BOOTLOADER_DEVICE --root-directory=$MOUNTPOINT --no-floppy --force grub-install $INSTALL_BOOTLOADER_DEVICE --root-directory=$MOUNTPOINT --no-floppy --force