summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDieter Plaetinck <dieter@plaetinck.be>2009-03-17 21:48:35 +0100
committerDieter Plaetinck <dieter@plaetinck.be>2009-03-17 21:48:35 +0100
commit81472eb69c02b643eb0b66b712013f104d060bdf (patch)
treebe670d0425966fb93729296bf08e8744e3345c2a
parent49b6cbba082c7d9fd42d1a11713ad71ffebeaf27 (diff)
slight refactoring of how to run/monitor a program. i quite broke it though
-rw-r--r--TODO8
-rw-r--r--src/core/libs/lib-misc.sh28
-rw-r--r--src/core/libs/lib-software.sh17
3 files changed, 42 insertions, 11 deletions
diff --git a/TODO b/TODO
index 82bc5f3..193b584 100644
--- a/TODO
+++ b/TODO
@@ -4,6 +4,13 @@ SHOWSTOPPERS:
- datetime refactoring
- grub menu.lst updating
- squashfs errors when typing reboot after automatic procedure
+- pkg installation hangs at menu 'Package installation will begin now. You can watch the output.." 2 proccessen 'dialog --tailboxbg
+ pacman.log', als ge het 2e killt dan ziet ge de tailbox bg dinges en kunde continue klikken. same for mkinitcpio after configure
+ system. check if this also occurs before my little change. i probably broke this in one of
+ these commits:
+ http://github.com/Dieterbe/aif/commit/a97a7ec396b082f8315a46bf57875c4088a9bbc8
+ http://github.com/Dieterbe/aif/commit/9b9ad8567f1246322904ee2a603b7e6f7f69c768
+
CURRENT ISSUES:
* use traps and initiate rollback when user wants to abort. see also http://www.davidpashley.com/articles/writing-robust-shell-scripts.html
@@ -17,7 +24,6 @@ CURRENT ISSUES:
* automatically configure grub for dm_crypt and lvm
* fs_params in partition editor: do we really need to show them? isn't this where we store our "own" stuff?
* move "/tmp/pacman.conf" to runtime directory and variablize everywhere
-* follow_progress in cli mode does not show all output. since we do a tail -f we miss some things, especially because we do a sleep in run_background. maybe we should run in foreground when in cli mode?
* a nice way to be able to "inject" functions/logic without:
* needing to redefine phases with only 1 entry different (duplicate code is not nice, less maintainable etc)
* override worker functions which are 90% copy-pasted because the parent functionality is mostly okay, but not exactly what we want
diff --git a/src/core/libs/lib-misc.sh b/src/core/libs/lib-misc.sh
index 9ce0fd8..1acebac 100644
--- a/src/core/libs/lib-misc.sh
+++ b/src/core/libs/lib-misc.sh
@@ -1,6 +1,34 @@
#!/bin/bash
+# runs a process and makes sure the output is shown to the user. sets the exit state of the executed program ($<identifier>_exitcode) so the caller can show a concluding message.
+# when in dia mode, we will run the program and a dialog instance in the background (cause that's just how it works with dia)
+# when in cli mode, the program will just run in the foreground. technically it can be run backgrounded but then we need tail -f (cli_follow_progress), and we miss the beginning of the output if it goes too fast, not to mention because of the sleep in run_background
+# $1 identifier
+# $2 command (will be eval'ed)
+# $3 logfile
+# $4 title to show while process is running
+run_controlled ()
+{
+ [ -z "$1" ] && die_error "run_controlled: please specify an identifier to keep track of the command!"
+ [ -z "$2" ] && die_error "run_controlled needs a command to execute!"
+ [ -z "$3" ] && die_error "run_controlled needs a logfile to redirect output to!"
+ [ -z "$4" ] && die_error "run_controlled needs a title to show while your process is running!"
+
+ if [ "$var_UI_TYPE" = dia ]
+ then
+ run_background $1 "$2" $3
+ follow_progress " $4 " $3 $BACKGROUND_PID # dia mode ignores the pid. cli uses it to know how long it must do tail -f
+ wait_for $1 $FOLLOW_PID
+ else
+ notify "$4"
+ var_exit=${1}_exitcode
+ eval "$2" >>$3 2>&1
+ read $var_exit <<< $?
+ fi
+}
+
+
# run a process in the background, and log it's stdout and stderr to a specific logfile
# returncode is stored in $<identifier>_exitcode
# pid of the backgrounded wrapper process is stored in BACKGROUND_PID (this is _not_ the pid of $2)
diff --git a/src/core/libs/lib-software.sh b/src/core/libs/lib-software.sh
index a915d4f..384cab4 100644
--- a/src/core/libs/lib-software.sh
+++ b/src/core/libs/lib-software.sh
@@ -9,9 +9,7 @@ run_mkinitcpio()
{
target_special_fs on
- run_background mkinitcpio "chroot $var_TARGET_DIR /sbin/mkinitcpio -p kernel26" $TMP_MKINITCPIO_LOG
- follow_progress "Rebuilding initcpio images ..." $TMP_MKINITCPIO_LOG $BACKGROUND_PID
- wait_for mkinitcpio $FOLLOW_PID
+ run_controlled mkinitcpio "chroot $var_TARGET_DIR /sbin/mkinitcpio -p kernel26" $TMP_MKINITCPIO_LOG "Rebuilding initcpio images ..."
target_special_fs off
@@ -24,18 +22,17 @@ run_mkinitcpio()
# installpkg(). taken from setup. modified bigtime
# performs package installation to the target system
installpkg() {
- notify "Package installation will begin now. You can watch the output in the progress window. Please be patient."
- target_special_fs on
-
ALL_PACKAGES=$var_TARGET_PACKAGES
[ -n "$TARGET_GROUPS" ] && ALL_PACKAGES="$ALL_PACKAGES "`list_packages group "$TARGET_GROUPS" | awk '{print $2}'`
ALL_PACKAGES=`echo $ALL_PACKAGES`
[ -z "$ALL_PACKAGES" ] && die_error "No packages/groups specified to install"
- run_background pacman_installpkg "$PACMAN_TARGET --noconfirm -S $ALL_PACKAGES" $TMP_PACMAN_LOG #TODO: There may be something wrong here. See http://projects.archlinux.org/?p=installer.git;a=commitdiff;h=f504e9ecfb9ecf1952bd8dcce7efe941e74db946 ASKDEV (Simo)
- follow_progress " Installing... Please Wait " $TMP_PACMAN_LOG $BACKGROUND_PID
- wait_for pacman_installpkg $FOLLOW_PID
-
+ target_special_fs on
+
+ notify "Package installation will begin now. You can watch the output in the progress window. Please be patient."
+
+ #TODO: There may be something wrong here. See http://projects.archlinux.org/?p=installer.git;a=commitdiff;h=f504e9ecfb9ecf1952bd8dcce7efe941e74db946 ASKDEV (Simo)
+ run_controlled pacman_installpkg "$PACMAN_TARGET --noconfirm -S $ALL_PACKAGES" $TMP_PACMAN_LOG "Installing... Please Wait"
local _result=''
if [ ${pacman_installpkg_exitcode} -ne 0 ]; then