Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to devel-flux cauldron by Karsten Behrmann (6772e557df51b56dd53cf8aa1ed955aa0622da06)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Karsten Behrmann <scm AT sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to devel-flux cauldron by Karsten Behrmann (6772e557df51b56dd53cf8aa1ed955aa0622da06)
  • Date: Fri, 22 Aug 2008 12:40:10 -0500

GIT changes to devel-flux cauldron by Karsten Behrmann
<BearPerson AT sourcemage.org>:

src/enchant/menu/libmenu | 13 ++++--
src/enchant/menu/modules/disk-format | 75
+++++++++++++++++------------------
2 files changed, 47 insertions(+), 41 deletions(-)

New commits:
commit 6772e557df51b56dd53cf8aa1ed955aa0622da06
Author: Karsten Behrmann <BearPerson AT sourcemage.org>
Commit: Karsten Behrmann <BearPerson AT sourcemage.org>

Cope better with chatty mkfs commands, and fix minor format issue
("Formatting will erase all data! Are you sure you want to continue?"
- "Oh no, hold my hand, mommy, I'm scared.")

commit aa4749daed52398f538f04d2ee994540f5439f0e
Author: Karsten Behrmann <bearperson AT sourcemage.org>
Commit: Karsten Behrmann <bearperson AT sourcemage.org>

Fix up subshells so exit hits through, and some minor fixes

diff --git a/src/enchant/menu/libmenu b/src/enchant/menu/libmenu
index de09f69..5fd705c 100644
--- a/src/enchant/menu/libmenu
+++ b/src/enchant/menu/libmenu
@@ -35,7 +35,7 @@ function run_dialog() {
# Menu / checklist / whatever
# If this returns 0, use result from dialog, otherwise the user cancelled
function menu_step() {
- run_dialog --extra-button --extra-label "back" --cancel-label "abort" "$@"
+ ANSWER=$(run_dialog --extra-button --extra-label "back" --cancel-label
"abort" "$@")
rc=$?
if [[ $rc == 0 ]] ;then # OK
return 0
@@ -54,7 +54,7 @@ function menu_step() {
# Only returns normally if the user pressed "OK", otherwise exits
function menu_intro() {
run_dialog --extra-button --extra-label "shell" --yes-label "start" \
- --no-label "main menu" --title "$1" --yesno "$2" 0 0
+ --cancel-label "main menu" --title "$1" --yesno "$2" 0 0
rc=$?
if [[ $rc == 0 ]] ;then
return 0
@@ -71,8 +71,8 @@ function menu_central_menu() {
local title=$1
local text=$2
shift 2
- run_dialog --extra-button --extra-label "done" --cancel-label "back" \
- --title "$title" --menu "$text" 0 0 0 "$@"
+ ANSWER=$(run_dialog --extra-button --extra-label "done" --cancel-label
"back" \
+ --title "$title" --menu "$text" 0 0 0 "$@")
local rc=$?
if [[ $rc != 0 ]] && [[ $rc != 1 ]] && [[ $rc != 3 ]] ;then
die_cmd "dialog" $rc
@@ -81,6 +81,11 @@ function menu_central_menu() {
return $rc
}

+function menu_message() {
+ run_dialog --title "$1" --msgbox "$2" 0 0
+ true # Don't return nonzero even if user pressed ESC
+}
+
function menu_menu() {
local title=$1
local text=$2
diff --git a/src/enchant/menu/modules/disk-format
b/src/enchant/menu/modules/disk-format
index 9f1dea5..3d01341 100644
--- a/src/enchant/menu/modules/disk-format
+++ b/src/enchant/menu/modules/disk-format
@@ -1,5 +1,7 @@
#!/bin/bash

+. ../libmenu
+
load_partitions() {
# Device Boot Start End MiB #blocks Id System
#/dev/sda1 * 0+ 9538- 9539- 9767488+ 83 Linux
@@ -10,11 +12,11 @@ load_partitions() {
local PART SIZE TYPE
while read PART _ _ SIZE _ _ TYPE ;do
[[ "$TYPE" == "Empty" ]] && continue
- PARTITIONS[i++]=$PARTITION
+ SIZE=${SIZE%+}; SIZE=${SIZE%-}
+ PARTITIONS[i++]=$PART
PARTITIONS[i++]="$SIZE MiB, $TYPE"
# Poor man's pipe: doesn't spawn a subshell.
- done < <(sfdisk -l -uM | grep '^/' |
- sed 's/\*//;s/ \+/\t/g' | cut -d$'\t' -f1,5,7-)
+ done < <(sfdisk -l -uM | grep '^/' )
}

mkfs_command() {
@@ -22,8 +24,8 @@ mkfs_command() {
ext2) echo "mke2fs $2" ;;
ext3) echo "mke2fs -j $2" ;;
reiserfs) echo "mkreiserfs $2" ;;
- xfs) echo "mkfs.xfs -f $2" ;; # ignore existing partition
- jfs) echo "mkfs.jfs $2" ;;
+ xfs) echo "mkfs.xfs $2" ;; # ignore existing partition
+ jfs) echo "mkfs.jfs $2" ;; # ditto
swap) echo "mkswap $2" ;;
custom) echo "... $2" ;;
*) return 1 ;;
@@ -43,9 +45,9 @@ gone and this should do"

