From fb96730dbfd801c45bc2009c1960d30403ecabc1 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sun, 22 Feb 2009 17:48:13 +0100 Subject: since we use /tmp now, no more need to hide files. some categorizing (tagging) of files is useful though --- src/core/procedures/base | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/procedures/base') diff --git a/src/core/procedures/base b/src/core/procedures/base index c22a01c..cf4e7e2 100644 --- a/src/core/procedures/base +++ b/src/core/procedures/base @@ -5,7 +5,7 @@ var_DEFAULTFS="/boot:32:ext2:+ swap:256:swap /:7500:ext3 /home:*:ext3" var_TARGET_DIR="/mnt" # When overriding this, do _not_ add a trailing /. It's not needed and maybe you could even break something var_RUNTIME_REPOSITORIES= # array like this ('name1' 'location of repo 1' ['name2' 'location of repo2',..]) var_RUNTIME_PACKAGES= -var_PKG_FILE=$RUNTIME_DIR/package-list # not used by default in base/interactive. can be used by custom procedures or profiles for the automatic procedure +var_PKG_FILE=$RUNTIME_DIR/aif-package-list # not used by default in base/interactive. can be used by custom procedures or profiles for the automatic procedure var_MIRRORLIST="/etc/pacman.d/mirrorlist" var_UI_TYPE="cli" # set to cli or dia for dialog var_ARCH=`uname -m` #i686 or x86_64. NOTE: this assumes you want to install the same arch as the installation environment you're using. maybe we could decouple those someday.. -- cgit v1.2.3-54-g00ecf From 5cd407fbb9b44b476ae7c9d460594322f465c24f Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Wed, 25 Feb 2009 22:09:05 +0100 Subject: adding refactored/reordered date/time setting logic into aif. based on tpowa's tz script. this also means an ncurses implementation of timezone selection --- src/core/libs/lib-misc.sh | 17 +++++++++++ src/core/libs/lib-ui-interactive.sh | 60 ++++++++++++++++++++----------------- src/core/libs/lib-ui.sh | 20 ++++++++++++- src/core/procedures/base | 24 ++++++++++++++- 4 files changed, 91 insertions(+), 30 deletions(-) (limited to 'src/core/procedures/base') diff --git a/src/core/libs/lib-misc.sh b/src/core/libs/lib-misc.sh index c7a5d2f..ac66bd1 100644 --- a/src/core/libs/lib-misc.sh +++ b/src/core/libs/lib-misc.sh @@ -68,3 +68,20 @@ cleanup_runtime () mkdir -p $RUNTIME_DIR || die_error "Cannot create $RUNTIME_DIR" rm -rf $RUNTIME_DIR/aif-dia* &>/dev/null } + + +dohwclock() { + infofy "Syncing hardwareclock to systemclock ..." + if [ "$HARDWARECLOCK" = "UTC" ]; then + HWCLOCK_PARAMS="$HWCLOCK_PARAMS --utc" + else + HWCLOCK_PARAMS="$HWCLOCK_PARAMS --localtime" + fi + + [ ! -d /var/lib/hwclock ] && mkdir -p /var/lib/hwclock + if [ ! -f /var/lib/hwclock/adjtime ]; then + echo "0.0 0 0.0" > /var/lib/hwclock/adjtime # what the hell is this for??? + fi + hwclock $HWCLOCK_PARAMS #tpowa does it without, but i would add --noadjtime here +} + diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index 804d3c3..f99518e 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -57,48 +57,52 @@ interactive_configure_system() } -# set_clock() -# prompts user to set hardware clock and timezone -# -# params: none -# returns: 1 on failure -interactive_set_clock() -{ - # utc or localtime? - ask_option no "Clock configuration" "Is your hardware clock in UTC or local time?" "UTC" " " "localtime" " " || return 1 - HARDWARECLOCK=$ANSWER_OPTION - - # timezone? +interactive_timezone () { ask_timezone || return 1 - TIMEZONE=$ANSWER_TIMEZONE + TIMEZONE=$ANSWER_TIMEZONE + infofy "Setting Timezone to $TIMEZONE" + [ -e /etc/localtime ] && rm -f /etc/localtime #why do we do this?? tpowa? + dohwclock +} + + + +interactive_time () { + # utc or localtime? + ask_option no "Clock configuration" "Is your hardware clock in UTC or local time?" "UTC" " " "localtime" " " || return 1 + HARDWARECLOCK=$ANSWER_OPTION + + dohwclock + + which ntpdate >/dev/null && ask_option yes "'ntpdate' was detected on your system.\n\nDo you want to use 'ntpdate' for syncing your clock,\nby using the internet clock pool?" "(You need a working internet connection for doing this!)" #TODO: only propose if network ok. + if [ $? -eq 0 ]; then + if ntpdate pool.ntp.org >/dev/null + then + notify "Synced clock with internet pool successfully.\n\nYour current time is now:\n$(date)" + else + show_warning 'Ntp failure' "An error has occured, time was not changed!" + fi + else + + # display and ask to set date/time + ask_datetime - # set system clock from hwclock - stolen from rc.sysinit - local HWCLOCK_PARAMS="" - if [ "$HARDWARECLOCK" = "UTC" ] - then - HWCLOCK_PARAMS="$HWCLOCK_PARAMS --utc" - else - HWCLOCK_PARAMS="$HWCLOCK_PARAMS --localtime" - fi if [ "$TIMEZONE" != "" -a -e "/usr/share/zoneinfo/$TIMEZONE" ] then /bin/rm -f /etc/localtime /bin/cp "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime fi - /sbin/hwclock --hctosys $HWCLOCK_PARAMS --noadjfile - - # display and ask to set date/time - ask_datetime # save the time date -s "$ANSWER_DATETIME" || show_warning "Date/time setting failed" "Something went wrong when doing date -s $ANSWER_DATETIME" - /sbin/hwclock --systohc $HWCLOCK_PARAMS --noadjfile - - return 0 + dohwclock } + + + interactive_autoprepare() { DISCS=$(finddisks) diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index 70cf9e3..aa1171c 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -395,7 +395,25 @@ _dia_ask_string () _dia_ask_timezone () { - ANSWER_TIMEZONE=`tzselect` #TODO: implement nicer then this + REGIONS="" + SET_ZONE="" + for i in $(grep ^[A-Z] /usr/share/zoneinfo/zone.tab | cut -f 3 | sed -e 's#/.*##g'| sort -u); do + REGIONS="$REGIONS $i -" + done + while ! [ "$SET_ZONE" = "1" ]; do + SET_REGION="" + ask_option no "Please select a region" '' $REGIONS + region=ANSWER_OPTION + if [ $? -eq 0 ]; then + ZONES="" + for i in $(grep ^[A-Z] /usr/share/zoneinfo/zone.tab | grep $region/ | cut -f 3 | sed -e "s#$region/##g"| sort -u); do + ZONES="$ZONES $i -" + done + ask_option no "Please select a timezone" '' $ZONES + zone=$ANSWER_OPTION + [ $? -gt 0 ] && ANSWER_TIMEZONE="$region/$zone" && return + fi + done } diff --git a/src/core/procedures/base b/src/core/procedures/base index cf4e7e2..845ce2d 100644 --- a/src/core/procedures/base +++ b/src/core/procedures/base @@ -101,7 +101,29 @@ worker_runtime_packages () worker_set_clock () { - interactive_set_clock + while true; do + default=no + [ -n "$NEXTITEM" ] && default="$NEXTITEM" + ask_option $default "Date/time configuration" '' \ + "1" "Select region and timezone" \ + "2" "Set time and date" \ + "3" "Return to Main Menu" + [ "$ANSWER_OPTION" = 1 ] && execute worker interactive_timezone && NEXTITEM=2 + [ "$ANSWER_OPTION" = 2 ] && check_depend worker interactive_timezone && execute worker interactive_time && NEXTITEM=3 + [ "$ANSWER_OPTION" = 3 ] && break + done +} + + +worker_interactive_timezone () +{ + interactive_timezone +} + + +worker_interactive_time () +{ + interactive_time } -- cgit v1.2.3-54-g00ecf From d2223b6d9806427c50d5fab4ee7bf919c98d0fd1 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 28 Feb 2009 15:17:45 +0100 Subject: ask_option now supports optional (skippable) and required menus. labels and exit codes are applied differently --- src/core/libs/lib-ui-interactive.sh | 30 +++++++++++++++--------------- src/core/libs/lib-ui.sh | 32 ++++++++++++++++++++------------ src/core/procedures/base | 2 +- src/core/procedures/interactive | 8 ++++---- tests/test-menus.sh | 12 +++++++++--- 5 files changed, 49 insertions(+), 35 deletions(-) (limited to 'src/core/procedures/base') diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index f015082..1e6d42f 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -28,7 +28,7 @@ interactive_configure_system() [ -n "$FILE" ] && DEFAULT="$FILE" helptext= grep -q '^/dev/mapper' $TMP_FSTAB && helptext="Don't forget to add the appropriate modules for your /dev/mapper devices to mkinitcpio.conf" #TODO: we can improve this a bit - ask_option $DEFAULT "Configuration" "$helptext" \ + ask_option $DEFAULT "Configuration" "$helptext" required \ "/etc/rc.conf" "System Config" \ "/etc/fstab" "Filesystem Mountpoints" \ "/etc/mkinitcpio.conf" "Initramfs Config" \ @@ -69,7 +69,7 @@ interactive_timezone () { interactive_time () { # utc or localtime? - ask_option no "Clock configuration" "Is your hardware clock in UTC or local time?" "UTC" " " "localtime" " " || return 1 + ask_option no "Clock configuration" "Is your hardware clock in UTC or local time?" required "UTC" " " "localtime" " " || return 1 HARDWARECLOCK=$ANSWER_OPTION dohwclock @@ -109,7 +109,7 @@ interactive_autoprepare() if [ $(echo $DISCS | wc -w) -gt 1 ] then notify "Available Disks:\n\n$(_getavaildisks)\n" - ask_option no 'Harddrive selection' "Select the hard drive to use" $(finddisks 1 _) || return 1 + ask_option no 'Harddrive selection' "Select the hard drive to use" required $(finddisks 1 _) || return 1 DISC=$ANSWER_OPTION else DISC=$DISCS @@ -148,7 +148,7 @@ interactive_autoprepare() CHOSEN_FS="" while [ "$CHOSEN_FS" = "" ] do - ask_option no 'Filesystem selection' "Select a filesystem for / and /home:" $FSOPTS || return 1 + ask_option no 'Filesystem selection' "Select a filesystem for / and /home:" required $FSOPTS || return 1 FSTYPE=$ANSWER_OPTION ask_yesno "$FSTYPE will be used for / and /home. Is this OK?" yes && CHOSEN_FS=1 done @@ -195,7 +195,7 @@ interactive_partition() { DISC="" while true; do # Prompt the user with a list of known disks - ask_option no 'Disc selection' "Select the disk you want to partition (select DONE when finished)" $DISCS || return 1 + ask_option no 'Disc selection' "Select the disk you want to partition (select DONE when finished)" required $DISCS || return 1 DISC=$ANSWER_OPTION if [ "$DISC" = "OTHER" ]; then ask_string "Enter the full path to the device you wish to partition" "/dev/sda" || return 1 @@ -253,7 +253,7 @@ interactive_filesystem () local old_fs_params=$fs_params ask_option edit "Alter this $fs_type filesystem on $part ?" \ - "Alter $fs_type filesystem (label:$fs_label, mountpoint:$fs_mountpoint) on $part (type:$part_type, label:$part_label) ?" \ + "Alter $fs_type filesystem (label:$fs_label, mountpoint:$fs_mountpoint) on $part (type:$part_type, label:$part_label) ?" required \ edit EDIT delete DELETE #TODO: nicer display if label is empty etc # Don't alter, and return if user cancels @@ -306,7 +306,7 @@ interactive_filesystem () else default= [ -n "$fs_type" ] && default="--default-item $fs_type" - ask_option no "Select filesystem" "Select a filesystem for $part:" $FSOPTS || return 1 + ask_option no "Select filesystem" "Select a filesystem for $part:" required $FSOPTS || return 1 fs_type=$ANSWER_OPTION fi @@ -463,7 +463,7 @@ interactive_filesystems() { menu_list="$menu_list $part $infostring" #don't add extra spaces, dialog doesn't like that. done < $TMP_BLOCKDEVICES - ask_option no "Manage filesystems" "Here you can manage your filesystems, block devices and virtual devices (device mapper). Note that you don't *need* to specify opts, labels or extra params if you're not using lvm, dm_crypt, etc." $menu_list DONE _ + ask_option no "Manage filesystems" "Here you can manage your filesystems, block devices and virtual devices (device mapper). Note that you don't *need* to specify opts, labels or extra params if you're not using lvm, dm_crypt, etc." required $menu_list DONE _ [ $? -gt 0 ] && USERHAPPY=1 && break [ "$ANSWER_OPTION" == DONE ] && USERHAPPY=1 && break @@ -492,7 +492,7 @@ interactive_filesystems() { list="XXX no-LV's-defined-yet-make-a-new-one" fi list="$list empty NEW" - ask_option empty "Manage LV's on this VG" "Edit/create new LV's on this VG:" $list + ask_option empty "Manage LV's on this VG" "Edit/create new LV's on this VG:" required $list EDIT_VG=$ANSWER_OPTION if [ "$ANSWER_OPTION" = XXX -o "$ANSWER_OPTION" = empty ] then @@ -631,7 +631,7 @@ interactive_runtime_network() { return 1 fi - ask_option no "Interface selection" "Select a network interface" $ifaces || return 1 #TODO: code used originaly --nocancel here. what's the use? + make ok button 'select' + ask_option no "Interface selection" "Select a network interface" required $ifaces || return 1 #TODO: code used originaly --nocancel here. what's the use? + make ok button 'select' INTERFACE=$ANSWER_OPTION @@ -763,7 +763,7 @@ EOF notify "No hard drives were found" return 1 fi - ask_option no "Boot device selection" "Select the boot device where the GRUB bootloader will be installed (usually the MBR and not a partition)." $DEVS || return 1 + ask_option no "Boot device selection" "Select the boot device where the GRUB bootloader will be installed (usually the MBR and not a partition)." required $DEVS || return 1 ROOTDEV=$ANSWER_OPTION infofy "Installing the GRUB bootloader..." cp -a $var_TARGET_DIR/usr/lib/grub/i386-pc/* $var_TARGET_DIR/boot/grub/ @@ -785,7 +785,7 @@ EOF fi ask_yesno "Do you have your system installed on software raid?\nAnswer 'YES' to install grub to another hard disk." no if [ $? -eq 0 ]; then - ask_option no "Boot partition device selection" "Please select the boot partition device, this cannot be autodetected!\nPlease redo grub installation for all partitions you need it!" $DEVS || return 1 + ask_option no "Boot partition device selection" "Please select the boot partition device, this cannot be autodetected!\nPlease redo grub installation for all partitions you need it!" required $DEVS || return 1 bootpart=$ANSWER_OPTION fi bootpart=$(mapdev $bootpart) @@ -832,7 +832,7 @@ interactive_select_source() var_FILE_URL="file:///src/core/pkg" var_SYNC_URL= - ask_option no "Source selection" "Please select an installation source" \ + ask_option no "Source selection" "Please select an installation source" required \ "1" "CD-ROM or OTHER SOURCE" \ "2" "FTP/HTTP" || return 1 @@ -866,7 +866,7 @@ interactive_select_mirror() { notify "Keep in mind ftp.archlinux.org is throttled.\nPlease select another mirror to get full download speed." # FIXME: this regex doesn't honor commenting MIRRORS=$(egrep -o '((ftp)|(http))://[^/]*' "${var_MIRRORLIST}" | sed 's|$| _|g') - ask_option no "Mirror selection" "Select an FTP/HTTP mirror" $MIRRORS "Custom" "_" || return 1 + ask_option no "Mirror selection" "Select an FTP/HTTP mirror" required $MIRRORS "Custom" "_" || return 1 local _server=$ANSWER_OPTION if [ "${_server}" = "Custom" ]; then ask_string "Enter the full URL to core repo." "ftp://ftp.archlinux.org/core/os/$var_ARCH" || return 1 @@ -889,7 +889,7 @@ interactive_get_editor() { which nano &>/dev/null && EDITOR_OPTS+=("nano" "nano (easier)") which joe &>/dev/null && EDITOR_OPTS+=("joe" "joe's editor") which vi &>/dev/null && EDITOR_OPTS+=("vi" "vi (advanced)") - ask_option no "Text editor selection" "Select a Text Editor to Use" "${EDITOR_OPTS[@]}" + ask_option no "Text editor selection" "Select a Text Editor to Use" required "${EDITOR_OPTS[@]}" #TODO: this code could be a little bit cleaner. case $ANSWER_OPTION in "nano") EDITOR="nano" ;; diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index 9e75cef..e81cbb3 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -190,7 +190,8 @@ ask_number () # $1 default item (set to 'no' for none) # $2 title # $3 additional explanation (default: '') -# shift;shift; $@ list of options. first tag. then name. (eg tagA itemA "tag B" 'item B' ) +# $4 type (required or optional). '' means required. cancel labels will be 'Cancel' and 'Skip' respectively. if (canceled), required will return >0, optional not. +# shift 4 ; $@ list of options. first tag. then name. (eg tagA itemA "tag B" 'item B' ) # the response will be echoed to stdout. but also $ANSWER_OPTION will be set. take that because the former method seems to not work. # $? if user cancelled. 0 otherwise ask_option () @@ -352,16 +353,20 @@ _dia_ask_option () [ "$1" != 'no' ] && DEFAULT="--default-item $1" [ -z "$2" ] && die_error "ask_option \$2 must be the title" # $3 is optional more info - [ -z "$5" ] && debug 'UI' "_dia_ask_option args: $@" && die_error "ask_option makes only sense if you specify at least one option (with tag and name)" #nothing wrong with only 1 option. it still shows useful info to the user + TYPE=${4:-required} + [ -z "$6" ] && debug 'UI' "_dia_ask_option args: $@" && die_error "ask_option makes only sense if you specify at least one option (with tag and name)" #nothing wrong with only 1 option. it still shows useful info to the user DIA_MENU_TITLE=$2 EXTRA_INFO=$3 - shift 3 - _dia_DIALOG $DEFAULT --colors --title " $DIA_MENU_TITLE " --menu "$DIA_MENU_TEXT $EXTRA_INFO" 20 80 16 "$@" 2>$ANSWER + shift 4 + CANCEL_LABEL= + [ $TYPE == optional ] && CANCEL_LABEL='--cancel-label "Skip"' + _dia_DIALOG $DEFAULT $CANCEL_LABEL --colors --title " $DIA_MENU_TITLE " --menu "$DIA_MENU_TEXT $EXTRA_INFO" 20 80 16 "$@" 2>$ANSWER ret=$? ANSWER_OPTION=`cat $ANSWER` debug 'UI' "dia_ask_option: User choose $ANSWER_OPTION ($DIA_MENU_TITLE)" - return $ret + [ $type == required ] && return $ret + return 0 # TODO: check if dialog returned >0 because of an other reason then the user hitting 'cancel/skip' } @@ -407,14 +412,14 @@ _dia_ask_timezone () done while [ "$SET_ZONE" != "1" ]; do SET_REGION="" - ask_option no "Please select a region" '' $REGIONS + ask_option no "Please select a region" '' required $REGIONS region=ANSWER_OPTION if [ $? -eq 0 ]; then ZONES="" for i in $(grep ^[A-Z] /usr/share/zoneinfo/zone.tab | grep $region/ | cut -f 3 | sed -e "s#$region/##g"| sort -u); do ZONES="$ZONES $i -" done - ask_option no "Please select a timezone" '' $ZONES + ask_option no "Please select a timezone" '' required $ZONES zone=$ANSWER_OPTION [ $? -gt 0 ] && ANSWER_TIMEZONE="$region/$zone" && return fi @@ -516,11 +521,12 @@ _cli_ask_option () [ "$1" != 'no' ] && DEFAULT=$1 #TODO: if user forgot to specify a default (eg all args are 1 pos to the left, we can end up in an endless loop :s) [ -z "$2" ] && die_error "ask_option \$2 must be the title" # $3 is optional more info - [ -z "$5" ] && debug 'UI' "_dia_ask_option args: $@" && die_error "ask_option makes only sense if you specify at least one option (with tag and name)" #nothing wrong with only 1 option. it still shows useful info to the user + TYPE=${4:-required} + [ -z "$6" ] && debug 'UI' "_dia_ask_option args: $@" && die_error "ask_option makes only sense if you specify at least one option (with tag and name)" #nothing wrong with only 1 option. it still shows useful info to the user MENU_TITLE=$2 EXTRA_INFO=$3 - shift 3 + shift 4 echo "$MENU_TITLE" [ -n "$EXTRA_INFO" ] && echo "$EXTRA_INFO" @@ -529,7 +535,9 @@ _cli_ask_option () echo "$1 ] $2" shift 2 done - echo "CANCEL ] CANCEL" + CANCEL_LABEL=CANCEL + [ $TYPE == optional ] && CANCEL_LABEL=SKIP + echo "$CANCEL_LABEL ] $CANCEL_LABEL" [ -n "$DEFAULT" ] && echo -n " > [ $DEFAULT ] " [ -z "$DEFAULT" ] && echo -n " > " read ANSWER_OPTION @@ -624,7 +632,7 @@ set_keymap () for i in $(find $KBDDIR/keymaps -name "*.gz" | sort); do KEYMAPS="$KEYMAPS ${i##$KBDDIR/keymaps/} -" done - ask_option "$var_KEYMAP" "Select A Keymap" '' $KEYMAPS && { + ask_option "$var_KEYMAP" "Select A Keymap" '' $KEYMAPS optional && { loadkeys -q $KBDDIR/keymaps/$ANSWER_OPTION var_KEYMAP=$ANSWER_OPTION } @@ -634,7 +642,7 @@ set_keymap () for i in $(find $KBDDIR/consolefonts -maxdepth 1 ! -name '*.cp.gz' -name "*.gz" | sed 's|^.*/||g' | sort); do FONTS="$FONTS $i -" done - ask_option "$var_CONSOLEFONT" "Select A Console Font" '' $FONTS && { + ask_option "$var_CONSOLEFONT" "Select A Console Font" '' optional $FONTS && { var_CONSOLEFONT=$ANSWER_OPTION for i in 1 2 3 4 do diff --git a/src/core/procedures/base b/src/core/procedures/base index 845ce2d..88bd9c3 100644 --- a/src/core/procedures/base +++ b/src/core/procedures/base @@ -104,7 +104,7 @@ worker_set_clock () while true; do default=no [ -n "$NEXTITEM" ] && default="$NEXTITEM" - ask_option $default "Date/time configuration" '' \ + ask_option $default "Date/time configuration" '' required \ "1" "Select region and timezone" \ "2" "Set time and date" \ "3" "Return to Main Menu" diff --git a/src/core/procedures/interactive b/src/core/procedures/interactive index 46bd6d7..ec9185a 100644 --- a/src/core/procedures/interactive +++ b/src/core/procedures/interactive @@ -53,7 +53,7 @@ mainmenu() [ -n "$NEXTITEM" ] && default="$NEXTITEM" #TODO: why does a '2' appear instead of '' ?? - ask_option $default "MAIN MENU" '' \ + ask_option $default "MAIN MENU" '' required \ "1" "$worker_select_source_title" \ "2" "$worker_set_clock_title" \ "3" "$worker_prepare_disks_title" \ @@ -96,7 +96,7 @@ mainmenu() select_source_extras_menu () { while true; do - ask_option no "FTP Installation" 'Make sure the network is ok before continuing the installer' \ + ask_option no "FTP Installation" 'Make sure the network is ok before continuing the installer' required \ "1" "$worker_runtime_network_title" \ "2" "$worker_select_mirror_title" \ "3" "Return to Main Menu" @@ -147,7 +147,7 @@ worker_prepare_disks() default=no [ -n "$NEXTITEM" ] && default="$NEXTITEM" - ask_option $default "Prepare Hard Drive" '' \ + ask_option $default "Prepare Hard Drive" '' required \ "1" "Auto-Prepare (erases the ENTIRE hard drive and sets up partitions and filesystems)" \ "2" "Partition Hard Drives" \ "3" "Configure block devices, filesystems and mountpoints" \ @@ -246,7 +246,7 @@ worker_select_mirror () worker_install_bootloader () { - ask_option Grub "Choose bootloader" "Which bootloader would you like to use? Grub is the Arch default." \ + ask_option Grub "Choose bootloader" "Which bootloader would you like to use? Grub is the Arch default." required \ "Grub" "Use the GRUB bootloader (default)" \ "None" "\Zb\Z1Warning\Z0\ZB: you must install your own bootloader!" diff --git a/tests/test-menus.sh b/tests/test-menus.sh index 9288ff6..4d0bd25 100644 --- a/tests/test-menus.sh +++ b/tests/test-menus.sh @@ -4,9 +4,15 @@ ANSWER="/tmp/.dialog-answer" var_UI_TYPE=dia -ask_option no 'menu title is this yes yes' 'extra explanation is here mkay' tagA itemA "tag B" 'item B' tag-c item\ C +ask_option no 'menu title is this yes yes' 'extra explanation is here mkay OPTIONAL' optional tagA itemA "tag B" 'item B' tag-c item\ C +echo "return code was $?" + +ask_option no 'menu title is this yes yes' 'extra explanation is here mkay REQUIRED' required tagA itemA "tag B" 'item B' tag-c item\ C echo "return code was $?" var_UI_TYPE=cli -ask_option tag-c 'menu title is this yes yes' 'extra explanation is here mkay' tagA itemA "tag B" 'item B' tag-c item\ C -echo "return code was $?" \ No newline at end of file +ask_option tag-c 'menu title is this yes yes' 'extra explanation is here mkay OPTIONAL' optional tagA itemA "tag B" 'item B' tag-c item\ C +echo "return code was $?" + +ask_option tag-c 'menu title is this yes yes' 'extra explanation is here mkay REQUIRED' required tagA itemA "tag B" 'item B' tag-c item\ C +echo "return code was $?" -- cgit v1.2.3-54-g00ecf From 7de8cf4fe3d38f508c721fdd7c50963f40699892 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Thu, 12 Mar 2009 20:56:37 +0100 Subject: various fixes re:keymap/font. + auto updating rc.conf in all procedures --- src/core/libs/lib-misc.sh | 5 +++++ src/core/libs/lib-ui.sh | 18 +++++++++++++----- src/core/procedures/base | 6 ++++++ src/core/procedures/interactive | 3 ++- 4 files changed, 26 insertions(+), 6 deletions(-) (limited to 'src/core/procedures/base') diff --git a/src/core/libs/lib-misc.sh b/src/core/libs/lib-misc.sh index c30e4cb..327a4c5 100644 --- a/src/core/libs/lib-misc.sh +++ b/src/core/libs/lib-misc.sh @@ -87,3 +87,8 @@ dohwclock() { hwclock $HWCLOCK_PARAMS #tpowa does it without, but i would add --noadjtime here } +target_configure_initial_keymap_font () +{ + [ -n "$var_KEYMAP" ] && sed -i "s/^KEYMAP=.*/KEYMAP=\"$var_KEYMAP\"/" ${var_TARGET_DIR}/etc/rc.conf + [ -n "$var_CONSOLEFONT" ] && sed -i "s/^CONSOLEFONT=.*/CONSOLEFONT=\"$var_CONSOLEFONT\"/" ${var_TARGET_DIR}/etc/rc.conf +} \ No newline at end of file diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index a8c242b..9719cbf 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -12,10 +12,16 @@ ANSWER=$RUNTIME_DIR/aif-dialog-answer DIA_MENU_TEXT="Use the UP and DOWN arrows to navigate menus. Use TAB to switch between buttons and ENTER to select." DIA_SUCCESSIVE_ITEMS=$RUNTIME_DIR/aif-dia-successive-items -#default keymap and consolefont configured on install CD. can be overridden -source /etc/rc.conf -var_KEYMAP=$KEYMAP -var_CONSOLEFONT=$CONSOLEFONT + +# get keymap/font (maybe configured by aif allready in another process or even in another shell) +# otherwise, take default keymap and consolefont as configured in /etc/rc.conf. can be overridden +# Note that the vars in /etc/rc.conf can also be empty! +[ -e $RUNTIME_DIR/aif-keymap ] && var_KEYMAP=` cat $RUNTIME_DIR/aif-keymap` +[ -e $RUNTIME_DIR/aif-consolefont ] && var_CONSOLEFONT=`cat $RUNTIME_DIR/aif-consolefont` +[ -z "$var_KEYMAP" ] && source /etc/rc.conf && var_KEYMAP=$KEYMAP +[ -z "$var_CONSOLEFONT" ] && source /etc/rc.conf && var_CONSOLEFONT=$CONSOLEFONT + + ### Functions that your code can use. Cli/dialog mode is fully transparant. This library takes care of it ### @@ -645,11 +651,12 @@ set_keymap () for i in $(find $KBDDIR/keymaps -name "*.gz" | sort); do KEYMAPS="$KEYMAPS ${i##$KBDDIR/keymaps/} -" done - ask_option "$var_KEYMAP" "Select A Keymap" '' optional $KEYMAPS + ask_option "${var_KEYMAP:-no}" "Select A Keymap" '' optional $KEYMAPS if [ -n "$ANSWER_OPTION" ] then loadkeys -q $KBDDIR/keymaps/$ANSWER_OPTION var_KEYMAP=$ANSWER_OPTION + echo "$var_KEYMAP" > $RUNTIME_DIR/aif-keymap fi FONTS= @@ -669,5 +676,6 @@ set_keymap () setfont $KBDDIR/consolefonts/$var_CONSOLEFONT -C /dev/tty$i fi done + echo "$var_CONSOLEFONT" > $RUNTIME_DIR/aif-consolefont fi } diff --git a/src/core/procedures/base b/src/core/procedures/base index 88bd9c3..379b154 100644 --- a/src/core/procedures/base +++ b/src/core/procedures/base @@ -31,6 +31,7 @@ phase_system=(\ auto_fstab \ auto_network \ auto_locale \ + auto_keymap_font \ configure_system \ mkinitcpio \ locales \ @@ -169,6 +170,11 @@ worker_auto_locale () } +worker_auto_keymap_font () +{ + target_configure_initial_keymap_font +} + worker_configure_system () { #TODO: what to do here? diff --git a/src/core/procedures/interactive b/src/core/procedures/interactive index ca9e489..0e59066 100644 --- a/src/core/procedures/interactive +++ b/src/core/procedures/interactive @@ -78,7 +78,8 @@ mainmenu() check_depend worker package_list && \ check_depend worker select_source && execute worker install_packages && { execute worker auto_fstab ; \ ended_ok worker runtime_network && execute worker auto_network ; \ - execute worker auto_locale ; } && NEXTITEM=6 ;; + execute worker auto_locale ; \ + execute worker auto_keymap_font; } && NEXTITEM=6 ;; "6") check_depend worker install_packages && execute worker configure_system && { execute worker mkinitcpio ; \ execute worker locales ; -- 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/procedures/base') 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 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/procedures/base') 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