From 5ca34737837827d5edf2beace58a36c37ddc648e Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Mon, 5 Sep 2011 01:41:11 +0200 Subject: [PATCH] usbinstall: use udisk; drop hal --- usbinstall/usbinstall.sh | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/usbinstall/usbinstall.sh b/usbinstall/usbinstall.sh index 2f699f1..0072956 100644 --- a/usbinstall/usbinstall.sh +++ b/usbinstall/usbinstall.sh @@ -17,8 +17,12 @@ filecpio=""~/openmamba-bootusb-it-snapshot-"$version".i586.cpio.gz"" TEXTDOMAIN=usbinstall TEXTDOMAINDIR=/usr/share/locale/ -# formattazione della chiavetta e installazione dei file necessari al boot di openmamba +function get_udisks_key() { + LANG=C udisks --show-info $1 | grep " $2:" | head -n1 | sed "s|[[:space:]]*$2:[[:space:]]*\(.*\)|\1|" +} + +# formattazione della chiavetta e installazione dei file necessari al boot di openmamba installa(){ conferma=0 chiave=$c @@ -97,21 +101,23 @@ exit 0 } scansione() { -#scansione di hal alla ricerca di tutte le periferiche di archiviazione usb +#ricerca di tutte le periferiche di archiviazione usb +devices=`udisks --enumerate-device-files | grep -v /dev/disk | sort -n` c=0 -for udi in $(/usr/bin/hal-find-by-capability --capability storage) -do - if [[ $(hal-get-property --udi $udi --key storage.removable) = "true" && - $(hal-get-property --udi $udi --key storage.drive_type) = "disk" ]]; then - c=$((c+1)) - device[$c]=$(hal-get-property --udi $udi --key block.device) - vendor[$c]=$(hal-get-property --udi $udi --key storage.vendor) - model[$c]=$(hal-get-property --udi $udi --key storage.model) - parent_udi=$(hal-find-by-property --key block.storage_device --string $udi) -# mount[$c]=$(hal-get-property --udi $parent_udi --key volume.mount_point) -# label[$c]=$(hal-get-property --udi $parent_udi --key volume.label) - media_size[$c]=$(hal-get-property --udi $udi --key storage.removable.media_size) - size[$c]=$(( ${media_size[$c]}/(1000*1000*1000))) + +for dev in $devices; do + native_path=`get_udisks_key $dev native-path` + vend=`get_udisks_key $dev vendor` + prod=`get_udisks_key $dev model` + [ -e $native_path/partition ] || continue + is_system_internal=`get_udisks_key $dev "system internal"` + if [ "$is_system_internal" != "1" ]; then + c=$((c+1)) + device[$c]=$dev + vendor[$c]=$vend + model[$c]=$prod + media_size[$c]=`get_udisks_key $dev size` + size[$c]=$((${media_size[$c]}/(1000*1000*1000))) fi done if [ $c -eq 0 ]; then