summaryrefslogtreecommitdiff
path: root/src/core
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 /src/core
parent49b6cbba082c7d9fd42d1a11713ad71ffebeaf27 (diff)
slight refactoring of how to run/monitor a program. i quite broke it though
Diffstat (limited to 'src/core')
-rw-r--r--src/core/libs/lib-misc.sh28
-rw-r--r--src/core/libs/lib-software.sh17
2 files changed, 35 insertions, 10 deletions
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