function get_part() {
load_partitions
- RESULT=$(menu_central_menu "Partition selection menu" \
+ menu_central_menu "Partition selection menu" \
"Select a partition to format or hit 'done'" \
- "${PARTITIONS[@]}" custom "Enter one manually")
+ "${PARTITIONS[@]}" custom "Enter one manually"
rc=$?
if [[ $rc == 1 ]] ;then
STATE=initial
@@ -55,7 +57,7 @@ function get_part() {
return 0
fi

- PARTITION=$RESULT
+ PARTITION=$ANSWER
if [[ $PARTITION == custom ]] ;then
STATE=enter_part
else
@@ -64,47 +66,47 @@ function get_part() {
}

function enter_part() {
- RESULT=$(menu_inputbox "Enter partition" \
+ menu_inputbox "Enter partition" \
"Please enter a partition to be formatted (including /dev/)" \
- "/dev/") ||
+ "/dev/" ||
{
STATE=get_part
return 0
}
- PARTITION=$RESULT
+ PARTITION=$ANSWER
STATE=get_fstype
}

function get_fstype() {
- RESULT=$(menu_menu "Filesystem Selection Menu" \
+ menu_menu "Filesystem Selection Menu" \
"Please select what filesystem to use for $PARTITION" \
"ext2" "Second Extended file system" \
"ext3" "Second Extended journaling file system" \
"reiserfs" "Reiserfs journaling file system" \
"xfs" "XFS journaling file system" \
"jfs" "JFS journaling file system" \
- "swap" "Swap partition"
- "custom" "your call") ||
+ "swap" "Swap partition" \
+ "custom" "your call" ||
{
STATE=get_part
return 0
}
- FSTYPE=$RESULT
+ FSTYPE=$ANSWER
MKFSCMD="$(mkfs_command $FSTYPE $PARTITION)"
STATE=confirm
}

function confirm() {
- RESULT=$(menu_menu "Confirmation Menu" \
+ menu_menu "Confirmation Menu" \
"Do you want to run the following command:
-$MKFSCMD"
- "doit" "Energize!"
- "modify" "Let me edit that line") ||
+$MKFSCMD" \
+ "doit" "Energize!" \
+ "modify" "Let me edit that line" ||
{
STATE=get_fstype
return 0
}
- if [[ $RESULT == doit ]] ;then
+ if [[ $ANSWER == doit ]] ;then
STATE=result
else
STATE=tunecmd
@@ -112,36 +114,35 @@ $MKFSCMD"
}

function tunecmd() {
- RESULT=$(menu_inputbox "Alter command" \
+ menu_inputbox "Alter command" \
"Alter the command below whatever way you like.
It will be executed as if typed on the command line." \
- "$MKFSCMD") ||
+ "$MKFSCMD" ||
{
- STATE=get_fstype
+ STATE=confirm
return 0
}
- MKFSCMD=$RESULT
+ MKFSCMD=$ANSWER
STATE=confirm
}

function result() {
echo "Creating filesystem..."
- eval "$MKFSCMD" 2>&1 | tee /tmp/mkfs.out
+ eval "$MKFSCMD"
rc=$?
if [[ $rc == 0 ]] ;then
- menu_message "Successful mkfs" \
- "Command ran successfully. Output was:
-$(cat /tmp/mkfs.out)"
- STATE=get_partition
+ echo "mkfs completed successfully. Press enter to continue..."
+ read LINE
+ STATE=get_part
else
- RESULT=$(menu_menu "mkfs failed" \
- "Command failed with exit status $rc. Output was:
-$(cat /tmp/mkfs.out)" \
- "edit" "Edit command and retry" \
- "return" "Return to partition menu")
- if [[ $RESULT == "return" ]] ;then
- STATE=get_partition
- else # return or "back"
+ cat <<EOF
+mkfs failed with exit status $rc. Enter 'cancel' to return
+to partition selection, anything else to re-edit the command...
+EOF
+ read ANSWER
+ if [[ $ANSWER == "cancel" ]] ;then
+ STATE=get_part
+ else
STATE=tunecmd
fi
fi



  • [SM-Commit] GIT changes to devel-flux cauldron by Karsten Behrmann (6772e557df51b56dd53cf8aa1ed955aa0622da06), Karsten Behrmann, 08/22/2008

Archive powered by MHonArc 2.6.24.

Top of Page