From 700345fbdfc3c00c28c263e0504b5108390a9a72 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sun, 22 Feb 2009 17:50:02 +0100 Subject: tmp logfiles location fix --- src/core/libs/lib-software.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core/libs/lib-software.sh') diff --git a/src/core/libs/lib-software.sh b/src/core/libs/lib-software.sh index 726d20f..607d046 100644 --- a/src/core/libs/lib-software.sh +++ b/src/core/libs/lib-software.sh @@ -1,7 +1,7 @@ #!/bin/bash -TMP_MKINITCPIO_LOG=$RUNTIME_DIR/mkinitcpio.log -TMP_PACMAN_LOG=$RUNTIME_DIR/pacman.log +TMP_MKINITCPIO_LOG=$LOG_DIR/mkinitcpio.log +TMP_PACMAN_LOG=$LOG_DIR/pacman.log # run_mkinitcpio() taken from setup. adapted a lot # runs mkinitcpio on the target system, displays output -- cgit v1.2.3-54-g00ecf From debbad71e110d7a39a1115ca4d954173137b959b Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 28 Feb 2009 18:43:37 +0100 Subject: fix for bash read: not a valid identifier, and hence, got rid of the pacman install pkg workaround (finally!!) --- TODO | 2 -- src/core/libs/lib-misc.sh | 8 ++++---- src/core/libs/lib-software.sh | 9 ++++----- 3 files changed, 8 insertions(+), 11 deletions(-) (limited to 'src/core/libs/lib-software.sh') diff --git a/TODO b/TODO index e8ca3f1..97c0bae 100644 --- a/TODO +++ b/TODO @@ -6,8 +6,6 @@ CURRENT ISSUES: * grub sedding sometimes does, and sometimes doesn't work. default config remains (eg /dev/hda3) * when invoking /arch/aif -p interactive on a "normal" pc, it always wants to abort * check everywhere that if users cancels something, we return 1, empty string behavior etc -* core/interactive: fix workaround needed for installpkg exitcode -* core/interactive: near end of pkg installation (after kernel) an error shows briefly: "aif: read..." this is probably related to the thing above. * dm_crypt unlock at boot is in qwerty. * after unlocking dm_crypt, FS check fails (reiserfs, must try other) * find a way to make _cli_ask_checklist still userfriendly for long lists.. maybe we should just propose/ask to use dia if the list is too long diff --git a/src/core/libs/lib-misc.sh b/src/core/libs/lib-misc.sh index d0ad3f0..ef7a000 100644 --- a/src/core/libs/lib-misc.sh +++ b/src/core/libs/lib-misc.sh @@ -3,7 +3,7 @@ # run a process in the background, and log it's stdout and stderr to a specific logfile # returncode is stored in $_exitcode -# $1 identifier +# $1 identifier -> WARNING: do never ever use -'s or other fancy characters here. only numbers, letters and _ please. (because $_exitcode must be a valid bash variable!) # $2 command (will be eval'ed) # $3 logfile run_background () @@ -20,8 +20,8 @@ run_background () echo "STARTING $1 . Executing $2 >>$3 2>&1\n" >> $3; var_exit=${1}_exitcode eval "$2" >>$3 2>&1 - read $var_exit <<< $? #TODO: bash complains about 'not a valid identifier' - debug 'MISC' "run_background done with $1: exitcode (\$$1_exitcode): ${!var_exit} .Logfile $3" #TODO ${!var_exit} doesn't show anything --> maybe fixed now + read $var_exit <<< $? + debug 'MISC' "run_background done with $1: exitcode (\$$1_exitcode): ${!var_exit} .Logfile $3" echo >> $3 rm -f $RUNTIME_DIR/aif-$1-running ) & @@ -31,7 +31,7 @@ run_background () # wait until a process is done -# $1 identifier +# $1 identifier. WARNING! see above wait_for () { [ -z "$1" ] && die_error "wait_for needs an identifier to known on which command to wait!" diff --git a/src/core/libs/lib-software.sh b/src/core/libs/lib-software.sh index 607d046..27bd6fd 100644 --- a/src/core/libs/lib-software.sh +++ b/src/core/libs/lib-software.sh @@ -26,14 +26,14 @@ run_mkinitcpio() installpkg() { notify "Package installation will begin now. You can watch the output in the progress window. Please be patient." target_special_fs on - run_background pacman-installpkg "$PACMAN_TARGET --noconfirm -S $TARGET_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) + run_background pacman_installpkg "$PACMAN_TARGET --noconfirm -S $TARGET_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 - wait_for pacman-installpkg + wait_for pacman_installpkg local _result='' - if [ ${pacman-installpkg_exitcode} -ne 0 ]; then + if [ ${pacman_installpkg_exitcode} -ne 0 ]; then _result="Installation Failed (see errors below)" echo -e "\nPackage Installation FAILED." >>$TMP_PACMAN_LOG else @@ -46,8 +46,7 @@ installpkg() { target_special_fs off sync - #return ${pacman-installpkg_exitcode} TODO: fix this. there is something wrong here - return 0 + return ${pacman_installpkg_exitcode} } -- cgit v1.2.3-54-g00ecf From 207061727ee23e040745771f72670813791748c3 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Wed, 11 Mar 2009 22:03:44 +0100 Subject: support specifying packages to install as group and by packagename --- examples/generic-install-on-sda | 5 +++++ src/core/libs/lib-software.sh | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src/core/libs/lib-software.sh') diff --git a/examples/generic-install-on-sda b/examples/generic-install-on-sda index 5e05b34..d2bff3c 100644 --- a/examples/generic-install-on-sda +++ b/examples/generic-install-on-sda @@ -6,6 +6,11 @@ AUTOMATIC_SYNC_URL= AUTOMATIC_RUNTIME_REPOSITORIES= AUTOMATIC_RUNTIME_PACKAGES= + +# packages to install +TARGET_GROUPS=base #all packages in this group will be installed +TARGET_PACKAGES=openssh # you can also specify separate packages + worker_intro () { infofy "Automatic procedure running the generic-install-on-sda example config. THIS WILL ERASE AND OVERWRITE YOUR /DEV/SDA. IF YOU DO NOT WANT THIS PRESS CTRL+C WITHIN 10 SECONDS" sleep 10 diff --git a/src/core/libs/lib-software.sh b/src/core/libs/lib-software.sh index 27bd6fd..b9ee8d7 100644 --- a/src/core/libs/lib-software.sh +++ b/src/core/libs/lib-software.sh @@ -26,7 +26,10 @@ run_mkinitcpio() installpkg() { notify "Package installation will begin now. You can watch the output in the progress window. Please be patient." target_special_fs on - run_background pacman_installpkg "$PACMAN_TARGET --noconfirm -S $TARGET_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) + + ALL_PACKAGES=$TARGET_PACKAGES + [ -n "$TARGET_GROUPS" ] && ALL_PACKAGES="$ALL_PACKAGES "`list_packages group "$TARGET_GROUPS" | awk '{print $2}'` + 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 wait_for pacman_installpkg -- cgit v1.2.3-54-g00ecf From fbb4ff7b4c89eab48af025c91517c292d83f9ce3 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Thu, 12 Mar 2009 19:26:39 +0100 Subject: fix for bad way to pass packages (newlines and things) --- src/core/libs/lib-software.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'src/core/libs/lib-software.sh') diff --git a/src/core/libs/lib-software.sh b/src/core/libs/lib-software.sh index b9ee8d7..53b4a69 100644 --- a/src/core/libs/lib-software.sh +++ b/src/core/libs/lib-software.sh @@ -29,6 +29,7 @@ installpkg() { ALL_PACKAGES=$TARGET_PACKAGES [ -n "$TARGET_GROUPS" ] && ALL_PACKAGES="$ALL_PACKAGES "`list_packages group "$TARGET_GROUPS" | awk '{print $2}'` + ALL_PACKAGES=`echo $ALL_PACKAGES` 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 -- cgit v1.2.3-54-g00ecf From a6cc5cce7cf5d8a18f605c2764f57b512b5c8683 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Thu, 12 Mar 2009 21:00:03 +0100 Subject: stupid typo/doc/todo fixes --- TODO | 3 ++- src/core/libs/lib-software.sh | 2 +- src/core/procedures/automatic | 2 +- src/core/procedures/base | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src/core/libs/lib-software.sh') diff --git a/TODO b/TODO index 6a67520..7094de7 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,7 @@ See also the FIXME's and TODO's in the code. - CURRENT ISSUES: +* use traps and initiate rollback when user wants to abort. see also http://www.davidpashley.com/articles/writing-robust-shell-scripts.html * differentiate between framework and installer in src/aif.sh, some things should be in base * check everywhere that if users cancels something, we return 1, empty string behavior etc * dm_crypt unlock at boot is in qwerty. @@ -11,6 +11,7 @@ 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 +* not all packages are shown when automatic procedure invoked pacman to install packages * 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-software.sh b/src/core/libs/lib-software.sh index 53b4a69..5969ab6 100644 --- a/src/core/libs/lib-software.sh +++ b/src/core/libs/lib-software.sh @@ -56,7 +56,7 @@ installpkg() { # auto_locale(). taken from setup # enable glibc locales from rc.conf and build initial locale DB -target_configure_inital_locale() +target_configure_initial_locale() { for i in $(grep "^LOCALE" ${var_TARGET_DIR}/etc/rc.conf | sed -e 's/.*="//g' -e's/\..*//g'); do sed -i -e "s/^#$i/$i/g" ${var_TARGET_DIR}/etc/locale.gen diff --git a/src/core/procedures/automatic b/src/core/procedures/automatic index 5dbd03e..f088ff8 100644 --- a/src/core/procedures/automatic +++ b/src/core/procedures/automatic @@ -7,7 +7,7 @@ # It should be: # phase_preparation=(configure intro sysprep select_source runtime_network runtime_repositories runtime_packages) # phase_basics=(set_clock prepare_disks) -# phase_system=(package_listTODO install_packages auto_fstab auto_networkTODO auto_locale configure_system mkinitcpio locales install_bootloader) +# phase_system=(package_listTODO install_packages auto_fstab auto_networkTODO auto_locale auto_keymap_font configure_system mkinitcpio locales install_bootloader) # phase_finish=(msg_report) # In theory, the only manual thing should maybe be configuring the runtime network and putting the configfile in place diff --git a/src/core/procedures/base b/src/core/procedures/base index 379b154..602fccb 100644 --- a/src/core/procedures/base +++ b/src/core/procedures/base @@ -166,7 +166,7 @@ worker_auto_network () worker_auto_locale () { - target_configure_inital_locale + target_configure_initial_locale } -- cgit v1.2.3-54-g00ecf From a97a7ec396b082f8315a46bf57875c4088a9bbc8 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Thu, 12 Mar 2009 21:33:36 +0100 Subject: support for storing the pid of background wrapper processes + support for non-blocking following of text files (eg tail --pid) --- src/core/libs/lib-misc.sh | 5 +++-- src/core/libs/lib-software.sh | 4 ++-- src/core/libs/lib-ui.sh | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) (limited to 'src/core/libs/lib-software.sh') diff --git a/src/core/libs/lib-misc.sh b/src/core/libs/lib-misc.sh index 327a4c5..0b77d93 100644 --- a/src/core/libs/lib-misc.sh +++ b/src/core/libs/lib-misc.sh @@ -3,6 +3,7 @@ # run a process in the background, and log it's stdout and stderr to a specific logfile # returncode is stored in $_exitcode +# pid of the backgrounded wrapper process is stored in BACKGROUND_PID (this is _not_ the pid of $2) # $1 identifier -> WARNING: do never ever use -'s or other fancy characters here. only numbers, letters and _ please. (because $_exitcode must be a valid bash variable!) # $2 command (will be eval'ed) # $3 logfile @@ -25,6 +26,7 @@ run_background () echo >> $3 rm -f $RUNTIME_DIR/aif-$1-running ) & + BACKGROUND_PID=$! sleep 2 } @@ -38,11 +40,10 @@ wait_for () while [ -f $RUNTIME_DIR/aif-$1-running ] do - #TODO: follow_progress dialog mode = nonblocking (so check and sleep is good), cli mode (tail -f )= blocking? (so check is probably not needed as it will be done) sleep 1 done - kill $(cat $ANSWER) #TODO: this may not work when mode = cli + kill $(cat $ANSWER) #TODO: this may not work when mode = cli (<--i wrote this before i used tail -f --pid. i don't remember what i meant with it). TODO: huh?? ANSWER? } diff --git a/src/core/libs/lib-software.sh b/src/core/libs/lib-software.sh index 5969ab6..51a6539 100644 --- a/src/core/libs/lib-software.sh +++ b/src/core/libs/lib-software.sh @@ -10,7 +10,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 + follow_progress "Rebuilding initcpio images ..." $TMP_MKINITCPIO_LOG $BACKGROUND_PID wait_for mkinitcpio target_special_fs off @@ -31,7 +31,7 @@ installpkg() { [ -n "$TARGET_GROUPS" ] && ALL_PACKAGES="$ALL_PACKAGES "`list_packages group "$TARGET_GROUPS" | awk '{print $2}'` ALL_PACKAGES=`echo $ALL_PACKAGES` 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 + follow_progress " Installing... Please Wait " $TMP_PACMAN_LOG $BACKGROUND_PID wait_for pacman_installpkg diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index 9719cbf..c438dc2 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -262,6 +262,7 @@ ask_yesno () # follow the progress of something by showing it's log, updating real-time # $1 title # $2 logfile +# $3 pid to monitor. if process stopped, stop following (only used in cli mode) follow_progress () { [ -z "$1" ] && die_error "follow_progress needs a title!" @@ -639,8 +640,8 @@ _cli_follow_progress () title=$1 logfile=$2 echo "Title: $1" - tail -f $2 - #TODO: don't block anymore when it's done + [ -n "$3" ] && tail -f $2 --pid=$3 + [ -z "$3" ] && tail -f $2 } set_keymap () -- cgit v1.2.3-54-g00ecf From 9b9ad8567f1246322904ee2a603b7e6f7f69c768 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Fri, 13 Mar 2009 17:37:53 +0100 Subject: fix for kill dialogs forked process from the follow_progress call in wait_for --- src/core/libs/lib-misc.sh | 3 ++- src/core/libs/lib-software.sh | 4 ++-- src/core/libs/lib-ui.sh | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src/core/libs/lib-software.sh') diff --git a/src/core/libs/lib-misc.sh b/src/core/libs/lib-misc.sh index 0b77d93..9ce0fd8 100644 --- a/src/core/libs/lib-misc.sh +++ b/src/core/libs/lib-misc.sh @@ -34,6 +34,7 @@ run_background () # wait until a process is done # $1 identifier. WARNING! see above +# $2 pid of a process to kill when done (optional). useful for dialog --no-kill --tailboxbg's pid. wait_for () { [ -z "$1" ] && die_error "wait_for needs an identifier to known on which command to wait!" @@ -43,7 +44,7 @@ wait_for () sleep 1 done - kill $(cat $ANSWER) #TODO: this may not work when mode = cli (<--i wrote this before i used tail -f --pid. i don't remember what i meant with it). TODO: huh?? ANSWER? + [ -n "$2" ] && kill $2 } diff --git a/src/core/libs/lib-software.sh b/src/core/libs/lib-software.sh index 51a6539..455a3cc 100644 --- a/src/core/libs/lib-software.sh +++ b/src/core/libs/lib-software.sh @@ -11,7 +11,7 @@ run_mkinitcpio() 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 + wait_for mkinitcpio $FOLLOW_PID target_special_fs off @@ -33,7 +33,7 @@ installpkg() { 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 + wait_for pacman_installpkg $FOLLOW_PID local _result='' diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index 57c0383..dc207e6 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -460,7 +460,7 @@ _dia_follow_progress () { title=$1 logfile=$2 - _dia_DIALOG --title "$1" --no-kill --tailboxbg "$2" 0 0 2>$ANSWER + FOLLOW_PID=`_dia_DIALOG --title "$1" --no-kill --tailboxbg "$2" 0 0 2>&1 >/dev/null` } -- cgit v1.2.3-54-g00ecf From 06e6aa5d5eaa01ff7a371a66c88da8568f7f7e68 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Fri, 13 Mar 2009 21:15:09 +0100 Subject: uniformize variable handling automatic procedure, change the package related variable stuff, support choosing grub device in automatic, fix grub installing bug, cleanup official vs dieters stuff, etc --- examples/deployconfig-dieter | 130 --------------------- examples/generic-install-on-sda | 25 ++-- src/core/libs/lib-software.sh | 3 +- src/core/libs/lib-ui-interactive.sh | 2 +- src/core/procedures/automatic | 65 ++++------- src/core/procedures/base | 6 +- unofficial/dieter-desktop-a7n8x.automaticprofile | 115 ++++++++++++++++++ .../modules/dieter/procedures/dieter-automatic | 27 +++++ 8 files changed, 186 insertions(+), 187 deletions(-) delete mode 100644 examples/deployconfig-dieter create mode 100644 unofficial/dieter-desktop-a7n8x.automaticprofile create mode 100644 unofficial/modules/dieter/procedures/dieter-automatic (limited to 'src/core/libs/lib-software.sh') diff --git a/examples/deployconfig-dieter b/examples/deployconfig-dieter deleted file mode 100644 index a866d54..0000000 --- a/examples/deployconfig-dieter +++ /dev/null @@ -1,130 +0,0 @@ -#!/bin/bash -# An example config for the deployment procedure - -# Use var_* for "standard" variables recognized by the automatic procedure. these should work for everyone. -# use all other variable names for your own stuff. (eg i use them to define some things needed to pull my stuff from svn.) - -# TODO: install ruby-gems too -# TODO * dieter/automatic: wait for yaourt --config fix ( http://forums.archlinux.fr/post23171.html#23171 ) -# TODO:* dieter/automatic: put config files from svn in place first, so that if a package has an update, it can do it's thing. - - -var_RUNTIME_REPOSITORIES=(archlinuxfr "Server = http://repo.archlinux.fr/$var_ARCH") -var_RUNTIME_PACKAGES="svn yaourt" - -DEPLOY_CLASS=desktop-a7n8x -HOSTNAME=dieter-ws -SVN_USERNAME=dieter -SVN_PASSWORD= -SVN_BASE=https://192.168.1.2/svn/repos - -var_PARTITIONS='/dev/sda 100:ext2:+ 2048:swap *:xfs' -var_BLOCKDATA='/dev/sda1 raw no_label ext2;yes;/boot;target;no_opts;no_label;no_params -/dev/sda2 raw no_label swap;yes;no_mountpoint;target;no_opts;no_label;no_params -/dev/sda3 raw no_label dm_crypt;yes;no_mountpoint;target;no_opts;sda3crypt;-c_aes-xts-plain_-y_-s_512 -/dev/mapper/sda3crypt dm_crypt no_label lvm-pv;yes;no_mountpoint;target;no_opts;no_label;no_params -/dev/mapper/sda3crypt+ lvm-pv no_label lvm-vg;yes;no_mountpoint;target;no_opts;cryptpool;/dev/mapper/sda3crypt -/dev/mapper/cryptpool lvm-vg cryptpool lvm-lv;yes;no_mountpoint;target;no_opts;cryptroot;5G|lvm-lv;yes;no_mountpoint;target;no_opts;crypthome;5G -/dev/mapper/cryptpool-cryptroot lvm-lv no_label xfs;yes;/;target;no_opts;no_label;no_params -/dev/mapper/cryptpool-crypthome lvm-lv no_label xfs;yes;/home;target;no_opts;no_label;no_params' - - - -phase_preparation=(accept_ssl_cert "${phase_preparation[@]}") # make accept_ssl_cert the very first thing. it needs to go before fetch_configs and it's not easy to put it somewhere in the middle, so... -phase_system+=(configure_home) - - -# Deprecated. I try to keep everything in 1 config file now. that's cooler. -#worker_fetch_configs () -#{ -# $SVN export $SVN_BASE/ddm-configs/$DEPLOY_CLASS/trunk/disks/.blockdata $RUNTIME_DIR/aif-blockdata || die_error "Could not svn export $SVN_BASE/ddm-configs/$DEPLOY_CLASS/trunk/disks/.blockdata to $RUNTIME_DIR/aif-blockdata" -# $SVN export $SVN_BASE/ddm-configs/$DEPLOY_CLASS/trunk/disks/.partitions $RUNTIME_DIR/aif-partitions || die_error "Could not svn export $SVN_BASE/ddm-configs/$DEPLOY_CLASS/trunk/disks/.partitions to $RUNTIME_DIR/aif-partitions" -#} - - - -worker_package_list () -{ - $SVN export $SVN_BASE/ddm-configs/$DEPLOY_CLASS/trunk/package-list $var_PKG_FILE || die_error "Could not export package list!" - # cat -> there are newlines in it -> var=`echo $var` -> not anymore :) - TARGET_PACKAGES=`cat $var_PKG_FILE` && TARGET_PACKAGES=`echo $TARGET_PACKAGES` || die_error "Could not cat package list. THIS SHOULD NEVER HAPPEN." - # Strip away all packages not known by pacman. To get all packages, you'll need to do that when the system is installed TODO: don't do this. WAITINGFOR: --config support in yaourt + 'list of md5s of trusted pkgbuilds' support in yaourt - # NOTE: maybe chrooting could be an option too (to avoid --config support, but problem 2 stays) - TARGET_PACKAGES=`$PACMAN_TARGET -Si $TARGET_PACKAGES 2>/dev/null | awk '/Name/ {print $3}'` - TARGET_PACKAGES=`echo $TARGET_PACKAGES` #TODO: some stuff goes wrong here -} - - -worker_accept_ssl_cert () -{ - mkdir -p /root/.subversion/auth/svn.ssl.server - cat > /root/.subversion/auth/svn.ssl.server/1123d3c8b27895efee3848cc779e526a << EOF -K 10 -ascii_cert -V 716 -MIICFTCCAX6gAwIBAgIBAjANBgkqhkiG9w0BAQQFADBVMRswGQYDVQQKExJBcGFjaGUgSFRUUCBTZXJ2ZXIxIjAgBgNVBAsTGUZvciB0ZXN0aW5nIHB1cnBvc2VzIG9ubHkxEjAQBgNVBAMTCWxvY2FsaG9zdDAeFw0wNjA3MjQxMjUwMzdaFw0wNzA3MjQxMjUwMzdaMEwxGzAZBgNVBAoTEkFwYWNoZSBIVFRQIFNlcnZlcjEZMBcGA1UECxMQVGVzdCBDZXJ0aWZpY2F0ZTESMBAGA1UEAxMJbG9jYWxob3N0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDF5PB1NnUve2jkisDTGsxKC9qzpnl+eX8UIR/1s+yX2ZIPNnIryeqTc6sS3cBHz2/AufIr0xbpXkTa4V5Es5bXA7W1D7+ZzuFHjjyi4E2eqYVkhkv1sRL5TpAovfjAA+96iaFHp3yKYiuw/nWwQTSW9M1VrDEym4ODxyJOtNdgQQIDAQABMA0GCSqGSIb3DQEBBAUAA4GBABY0bnBf9tL1WMC1sLxB1eDXvs5qNY96mny+EKGAbyQROPaXwsRQB0HrAkuWfHzQlgIdD6AfGsd+YMcEuqSPzIz6t6mA45jl++WvI6we9t3eYChtdPD2xjgHti0aSiDyVLTJbXPnkdgzKvIjYZcXBwbmbQSrg0STO5m+cSYt3chx -K 8 -failures -V 2 -14 -K 15 -svn:realmstring -V 23 -https://192.168.1.2:443 -END -EOF -} - - -worker_configure_home () -{ - #TODO checkout from svn - true -} - - - -# See http://wiki.archlinux.org/index.php/Yaourt - -# Not needed yet... -#worker_install_packages () #pre_ / post_ callbacks would be useful here -#{ -# PACMAN_BACKUP=$PACMAN -# PACMAN_TARGET_BACKUP=$PACMAN_TARGET -# PACMAN=${PACMAN//pacman/yaourt} -# PACMAN_TARGET=${PACMAN_TARGET//pacman/yaourt} - -# target_prepare_pacman core -# [ -z "$TARGET_PACKAGES" ] && die_error "No packages listed to be installed!" -# installpkg - -# PACMAN=$PACMAN_BACKUP -# PACMAN_TARGET=$PACMAN_TARGET_BACKUP -#} - - -# Check if we have all needed settings loaded from the profile -post_worker_configure () -{ - if check_is_in svn $var_RUNTIME_PACKAGES - then - [ -z "$SVN_USERNAME" ] && ask_string "Please enter your svn username" && SVN_USERNAME=$ANSWER_STRING - [ -z "$SVN_PASSWORD" ] && ask_password svn #TODO: if user entered incorrect password, the install process will just fail.. - [ -z "$SVN_BASE" ] && ask_string "What's the base path of your svn repo? (no ending /) " && SVN_BASE=$ANSWER_STRING - [ -z "$DEPLOY_CLASS" ] && ask_string "Which hostclass are you installing? (optional)" '' 0 && DEPLOY_CLASS=$ANSWER_STRING - SVN="svn --username $SVN_USERNAME --password $SVN_PASSWORD" - elif check_is_in moo $var_RUNTIME_PACKAGES - then - # Maybe more stuff later - true - fi - [ -z "$HOSTNAME" ] && ask_string "Hostname of target system?" && HOSTNAME=$ANSWER_STRING - - return 0 -} - -worker_set_clock () -{ - #Not doing anything. hwclock is set already, configs are coming from svn anyway and we'll use ntp. - true -} diff --git a/examples/generic-install-on-sda b/examples/generic-install-on-sda index 0afdea5..9d25776 100644 --- a/examples/generic-install-on-sda +++ b/examples/generic-install-on-sda @@ -1,23 +1,28 @@ -# these variables are defaults, but it doesn't hurt to define them. +# these variables are optional, here are the defaults (feel free to omit them) -AUTOMATIC_SOURCE=cd -AUTOMATIC_FILE_URL=file:///src/core/pkg -AUTOMATIC_SYNC_URL= +SOURCE=cd +FILE_URL=file:///src/core/pkg +SYNC_URL= # Do you want to have additional pacman repositories or packages available at runtime (during installation)? -AUTOMATIC_RUNTIME_REPOSITORIES= -AUTOMATIC_RUNTIME_PACKAGES= +RUNTIME_REPOSITORIES= +RUNTIME_PACKAGES= # packages to install -TARGET_GROUPS=base #all packages in this group will be installed -TARGET_PACKAGES=openssh # you can also specify separate packages +TARGET_GROUPS=base #all packages in this group will be installed (defaults to base if no group and no packages are specified) +TARGET_PACKAGES=openssh # you can also specify separate packages (this is empty by default) +# you can optionally also override some functions... worker_intro () { infofy "Automatic procedure running the generic-install-on-sda example config. THIS WILL ERASE AND OVERWRITE YOUR /DEV/SDA. IF YOU DO NOT WANT THIS PRESS CTRL+C WITHIN 10 SECONDS" sleep 10 } -var_PARTITIONS='/dev/sda 100:ext2:+ 512:swap *:ext4' -var_BLOCKDATA='/dev/sda1 raw no_label ext2;yes;/boot;target;no_opts;no_label;no_params + +# These variables are mandatory + +GRUB_DEVICE=/dev/sda +PARTITIONS='/dev/sda 100:ext2:+ 512:swap *:ext4' +BLOCKDATA='/dev/sda1 raw no_label ext2;yes;/boot;target;no_opts;no_label;no_params /dev/sda2 raw no_label swap;yes;no_mountpoint;target;no_opts;no_label;no_params /dev/sda3 raw no_label ext4;yes;/;target;no_opts;no_label;no_params' \ No newline at end of file diff --git a/src/core/libs/lib-software.sh b/src/core/libs/lib-software.sh index 455a3cc..a915d4f 100644 --- a/src/core/libs/lib-software.sh +++ b/src/core/libs/lib-software.sh @@ -27,9 +27,10 @@ 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=$TARGET_PACKAGES + 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 diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index 33522d2..bce3790 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -634,7 +634,7 @@ interactive_select_packages() { _pkglist="$(echo "$_pkglist" | sort -f -k 2)" ask_checklist "Select Packages To Install." $_pkglist || return 1 - TARGET_PACKAGES=$ANSWER_CHECKLIST # contains now all package names + var_TARGET_PACKAGES=$ANSWER_CHECKLIST # contains now all package names return 0 } diff --git a/src/core/procedures/automatic b/src/core/procedures/automatic index f088ff8..65174de 100644 --- a/src/core/procedures/automatic +++ b/src/core/procedures/automatic @@ -1,5 +1,4 @@ #!/bin/bash -# This procedure is in development!! # This is a procedure for automatic deployment/installation/configuration of systems. # TODO: document! (readme, notes about deployment profiles, examples, ...) # check /usr/share/aif/examples for some example config files. # This procedure can easily replace the old quickinst script if you look at the "generic install" config file @@ -7,13 +6,13 @@ # It should be: # phase_preparation=(configure intro sysprep select_source runtime_network runtime_repositories runtime_packages) # phase_basics=(set_clock prepare_disks) -# phase_system=(package_listTODO install_packages auto_fstab auto_networkTODO auto_locale auto_keymap_font configure_system mkinitcpio locales install_bootloader) +# phase_system=(package_list install_packages auto_fstab auto_networkTODO auto_locale auto_keymap_font configure_system mkinitcpio locales install_bootloader) # phase_finish=(msg_report) # In theory, the only manual thing should maybe be configuring the runtime network and putting the configfile in place # TODO: I don't know if you can do non-interactive dm_crypt stuff.. maybe by pulling luks keyfiles from svn/git/..? # TODO: for worker_configure_system, we probably want the user to specify hostname, root pass etc. - +# TODO: implement setting hostname, keymap, consolefont, network settings # for a list of recognized variables, see examples/generic-install-on-sda depend_procedure core base @@ -37,7 +36,7 @@ process_args () worker_intro () { - notify "Automatic procedure running..." + notify "Automatic procedure running profile $var_AUTOMATIC_PROFILE ..." } @@ -46,17 +45,23 @@ worker_configure () var_UI_TYPE=${arg_ui_type:-cli} [ -z "$var_AUTOMATIC_PROFILE" ] && die_error "You must specify a config file to use this procedure" source $var_AUTOMATIC_PROFILE || die_error "Could not source config $var_AUTOMATIC_PROFILE" - var_RUNTIME_REPOSITORIES=$AUTOMATIC_RUNTIME_REPOSITORIES - var_RUNTIME_PACKAGES=$AUTOMATIC_RUNTIME_PACKAGES - [ -z "$var_PARTITIONS" ] && die_error "You did not specify a partition scheme" - [ -z "$var_BLOCKDATA" ] && die_error "You did not specify a partition scheme" + # Check mandatory options + [ -z "$PARTITIONS" ] && die_error "You did not specify a partition scheme" + [ -z "$BLOCKDATA" ] && die_error "You did not specify a partition scheme" + [ -z "$GRUB_DEVICE" ] && die_error "You did not specify a grub device" + # initialize internal variables based on variables set by the user (some of the vars are handled in other workers): + var_RUNTIME_REPOSITORIES=$RUNTIME_REPOSITORIES + var_RUNTIME_PACKAGES=$RUNTIME_PACKAGES + var_GRUB_DEVICE=$GRUB_DEVICE + var_PARTITIONS=$PARTITIONS + var_BLOCKDATA=$BLOCKDATA } worker_select_source () { - var_PKG_SOURCE_TYPE=${AUTOMATIC_SOURCE:-cd} - var_FILE_URL=${AUTOMATIC_FILE_URL:-file:///src/core/pkg} - var_SYNC_URL=${AUTOMATIC_SYNC_URL:-} + var_PKG_SOURCE_TYPE=${SOURCE:-cd} + var_FILE_URL=${FILE_URL:-file:///src/core/pkg} + var_SYNC_URL=${SYNC_URL:-} } worker_runtime_network () @@ -72,27 +77,6 @@ worker_runtime_network () } -# Check if we have all needed settings loaded from the profile -worker_runtime_settings () -{ - if check_is_in svn $var_RUNTIME_PACKAGES - then - [ -z "$SVN_USERNAME" ] && ask_string "Please enter your svn username" && SVN_USERNAME=$ANSWER_STRING - [ -z "$SVN_PASSWORD" ] && ask_password svn #TODO: if user entered incorrect password, the install process will just fail.. - [ -z "$SVN_BASE" ] && ask_string "What's the base path of your svn repo? (no ending /) " && SVN_BASE=$ANSWER_STRING - [ -z "$DEPLOY_CLASS" ] && ask_string "Which hostclass are you installing? (optional)" '' 0 && DEPLOY_CLASS=$ANSWER_STRING - SVN="svn --username $SVN_USERNAME --password $SVN_PASSWORD" - elif check_is_in moo $var_RUNTIME_PACKAGES - then - # Maybe more stuff later - true - fi - [ -z "$HOSTNAME" ] && ask_string "Hostname of target system?" && HOSTNAME=$ANSWER_STRING - - return 0 -} - - worker_prepare_disks () { echo "$var_PARTITIONS" > $TMP_PARTITIONS @@ -111,11 +95,17 @@ worker_prepare_disks () true } +worker_package_list () +{ + var_TARGET_PACKAGES=$TARGET_PACKAGES + var_TARGET_GROUPS=$TARGET_GROUPS + [ -z "$var_TARGET_PACKAGES" -a -z "$var_TARGET_GROUPS" ] && var_TARGET_GROUPS=base +} + worker_install_packages () { target_prepare_pacman core extra community #TODO: it would be better if this was a separate worker, i think - [ -z "$TARGET_PACKAGES" ] && die_error "No packages listed to be installed!" installpkg } @@ -135,12 +125,5 @@ worker_auto_network () { worker_install_bootloader () { - install-grub /dev/sda #TODO: this can be more flexible.. -} - - -worker_runtime_yaourt () -{ - _yaourt_replace_pacman + grub_install $var_GRUB_DEVICE --root-directory=/mnt } - diff --git a/src/core/procedures/base b/src/core/procedures/base index 602fccb..6d99421 100644 --- a/src/core/procedures/base +++ b/src/core/procedures/base @@ -135,18 +135,16 @@ worker_prepare_disks () } -# Put the list of packages to be installed in $TARGET_PACKAGES +# Put the list of packages to be installed in $var_TARGET_PACKAGES and $var_TARGET_GROUPS worker_package_list () { - #TODO: sensible list of packages. maybe just 'base' - true + var_TARGET_GROUPS=base } worker_install_packages () { target_prepare_pacman core #TODO: it would be better if this was a separate worker, i think - [ -z "$TARGET_PACKAGES" ] && die_error "No packages listed to be installed!" installpkg } diff --git a/unofficial/dieter-desktop-a7n8x.automaticprofile b/unofficial/dieter-desktop-a7n8x.automaticprofile new file mode 100644 index 0000000..2e63a78 --- /dev/null +++ b/unofficial/dieter-desktop-a7n8x.automaticprofile @@ -0,0 +1,115 @@ +#!/bin/bash +# An example config for the deployment procedure + +# Use var_* for "standard" variables recognized by the automatic procedure. these should work for everyone. +# use all other variable names for your own stuff. (eg i use them to define some things needed to pull my stuff from svn.) + +# TODO: install ruby-gems too +# TODO * dieter/automatic: wait for yaourt --config fix ( http://forums.archlinux.fr/post23171.html#23171 ) +# TODO:* dieter/automatic: put config files from svn in place first, so that if a package has an update, it can do it's thing. + + +var_RUNTIME_REPOSITORIES=(archlinuxfr "Server = http://repo.archlinux.fr/$var_ARCH") +var_RUNTIME_PACKAGES="svn yaourt" + +DEPLOY_CLASS=desktop-a7n8x +HOSTNAME=dieter-ws +SVN_USERNAME=dieter +SVN_PASSWORD= +SVN_BASE=https://192.168.1.2/svn/repos + +var_PARTITIONS='/dev/sda 100:ext2:+ 2048:swap *:xfs' +var_BLOCKDATA='/dev/sda1 raw no_label ext2;yes;/boot;target;no_opts;no_label;no_params +/dev/sda2 raw no_label swap;yes;no_mountpoint;target;no_opts;no_label;no_params +/dev/sda3 raw no_label dm_crypt;yes;no_mountpoint;target;no_opts;sda3crypt;-c_aes-xts-plain_-y_-s_512 +/dev/mapper/sda3crypt dm_crypt no_label lvm-pv;yes;no_mountpoint;target;no_opts;no_label;no_params +/dev/mapper/sda3crypt+ lvm-pv no_label lvm-vg;yes;no_mountpoint;target;no_opts;cryptpool;/dev/mapper/sda3crypt +/dev/mapper/cryptpool lvm-vg cryptpool lvm-lv;yes;no_mountpoint;target;no_opts;cryptroot;5G|lvm-lv;yes;no_mountpoint;target;no_opts;crypthome;5G +/dev/mapper/cryptpool-cryptroot lvm-lv no_label xfs;yes;/;target;no_opts;no_label;no_params +/dev/mapper/cryptpool-crypthome lvm-lv no_label xfs;yes;/home;target;no_opts;no_label;no_params' + + + +phase_preparation=(accept_ssl_cert "${phase_preparation[@]}") # make accept_ssl_cert the very first thing. it needs to go before fetch_configs and it's not easy to put it somewhere in the middle, so... +phase_system+=(configure_home) + + +# Deprecated. I try to keep everything in 1 config file now. that's cooler. +#worker_fetch_configs () +#{ +# $SVN export $SVN_BASE/ddm-configs/$DEPLOY_CLASS/trunk/disks/.blockdata $RUNTIME_DIR/aif-blockdata || die_error "Could not svn export $SVN_BASE/ddm-configs/$DEPLOY_CLASS/trunk/disks/.blockdata to $RUNTIME_DIR/aif-blockdata" +# $SVN export $SVN_BASE/ddm-configs/$DEPLOY_CLASS/trunk/disks/.partitions $RUNTIME_DIR/aif-partitions || die_error "Could not svn export $SVN_BASE/ddm-configs/$DEPLOY_CLASS/trunk/disks/.partitions to $RUNTIME_DIR/aif-partitions" +#} + + + +worker_package_list () +{ + $SVN export $SVN_BASE/ddm-configs/$DEPLOY_CLASS/trunk/package-list $var_PKG_FILE || die_error "Could not export package list!" + # cat -> there are newlines in it -> var=`echo $var` -> not anymore :) + TARGET_PACKAGES=`cat $var_PKG_FILE` && TARGET_PACKAGES=`echo $TARGET_PACKAGES` || die_error "Could not cat package list. THIS SHOULD NEVER HAPPEN." + # Strip away all packages not known by pacman. To get all packages, you'll need to do that when the system is installed TODO: don't do this. WAITINGFOR: --config support in yaourt + 'list of md5s of trusted pkgbuilds' support in yaourt + # NOTE: maybe chrooting could be an option too (to avoid --config support, but problem 2 stays) + TARGET_PACKAGES=`$PACMAN_TARGET -Si $TARGET_PACKAGES 2>/dev/null | awk '/Name/ {print $3}'` + TARGET_PACKAGES=`echo $TARGET_PACKAGES` #TODO: some stuff goes wrong here +} + + +worker_accept_ssl_cert () +{ + mkdir -p /root/.subversion/auth/svn.ssl.server + cat > /root/.subversion/auth/svn.ssl.server/1123d3c8b27895efee3848cc779e526a << EOF +K 10 +ascii_cert +V 716 +MIICFTCCAX6gAwIBAgIBAjANBgkqhkiG9w0BAQQFADBVMRswGQYDVQQKExJBcGFjaGUgSFRUUCBTZXJ2ZXIxIjAgBgNVBAsTGUZvciB0ZXN0aW5nIHB1cnBvc2VzIG9ubHkxEjAQBgNVBAMTCWxvY2FsaG9zdDAeFw0wNjA3MjQxMjUwMzdaFw0wNzA3MjQxMjUwMzdaMEwxGzAZBgNVBAoTEkFwYWNoZSBIVFRQIFNlcnZlcjEZMBcGA1UECxMQVGVzdCBDZXJ0aWZpY2F0ZTESMBAGA1UEAxMJbG9jYWxob3N0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDF5PB1NnUve2jkisDTGsxKC9qzpnl+eX8UIR/1s+yX2ZIPNnIryeqTc6sS3cBHz2/AufIr0xbpXkTa4V5Es5bXA7W1D7+ZzuFHjjyi4E2eqYVkhkv1sRL5TpAovfjAA+96iaFHp3yKYiuw/nWwQTSW9M1VrDEym4ODxyJOtNdgQQIDAQABMA0GCSqGSIb3DQEBBAUAA4GBABY0bnBf9tL1WMC1sLxB1eDXvs5qNY96mny+EKGAbyQROPaXwsRQB0HrAkuWfHzQlgIdD6AfGsd+YMcEuqSPzIz6t6mA45jl++WvI6we9t3eYChtdPD2xjgHti0aSiDyVLTJbXPnkdgzKvIjYZcXBwbmbQSrg0STO5m+cSYt3chx +K 8 +failures +V 2 +14 +K 15 +svn:realmstring +V 23 +https://192.168.1.2:443 +END +EOF +} + + +worker_configure_home () +{ + #TODO checkout from svn + true +} + + + +# See http://wiki.archlinux.org/index.php/Yaourt + +# Not needed yet... +#worker_install_packages () #pre_ / post_ callbacks would be useful here +#{ +# PACMAN_BACKUP=$PACMAN +# PACMAN_TARGET_BACKUP=$PACMAN_TARGET +# PACMAN=${PACMAN//pacman/yaourt} +# PACMAN_TARGET=${PACMAN_TARGET//pacman/yaourt} + +# target_prepare_pacman core +# [ -z "$TARGET_PACKAGES" ] && die_error "No packages listed to be installed!" +# installpkg + +# PACMAN=$PACMAN_BACKUP +# PACMAN_TARGET=$PACMAN_TARGET_BACKUP +#} + + +worker_set_clock () +{ + #Not doing anything. hwclock is set already, configs are coming from svn anyway and we'll use ntp. + true +} + +worker_runtime_yaourt () +{ + _yaourt_replace_pacman +} diff --git a/unofficial/modules/dieter/procedures/dieter-automatic b/unofficial/modules/dieter/procedures/dieter-automatic new file mode 100644 index 0000000..09e8972 --- /dev/null +++ b/unofficial/modules/dieter/procedures/dieter-automatic @@ -0,0 +1,27 @@ +#!/bin/bash +# Dieters personal procedure, adds a bit on top of the official automatic procedure. +# TODO: implement this. + +depend_procedure core automatic + + +# Check if we have all needed settings loaded from the profile +worker_runtime_settings () #TODO: add to a phase +{ + if check_is_in svn $var_RUNTIME_PACKAGES + then + [ -z "$SVN_USERNAME" ] && ask_string "Please enter your svn username" && SVN_USERNAME=$ANSWER_STRING + [ -z "$SVN_PASSWORD" ] && ask_password svn #TODO: if user entered incorrect password, the install process will just fail.. + [ -z "$SVN_BASE" ] && ask_string "What's the base path of your svn repo? (no ending /) " && SVN_BASE=$ANSWER_STRING + [ -z "$DEPLOY_CLASS" ] && ask_string "Which hostclass are you installing? (optional)" '' 0 && DEPLOY_CLASS=$ANSWER_STRING + SVN="svn --username $SVN_USERNAME --password $SVN_PASSWORD" + elif check_is_in moo $var_RUNTIME_PACKAGES + then + # Maybe more stuff later + true + fi + [ -z "$HOSTNAME" ] && ask_string "Hostname of target system?" && + HOSTNAME=$ANSWER_STRING + + return 0 +} -- cgit v1.2.3-54-g00ecf From 81472eb69c02b643eb0b66b712013f104d060bdf Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Tue, 17 Mar 2009 21:48:35 +0100 Subject: slight refactoring of how to run/monitor a program. i quite broke it though --- TODO | 8 +++++++- src/core/libs/lib-misc.sh | 28 ++++++++++++++++++++++++++++ src/core/libs/lib-software.sh | 17 +++++++---------- 3 files changed, 42 insertions(+), 11 deletions(-) (limited to 'src/core/libs/lib-software.sh') 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 ($_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 $_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 -- cgit v1.2.3-54-g00ecf