diff options
author | Dieter Plaetinck <dieter@plaetinck.be> | 2008-11-22 14:28:03 +0100 |
---|---|---|
committer | Dieter Plaetinck <dieter@plaetinck.be> | 2008-11-22 14:28:03 +0100 |
commit | 95aa9229661a362c65eb94f6c042e92dc5277202 (patch) | |
tree | b902b831a3b720212ac556b053cfbc0369ae42b2 /src | |
parent | 07a3d23197d60b357f3b42e0cc2e490d07702982 (diff) |
made find{partitions,disks} more flexible for output control + tiny bit more work in interactive_filesystems
Diffstat (limited to 'src')
-rw-r--r-- | src/core/libs/lib-blockdevices-filesystems.sh | 55 | ||||
-rw-r--r-- | src/core/libs/lib-ui-interactive.sh | 21 |
2 files changed, 45 insertions, 31 deletions
diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh index 7624b2c..d51bcf1 100644 --- a/src/core/libs/lib-blockdevices-filesystems.sh +++ b/src/core/libs/lib-blockdevices-filesystems.sh @@ -48,39 +48,45 @@ target_umountall() } -# literally taken from setup script +# taken from setup script, modified for separator control +# $1 set to 1 to echo a newline after device instead of a space (optional) +# $2 extra things to echo for each device (optional) finddisks() { workdir="$PWD" cd /sys/block # ide devices for dev in $(ls | egrep '^hd'); do if [ "$(cat $dev/device/media)" = "disk" ]; then - echo "/dev/$dev" - [ "$1" ] && echo $1 + echo -n "/dev/$dev" + [ "$1" = 1 ] && echo || echo -n ' ' + [ "$2" ] && echo $2 fi done #scsi/sata devices for dev in $(ls | egrep '^sd'); do # TODO: what is the significance of 5? ASKDEV if ! [ "$(cat $dev/device/type)" = "5" ]; then - echo "/dev/$dev" - [ "$1" ] && echo $1 + echo -n "/dev/$dev" + [ "$1" = 1 ] && echo || echo -n ' ' + [ "$2" ] && echo $2 fi done # cciss controllers if [ -d /dev/cciss ] ; then cd /dev/cciss for dev in $(ls | egrep -v 'p'); do - echo "/dev/cciss/$dev" - [ "$1" ] && echo $1 + echo -n "/dev/cciss/$dev" + [ "$1" = 1 ] && echo || echo -n ' ' + [ "$2" ] && echo $2 done fi # Smart 2 controllers if [ -d /dev/ida ] ; then cd /dev/ida for dev in $(ls | egrep -v 'p'); do - echo "/dev/ida/$dev" - [ "$1" ] && echo $1 + echo -n"/dev/ida/$dev" + [ "$1" = 1 ] && echo || echo -n ' ' + [ "$2" ] && echo $2 done fi cd "$workdir" @@ -101,7 +107,9 @@ getuuid() } -# taken from setup. slightly optimized. +# taken from setup script, slightly optimized and modified for separator control +# $1 set to 1 to echo a newline after device instead of a space (optional) +# $2 extra things to echo for each device (optional) findpartitions() { workdir="$PWD" for devpath in $(finddisks) @@ -115,8 +123,9 @@ findpartitions() { then if [ -d $part ] then - echo "/dev/$part" - [ "$1" ] && echo $1 + echo -n "/dev/$part" + [ "$1" = 1 ] && echo || echo -n ' ' + [ "$2" ] && echo $2 fi fi done @@ -124,16 +133,18 @@ findpartitions() { # include any mapped devices for devpath in $(ls /dev/mapper 2>/dev/null | grep -v control) do - echo "/dev/mapper/$devpath" - [ "$1" ] && echo $1 + echo -n "/dev/mapper/$devpath" + [ "$1" = 1 ] && echo || echo -n ' ' + [ "$2" ] && echo $2 done # include any raid md devices for devpath in $(ls -d /dev/md* | grep '[0-9]' 2>/dev/null) do if grep -qw $(echo $devpath /proc/mdstat | sed -e 's|/dev/||g') then - echo "$devpath" - [ "$1" ] && echo $1 + echo -n "$devpath" + [ "$1" = 1 ] && echo || echo -n ' ' + [ "$2" ] && echo $2 fi done # inlcude cciss controllers @@ -142,8 +153,9 @@ findpartitions() { cd /dev/cciss for dev in $(ls | egrep 'p') do - echo "/dev/cciss/$dev" - [ "$1" ] && echo $1 + echo -n "/dev/cciss/$dev" + [ "$1" = 1 ] && echo || echo -n ' ' + [ "$2" ] && echo $2 done fi # inlcude Smart 2 controllers @@ -152,8 +164,9 @@ findpartitions() { cd /dev/ida for dev in $(ls | egrep 'p') do - echo "/dev/ida/$dev" - [ "$1" ] && echo $1 + echo -n "/dev/ida/$dev" + [ "$1" = 1 ] && echo || echo -n ' ' + [ "$2" ] && echo $2 done fi @@ -376,8 +389,6 @@ fix_filesystems_deprecated () #TMP_PARTITIONS # disk partition-scheme - - # go over each disk in $TMP_PARTITIONS and partition it process_disks () { diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index 77b0033..4b3fae3 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -109,7 +109,7 @@ interactive_autoprepare() DISCS=$(finddisks) if [ $(echo $DISCS | wc -w) -gt 1 ]; then notify "Available Disks:\n\n$(_getavaildisks)\n" - ask_option no "Select the hard drive to use" $(finddisks _) || return 1 + ask_option no "Select the hard drive to use" $(finddisks 1 _) || return 1 DISC=$ANSWER_OPTION else DISC=$DISCS @@ -203,7 +203,7 @@ interactive_partition() { target_umountall # Select disk to partition - DISCS=$(finddisks _) + DISCS=$(finddisks 1 _) DISCS="$DISCS OTHER - DONE +" notify "Available Disks:\n\n$(_getavaildisks)\n" DISC="" @@ -242,13 +242,16 @@ interactive_filesystems() { # Let the user make filesystems and mountpoints USERHAPPY=0 + TMP_MENU=/home/arch/aif/runtime/.tmpmenu + findpartitions 0 'no filesystem, no mountpoint' > $TMP_MENU while [ "$USERHAPPY" = 0 ] do - PARTS=$(findpartitions _) - ask_option no "Add/edit partitions" $PARTS $UPCOMINGPARTS - ANSWER_OPTION - - #TODO: let user choose FS, mountpoint etc, and even create lvm pv's, dm_crypt stuff etc, create $UPCOMINGPARTS as needed + ask_option no "Add/edit partitions" `cat $TMP_MENU` + part=$ANSWER_OPTION + --default-item +_dia_DIALOG --menu "Select a filesystem for / and /home:" 13 45 6 $FSOPTS 2>$ANSWER || return 1 + FSTYPE=$(cat $ANSWER) + #TODO: let user choose FS, mountpoint etc, and even create lvm pv's, dm_crypt stuff etc, update entries in $TMP_MENU and add 'fake' ones as needed # also show the disks along with the fs, mountpoint that has been choosen (maybe) already done @@ -499,8 +502,8 @@ EOF [ "$EDITOR" ] || interactive_get_editor $EDITOR $grubmenu - DEVS=$(finddisks _) - DEVS="$DEVS $(findpartitions _)" + DEVS=$(finddisks 1 _) + DEVS="$DEVS $(findpartitions 1 _)" if [ "$DEVS" = "" ]; then notify "No hard drives were found" return 1 |