Skip to Content.
Sympa Menu

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

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 (4e89a85737c377dab20d99ff4ba067ff03293e04)
  • Date: Wed, 20 Aug 2008 17:39:25 -0500

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

src/enchant/menu/libmenu | 49 +++++++++++++++++++++++
src/enchant/menu/menu.sh | 34 ++++++++++++++++
src/enchant/menu/modules/disk | 88
++++++++++++++++++++++++++++++++++++++++++
3 files changed, 171 insertions(+)

New commits:
commit 4e89a85737c377dab20d99ff4ba067ff03293e04
Author: Karsten Behrmann <BearPerson AT sourcemage.org>
Commit: Karsten Behrmann <BearPerson AT sourcemage.org>

Some initial concept code for dialog-gui'd steps

diff --git a/src/enchant/menu/libmenu b/src/enchant/menu/libmenu
new file mode 100644
index 0000000..84e3de5
--- /dev/null
+++ b/src/enchant/menu/libmenu
@@ -0,0 +1,49 @@
+# Menu / checklist / whatever
+# If this returns 0, use result from dialog, otherwise the user cancelled
+function menu_step() {
+ "${DIALOG[@]}" "$@"
+ rc=$?
+ if [[ $rc == 0 ]] ;then # OK
+ return 0
+ elif [[ $rc == 1 ]] ;then # back
+ return 1
+ elif [[ $rc == 3 ]] ;then # abort/cancel
+ exit 1
+ else
+ echo "Unrecognized exit code $? from dialog, bailing out" >&2
+ exit 3
+ fi
+ return $rc
+}
+
+# Displays the doc blurb at the start of a step
+# Buttons: OK, main menu, shell
+# Only returns normally if the user pressed "OK", otherwise exits
+function menu_docbox() {
+ "${DIALOG[@]}" "$@"
+ rc=$?
+ if [[ $rc == 0 ]] ;then
+ ((STATE++))
+ elif [[ $rc == 1 ]] ;then # main menu
+ exit 1
+ elif [[ $rc == 3 ]] ;then # shell
+ exit 2
+ else
+ echo "Unrecognized exit code $? from dialog, bailing out" >&2
+ exit 3
+ fi
+}
+
+function menu_loop() {
+ STATE=initial
+ while [[ $STATE != mainmenu ]] ;do
+ $STATE || # Function call
+ {
+ echo "State $STATE failed (code $?), bailing out" >&2
+ exit 3
+ }
+ done
+
+ # Exit to main menu on normal completion of loop
+ exit 1
+}
diff --git a/src/enchant/menu/menu.sh b/src/enchant/menu/menu.sh
new file mode 100644
index 0000000..8d57743
--- /dev/null
+++ b/src/enchant/menu/menu.sh
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+. /usr/share/smgl.install/libenchant
+
+function main_menu() {
+}
+
+function main_loop() {
+ if $MENU ;then
+ main_menu
+ MENU=false
+ else
+ step=$(enchant_getstep)
+ if ! [[ -x /usr/share/smgl.install/menu/$step ]] ;then
+ echo "No gui code found for step $step, falling back to shell..."
+ exit
+ fi
+ /usr/share/smgl.install/menu/$step
+ rc=$?
+ if [[ $rc == 0 ]] ;then
+ : # Carry on with the next step, nothing to do
+ # (Step will have set the current installer step already)
+ elif [[ $rc == 1 ]] ;then
+ MENU=true
+ elif [[ $rc == 2 ]] ;then
+ echo "Switching to shell, type \e[1mmenu\e[1m to return to menu"
+ echo "Type \e[1mtodo\e1m to see the current step's documentation"
+ exit
+ else
+ echo "Bailing to shell (gui step returned $rc)..."
+ exit
+ fi
+ fi
+}
diff --git a/src/enchant/menu/modules/disk b/src/enchant/menu/modules/disk
new file mode 100644
index 0000000..eeb71c8
--- /dev/null
+++ b/src/enchant/menu/modules/disk
@@ -0,0 +1,88 @@
+#!/bin/bash
+# Exit code convention:
+# 0 - [re]launch menu for current step
+# 1 - display main menu
+# 2 - exit to shell (user-initiated)
+# * - exit to shell (unplanned)
+
+function initial() {
+ menu_docbox "Do the disk stuff"
+ STATE=get_part
+ return 0
+}
+
+function get_part() {
+ RESULT=$(dialog_menu /dev/hda1 /dev/sda2 custom)
+ rc=$?
+ if [[ $rc == 1 ]] ;then
+ STATE=initial
+ return 0
+ elif [[ $rc == 3 ]] ;then
+ STATE=finish
+ return 0
+ else
+ echo "Unrecognized exit code $? from dialog, bailing out" >&2
+ exit 3
+ fi
+
+ PARTITION=$RESULT
+ if [[ $PARTITION == custom ]] ;then
+ STATE=enter_part
+ else
+ STATE=get_fstype
+ fi
+}
+
+function enter_part() {
+ RESULT=$(menu_txtbox "Enter partition") ||
+ {
+ STATE=get_part
+ return 0
+ }
+ PARTITION=$RESULT
+ STATE=get_fstype
+}
+
+function get_fstype() {
+ RESULT=$(menu_menu ext2 ext3 jfs reiserfs xfs custom) ||
+ {
+ STATE=get_part
+ return 0
+ }
+ FSTYPE=$RESULT
+ MKFSCMD="mkfs.$FSTYPE $PARTITION"
+ STATE=confirm
+}
+
+function confirm() {
+ RESULT=$(menu_menu doit modify) ||
+ {
+ STATE=get_fstype
+ return 0
+ }
+ if [[ $RESULT == doit ]] ;then
+ STATE=result
+ else
+ STATE=tunecmd
+ fi
+}
+
+function result() {
+ echo "Creating filesystem..."
+ eval "$MKFSCMD"
+ rc=$?
+ if [[ $rc == 0 ]] ;then
+ STATE=get_partition
+ else
+ STATE=get_partition
+ STATE=tunecmd
+ fi
+}
+
+function finish() {
+ installer_next
+ exit 0
+}
+
+register_states initial get_part get_fstype confirm result finish
+menu_loop



  • [SM-Commit] GIT changes to devel-flux cauldron by Karsten Behrmann (4e89a85737c377dab20d99ff4ba067ff03293e04), Karsten Behrmann, 08/20/2008

Archive powered by MHonArc 2.6.24.

Top of Page