installer.kmdr: calculated needed system space using medium occupacy (/squashfs)

This commit is contained in:
Silvan Calarco 2011-09-04 22:47:19 +02:00
parent 670a071a66
commit 3eae6ced60

View File

@ -1451,114 +1451,6 @@ dcop @dcopid KommanderIf setBusyCursor false
<set>WordBreak|AlignVCenter</set>
</property>
</widget>
<widget class="ScriptObject">
<property name="name">
<cstring>scandisks</cstring>
</property>
<property name="geometry">
<rect>
<x>550</x>
<y>0</y>
<width>32</width>
<height>32</height>
</rect>
</property>
<property name="associations" stdset="0">
<stringlist>
<string>@partitionslabel.clear
@BackBox.setChecked(true)
@execBegin
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=
memsize=`cat /proc/meminfo |grep MemTotal:|sed "s|[^0-9]||g"`
if [ $memsize -lt 1048576 ]; then
swaprequired=`expr $memsize / 512`
elif [ $memsize -lt 4194304 ]; then
swaprequired=`expr $memsize / 683`
else
swaprequired=`expr $memsize / 1024`
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 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
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=1
thispart="$thispart&lt;td&gt;&lt;b&gt;@i18n("OK for swap")&lt;/b&gt;&lt;/td&gt;"
fi
;;
linux|ext2|ext3|ext4|reiserfs|reiser4)
if [ $systemrequired -le $volsize ]; then
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})&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"
fi
insthint=""
[ "$linuxok" ] || insthint="${insthint}@i18n("You need to create a Linux type partition&lt;br&gt;")"
[ "$swapok" ] || insthint="${insthint}@i18n("You need to create a SWAP type partition&lt;br&gt;")"
if [ "$linuxok" -a "$swapok" ]; then
insthint="${insthint}&lt;b&gt;@i18n("GOOD, you have both a Linux and SWAP partition.")&lt;/b&gt;&lt;br&gt;@i18n("Please, modify the partitions or press Next to proceed with the installation.")"
dcop @dcopid KommanderIf setChecked NextBox "true"
else
insthint="${insthint}&lt;br&gt;&lt;br&gt;@i18n("Please, press the button above and modify the partitions as needed before proceeding.")&lt;br&gt;"
dcop @dcopid KommanderIf setChecked NextBox "false"
fi
dcop @dcopid KommanderIf setText installhint "$insthint"
@execEnd
</string>
</stringlist>
</property>
</widget>
<widget class="ExecButton">
<property name="name">
<cstring>PartToolButton</cstring>
@ -1651,6 +1543,120 @@ done
@exec("dcop kded kded loadModule medianotifier")
@PartitionBox.setEnabled(true)
@BootloaderBox.setEnabled(true)
</string>
</stringlist>
</property>
</widget>
<widget class="ScriptObject">
<property name="name">
<cstring>scandisks</cstring>
</property>
<property name="geometry">
<rect>
<x>550</x>
<y>0</y>
<width>32</width>
<height>32</height>
</rect>
</property>
<property name="associations" stdset="0">
<stringlist>
<string>@partitionslabel.clear
@BackBox.setChecked(true)
@execBegin
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=
memsize=`cat /proc/meminfo |grep MemTotal:|sed "s|[^0-9]||g"`
if [ $memsize -lt 1048576 ]; then
swaprequired=`expr $memsize / 512`
elif [ $memsize -lt 4194304 ]; then
swaprequired=`expr $memsize / 683`
else
swaprequired=`expr $memsize / 1024`
fi
if [ -e /squashfs ]; then
systemoccupacy=`du -sm /squashfs | sed "s|[[:space:]].*||"`
systemrequired=`expr $systemoccupacy \* 2`
else
systemrequired=5120
fi
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 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
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=1
thispart="$thispart&lt;td&gt;&lt;b&gt;@i18n("OK for swap")&lt;/b&gt;&lt;/td&gt;"
fi
;;
linux|ext2|ext3|ext4|reiserfs|reiser4)
if [ $systemrequired -le $volsize ]; then
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})&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"
fi
insthint=""
[ "$linuxok" ] || insthint="${insthint}@i18n("You need to create a Linux type partition&lt;br&gt;")"
[ "$swapok" ] || insthint="${insthint}@i18n("You need to create a SWAP type partition&lt;br&gt;")"
if [ "$linuxok" -a "$swapok" ]; then
insthint="${insthint}&lt;b&gt;@i18n("GOOD, you have both a Linux and SWAP partition.")&lt;/b&gt;&lt;br&gt;@i18n("Please, modify the partitions or press Next to proceed with the installation.")"
dcop @dcopid KommanderIf setChecked NextBox "true"
else
insthint="${insthint}&lt;br&gt;&lt;br&gt;@i18n("Please, press the button above and modify the partitions as needed before proceeding.")&lt;br&gt;"
dcop @dcopid KommanderIf setChecked NextBox "false"
fi
dcop @dcopid KommanderIf setText installhint "$insthint"
@execEnd
</string>
</stringlist>
</property>
@ -2087,84 +2093,6 @@ done
</hbox>
</widget>
</widget>
<widget class="ScriptObject">
<property name="name">
<cstring>scanDevices</cstring>
</property>
<property name="geometry">
<rect>
<x>540</x>
<y>0</y>
<width>32</width>
<height>32</height>
</rect>
</property>
<property name="associations" stdset="0">
<stringlist>
<string>@devicesbox.clear
@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
}
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
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=`get_udisks_key $device usage`
[ "$parttype" ] || parttype="unknown"
partscheme=`get_udisks_key $device scheme`
[ "$partscheme" ] || partscheme="unknown"
fstype=`get_udisks_key $device type`
[ "$fstype" ] || fstype="unformatted"
add_info=""
[ "$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 "$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
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 ;;
*) ;;
esac
fi
done
@execEnd
@if (@devicesbox.count == "0")
@switch(@Message.question(@i18n("No installable partitions found, do you want to launch the partitioning tool?"), @i18n("No installable partitions found"), Launch, Abort))
@case(1)
@RunPartTool.execute()
@case(2)
@Message.info(@i18n("Installation aborted."))
@dcop(@dcopid, MainApplication-Interface, quit())
@end
@endif</string>
</stringlist>
</property>
</widget>
<widget class="ScriptObject">
<property name="name">
<cstring>setlabel</cstring>
@ -2216,6 +2144,92 @@ function get_udisks_key() {
</stringlist>
</property>
</widget>
<widget class="ScriptObject">
<property name="name">
<cstring>scanDevices</cstring>
</property>
<property name="geometry">
<rect>
<x>540</x>
<y>0</y>
<width>32</width>
<height>32</height>
</rect>
</property>
<property name="associations" stdset="0">
<stringlist>
<string>@devicesbox.clear
@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
}
if [ -e /squashfs ]; then
systemoccupacy=`du -sm /squashfs | sed "s|[[:space:]].*||"`
systemrequired=`expr $systemoccupacy \* 2`
else
systemrequired=5120
fi
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
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`
[ "$volname" ] || volname="unnamed"
parttype=`get_udisks_key $device usage`
[ "$parttype" ] || parttype="unknown"
partscheme=`get_udisks_key $device scheme`
[ "$partscheme" ] || partscheme="unknown"
fstype=`get_udisks_key $device type`
[ "$fstype" ] || fstype="unformatted"
add_info=""
[ "$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 "$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
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 ;;
*) ;;
esac
fi
done
@execEnd
@if (@devicesbox.count == "0")
@switch(@Message.question(@i18n("No installable partitions found, do you want to launch the partitioning tool?"), @i18n("No installable partitions found"), Launch, Abort))
@case(1)
@RunPartTool.execute()
@case(2)
@Message.info(@i18n("Installation aborted."))
@dcop(@dcopid, MainApplication-Interface, quit())
@end
@endif</string>
</stringlist>
</property>
</widget>
</widget>
<widget class="QWidget">
<property name="name">