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/libs/lib-blockdevices-filesystems.sh | 10 +++++----- src/core/libs/lib-misc.sh | 8 ++++---- src/core/libs/lib-ui.sh | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh index 3b43541..1cbfcbe 100644 --- a/src/core/libs/lib-blockdevices-filesystems.sh +++ b/src/core/libs/lib-blockdevices-filesystems.sh @@ -25,11 +25,11 @@ modprobe aes-i586 || show_warning modprobe 'Could not modprobe aes-i586. no supp -TMP_DEV_MAP=$RUNTIME_DIR/dev.map -TMP_FSTAB=$RUNTIME_DIR/.fstab -TMP_PARTITIONS=$RUNTIME_DIR/.partitions -TMP_FILESYSTEMS=$RUNTIME_DIR/.filesystems # Only used internally by this library. Do not even think about using this as interface to this library. it won't work -TMP_BLOCKDEVICES=$RUNTIME_DIR/.blockdata +TMP_DEV_MAP=$RUNTIME_DIR/aif-dev.map +TMP_FSTAB=$RUNTIME_DIR/aif-fstab +TMP_PARTITIONS=$RUNTIME_DIR/aif-partitions +TMP_FILESYSTEMS=$RUNTIME_DIR/aif-filesystems # Only used internally by this library. Do not even think about using this as interface to this library. it won't work +TMP_BLOCKDEVICES=$RUNTIME_DIR/aif-blockdata diff --git a/src/core/libs/lib-misc.sh b/src/core/libs/lib-misc.sh index 01c291f..c7a5d2f 100644 --- a/src/core/libs/lib-misc.sh +++ b/src/core/libs/lib-misc.sh @@ -14,7 +14,7 @@ run_background () debug "run_background called. identifier: $1, command: $2, logfile: $3" ( \ - touch $RUNTIME_DIR/.$1-running + touch $RUNTIME_DIR/aif-$1-running debug "run_background starting $1: $2 >>$3 2>&1" [ -f $3 ] && echo -e "\n\n\n" >>$3 echo "STARTING $1 . Executing $2 >>$3 2>&1\n" >> $3; @@ -23,7 +23,7 @@ run_background () read $var_exit <<< $? #TODO: bash complains about 'not a valid identifier' debug "run_background done with $1: exitcode (\$$1_exitcode): "${!var_exit}" .Logfile $3" #TODO ${!var_exit} doesn't show anything --> maybe fixed now echo >> $3 - rm -f $RUNTIME_DIR/.$1-running + rm -f $RUNTIME_DIR/aif-$1-running ) & sleep 2 @@ -36,7 +36,7 @@ wait_for () { [ -z "$1" ] && die_error "wait_for needs an identifier to known on which command to wait!" - while [ -f $RUNTIME_DIR/.$1-running ] + 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 @@ -66,5 +66,5 @@ check_is_in () cleanup_runtime () { mkdir -p $RUNTIME_DIR || die_error "Cannot create $RUNTIME_DIR" - rm -rf $RUNTIME_DIR/.dia* &>/dev/null + rm -rf $RUNTIME_DIR/aif-dia* &>/dev/null } diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index 2315394..0664817 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -6,9 +6,9 @@ # Taken from setup. we store dialog output in a file. TODO: can't we do this with variables? ASKDEV -ANSWER=$RUNTIME_DIR/.dialog-answer +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/.dia-successive-items +DIA_SUCCESSIVE_ITEMS=$RUNTIME_DIR/aif-dia-successive-items ### Functions that your code can use. Cli/dialog mode is fully transparant. This library takes care of it ### -- cgit v1.2.3-54-g00ecf 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') 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 0fb2a618b05a4cc69a8036ba93e07943289fd5dd Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sun, 22 Feb 2009 19:43:58 +0100 Subject: cleanup in blockdevice size stuff. correct usage of units etc. inspired by FS#12949 - "hdparm -I" fails in VMware 0001-Using-fdisk-instead-of-hdparm-to-get-disc-capacity.patch --- src/core/libs/lib-blockdevices-filesystems.sh | 35 ++++++++++++++++----------- src/core/libs/lib-ui-interactive.sh | 6 ++--- src/core/libs/lib-ui.sh | 15 +++++++----- 3 files changed, 33 insertions(+), 23 deletions(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh index 1cbfcbe..28fb51c 100644 --- a/src/core/libs/lib-blockdevices-filesystems.sh +++ b/src/core/libs/lib-blockdevices-filesystems.sh @@ -736,24 +736,31 @@ get_filesystem_program () # $1 blockdevice -# $2 standard SI for 1000*n, IEC for 1024*n (optional. defaults to SI) -# --> Note that if you do SI on a partition, you get the size of the entire disk, so for now you need IEC for single partitions -# output will be in $BLOCKDEVICE_SIZE in MB/MiB +# $2 unit: B, KiB, kB, MiB, MB, GiB or GB. defaults to B (we follow IEEE 1541-2002 ) +# output will be in $BLOCKDEVICE_SIZE # WARNING: hdparm works - by design - only for ide/sata. not scsi et al -# TODO: clean up all disk size related stuff. see http://bugs.archlinux.org/task/12949 get_blockdevice_size () { [ -b "$1" ] || die_error "get_blockdevice_size needs a blockdevice as \$1 ($1 given)" - standard=${2:-SI} - - if [ "$standard" = SI ] - then - BLOCKDEVICE_SIZE=$(hdparm -I $1 | grep -F '1000*1000' | sed "s/^.*:[ \t]*\([0-9]*\) MBytes.*$/\1/") - elif [ "$standard" = IEC ] + unit=${2:-B} + allowed_units=(B KiB kB MiB MB GiB GB) + if ! is_in $unit "${allowed_units[@]}" then - #NOTE: unreliable method: on some interwebs they say 1 block = 512B, on other internets they say 1 block = 1kiB. 1kiB seems to work for me. don't sue me if it doesn't for you - #blocks=`fdisk -s $1` || show_warning "Fdisk problem" "Something failed when trying to do fdisk -s $1" - #BLOCKDEVICE_SIZE=$(($blocks/1024)) - BLOCKDEVICE_SIZE=$((`fdisk -l $1 | sed -n '2p' | cut -d' ' -f5`/1024)) + die_error "Unrecognized unit $unit!" fi + + # NOTES about older, deprecated methods: + # - BLOCKDEVICE_SIZE=$(hdparm -I $1 | grep -F '1000*1000' | sed "s/^.*:[ \t]*\([0-9]*\) MBytes.*$/\1/") # if you do this on a partition, you get the size of the entire disk ! + hdparm only supports sata and ide. not scsi. + # - unreliable method: on some interwebs they say 1 block = 512B, on other internets they say 1 block = 1kiB. 1kiB seemed to work for me. + # blocks=`fdisk -s $1` || show_warning "Fdisk problem" "Something failed when trying to do fdisk -s $1" + # BLOCKDEVICE_SIZE=$(($blocks/1024)) + # + bytes=$((`fdisk -l $1 2>/dev/null | sed -n '2p' | cut -d' ' -f5`)) + [ $unit = B ] && BLOCKDEVICE_SIZE=$bytes + [ $unit = KiB ] && BLOCKDEVICE_SIZE=$(($bytes/2*10)) # /1024 + [ $unit = kB ] && BLOCKDEVICE_SIZE=$(($bytes/10**3)) # /1000 + [ $unit = MiB ] && BLOCKDEVICE_SIZE=$(($bytes/2*20)) # ... + [ $unit = MB ] && BLOCKDEVICE_SIZE=$(($bytes/10**6)) + [ $unit = GiB ] && BLOCKDEVICE_SIZE=$(($bytes/2*30)) + [ $unit = GB ] && BLOCKDEVICE_SIZE=$(($bytes/10**9)) } diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index 8fdc5dc..8076a0e 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -113,7 +113,7 @@ interactive_autoprepare() DISC=${DISC// /} # strip all whitespace. we need this for some reason.TODO: find out why - get_blockdevice_size $DISC SI + get_blockdevice_size $DISC MB FSOPTS= which `get_filesystem_program ext2` &>/dev/null && FSOPTS="$FSOPTS ext2 Ext2" which `get_filesystem_program ext3` &>/dev/null && FSOPTS="$FSOPTS ext3 Ext3" @@ -449,9 +449,9 @@ interactive_filesystems() { fs_display=${fs//;target/} [ "$label" != no_label ] && label_display="($label)" [ "$label" = no_label ] && label_display= - if [ -b "${part/+/}" ] && get_blockdevice_size ${part/+/} IEC # test -b <-- exit's 0, test -b '' exits >0. + if [ -b "${part/+/}" ] && get_blockdevice_size ${part/+/} MB # test -b <-- exit's 0, test -b '' exits >0. then - infostring="${type},${BLOCKDEVICE_SIZE}MB${label_display}->$fs_display" # add size in MB for existing blockdevices (eg not for mapper devices that are not yet created yet) #TODO: ${BLOCKDEVICE_SIZE} is empty sometimes? + infostring="${type},${BLOCKDEVICE_SIZE}MB${label_display}->$fs_display" # add size in MB for existing blockdevices (eg not for mapper devices that are not yet created yet) else infostring="${type}${label_display}->$fs_display" fi diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index 0664817..3a40eb2 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -129,14 +129,17 @@ printk() # TODO: pass disks as argument to decouple backend logic -# Get a list of available disks for use in the "Available disks" dialogs. This -# will print the disks as follows, getting size info from hdparm: -# /dev/sda: 640133 MBytes (640 GB) -# /dev/sdb: 640135 MBytes (640 GB) +# Get a list of available disks for use in the "Available disks" dialogs. +# Something like: +# /dev/sda: 640133 MB (640 GB) +# /dev/sdb: 640135 MB (640 GB) _getavaildisks() { - # NOTE: to test as non-root, stick in a 'sudo' before the hdparm call - for i in $(finddisks); do echo -n "$i: "; hdparm -I $i | grep -F '1000*1000' | sed "s/.*1000:[ \t]*\(.*\)/\1/"; echo "\n"; done + for i in $(finddisks) + do + get_blockdevice_size $i MB + echo "$i: $BLOCKDEVICE_SIZE MB ($(($BLOCKDEVICE_SIZE/1000)) GB)\n" + done } -- cgit v1.2.3-54-g00ecf From 857ede360d7877576fb146b3db5f7cccf2f7658a Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sun, 22 Feb 2009 20:21:56 +0100 Subject: various fixes/features for ask_number --- src/core/libs/lib-ui.sh | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index 3a40eb2..70cf9e3 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -131,14 +131,14 @@ printk() # TODO: pass disks as argument to decouple backend logic # Get a list of available disks for use in the "Available disks" dialogs. # Something like: -# /dev/sda: 640133 MB (640 GB) -# /dev/sdb: 640135 MB (640 GB) +# /dev/sda: 640133 MiB (640 GiB) +# /dev/sdb: 640135 MiB (640 GiB) _getavaildisks() { for i in $(finddisks) do - get_blockdevice_size $i MB - echo "$i: $BLOCKDEVICE_SIZE MB ($(($BLOCKDEVICE_SIZE/1000)) GB)\n" + get_blockdevice_size $i MiB + echo "$i: $BLOCKDEVICE_SIZE MiB ($(($BLOCKDEVICE_SIZE/2**10)) GiB)\n" done } @@ -166,17 +166,18 @@ ask_datetime () # ask for a number. # $1 question # $2 lower limit (optional) -# $3 upper limit (optional) -# $4 default : TODO implement in cli -# echo's the number the user said +# $3 upper limit (optional. set 0 for none) +# $4 default (optional) +# sets $ANSWER_NUMBER to the number the user specified # returns 1 if the user cancelled or did not enter a numeric, 0 otherwise ask_number () { [ -z "$1" ] && die_error "ask_number needs a question!" - [ -n "$2" ] && [[ $2 = *[^0-9]* ]] && die_error "ask_number \$2 must be a number! not $2" - [ -n "$3" ] && [[ $3 = *[^0-9]* ]] && die_error "ask_number \$3 must be a number! not $3" - [ "$var_UI_TYPE" = dia ] && { _dia_ask_number "$1" "$2" "$3" ; return $? ; } - [ "$var_UI_TYPE" = cli ] && { _cli_ask_number "$1" "$2" "$3" ; return $? ; } + [ -n "$2" ] && [[ "$2" = *[^0-9]* ]] && die_error "ask_number \$2 must be a number! not $2" + [ -n "$3" ] && [[ "$3" = *[^0-9]* ]] && die_error "ask_number \$3 must be a number! not $3" + [ -n "$4" ] && [[ "$4" = *[^0-9]* ]] && die_error "ask_number \$4 must be a number! not $4" + [ "$var_UI_TYPE" = dia ] && { _dia_ask_number "$1" $2 $3 $4; return $? ; } + [ "$var_UI_TYPE" = cli ] && { _cli_ask_number "$1" $2 $3 $4; return $? ; } } @@ -313,17 +314,17 @@ _dia_ask_number () while true do str="$1" - [ -n "$2" ] && str2="min $2" - [ -n "$3" ] && str2="$str2 max $3" + [ -n $2 ] && str2="min $2" + [ -n $3 -a $3 != '0' ] && str2="$str2 max $3" [ -n "$str2" ] && str="$str ( $str2 )" - _dia_DIALOG --inputbox "$str" 8 65 "$4" 2>$ANSWER + _dia_DIALOG --inputbox "$str" 8 65 $4 2>$ANSWER ret=$? ANSWER_NUMBER=`cat $ANSWER` if [[ $ANSWER_NUMBER = *[^0-9]* ]] #TODO: handle exit state then show_warning "$ANSWER_NUMBER is not a number! try again." else - if [ -n "$3" -a $ANSWER_NUMBER -gt $3 ] + if [ -n "$3" -a $3 != '0' -a $ANSWER_NUMBER -gt $3 ] then show_warning "$ANSWER_NUMBER is bigger then the maximum,$3! try again." elif [ -n "$2" -a $ANSWER_NUMBER -lt $2 ] @@ -457,8 +458,9 @@ _cli_ask_number () while true do str="$1" - [ -n "$2" ] && str2="min $2" - [ -n "$3" ] && str2="$str2 max $3" + [ -n $2 ] && str2="min $2" + [ -n $3 -a $3 != '0' ] && str2="$str2 max $3" + [ -n $4 ] && str2=" default $4" [ -n "$str2" ] && str="$str ( $str2 )" echo "$str" read ANSWER_NUMBER @@ -466,7 +468,15 @@ _cli_ask_number () then show_warning "$ANSWER_NUMBER is not a number! try again." else - break + if [ -n "$3" -a $3 != '0' -a $ANSWER_NUMBER -gt $3 ] + then + show_warning "$ANSWER_NUMBER is bigger then the maximum,$3! try again." + elif [ -n "$2" -a $ANSWER_NUMBER -lt $2 ] + then + show_warning "$ANSWER_NUMBER is smaller then the minimum,$2! try again." + else + break + fi fi done debug "cli_ask_number: user entered: $ANSWER_NUMBER" -- cgit v1.2.3-54-g00ecf From b99b1a15867c7b10c65f19d2fd0683237a6195d5 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sun, 22 Feb 2009 20:33:08 +0100 Subject: blockdevice documentation cleanup + use MiB in interactive blockdevice things instead of MB. inspired by FS#12949 - "hdparm -I" fails in VMware 0002-Using-MiB-and-GiB-instead-of-MB-and-GB-respectively.patch --- src/core/libs/lib-blockdevices-filesystems.sh | 35 ++++++++++++++------------- src/core/libs/lib-ui-interactive.sh | 21 ++++++++-------- 2 files changed, 29 insertions(+), 27 deletions(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh index 28fb51c..4400b8b 100644 --- a/src/core/libs/lib-blockdevices-filesystems.sh +++ b/src/core/libs/lib-blockdevices-filesystems.sh @@ -3,18 +3,23 @@ # FORMAT DEFINITIONS: -# MAIN FORMAT FOR $TMP_BLOCKDEVICES (format used to interface with this library): one line per blockdevice, multiple fs'es in 1 'fs-string' -# $TMP_BLOCKDEVICES entry. -# type label/no_label /no_fs -# FS-string: -# type;recreate(yes/no);mountpoint;mount?(target,runtime,no);opts;label;params[|FS-string|...] where opts/params have _'s instead of whitespace if needed -# NOTE: the 'mount?' for now just matters for the location (if 'target', the target path gets prepended and mounted in the runtime system) -# NOTE: filesystems that span multiple underlying filesystems/devices (eg lvm VG) should specify those in params, separated by colons. \ -# the in the beginning doesn't matter much, it can be pretty much any device, or not existent, i think. But it's probably best to make it one of the devices listed in params -# no '+' characters allowed for devices in $fs_params (eg use the real names) - - -# ADDITIONAL INTERNAL FORMAT FOR $TMP_FILESYSTEMS: each filesystem on a separate line, so block devices can appear multiple times be on multiple lines (eg LVM volumegroups with more lvm LV's) +# -- formats used to interface with this library -- +# $TMP_PARTITIONS +# one line per partition, blockdevice + partioning string for sfdisk. See docs for function partition for more info. +# $TMP_BLOCKDEVICES +# one line per blockdevice, multiple fs'es in 1 'fs-string' +# $TMP_BLOCKDEVICES entry. +# type label/no_label /no_fs +# FS-string: +# type;recreate(yes/no);mountpoint;mount?(target,runtime,no);opts;label;params[|FS-string|...] where opts/params have _'s instead of whitespace if needed +# NOTE: the 'mount?' for now just matters for the location (if 'target', the target path gets prepended and mounted in the runtime system) +# NOTE: filesystems that span multiple underlying filesystems/devices (eg lvm VG) should specify those in params, separated by colons. \ +# the in the beginning doesn't matter much, it can be pretty much any device, or not existent, i think. But it's probably best to make it one of the devices listed in params +# no '+' characters allowed for devices in $fs_params (eg use the real names) + + +# -- ADDITIONAL INTERNAL FORMATS -- +# $TMP_FILESYSTEMS: each filesystem on a separate line, so block devices can appear multiple times be on multiple lines (eg LVM volumegroups with more lvm LV's) # part part_type part_label fs_type fs_create fs_mountpoint fs_mount fs_opts fs_label fs_params @@ -271,7 +276,7 @@ target_configure_fstab() # partitions a disk. heavily altered # $1 device to partition -# $2 a string of the form: :[:+] (the + is bootable flag) +# $2 a string of the form: :[:+] (the + is bootable flag) partition() { debug "Partition called like: partition '$1' '$2'" @@ -329,10 +334,6 @@ EOF } -# file layout: -#TMP_PARTITIONS -# disk partition-scheme - # go over each disk in $TMP_PARTITIONS and partition it process_disks () { diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index 8076a0e..606a0e0 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -113,7 +113,7 @@ interactive_autoprepare() DISC=${DISC// /} # strip all whitespace. we need this for some reason.TODO: find out why - get_blockdevice_size $DISC MB + get_blockdevice_size $DISC MiB FSOPTS= which `get_filesystem_program ext2` &>/dev/null && FSOPTS="$FSOPTS ext2 Ext2" which `get_filesystem_program ext3` &>/dev/null && FSOPTS="$FSOPTS ext3 Ext3" @@ -123,12 +123,12 @@ interactive_autoprepare() which `get_filesystem_program jfs` &>/dev/null && FSOPTS="$FSOPTS jfs JFS" which `get_filesystem_program vfat` &>/dev/null && FSOPTS="$FSOPTS vfat VFAT" - ask_number "Enter the size (MB) of your /boot partition. Recommended size: 100MB\n\nDisk space left: $BLOCKDEVICE_SIZE MB" 16 $BLOCKDEVICE_SIZE || return 1 + ask_number "Enter the size (MiB) of your /boot partition. Recommended size: 100MiB\n\nDisk space left: $BLOCKDEVICE_SIZE MiB" 16 $BLOCKDEVICE_SIZE 100 || return 1 BOOT_PART_SIZE=$ANSWER_NUMBER BLOCKDEVICE_SIZE=$(($BLOCKDEVICE_SIZE-$BOOT_PART_SIZE)) - ask_number "Enter the size (MB) of your swap partition. Recommended size: 256MB\n\nDisk space left: $BLOCKDEVICE_SIZE MB" 1 $BLOCKDEVICE_SIZE || return 1 + ask_number "Enter the size (MiB) of your swap partition. Recommended size: 256MiB\n\nDisk space left: $BLOCKDEVICE_SIZE MiB" 1 $BLOCKDEVICE_SIZE 256 || return 1 SWAP_PART_SIZE=$ANSWER_NUMBER BLOCKDEVICE_SIZE=$(($BLOCKDEVICE_SIZE-$SWAP_PART_SIZE)) @@ -136,9 +136,9 @@ interactive_autoprepare() ROOT_PART_SET="" while [ "$ROOT_PART_SET" = "" ] do - ask_number "Enter the size (MB) of your / partition. Recommended size:7500. The /home partition will use the remaining space.\n\nDisk space left: $BLOCKDEVICE_SIZE MB" 1 $BLOCKDEVICE_SIZE || return 1 + ask_number "Enter the size (MiB) of your / partition. Recommended size:7500. The /home partition will use the remaining space.\n\nDisk space left: $BLOCKDEVICE_SIZE MiB" 1 $BLOCKDEVICE_SIZE 7500 || return 1 ROOT_PART_SIZE=$ANSWER_NUMBER - ask_yesno "$(($BLOCKDEVICE_SIZE-$ROOT_PART_SIZE)) MB will be used for your /home partition. Is this OK?" yes && ROOT_PART_SET=1 #TODO: when doing yes, cli mode prints option JFS all the time, dia mode goes back to disks menu + ask_yesno "$(($BLOCKDEVICE_SIZE-$ROOT_PART_SIZE)) MiB will be used for your /home partition. Is this OK?" yes && ROOT_PART_SET=1 #TODO: when doing yes, cli mode prints option JFS all the time, dia mode goes back to disks menu done CHOSEN_FS="" @@ -351,10 +351,11 @@ interactive_filesystem () fi if [ "$fs_type" = lvm-lv ] then - [ -z "$fs_params" ] && default='5G' + [ -z "$fs_params" ] && default='5000' [ -n "$fs_params" ] && default="$fs_params" - ask_string "Enter the size for this $fs_type on $part (suffix K,M,G,T,P,E. default is M)" "$default" || return 1 - fs_params=$ANSWER_STRING + ask_number "Enter the size for this $fs_type on $part in MiB" 1 0 "$default" || return 1 #TODO: can we get the upperlimit from somewhere? + # Lvm tools use binary units but have their own suffixes ( K,M,G,T,P,E, but they mean KiB, MiB etc) + fs_params="${ANSWER_NUMBER}M" fi if [ "$fs_type" = dm_crypt ] then @@ -449,9 +450,9 @@ interactive_filesystems() { fs_display=${fs//;target/} [ "$label" != no_label ] && label_display="($label)" [ "$label" = no_label ] && label_display= - if [ -b "${part/+/}" ] && get_blockdevice_size ${part/+/} MB # test -b <-- exit's 0, test -b '' exits >0. + if [ -b "${part/+/}" ] && get_blockdevice_size ${part/+/} MiB # test -b <-- exit's 0, test -b '' exits >0. then - infostring="${type},${BLOCKDEVICE_SIZE}MB${label_display}->$fs_display" # add size in MB for existing blockdevices (eg not for mapper devices that are not yet created yet) + infostring="${type},${BLOCKDEVICE_SIZE}MiB${label_display}->$fs_display" # add size in MiB for existing blockdevices (eg not for mapper devices that are not yet created yet) else infostring="${type}${label_display}->$fs_display" fi -- cgit v1.2.3-54-g00ecf From d9214396c1e28ab0dd1ea2f18d6d88912793d156 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sun, 22 Feb 2009 20:43:13 +0100 Subject: todo updates --- TODO | 2 +- src/core/libs/lib-blockdevices-filesystems.sh | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'src/core/libs') diff --git a/TODO b/TODO index afd619b..c7b04ef 100644 --- a/TODO +++ b/TODO @@ -35,7 +35,7 @@ CURRENT ISSUES: * refactor all pacman stuff (modularize/functionize etc) * in lvm VG editor you can press "cancel" (when 'new' is selected, maybe otherwise too) and create a new LV which will get a block entry, but no fs entry on the VG block! * aif : na "mijn" partitielayout: bij grub ( nog voor text editor op menu.lst) zegt iets ( op foreground van ncurses) Can't remove.. ik denk zelfs 'Grub: Can't remove..' en daarna een gewone entry, geen uuid's gewoon /dev/sda3 ro -* port from /arch/setup: grub install chroot thing (waiting for ticket), 2 patches from foutrelis @ http://bugs.archlinux.org/task/12949 +* port from /arch/setup: grub install chroot thing (http://projects.archlinux.org/?p=installer.git;a=commitdiff;h=4565577dbd2182dd49612f1e0b68288f5573bf7b) (waiting for ticket http://bugs.archlinux.org/task/13277) * ext4 default options? -O dir_index,extent,uninit_bg ? * find a way to not have to preload libs and stuff, only load them when needed. -> faster start of install program * if dhcpd already runs for $reason, the installer will try again @ configure network and fail. diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh index 4400b8b..7369ec4 100644 --- a/src/core/libs/lib-blockdevices-filesystems.sh +++ b/src/core/libs/lib-blockdevices-filesystems.sh @@ -24,7 +24,6 @@ -#TODO: this should be fixed on the installcd. modprobe dm-crypt || show_warning modprobe 'Could not modprobe dm-crypt. no support for disk encryption' modprobe aes-i586 || show_warning modprobe 'Could not modprobe aes-i586. no support for disk encryption' -- cgit v1.2.3-54-g00ecf From e65d1175c2c6e4156280d2ee5980f65e2794f776 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sun, 22 Feb 2009 21:11:28 +0100 Subject: port of FS#13241 - Use "localtime" instead of "local". --- src/core/libs/lib-ui-interactive.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index 606a0e0..804d3c3 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -64,8 +64,8 @@ interactive_configure_system() # returns: 1 on failure interactive_set_clock() { - # utc or local? - ask_option no "Clock configuration" "Is your hardware clock in UTC or local time?" "UTC" " " "local" " " || return 1 + # 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? -- 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/libs') 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 4ad04ca98456523ec35a11e50fe8e01d7c58cd24 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Wed, 25 Feb 2009 22:36:46 +0100 Subject: syntax fix --- src/core/libs/lib-ui-interactive.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index f99518e..e8f52c2 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -74,15 +74,15 @@ interactive_time () { 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 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. + 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 + if # display and ask to set date/time ask_datetime -- cgit v1.2.3-54-g00ecf From c7dbcffcd5ec6ee405ba1cf063f7b244d4a7359e Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Wed, 25 Feb 2009 22:45:17 +0100 Subject: syntax fix --- src/core/libs/lib-ui-interactive.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index e8f52c2..ccb912f 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -82,7 +82,7 @@ interactive_time () { else show_warning 'Ntp failure' "An error has occured, time was not changed!" fi - if + fi # display and ask to set date/time ask_datetime -- cgit v1.2.3-54-g00ecf From a44e96a7df3e117b544e26e30df21a26d61ff17a Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Thu, 26 Feb 2009 21:28:23 +0100 Subject: ui function to set keymap and font + partial procedure for it --- TODO | 1 + src/core/libs/lib-ui.sh | 35 ++++++++++++++++++++++++++++++++++- src/core/procedures/partial-keymap | 6 ++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/core/procedures/partial-keymap (limited to 'src/core/libs') diff --git a/TODO b/TODO index c7b04ef..b196487 100644 --- a/TODO +++ b/TODO @@ -3,6 +3,7 @@ See also the FIXME's and TODO's in the code. CURRENT ISSUES: * grub sedding sometimes does, and sometimes doesn't work. default config remains (eg /dev/hda3) +* select timezone -> it hangs :? * 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 diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index aa1171c..53ff8ea 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -9,6 +9,8 @@ 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 +var_KEYMAP=`sed -n '/^KEYMAP/p' /etc/rc.conf | sed 's/KEYMAP=//' | sed 's/"//g'` #default keymap as configured on install CD. can be overridden +var_CONSOLEFONT=`sed -n '/^CONSOLEFONT/p' /etc/rc.conf | sed 's/KEYMAP=//' | sed 's/"//g'` #default consolefont as configured on install CD. can be overridden ### Functions that your code can use. Cli/dialog mode is fully transparant. This library takes care of it ### @@ -400,7 +402,7 @@ _dia_ask_timezone () 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 + while [ "$SET_ZONE" != "1" ]; do SET_REGION="" ask_option no "Please select a region" '' $REGIONS region=ANSWER_OPTION @@ -610,3 +612,34 @@ _cli_follow_progress () tail -f $2 #TODO: don't block anymore when it's done } + +set_keymap () +{ + KBDDIR="/usr/share/kbd" + + KEYMAPS= + for i in $(find $KBDDIR/keymaps -name "*.gz" | sort); do + KEYMAPS="$KEYMAPS ${i##$KBDDIR/keymaps/} -" + done + ask_option "$var_KEYMAP" "Select A Keymap" '' $KEYMAPS && { + loadkeys -q $KBDDIR/keymaps/$ANSWER_OPTION + var_KEYMAP=$ANSWER_OPTION + } + + FONTS= + # skip .cp.gz and partialfonts files for now see bug #6112, #6111 + 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 && { + var_CONSOLEFONT=$ANSWER_OPTION + for i in 1 2 3 4 + do + if [ -d /dev/vc ]; then + setfont $KBDDIR/consolefonts/$var_CONSOLEFONT -C /dev/vc/$i + else + setfont $KBDDIR/consolefonts/$var_CONSOLEFONT -C /dev/tty$i + fi + done + } +} diff --git a/src/core/procedures/partial-keymap b/src/core/procedures/partial-keymap new file mode 100644 index 0000000..9bb8581 --- /dev/null +++ b/src/core/procedures/partial-keymap @@ -0,0 +1,6 @@ +#!/bin/bash + +start_process () +{ + set_keymap +} -- cgit v1.2.3-54-g00ecf From 8be65c346aa8ca9c7650f935ad608a82250d9a0d Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 28 Feb 2009 13:22:21 +0100 Subject: support for debug categories --- src/aif.sh | 25 +++++++++------- src/core/libs/lib-blockdevices-filesystems.sh | 38 ++++++++++++------------ src/core/libs/lib-misc.sh | 8 ++--- src/core/libs/lib-ui-interactive.sh | 2 +- src/core/libs/lib-ui.sh | 42 +++++++++++++-------------- src/core/procedures/interactive | 2 +- 6 files changed, 61 insertions(+), 56 deletions(-) (limited to 'src/core/libs') diff --git a/src/aif.sh b/src/aif.sh index 2e3eac9..618519d 100755 --- a/src/aif.sh +++ b/src/aif.sh @@ -40,6 +40,7 @@ Available procedures: notify () { + debug 'UI' "notify: $@" echo -e "$@" } @@ -52,13 +53,17 @@ log () [ "$LOG_TO_FILE" = 1 ] && echo -e "$str" >> $LOGFILE } - +# $1 = category. one of MAIN, PROCEDURE, UI, UI-INTERACTIVE, FS, MISC, NETWORK, PACMAN, SOFTWARE +# $2 = string to log debug () { + [ "$1" == 'MAIN' -o "$1" == 'PROCEDURE' -o "$1" == 'UI' -o "$1" == 'UI-INTERACTIVE' -o "$1" == 'FS' -o "$1" == 'MISC' -o "$1" == 'NETWORK' -o "$1" == 'PACMAN' -o "$1" == 'SOFTWARE' ] || die_error "debug \$1 ($1) is not a valid debug category" + [ -n "$2" ] || die_error "debug \$2 cannot be empty" + mkdir -p $LOG_DIR || die_error "Cannot create log directory" - str="[DEBUG] $@" if [ "$DEBUG" = "1" ] then + str="[DEBUG $1 ] $2" echo -e "$str" > $LOG [ "$LOG_TO_FILE" = 1 ] && echo -e "$str" >> $LOGFILE fi @@ -132,8 +137,8 @@ load_lib () # $3... extra args for phase/worker (optional) execute () { - [ -z "$1" -o -z "$2" ] && debug "execute $@" && die_error "Use the execute function like this: execute with type=phase/worker" - [ "$1" != phase -a "$1" != worker ] && debug "execute $@" && die_error "execute's first argument must be a valid type (phase/worker)" + [ -z "$1" -o -z "$2" ] && debug 'MAIN' "execute $@" && die_error "Use the execute function like this: execute with type=phase/worker" + [ "$1" != phase -a "$1" != worker ] && debug 'MAIN' "execute $@" && die_error "execute's first argument must be a valid type (phase/worker)" PWD_BACKUP=`pwd` object=$1_$2 @@ -156,11 +161,11 @@ execute () exit_var=exit_$object read $exit_var <<< 0 # TODO: for some reason the hack below does not work (tested in virtualbox), even though it really should. Someday I must get indirect array variables working and clean this up... - # debug "\$1: $1, \$2: $2, \$object: $object, \$exit_$object: $exit_object" - # debug "declare: `declare | grep -e "^${object}=" | cut -d"=" -f 2-`" + # debug 'MAIN' "\$1: $1, \$2: $2, \$object: $object, \$exit_$object: $exit_object" + # debug 'MAIN' "declare: `declare | grep -e "^${object}=" | cut -d"=" -f 2-`" # props to jedinerd at #bash for this hack. # eval phase=$(declare | grep -e "^${object}=" | cut -d"=" -f 2-) - #debug "\$phase: $phase - ${phase[@]}" + #debug 'MAIN' "\$phase: $phase - ${phase[@]}" unset phase [ "$2" = preparation ] && phase=( "${phase_preparation[@]}" ) [ "$2" = basics ] && phase=( "${phase_basics[@]}" ) @@ -169,13 +174,13 @@ execute () # worker_str contains the name of the worker and optionally any arguments for worker_str in "${phase[@]}" do - debug "Loop iteration. \$worker_str: $worker_str" + debug 'MAIN' "Loop iteration. \$worker_str: $worker_str" execute worker $worker_str || read $exit_var <<< $? # assign last failing exit code to exit_phase_, if any. done ret=${!exit_var} fi - debug "Execute(): $object exit state was $ret" + debug 'MAIN' "Execute(): $object exit state was $ret" cd $PWD_BACKUP return $ret } @@ -191,7 +196,7 @@ ended_ok () [ "$1" != phase -a "$1" != worker ] && die_error "ended_ok's first argument must be a valid type (phase/worker)" object=$1_$2 exit_var=exit_$object - debug "Ended_ok? -> Exit state of $object was: ${!exit_var} (if empty. it's not executed yet)" + debug 'MAIN' "Ended_ok? -> Exit state of $object was: ${!exit_var} (if empty. it's not executed yet)" [ "${!exit_var}" = '0' ] && return 0 [ "${!exit_var}" = '' ] && return 1 return ${!exit_var} diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh index 7369ec4..ae4f5d0 100644 --- a/src/core/libs/lib-blockdevices-filesystems.sh +++ b/src/core/libs/lib-blockdevices-filesystems.sh @@ -278,7 +278,7 @@ target_configure_fstab() # $2 a string of the form: :[:+] (the + is bootable flag) partition() { - debug "Partition called like: partition '$1' '$2'" + debug 'FS' "Partition called like: partition '$1' '$2'" [ -z "$1" ] && die_error "partition() requires a device file and a partition string" [ -z "$2" ] && die_error "partition() requires a partition string" @@ -317,7 +317,7 @@ partition() sfdisk_input=$(printf "$sfdisk_input") # convert \n to newlines # invoke sfdisk - debug "Partition calls: sfdisk $DEVICE -uM >$LOG 2>&1 <<< $sfdisk_input" + debug 'FS' "Partition calls: sfdisk $DEVICE -uM >$LOG 2>&1 <<< $sfdisk_input" printk off sfdisk $DEVICE -uM >$LOG 2>&1 <Already done" + debug 'FS' "$fs_id ->Already done" else # We can't always do -b on the lvm VG. because the devicefile sometimes doesn't exist for a VG. vgdisplay to the rescue! if [ "$part_type" = lvm-vg ] && vgdisplay $part | grep -q 'VG Name' # $part is a lvm VG and it exists. note that vgdisplay exists 0 when the requested vg doesn't exist. then - debug "$fs_id ->Still need to do it: Making the filesystem on a vg volume" + debug 'FS' "$fs_id ->Still need to do it: Making the filesystem on a vg volume" infofy "Making $fs_type filesystem on $part" disks process_filesystem $part $fs_type $fs_create $fs_mountpoint no_mount $fs_opts $fs_label $fs_params && done_filesystems+=("$fs_id") || returncode=1 elif [ "$part_type" != lvm-pv -a -b "$part" ] # $part is not a lvm PV and it exists then - debug "$fs_id ->Still need to do it: Making the filesystem on a non-pv volume" + debug 'FS' "$fs_id ->Still need to do it: Making the filesystem on a non-pv volume" infofy "Making $fs_type filesystem on $part" disks process_filesystem $part $fs_type $fs_create $fs_mountpoint no_mount $fs_opts $fs_label $fs_params && done_filesystems+=("$fs_id") || returncode=1 elif [ "$part_type" = lvm-pv ] && pvdisplay ${fs_params//:/ } >/dev/null # $part is a lvm PV. all needed lvm pv's exist. note that pvdisplay exits 5 as long as one of the args doesn't exist then - debug "$fs_id ->Still need to do it: Making the filesystem on a pv volume" + debug 'FS' "$fs_id ->Still need to do it: Making the filesystem on a pv volume" infofy "Making $fs_type filesystem on $part" disks process_filesystem ${part/+/} $fs_type $fs_create $fs_mountpoint no_mount $fs_opts $fs_label $fs_params && done_filesystems+=("$fs_id") || returncode=1 else - debug "$fs_id ->Cannot do right now..." + debug 'FS' "$fs_id ->Cannot do right now..." open_items=1 fi fi @@ -512,7 +512,7 @@ rollback_filesystems () then if pvdisplay $real_part &>/dev/null then - debug "$part ->Cannot do right now..." + debug 'FS' "$part ->Cannot do right now..." open_items=1 else infofy "Attempting destruction of device $part (type $part_type)" disks @@ -523,7 +523,7 @@ rollback_filesystems () fi fi else - debug "Skipping destruction of device $part (type $part_type) because it doesn't exist" + debug 'FS' "Skipping destruction of device $part (type $part_type) because it doesn't exist" fi elif [ "$part_type" = lvm-pv ] # Can be in use for: lvm-vg then @@ -531,7 +531,7 @@ rollback_filesystems () then if vgdisplay -v 2>/dev/null | grep -q $real_part # check if it's in use then - debug "$part ->Cannot do right now..." + debug 'FS' "$part ->Cannot do right now..." open_items=1 else infofy "Attempting destruction of device $part (type $part_type)" disks @@ -542,7 +542,7 @@ rollback_filesystems () fi fi else - debug "Skipping destruction of device $part (type $part_type) because it doesn't exist" + debug 'FS' "Skipping destruction of device $part (type $part_type) because it doesn't exist" fi elif [ "$part_type" = lvm-vg ] #Can be in use for: lvm-lv then @@ -551,7 +551,7 @@ rollback_filesystems () open_lv=`vgdisplay -c $part 2>/dev/null | cut -d ':' -f6` if [ $open_lv -gt 0 ] then - debug "$part ->Cannot do right now..." + debug 'FS' "$part ->Cannot do right now..." open_items=1 else infofy "Attempting destruction of device $part (type $part_type)" disks @@ -562,7 +562,7 @@ rollback_filesystems () fi fi else - debug "Skipping destruction of device $part (type $part_type) because it doesn't exist" + debug 'FS' "Skipping destruction of device $part (type $part_type) because it doesn't exist" fi elif [ "$part_type" = lvm-lv ] #Can be in use for: dm_crypt or raw. we don't need to care about raw (it will be unmounted so it can be destroyed) then @@ -570,7 +570,7 @@ rollback_filesystems () then if cryptsetup isLuks $part &>/dev/null then - debug "$part ->Cannot do right now..." + debug 'FS' "$part ->Cannot do right now..." open_items=1 else infofy "Attempting destruction of device $part (type $part_type)" disks @@ -581,7 +581,7 @@ rollback_filesystems () fi fi else - debug "Skipping destruction of device $part (type $part_type) because it doesn't exist" + debug 'FS' "Skipping destruction of device $part (type $part_type) because it doesn't exist" fi else die_error "Unrecognised partition type $part_type for partition $part. This should never happen. please report this" @@ -616,7 +616,7 @@ process_filesystem () { [ "$2" != lvm-lv ] && [ -z "$1" -o ! -b "$1" ] && die_error "process_filesystem needs a partition as \$1" # Don't do this for lv's. It's a hack to workaround non-existence of VG device files. [ -z "$2" ] && die_error "process_filesystem needs a filesystem type as \$2" - debug "process_filesystem $@" + debug 'FS' "process_filesystem $@" part=$1 fs_type=$2 fs_create=${3:-yes} @@ -674,12 +674,12 @@ process_filesystem () BLOCK_ROLLBACK_USELESS=0 if [ "$fs_type" = swap ] then - debug "swaponning $part" + debug 'FS' "swaponning $part" swapon $part >$LOG 2>&1 || ( show_warning 'Swapon' "Error activating swap: swapon $part" ; return 1 ) else [ "$fs_mount" = runtime ] && dst=$fs_mountpoint [ "$fs_mount" = target ] && dst=$var_TARGET_DIR$fs_mountpoint - debug "mounting $part on $dst" + debug 'FS' "mounting $part on $dst" mkdir -p $dst &>/dev/null # directories may or may not already exist mount -t $fs_type $part $dst >$LOG 2>&1 || ( show_warning 'Mount' "Error mounting $part on $dst" ; return 1 ) if [ "$fs_mount" = target -a $fs_mountpoint = '/' ] diff --git a/src/core/libs/lib-misc.sh b/src/core/libs/lib-misc.sh index ac66bd1..97252b9 100644 --- a/src/core/libs/lib-misc.sh +++ b/src/core/libs/lib-misc.sh @@ -12,16 +12,16 @@ run_background () [ -z "$2" ] && die_error "run_background needs a command to execute!" [ -z "$3" ] && die_error "run_background needs a logfile to redirect output to!" - debug "run_background called. identifier: $1, command: $2, logfile: $3" + debug 'MISC' "run_background called. identifier: $1, command: $2, logfile: $3" ( \ touch $RUNTIME_DIR/aif-$1-running - debug "run_background starting $1: $2 >>$3 2>&1" + debug 'MISC' "run_background starting $1: $2 >>$3 2>&1" [ -f $3 ] && echo -e "\n\n\n" >>$3 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 "run_background done with $1: exitcode (\$$1_exitcode): "${!var_exit}" .Logfile $3" #TODO ${!var_exit} doesn't show anything --> maybe fixed now + debug 'MISC' "run_background done with $1: exitcode (\$$1_exitcode): ${!var_exit} .Logfile $3" #TODO ${!var_exit} doesn't show anything --> maybe fixed now echo >> $3 rm -f $RUNTIME_DIR/aif-$1-running ) & @@ -50,7 +50,7 @@ wait_for () # $2 needle check_is_in () { - [ -z "$1" ] && debug "check_is_in $1 $2" && die_error "check_is_in needs a non-empty needle as \$2 and a haystack as \$1!" # haystack can be empty though + [ -z "$1" ] && debug 'MISC' "check_is_in $1 $2" && die_error "check_is_in needs a non-empty needle as \$2 and a haystack as \$1!" # haystack can be empty though local pattern="$1" element shift diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index ccb912f..f015082 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -417,7 +417,7 @@ remove_blockdevice () declare target_escaped=${target//\//\\/} # note: apparently no need to escape the '+' sign for sed. declare target_escawk=${target_escaped/+/\\+} # ...but that doesn't count for awk fs_string=`awk "/^$target_escawk / { print \$4}" $TMP_BLOCKDEVICES` #TODO: fs_string is the entire line, incl part? - debug "Cleaning up partition $part (type $part_type, label $part_label). It has the following FS's on it: $fs_string" + debug 'UI-INTERACTIVE' "Cleaning up partition $part (type $part_type, label $part_label). It has the following FS's on it: $fs_string" sed -i "/$target_escaped/d" $TMP_BLOCKDEVICES || show_warning "blockdevice removal" "Could not remove partition $part (type $part_type, label $part_label). This is a bug. please report it" for fs in `sed 's/|/ /g' <<< $fs_string` do diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index 53ff8ea..bfe49dc 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -18,7 +18,7 @@ var_CONSOLEFONT=`sed -n '/^CONSOLEFONT/p' /etc/rc.conf | sed 's/KEYMAP=//' | sed # display error message and die die_error () { - debug "die_error: ERROR: $@" + debug 'UI' "die_error: ERROR: $@" notify "ERROR: $@" exit 2 } @@ -35,7 +35,7 @@ show_warning () [ -n "$3" -a "$3" != msg -a "$3" != text ] && die_error "show_warning \$3 must be text or msg" type=msg [ -n "$3" ] && type=$3 - debug "show_warning '$1': $2 ($type)" + debug 'UI' "show_warning '$1': $2 ($type)" if [ "$var_UI_TYPE" = dia ] then _dia_DIALOG --title "$1" --exit-label "Continue" --${type}box "$2" 18 70 || die_error "dialog could not show --${type}box $2. often this means a file does not exist" @@ -52,7 +52,7 @@ show_warning () #notify user notify () { - debug "notify: $@" + debug 'UI' "notify: $@" if [ "$var_UI_TYPE" = dia ] then _dia_DIALOG --msgbox "$@" 20 50 @@ -72,7 +72,7 @@ infofy () #TODO: when using successive things, the screen can become full and yo { successive=${2:-0} succ_last=${3:-0} - debug "infofy: $1" + debug 'UI' "infofy: $1" if [ "$var_UI_TYPE" = dia ] then str="$1" @@ -152,7 +152,7 @@ _getavaildisks() ask_checklist () { [ -z "$1" ] && die_error "ask_checklist needs a question!" - [ -z "$4" ] && debug "ask_checklist args: $@" && die_error "ask_checklist makes only sense if you specify at least 1 thing (tag,item and ON/OFF switch)" + [ -z "$4" ] && debug 'UI' "ask_checklist args: $@" && die_error "ask_checklist makes only sense if you specify at least 1 thing (tag,item and ON/OFF switch)" [ "$var_UI_TYPE" = dia ] && { _dia_ask_checklist "$@" ; return $? ; } [ "$var_UI_TYPE" = cli ] && { _cli_ask_checklist "$@" ; return $? ; } } @@ -289,7 +289,7 @@ _dia_ask_checklist () _dia_DIALOG --checklist "$str" 30 60 20 $list 2>$ANSWER ret=$? ANSWER_CHECKLIST=`cat $ANSWER` - debug "_dia_ask_checklist: user checked ON: $ANSWER_CHECKLIST" + debug 'UI' "_dia_ask_checklist: user checked ON: $ANSWER_CHECKLIST" return $ret } @@ -301,7 +301,7 @@ _dia_ask_datetime () local _date="$(cat $ANSWER)" # form like: 07/12/2008 dialog --timebox "Set the time.\nUse to navigate and up/down to change values." 0 0 2> $ANSWER || return 1 local _time="$(cat $ANSWER)" # form like: 15:26:46 - debug "Date as specified by user $_date time: $_time" + debug 'UI' "Date as specified by user $_date time: $_time" # DD/MM/YYYY hh:mm:ss -> MMDDhhmmYYYY.ss (date default format, set like date $ANSWER_DATETIME) Not enabled because there is no use for it i think. # ANSWER_DATETIME=$(echo "$_date" "$_time" | sed 's#\(..\)/\(..\)/\(....\) \(..\):\(..\):\(..\)#\2\1\4\5\3\6#g') @@ -337,7 +337,7 @@ _dia_ask_number () fi fi done - debug "_dia_ask_number: user entered: $ANSWER_NUMBER" + debug 'UI' "_dia_ask_number: user entered: $ANSWER_NUMBER" [ -z "$ANSWER_NUMBER" ] && return 1 return $ret } @@ -349,7 +349,7 @@ _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 "_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 + [ -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 DIA_MENU_TITLE=$2 EXTRA_INFO=$3 @@ -357,7 +357,7 @@ _dia_ask_option () _dia_DIALOG $DEFAULT --colors --title " $DIA_MENU_TITLE " --menu "$DIA_MENU_TEXT $EXTRA_INFO" 20 80 16 "$@" 2>$ANSWER ret=$? ANSWER_OPTION=`cat $ANSWER` - debug "dia_ask_option: User choose $ANSWER_OPTION ($DIA_MENU_TITLE)" + debug 'UI' "dia_ask_option: User choose $ANSWER_OPTION ($DIA_MENU_TITLE)" return $ret } @@ -378,7 +378,7 @@ _dia_ask_password () [ -n "$type_u" ] && read ${type_u}_PASSWORD < $ANSWER [ -z "$type_u" ] && read PASSWORD < $ANSWER cat $ANSWER - debug "_dia_ask_password: user entered <>" + debug 'UI' "_dia_ask_password: user entered <>" return $ret } @@ -389,7 +389,7 @@ _dia_ask_string () _dia_DIALOG --inputbox "$1" 8 65 "$2" 2>$ANSWER ret=$? ANSWER_STRING=`cat $ANSWER` - debug "_dia_ask_string: user entered $ANSWER_STRING" + debug 'UI' "_dia_ask_string: user entered $ANSWER_STRING" [ -z "$ANSWER_STRING" ] && return $exitcode return $ret } @@ -427,8 +427,8 @@ _dia_ask_yesno () [ -n "$2" ] && str="$str (default: $2)" dialog --yesno "$str" $height 55 # returns 0 for yes, 1 for no ret=$? - [ $ret -eq 0 ] && debug "dia_ask_yesno: User picked YES" - [ $ret -gt 0 ] && debug "dia_ask_yesno: User picked NO" + [ $ret -eq 0 ] && debug 'UI' "dia_ask_yesno: User picked YES" + [ $ret -gt 0 ] && debug 'UI' "dia_ask_yesno: User picked NO" return $ret } @@ -468,7 +468,7 @@ _cli_ask_datetime () { ask_string "Enter date [YYYY-MM-DD hh:mm:ss]" ANSWER_DATETIME=$ANSWER_STRING - debug "Date as picked by user: $ANSWER_STRING" + debug 'UI' "Date as picked by user: $ANSWER_STRING" } @@ -499,7 +499,7 @@ _cli_ask_number () fi fi done - debug "cli_ask_number: user entered: $ANSWER_NUMBER" + debug 'UI' "cli_ask_number: user entered: $ANSWER_NUMBER" [ -z "$ANSWER_NUMBER" ] && return 1 return 0 } @@ -513,7 +513,7 @@ _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 "_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 + [ -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 MENU_TITLE=$2 EXTRA_INFO=$3 @@ -531,7 +531,7 @@ _cli_ask_option () [ -z "$DEFAULT" ] && echo -n " > " read ANSWER_OPTION [ -z "$ANSWER_OPTION" -a -n "$DEFAULT" ] && ANSWER_OPTION="$DEFAULT" - debug "cli_ask_option: User choose $ANSWER_OPTION ($MENU_TITLE)" + debug 'UI' "cli_ask_option: User choose $ANSWER_OPTION ($MENU_TITLE)" [ "$ANSWER_OPTION" = CANCEL ] && return 1 return 0 } @@ -565,7 +565,7 @@ _cli_ask_string () [ -n "$2" ] && echo "(Press enter for default. Default: $2)" echo -n ">" read ANSWER_STRING - debug "cli_ask_string: User entered: $ANSWER_STRING" + debug 'UI' "cli_ask_string: User entered: $ANSWER_STRING" if [ -z "$ANSWER_STRING" ] then if [ -n "$2" ] @@ -595,10 +595,10 @@ _cli_ask_yesno () answer=`tr '[:upper:]' '[:lower:]' <<< $answer` if [ "$answer" = y -o "$answer" = yes ] || [ -z "$answer" -a "$2" = yes ] then - debug "cli_ask_yesno: User picked YES" + debug 'UI' "cli_ask_yesno: User picked YES" return 0 else - debug "cli_ask_yesno: User picked NO" + debug 'UI' "cli_ask_yesno: User picked NO" return 1 fi } diff --git a/src/core/procedures/interactive b/src/core/procedures/interactive index 051d187..46bd6d7 100644 --- a/src/core/procedures/interactive +++ b/src/core/procedures/interactive @@ -114,7 +114,7 @@ worker_configure_system() # /etc/pacman.d/mirrorlist # add installer-selected mirror to the top of the mirrorlist if [ "$var_PKG_SOURCE_TYPE" = "ftp" -a "${var_SYNC_URL}" != "" ]; then - debug "Adding choosen mirror (${var_SYNC_URL}) to ${var_TARGET_DIR}/$var_MIRRORLIST" + debug 'PROCEDURE' "Adding choosen mirror (${var_SYNC_URL}) to ${var_TARGET_DIR}/$var_MIRRORLIST" mirrorlist=`awk "BEGIN { printf(\"# Mirror used during installation\nServer = "${var_SYNC_URL}"\n\n\") } 1 " "${var_TARGET_DIR}/$var_MIRRORLIST"` echo "$mirrorlist" > "${var_TARGET_DIR}/$var_MIRRORLIST" #TODO: test this, this may not work fi -- cgit v1.2.3-54-g00ecf From 228da8e66ed4b9b1e88d81b5817ffcad9b7dfdac Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 28 Feb 2009 14:45:59 +0100 Subject: cleaner way + fix for correct consolefont and keymap --- src/core/libs/lib-ui.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index bfe49dc..9e75cef 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -9,8 +9,11 @@ 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 -var_KEYMAP=`sed -n '/^KEYMAP/p' /etc/rc.conf | sed 's/KEYMAP=//' | sed 's/"//g'` #default keymap as configured on install CD. can be overridden -var_CONSOLEFONT=`sed -n '/^CONSOLEFONT/p' /etc/rc.conf | sed 's/KEYMAP=//' | sed 's/"//g'` #default consolefont as configured on install CD. can be overridden + +#default keymap and consolefont configured on install CD. can be overridden +source /etc/rc.conf +var_KEYMAP=$KEYMAP +var_CONSOLEFONT=$CONSOLEFONT ### Functions that your code can use. Cli/dialog mode is fully transparant. This library takes care of it ### -- 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/libs') 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 e23d522bb23a728613fcf02ae3f1634c527e091b Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 28 Feb 2009 15:19:26 +0100 Subject: select_time ask yesno fix --- src/core/libs/lib-ui-interactive.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index 1e6d42f..a782a12 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -74,7 +74,7 @@ interactive_time () { dohwclock - if 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 which ntpdate >/dev/null && ask_yesno "'ntpdate' was detected on your system.\n\nDo you want to use 'ntpdate' for syncing your clock,\nby using the internet clock pool?\n(You need a working internet connection for doing this!)" yes #TODO: only propose if network ok. then if ntpdate pool.ntp.org >/dev/null then -- cgit v1.2.3-54-g00ecf From 9f9c8d5450da681c6920bea816cbf9a0db170879 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 28 Feb 2009 15:29:17 +0100 Subject: set_keymap option dialog fix --- src/core/libs/lib-ui.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index e81cbb3..1724ed1 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -632,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 optional && { + ask_option "$var_KEYMAP" "Select A Keymap" '' optional $KEYMAPS && { loadkeys -q $KBDDIR/keymaps/$ANSWER_OPTION var_KEYMAP=$ANSWER_OPTION } -- cgit v1.2.3-54-g00ecf From 7cc05b89cbe71455d5ea3859341908b3af451baa Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 28 Feb 2009 15:35:15 +0100 Subject: ask_option fixes --- src/core/libs/lib-ui.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index 1724ed1..5955334 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -359,13 +359,13 @@ _dia_ask_option () DIA_MENU_TITLE=$2 EXTRA_INFO=$3 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 + CANCEL_LABEL=Cancel + [ $TYPE == optional ] && CANCEL_LABEL='Skip' + _dia_DIALOG $DEFAULT --cancel-label $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)" - [ $type == required ] && 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' } -- cgit v1.2.3-54-g00ecf From 0fc9ade9bbd89355acef54733378066aeaf265cb Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 28 Feb 2009 16:02:20 +0100 Subject: ask_option fixes --- src/core/libs/lib-ui.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index 5955334..d7481e4 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -190,10 +190,11 @@ ask_number () # $1 default item (set to 'no' for none) # $2 title # $3 additional explanation (default: '') -# $4 type (required or optional). '' means required. cancel labels will be 'Cancel' and 'Skip' respectively. if (canceled), required will return >0, optional not. +# $4 type (required or optional). '' means required. cancel labels will be 'Cancel' and 'Skip' respectively. # 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 + +# $ANSWER_OPTION : selected answer (if none selected: default (if available), or empty string otherwise). if user hits cancel or skip, this is an empty string. +# $? : 0 if the user selected anything or skipped (when optional), when user cancelled: 1 ask_option () { [ "$var_UI_TYPE" = dia ] && { _dia_ask_option "$@" ; return $? ; } @@ -517,7 +518,7 @@ _cli_ask_option () { #TODO: strip out color codes #TODO: if user entered incorrect choice, ask him again - DEFAULT="" + DEFAULT= [ "$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 @@ -544,6 +545,7 @@ _cli_ask_option () [ -z "$ANSWER_OPTION" -a -n "$DEFAULT" ] && ANSWER_OPTION="$DEFAULT" debug 'UI' "cli_ask_option: User choose $ANSWER_OPTION ($MENU_TITLE)" [ "$ANSWER_OPTION" = CANCEL ] && return 1 + [ -z "$ANSWER_OPTION" -a type == required ] && return 1 return 0 } -- cgit v1.2.3-54-g00ecf From 4d7dbff90b8333deb2c2c3c0dbd1aa3e9aafa3d5 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 28 Feb 2009 16:09:46 +0100 Subject: fixes in set_keymap --- src/core/libs/lib-ui.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index d7481e4..b7f24f9 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -634,17 +634,21 @@ 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" "Select A Keymap" '' optional $KEYMAPS + if [ -n "$ANSWER_OPTION" ] + then loadkeys -q $KBDDIR/keymaps/$ANSWER_OPTION var_KEYMAP=$ANSWER_OPTION - } + fi FONTS= # skip .cp.gz and partialfonts files for now see bug #6112, #6111 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" '' optional $FONTS && { + ask_option "$var_CONSOLEFONT" "Select A Console Font" '' optional $FONTS + if [ -n "$ANSWER_OPTION" ] + then var_CONSOLEFONT=$ANSWER_OPTION for i in 1 2 3 4 do @@ -654,5 +658,5 @@ set_keymap () setfont $KBDDIR/consolefonts/$var_CONSOLEFONT -C /dev/tty$i fi done - } + fi } -- cgit v1.2.3-54-g00ecf From a22294e811ffc7b5765aa0b7190b438588222e1b Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 28 Feb 2009 16:29:49 +0100 Subject: error checking on $TYPE in ask_option --- src/core/libs/lib-ui.sh | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index b7f24f9..336a3e7 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -355,6 +355,7 @@ _dia_ask_option () [ -z "$2" ] && die_error "ask_option \$2 must be the title" # $3 is optional more info TYPE=${4:-required} + [ "$TYPE" != required -a "$TYPE" != optional ] && debug 'UI' "_dia_ask_option args: $@" && die_error "ask option \$4 must be required or optional or ''. not $TYPE" [ -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 @@ -523,6 +524,7 @@ _cli_ask_option () [ -z "$2" ] && die_error "ask_option \$2 must be the title" # $3 is optional more info TYPE=${4:-required} + [ "$TYPE" != required -a "$TYPE" != optional ] && debug 'UI' "_dia_ask_option args: $@" && die_error "ask option \$4 must be required or optional or ''. not $TYPE" [ -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 -- cgit v1.2.3-54-g00ecf From 008773ad691bfa59bc3e0a1ef89b798cea5107bf Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 28 Feb 2009 17:07:01 +0100 Subject: clearer debugging in ask_option functions + fixes in cli_ask_option + font fix in set_keymap --- src/core/libs/lib-ui.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index 336a3e7..90afeba 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -366,7 +366,7 @@ _dia_ask_option () _dia_DIALOG $DEFAULT --cancel-label $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)" + debug 'UI' "dia_ask_option: ANSWER_OPTION: $ANSWER_OPTION, returncode (skip/cancel): $ret ($DIA_MENU_TITLE)" [ $TYPE == required ] && return $ret return 0 # TODO: check if dialog returned >0 because of an other reason then the user hitting 'cancel/skip' } @@ -544,11 +544,14 @@ _cli_ask_option () [ -n "$DEFAULT" ] && echo -n " > [ $DEFAULT ] " [ -z "$DEFAULT" ] && echo -n " > " read ANSWER_OPTION + ret=0 [ -z "$ANSWER_OPTION" -a -n "$DEFAULT" ] && ANSWER_OPTION="$DEFAULT" - debug 'UI' "cli_ask_option: User choose $ANSWER_OPTION ($MENU_TITLE)" - [ "$ANSWER_OPTION" = CANCEL ] && return 1 - [ -z "$ANSWER_OPTION" -a type == required ] && return 1 - return 0 + [ "$ANSWER_OPTION" == CANCEL ] && ret=1 && ANSWER_OPTION= + [ "$ANSWER_OPTION" == SKIP ] && ret=0 && ANSWER_OPTION= + [ -z "$ANSWER_OPTION" -a "$TYPE" == required ] && ret=1 + + debug 'UI' "cli_ask_option: ANSWER_OPTION: $ANSWER_OPTION, returncode (skip/cancel): $ret ($MENU_TITLE)" + return $ret } @@ -648,7 +651,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" '' optional $FONTS + ask_option "${var_CONSOLEFONT:-no}" "Select A Console Font" '' optional $FONTS if [ -n "$ANSWER_OPTION" ] then var_CONSOLEFONT=$ANSWER_OPTION -- cgit v1.2.3-54-g00ecf From 0426846d1ecbda0fd90451fb26262286b0bf05ad Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 28 Feb 2009 17:27:41 +0100 Subject: fix for lvm cancel bug and todo updates --- TODO | 2 - src/core/libs/lib-ui-interactive.sh | 77 ++++++++++++++++++------------------- 2 files changed, 38 insertions(+), 41 deletions(-) (limited to 'src/core/libs') diff --git a/TODO b/TODO index cdcb4bf..8ee60bd 100644 --- a/TODO +++ b/TODO @@ -3,7 +3,6 @@ See also the FIXME's and TODO's in the code. CURRENT ISSUES: * date/time setting stuff (see ML thread) hangs at select timezone? -* keyboard stuff (setting consolefont and keymap + setting in $target/etc/rc.conf ) * 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 @@ -33,7 +32,6 @@ CURRENT ISSUES: * the old installer asked a lot of questions before actually configuring the system, eg like 'do you need support for booting from nfs/softraid/lvm2/encrypted, custom dst file?' etc.\ do we still need this? why (not)?, and a select tag thingie would be nicer imho * refactor all pacman stuff (modularize/functionize etc) -* in lvm VG editor you can press "cancel" (when 'new' is selected, maybe otherwise too) and create a new LV which will get a block entry, but no fs entry on the VG block! * aif : na "mijn" partitielayout: bij grub ( nog voor text editor op menu.lst) zegt iets ( op foreground van ncurses) Can't remove.. ik denk zelfs 'Grub: Can't remove..' en daarna een gewone entry, geen uuid's gewoon /dev/sda3 ro * port from /arch/setup: grub install chroot thing (http://projects.archlinux.org/?p=installer.git;a=commitdiff;h=4565577dbd2182dd49612f1e0b68288f5573bf7b) (waiting for ticket http://bugs.archlinux.org/task/13277) * ext4 default options? -O dir_index,extent,uninit_bg ? diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index a782a12..bd66038 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -484,53 +484,52 @@ interactive_filesystems() { then for lv in `sed 's/|/ /g' <<< $fs` do - label=$( cut -d ';' -f 6 <<< $lv) - size=$(cut -d ';' -f 7 <<< $lv) + label=$(cut -d ';' -f 6 <<< $lv) + size=$( cut -d ';' -f 7 <<< $lv) list="$list $label $size" done - else - 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:" required $list - EDIT_VG=$ANSWER_OPTION - if [ "$ANSWER_OPTION" = XXX -o "$ANSWER_OPTION" = empty ] - then - # a new LV must be created on this VG - if interactive_filesystem $part $part_type $part_label '' + 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" = empty ] then - if [ "$NEW_FILESYSTEM" != no_fs ] + # a new LV must be created on this VG + if interactive_filesystem $part $part_type $part_label '' then - [ -n "$fs" ] && fs="$fs|$NEW_FILESYSTEM" - [ -z "$fs" ] && fs=$NEW_FILESYSTEM + if [ "$NEW_FILESYSTEM" != no_fs ] + then + [ -n "$fs" ] && fs="$fs|$NEW_FILESYSTEM" + [ -z "$fs" ] && fs=$NEW_FILESYSTEM + fi fi + else + # an existing LV will be edited and it's settings updated + for lv in `sed 's/|/ /g' <<< $fs` + do + label=$(cut -d ';' -f 6 <<< $lv) + [ "$label" = "$EDIT_VG" ] && found_lv="$lv" + done + interactive_filesystem $part $part_type $part_label "$found_lv" + newfs= + for lv in `sed 's/|/ /g' <<< $fs` + do + label=$(cut -d ';' -f 6 <<< $lv) + if [ "$label" != "$EDIT_VG" ] + then + add=$lv + elif [ $NEW_FILESYSTEM != no_fs ] + then + add=$NEW_FILESYSTEM + else + add= + fi + [ -n "$add" -a -n "$newfs" ] && newfs="$newfs|$add" + [ -n "$add" -a -z "$newfs" ] && newfs=$add + done + fs=$newfs fi - else - # an existing LV will be edited and it's settings updated - for lv in `sed 's/|/ /g' <<< $fs` - do - label=$(cut -d ';' -f 6 <<< $lv) - [ "$label" = "$EDIT_VG" ] && found_lv="$lv" - done - interactive_filesystem $part $part_type $part_label "$found_lv" - newfs= - for lv in `sed 's/|/ /g' <<< $fs` - do - label=$(cut -d ';' -f 6 <<< $lv) - if [ "$label" != "$EDIT_VG" ] - then - add=$lv - elif [ $NEW_FILESYSTEM != no_fs ] - then - add=$NEW_FILESYSTEM - else - add= - fi - [ -n "$add" -a -n "$newfs" ] && newfs="$newfs|$add" - [ -n "$add" -a -z "$newfs" ] && newfs=$add - done - fs=$newfs - fi + } else interactive_filesystem $part $part_type "$part_label" "$fs" [ $? -eq 0 ] && fs=$NEW_FILESYSTEM -- cgit v1.2.3-54-g00ecf From 07d9ffe35c6dffda66987832a25802cbf54f2f4e Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 28 Feb 2009 17:33:25 +0100 Subject: check_is_in fixes --- src/core/libs/lib-blockdevices-filesystems.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh index ae4f5d0..1307d52 100644 --- a/src/core/libs/lib-blockdevices-filesystems.sh +++ b/src/core/libs/lib-blockdevices-filesystems.sh @@ -395,7 +395,7 @@ process_filesystems () fs_id="$part $fs_type $fs_mountpoint $fs_opts $fs_label $fs_params" if [ "$fs_create" = yes ] then - if check_is_in "$fs_id" "${done_filesystems[@]}" + if check_is_in "${done_filesystems[@]}" "$fs_id" then debug 'FS' "$fs_id ->Already done" else @@ -472,7 +472,7 @@ rollback_filesystems () elif [ "$fs_mountpoint" != no_mountpoint ] then part_real=${part/+/} - if ! check_is_in "$part_real" "${done_umounts[@]}" + if ! check_is_in "${done_umounts[@]}" "$part_real" then infofy "(Maybe) Umounting $part_real" disks if mount | grep -q "^$part_real " # could be that this was not mounted yet. no problem, we can just skip it then. @@ -744,7 +744,7 @@ get_blockdevice_size () [ -b "$1" ] || die_error "get_blockdevice_size needs a blockdevice as \$1 ($1 given)" unit=${2:-B} allowed_units=(B KiB kB MiB MB GiB GB) - if ! is_in $unit "${allowed_units[@]}" + if ! check_is_in "${allowed_units[@]}" $unit then die_error "Unrecognized unit $unit!" fi -- cgit v1.2.3-54-g00ecf From 6f20b17624a1fb9c6e4d6fd1ba4efaf463209065 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 28 Feb 2009 18:02:11 +0100 Subject: check_is_in fixes.. and this time i mean it.. i think. hopefully. + test script for check_is_in --- src/core/libs/lib-blockdevices-filesystems.sh | 6 +++--- src/core/libs/lib-misc.sh | 10 ++++++---- src/core/procedures/automatic | 4 ++-- tests/test-check_is_in.sh | 7 +++++++ 4 files changed, 18 insertions(+), 9 deletions(-) create mode 100755 tests/test-check_is_in.sh (limited to 'src/core/libs') diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh index 1307d52..4979c1f 100644 --- a/src/core/libs/lib-blockdevices-filesystems.sh +++ b/src/core/libs/lib-blockdevices-filesystems.sh @@ -395,7 +395,7 @@ process_filesystems () fs_id="$part $fs_type $fs_mountpoint $fs_opts $fs_label $fs_params" if [ "$fs_create" = yes ] then - if check_is_in "${done_filesystems[@]}" "$fs_id" + if check_is_in "$fs_id" "${done_filesystems[@]}" then debug 'FS' "$fs_id ->Already done" else @@ -472,7 +472,7 @@ rollback_filesystems () elif [ "$fs_mountpoint" != no_mountpoint ] then part_real=${part/+/} - if ! check_is_in "${done_umounts[@]}" "$part_real" + if ! check_is_in "$part_real" "${done_umounts[@]}" then infofy "(Maybe) Umounting $part_real" disks if mount | grep -q "^$part_real " # could be that this was not mounted yet. no problem, we can just skip it then. @@ -744,7 +744,7 @@ get_blockdevice_size () [ -b "$1" ] || die_error "get_blockdevice_size needs a blockdevice as \$1 ($1 given)" unit=${2:-B} allowed_units=(B KiB kB MiB MB GiB GB) - if ! check_is_in "${allowed_units[@]}" $unit + if ! check_is_in $unit "${allowed_units[@]}" then die_error "Unrecognized unit $unit!" fi diff --git a/src/core/libs/lib-misc.sh b/src/core/libs/lib-misc.sh index 97252b9..6f7af95 100644 --- a/src/core/libs/lib-misc.sh +++ b/src/core/libs/lib-misc.sh @@ -46,18 +46,20 @@ wait_for () } -# $1 set (array) haystack -# $2 needle +# $1 needle +# $2 set (array) haystack check_is_in () { - [ -z "$1" ] && debug 'MISC' "check_is_in $1 $2" && die_error "check_is_in needs a non-empty needle as \$2 and a haystack as \$1!" # haystack can be empty though + [ -z "$1" ] && debug 'MISC' "check_is_in $1 $2" && die_error "check_is_in needs a non-empty needle as \$1 and a haystack as \$2!" # haystack can be empty though local pattern="$1" element shift for element do - [[ $element = $pattern ]] && return 0 + [[ $element = $pattern ]] && debug 'MISC' "Checking if $element = $pattern ..yes !" && return 0 + debug 'MISC' "Checking if $element = $pattern ... no" done + debug 'MISC' "Check_is_in could not find $1 in $2" return 1 } diff --git a/src/core/procedures/automatic b/src/core/procedures/automatic index 3c93167..cde7f6a 100644 --- a/src/core/procedures/automatic +++ b/src/core/procedures/automatic @@ -71,14 +71,14 @@ worker_runtime_network () # Check if we have all needed settings loaded from the profile worker_runtime_settings () { - if check_is_in $var_RUNTIME_PACKAGES svn + 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 $var_RUNTIME_PACKAGES moo + elif check_is_in moo $var_RUNTIME_PACKAGES then # Maybe more stuff later true diff --git a/tests/test-check_is_in.sh b/tests/test-check_is_in.sh new file mode 100755 index 0000000..0d97361 --- /dev/null +++ b/tests/test-check_is_in.sh @@ -0,0 +1,7 @@ +basedir=$(dirname "`dirname $0`") +source $basedir/src/core/libs/lib-ui.sh #dependency needed +source $basedir/src/core/libs/lib-misc.sh + +vars=(A B C D E F) +check_is_in C "${vars[@]}" && echo 'ok C was in there' || echo 'wtf' +check_is_in AOEUAU "${vars[@]}" && echo wtf || echo 'ok it was not in there' -- cgit v1.2.3-54-g00ecf From 031b0a3936898a64976ba06fb2c8bb242fac046e Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 28 Feb 2009 18:22:15 +0100 Subject: debug fix in check_is_in --- src/core/libs/lib-misc.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-misc.sh b/src/core/libs/lib-misc.sh index 6f7af95..d0ad3f0 100644 --- a/src/core/libs/lib-misc.sh +++ b/src/core/libs/lib-misc.sh @@ -51,15 +51,17 @@ wait_for () check_is_in () { [ -z "$1" ] && debug 'MISC' "check_is_in $1 $2" && die_error "check_is_in needs a non-empty needle as \$1 and a haystack as \$2!" # haystack can be empty though + NEEDLE=$1 + HAYSTACK=$2 - local pattern="$1" element + local pattern="$NEEDLE" element shift for element do [[ $element = $pattern ]] && debug 'MISC' "Checking if $element = $pattern ..yes !" && return 0 debug 'MISC' "Checking if $element = $pattern ... no" done - debug 'MISC' "Check_is_in could not find $1 in $2" + debug 'MISC' "Check_is_in could not find $NEEDLE in $HAYSTACK" return 1 } -- 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') 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 931ab8f34899cabe293df900d19f470c50537ce6 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sun, 1 Mar 2009 17:59:07 +0100 Subject: fix for undefined die_error + avoid loops --- src/aif.sh | 10 +++++++++- src/core/libs/lib-ui.sh | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'src/core/libs') diff --git a/src/aif.sh b/src/aif.sh index 92467d9..54ed0a7 100755 --- a/src/aif.sh +++ b/src/aif.sh @@ -35,7 +35,15 @@ Available procedures: } -##### TMP functions that we need during early bootstrap but will be overidden with decent functions by libraries ###### +##### TMP functions that we need during early bootstrap but will be overidden with decent functions from libraries ###### + + +# Do not call other functions like debug, notify, .. here because that might cause loops! +die_error () +{ + echo "ERROR: $@" >&2 + exit 2 +} notify () diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index 90afeba..76aeecf 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -19,10 +19,10 @@ var_CONSOLEFONT=$CONSOLEFONT # display error message and die +# Do not call other functions like debug, notify, .. here because that might cause loops! die_error () { - debug 'UI' "die_error: ERROR: $@" - notify "ERROR: $@" + echo "ERROR: $@" >&2 exit 2 } -- cgit v1.2.3-54-g00ecf From 08c0adf9142dffb6a001466d5d4772e11c20c2e1 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sun, 1 Mar 2009 18:32:30 +0100 Subject: port my previous fixes to lib-ui --- src/core/libs/lib-ui.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index 76aeecf..cb40c9e 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -98,12 +98,12 @@ log () str="[LOG] `date +"%Y-%m-%d %H:%M:%S"` $@" if [ "$var_UI_TYPE" = dia ] then - echo -e "$str" >$LOG + echo -e "$str" >$LOG || die_error "Cannot log $str to $LOG" else - echo -e "$str" >$LOG + echo -e "$str" >$LOG || die_error "Cannot log $str to $LOG" fi - [ "$LOG_TO_FILE" = 1 ] && echo -e "$str" >> $LOGFILE + [ "$LOG_TO_FILE" = 1 ] && ( echo -e "$str" >> $LOGFILE || die_error "Cannot log $str to $LOGFILE" ) } @@ -114,11 +114,11 @@ debug () then if [ "$var_UI_TYPE" = dia ] then - echo -e "$str" > $LOG + echo -e "$str" > $LOG || die_error "Cannot debug $str to $LOG" else - echo -e "$str" > $LOG + echo -e "$str" > $LOG || die_error "Cannot debug $str to $LOG" fi - [ "$LOG_TO_FILE" = 1 ] && echo -e "$str" >> $LOGFILE + [ "$LOG_TO_FILE" = 1 ] && ( echo -e "$str" >> $LOGFILE || die_error "Cannot debug $str to $LOGFILE" ) fi } -- cgit v1.2.3-54-g00ecf From 3bae4b8c3c88b6a42c1ee14267648f47ddbcd989 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sun, 1 Mar 2009 21:19:50 +0100 Subject: fix for incorrect string replacement in repository adress for pacman repos. props to Gerhard B. --- src/core/libs/lib-pacman.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-pacman.sh b/src/core/libs/lib-pacman.sh index 4497074..2fc7663 100644 --- a/src/core/libs/lib-pacman.sh +++ b/src/core/libs/lib-pacman.sh @@ -78,7 +78,7 @@ do then add_pacman_repo target ${repo} "Include = $var_MIRRORLIST" else - add_pacman_repo target ${repo} "Server = ${serverurl/\/\$repo\//\/$repo\/}" # replace literal '/$repo/' in the serverurl string by "/$repo/" where $repo is our variable. + add_pacman_repo target ${repo} "Server = ${serverurl/\$repo/$repo}" # replace literal '$repo' in the serverurl string by "$repo" where $repo is our variable. fi done # Set up the necessary directories for pacman use -- cgit v1.2.3-54-g00ecf From 316afee4ea5b49bf75eb66b7e95c3ad3bd0ef21e Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Thu, 5 Mar 2009 21:03:17 +0100 Subject: fix for killing dhcpcd. Thanks Gerhard B.! --- TODO | 4 ---- src/core/libs/lib-ui-interactive.sh | 3 +-- 2 files changed, 1 insertion(+), 6 deletions(-) (limited to 'src/core/libs') diff --git a/TODO b/TODO index 6ed3e71..f58f885 100644 --- a/TODO +++ b/TODO @@ -35,10 +35,6 @@ CURRENT ISSUES: * port from /arch/setup: grub install chroot thing (http://projects.archlinux.org/?p=installer.git;a=commitdiff;h=4565577dbd2182dd49612f1e0b68288f5573bf7b) (waiting for ticket http://bugs.archlinux.org/task/13277) * ext4 default options? -O dir_index,extent,uninit_bg ? * find a way to not have to preload libs and stuff, only load them when needed. -> faster start of install program -* if dhcpd already runs for $reason, the installer will try again @ configure network and fail. - i tried killall dhcpd, killall -9 dhcpd first but that didn't help: it can't kill the process or something... - I can also add something like for iface in `moo` (or only the one selected iface); do ifconfig $iface down; - ifconfig $iface up; done, and then dhcpd again * core/interactive: do not check hard for the dependencies. a user could really know what he's doing or need to reboot after partitioning a disk and skip that check or something. Alternatively, maybe just show which steps are done successfully in the main menu * support maybe ntp to set clock diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index bd66038..85b9b58 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -637,8 +637,7 @@ interactive_runtime_network() { ask_yesno "Do you want to use DHCP?" if [ $? -eq 0 ]; then infofy "Please wait. Polling for DHCP server on $INTERFACE..." - killall dhcpd - killall -9 dhcpd + dhcpcd -k $INTERFACE >$LOG 2>&1 sleep 1 dhcpcd $INTERFACE >$LOG 2>&1 if [ $? -ne 0 ]; then -- cgit v1.2.3-54-g00ecf From 178f56fa2a83511ad56b10f2848ebea4bc8ed656 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Fri, 6 Mar 2009 19:07:31 +0100 Subject: load lib-ui in early bootstrap so we dont need to define some functions redundantly in aif.sh --- src/aif.sh | 49 ++++-------------------------------- src/core/libs/lib-ui.sh | 66 ++++++++++++++++++++++++------------------------- 2 files changed, 38 insertions(+), 77 deletions(-) (limited to 'src/core/libs') diff --git a/src/aif.sh b/src/aif.sh index 78275de..09c1f8b 100755 --- a/src/aif.sh +++ b/src/aif.sh @@ -11,11 +11,15 @@ LOG_DIR=/var/log/aif LOGFILE=$LOG_DIR/aif.log +###### Early bootstrap ###### + +# load the lib-ui, it is one we need everywhere so we must load it early. +source $LIB_CORE/libs/lib-ui.sh || ( echo "Something went wrong while sourcing library $LIB_CORE/libs/lib-ui.sh" >&2 && exit 2) + ###### Miscalleaneous functions ###### usage () { - #NOTE: you can't use dia mode here yet because lib-ui isn't sourced yet. But cli is ok for this anyway. msg="aif -p Select a procedure # If given, this *must* be the first option -i Override interface type (optional) -d Explicitly enable debugging (optional) @@ -32,49 +36,6 @@ Available procedures: [ -n "$procedure" ] && msg="$msg\nProcedure ($procedure) specific options:\n$var_ARGS_USAGE" echo -e "$msg" - -} - -##### TMP functions that we need during early bootstrap but will be overidden with decent functions from libraries ###### - - -# Do not call other functions like debug, notify, .. here because that might cause loops! -die_error () -{ - echo "ERROR: $@" >&2 - exit 2 -} - - -notify () -{ - debug 'UI' "notify: $@" - echo -e "$@" -} - - -log () -{ - mkdir -p $LOG_DIR || die_error "Cannot create log directory" - str="[LOG] `date +"%Y-%m-%d %H:%M:%S"` $@" - echo -e "$str" > $LOG || die_error "Cannot log $str to $LOG" - [ "$LOG_TO_FILE" = 1 ] && ( echo -e "$str" >> $LOGFILE || die_error "Cannot log $str to $LOGFILE" ) -} - -# $1 = category. one of MAIN, PROCEDURE, UI, UI-INTERACTIVE, FS, MISC, NETWORK, PACMAN, SOFTWARE -# $2 = string to log -debug () -{ - [ "$1" == 'MAIN' -o "$1" == 'PROCEDURE' -o "$1" == 'UI' -o "$1" == 'UI-INTERACTIVE' -o "$1" == 'FS' -o "$1" == 'MISC' -o "$1" == 'NETWORK' -o "$1" == 'PACMAN' -o "$1" == 'SOFTWARE' ] || die_error "debug \$1 ($1) is not a valid debug category" - [ -n "$2" ] || die_error "debug \$2 cannot be empty" - - mkdir -p $LOG_DIR || die_error "Cannot create log directory" - if [ "$DEBUG" = "1" ] - then - str="[DEBUG $1 ] $2" - echo -e "$str" > $LOG || die_error "Cannot debug $str to $LOG" - [ "$LOG_TO_FILE" = 1 ] && ( echo -e "$str" >> $LOGFILE || die_error "Cannot debug $str to $LOGFILE" ) - fi } diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index cb40c9e..a67388a 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -1,4 +1,6 @@ #!/bin/bash +# Note that $var_UI_TYPE may not be set here. especially if being loaded in the "early bootstrap" phase + # TODO: implement 'retry until user does it correctly' everywhere # TODO: at some places we should check if $1 etc is only 1 word because we often depend on that # TODO: standardize. eg everything $1= question/title, $2=default @@ -18,12 +20,13 @@ var_CONSOLEFONT=$CONSOLEFONT ### Functions that your code can use. Cli/dialog mode is fully transparant. This library takes care of it ### + # display error message and die # Do not call other functions like debug, notify, .. here because that might cause loops! die_error () { echo "ERROR: $@" >&2 - exit 2 + exit 2 } @@ -33,25 +36,25 @@ die_error () # $3 type of item. msg or text if it's a file. (optional. defaults to msg) show_warning () { - [ -z "$1" ] && die_error "show_warning needs a title" - [ -z "$2" ] && die_error "show_warning needs an item to show" - [ -n "$3" -a "$3" != msg -a "$3" != text ] && die_error "show_warning \$3 must be text or msg" - type=msg - [ -n "$3" ] && type=$3 - debug 'UI' "show_warning '$1': $2 ($type)" - if [ "$var_UI_TYPE" = dia ] - then - _dia_DIALOG --title "$1" --exit-label "Continue" --${type}box "$2" 18 70 || die_error "dialog could not show --${type}box $2. often this means a file does not exist" - else - echo "WARNING: $1" - [ "${type}" = msg ] && echo -e "$2" - [ "${type}" = text ] && (cat $2 || die_error "Could not cat $2") - fi + [ -z "$1" ] && die_error "show_warning needs a title" + [ -z "$2" ] && die_error "show_warning needs an item to show" + [ -n "$3" -a "$3" != msg -a "$3" != text ] && die_error "show_warning \$3 must be text or msg" + type=msg + [ -n "$3" ] && type=$3 + debug 'UI' "show_warning '$1': $2 ($type)" + if [ "$var_UI_TYPE" = dia ] + then + _dia_DIALOG --title "$1" --exit-label "Continue" --${type}box "$2" 18 70 || die_error "dialog could not show --${type}box $2. often this means a file does not exist" + else + echo "WARNING: $1" + [ "${type}" = msg ] && echo -e "$2" + [ "${type}" = text ] && (cat $2 || die_error "Could not cat $2") + fi return 0 } - - + + #notify user notify () { @@ -91,38 +94,35 @@ infofy () #TODO: when using successive things, the screen can become full and yo fi } - # logging of stuff log () { + mkdir -p $LOG_DIR || die_error "Cannot create log directory" str="[LOG] `date +"%Y-%m-%d %H:%M:%S"` $@" - if [ "$var_UI_TYPE" = dia ] - then - echo -e "$str" >$LOG || die_error "Cannot log $str to $LOG" - else - echo -e "$str" >$LOG || die_error "Cannot log $str to $LOG" - fi + echo -e "$str" > $LOG || die_error "Cannot log $str to $LOG" [ "$LOG_TO_FILE" = 1 ] && ( echo -e "$str" >> $LOGFILE || die_error "Cannot log $str to $LOGFILE" ) } +# $1 = category. one of MAIN, PROCEDURE, UI, UI-INTERACTIVE, FS, MISC, NETWORK, PACMAN, SOFTWARE +# $2 = string to log debug () { - str="[DEBUG] $@" + [ "$1" == 'MAIN' -o "$1" == 'PROCEDURE' -o "$1" == 'UI' -o "$1" == 'UI-INTERACTIVE' -o "$1" == 'FS' -o "$1" == 'MISC' -o "$1" == 'NETWORK' -o "$1" == 'PACMAN' -o "$1" == 'SOFTWARE' ] || die_error "debug \$1 ($1) is not a valid debug category" + [ -n "$2" ] || die_error "debug \$2 cannot be empty" + + mkdir -p $LOG_DIR || die_error "Cannot create log directory" if [ "$DEBUG" = "1" ] then - if [ "$var_UI_TYPE" = dia ] - then - echo -e "$str" > $LOG || die_error "Cannot debug $str to $LOG" - else - echo -e "$str" > $LOG || die_error "Cannot debug $str to $LOG" - fi - [ "$LOG_TO_FILE" = 1 ] && ( echo -e "$str" >> $LOGFILE || die_error "Cannot debug $str to $LOGFILE" ) - fi + str="[DEBUG $1 ] $2" + echo -e "$str" > $LOG || die_error "Cannot debug $str to $LOG" + [ "$LOG_TO_FILE" = 1 ] && ( echo -e "$str" >> $LOGFILE || die_error "Cannot debug $str to $LOGFILE" ) + fi } + # taken from setup printk() { -- cgit v1.2.3-54-g00ecf From 2943c75ea213347975eec9b4b92c96cae8214f50 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 7 Mar 2009 10:51:25 +0100 Subject: switched dialog to use autosizing everywhere. lets see what this gives... --- src/core/libs/lib-ui.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index a67388a..fcb5c83 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -44,7 +44,7 @@ show_warning () debug 'UI' "show_warning '$1': $2 ($type)" if [ "$var_UI_TYPE" = dia ] then - _dia_DIALOG --title "$1" --exit-label "Continue" --${type}box "$2" 18 70 || die_error "dialog could not show --${type}box $2. often this means a file does not exist" + _dia_DIALOG --title "$1" --exit-label "Continue" --${type}box "$2" 0 0 || die_error "dialog could not show --${type}box $2. often this means a file does not exist" else echo "WARNING: $1" [ "${type}" = msg ] && echo -e "$2" @@ -61,7 +61,7 @@ notify () debug 'UI' "notify: $@" if [ "$var_UI_TYPE" = dia ] then - _dia_DIALOG --msgbox "$@" 20 50 + _dia_DIALOG --msgbox "$@" 0 0 else echo -e "$@" fi @@ -88,7 +88,7 @@ infofy () #TODO: when using successive things, the screen can become full and yo str=`cat $DIA_SUCCESSIVE_ITEMS-$successive` fi [ "$succ_last" = 1 ] && rm $DIA_SUCCESSIVE_ITEMS-$successive - _dia_DIALOG --infobox "$str" 20 50 + _dia_DIALOG --infobox "$str" 0 0 else echo -e "$1" fi @@ -291,7 +291,7 @@ _dia_ask_checklist () list="$list $1 $2 $3" shift 3 done - _dia_DIALOG --checklist "$str" 30 60 20 $list 2>$ANSWER + _dia_DIALOG --checklist "$str" 0 0 0 $list 2>$ANSWER ret=$? ANSWER_CHECKLIST=`cat $ANSWER` debug 'UI' "_dia_ask_checklist: user checked ON: $ANSWER_CHECKLIST" @@ -324,7 +324,7 @@ _dia_ask_number () [ -n $2 ] && str2="min $2" [ -n $3 -a $3 != '0' ] && str2="$str2 max $3" [ -n "$str2" ] && str="$str ( $str2 )" - _dia_DIALOG --inputbox "$str" 8 65 $4 2>$ANSWER + _dia_DIALOG --inputbox "$str" 0 0 $4 2>$ANSWER ret=$? ANSWER_NUMBER=`cat $ANSWER` if [[ $ANSWER_NUMBER = *[^0-9]* ]] #TODO: handle exit state @@ -363,7 +363,7 @@ _dia_ask_option () shift 4 CANCEL_LABEL=Cancel [ $TYPE == optional ] && CANCEL_LABEL='Skip' - _dia_DIALOG $DEFAULT --cancel-label $CANCEL_LABEL --colors --title " $DIA_MENU_TITLE " --menu "$DIA_MENU_TEXT $EXTRA_INFO" 20 80 16 "$@" 2>$ANSWER + _dia_DIALOG $DEFAULT --cancel-label $CANCEL_LABEL --colors --title " $DIA_MENU_TITLE " --menu "$DIA_MENU_TEXT $EXTRA_INFO" 0 0 0 "$@" 2>$ANSWER ret=$? ANSWER_OPTION=`cat $ANSWER` debug 'UI' "dia_ask_option: ANSWER_OPTION: $ANSWER_OPTION, returncode (skip/cancel): $ret ($DIA_MENU_TITLE)" @@ -396,7 +396,7 @@ _dia_ask_password () _dia_ask_string () { exitcode=${3:-1} - _dia_DIALOG --inputbox "$1" 8 65 "$2" 2>$ANSWER + _dia_DIALOG --inputbox "$1" 0 0 "$2" 2>$ANSWER ret=$? ANSWER_STRING=`cat $ANSWER` debug 'UI' "_dia_ask_string: user entered $ANSWER_STRING" @@ -447,7 +447,7 @@ _dia_follow_progress () { title=$1 logfile=$2 - _dia_DIALOG --title "$1" --no-kill --tailboxbg "$2" 18 70 2>$ANSWER + _dia_DIALOG --title "$1" --no-kill --tailboxbg "$2" 0 0 2>$ANSWER } -- cgit v1.2.3-54-g00ecf From 338d994ddb9c6ee0e15a07157ea3fd344169eaf8 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sun, 8 Mar 2009 11:38:17 +0100 Subject: fix for broken blockdevice size calculations --- src/core/libs/lib-blockdevices-filesystems.sh | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh index 4979c1f..4c725e1 100644 --- a/src/core/libs/lib-blockdevices-filesystems.sh +++ b/src/core/libs/lib-blockdevices-filesystems.sh @@ -738,7 +738,6 @@ get_filesystem_program () # $1 blockdevice # $2 unit: B, KiB, kB, MiB, MB, GiB or GB. defaults to B (we follow IEEE 1541-2002 ) # output will be in $BLOCKDEVICE_SIZE -# WARNING: hdparm works - by design - only for ide/sata. not scsi et al get_blockdevice_size () { [ -b "$1" ] || die_error "get_blockdevice_size needs a blockdevice as \$1 ($1 given)" @@ -754,13 +753,13 @@ get_blockdevice_size () # - unreliable method: on some interwebs they say 1 block = 512B, on other internets they say 1 block = 1kiB. 1kiB seemed to work for me. # blocks=`fdisk -s $1` || show_warning "Fdisk problem" "Something failed when trying to do fdisk -s $1" # BLOCKDEVICE_SIZE=$(($blocks/1024)) - # + bytes=$((`fdisk -l $1 2>/dev/null | sed -n '2p' | cut -d' ' -f5`)) - [ $unit = B ] && BLOCKDEVICE_SIZE=$bytes - [ $unit = KiB ] && BLOCKDEVICE_SIZE=$(($bytes/2*10)) # /1024 - [ $unit = kB ] && BLOCKDEVICE_SIZE=$(($bytes/10**3)) # /1000 - [ $unit = MiB ] && BLOCKDEVICE_SIZE=$(($bytes/2*20)) # ... - [ $unit = MB ] && BLOCKDEVICE_SIZE=$(($bytes/10**6)) - [ $unit = GiB ] && BLOCKDEVICE_SIZE=$(($bytes/2*30)) - [ $unit = GB ] && BLOCKDEVICE_SIZE=$(($bytes/10**9)) + [ $unit = B ] && BLOCKDEVICE_SIZE=$bytes + [ $unit = KiB ] && BLOCKDEVICE_SIZE=$((bytes/2**10)) # /1024 + [ $unit = kB ] && BLOCKDEVICE_SIZE=$((bytes/10**3)) # /1000 + [ $unit = MiB ] && BLOCKDEVICE_SIZE=$((bytes/2**20)) # ... + [ $unit = MB ] && BLOCKDEVICE_SIZE=$((bytes/10**6)) + [ $unit = GiB ] && BLOCKDEVICE_SIZE=$((bytes/2**30)) + [ $unit = GB ] && BLOCKDEVICE_SIZE=$((bytes/10**9)) } -- cgit v1.2.3-54-g00ecf From 0470af2a8ef914d68fe4e7b303c0c527c9ee943b Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sun, 8 Mar 2009 14:39:11 +0100 Subject: various fixes and cleanups in interactive_runtime_network --- src/core/libs/lib-ui-interactive.sh | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index 85b9b58..c7d8692 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -634,18 +634,19 @@ interactive_runtime_network() { INTERFACE=$ANSWER_OPTION - ask_yesno "Do you want to use DHCP?" - if [ $? -eq 0 ]; then + if ask_yesno "Do you want to use DHCP?" + then infofy "Please wait. Polling for DHCP server on $INTERFACE..." dhcpcd -k $INTERFACE >$LOG 2>&1 - sleep 1 - dhcpcd $INTERFACE >$LOG 2>&1 - if [ $? -ne 0 ]; then - notify "Failed to run dhcpcd. See $LOG for details." + if ! dhcpcd $INTERFACE >$LOG 2>&1 + then + show_warning "Dhcpcd problem" "Failed to run dhcpcd. See $LOG for details." return 1 fi - if [ ! $(ifconfig $INTERFACE | grep 'inet addr:') ]; then - notify "DHCP request failed." || return 1 + if ! ifconfig $INTERFACE | grep -q 'inet addr:' + then + show_warning "Dhcpcd problem" "DHCP request failed. dhcpcd returned 0 but no ip configured for $INTERFACE" + return 1 fi S_DHCP=1 else @@ -672,16 +673,20 @@ interactive_runtime_network() { esac done echo "running: ifconfig $INTERFACE $IPADDR netmask $SUBNET broadcast $BROADCAST up" >$LOG - ifconfig $INTERFACE $IPADDR netmask $SUBNET broadcast $BROADCAST up >$LOG 2>&1 || notify "Failed to setup $INTERFACE interface." || return 1 - if [ "$GW" != "" ]; then + if ! ifconfig $INTERFACE $IPADDR netmask $SUBNET broadcast $BROADCAST up >$LOG 2>&1 + then + show_warning "Ifconfig problem" "Failed to setup interface $INTERFACE" + return 1 + fi + if [ -n "$GW" ]; then route add default gw $GW >$LOG 2>&1 || notify "Failed to setup your gateway." || return 1 fi - if [ "$PROXY_HTTP" = "" ]; then + if [ -z "$PROXY_HTTP" ]; then unset http_proxy else export http_proxy=$PROXY_HTTP fi - if [ "$PROXY_FTP" = "" ]; then + if [ -z "$PROXY_FTP" ]; then unset ftp_proxy else export ftp_proxy=$PROXY_FTP -- cgit v1.2.3-54-g00ecf From 84f3b27c7a0c48f33d2d5fad33645f34c3bc4e7d Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sun, 8 Mar 2009 16:34:50 +0100 Subject: better way to handle issues after partitioning --- src/core/libs/lib-ui-interactive.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index c7d8692..53e0a05 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -440,7 +440,7 @@ interactive_filesystems() { ALLOK=0 while [ "$ALLOK" = 0 ] do - # Let the user make filesystems and mountpoints + # Let the user make filesystems and mountpoints. USERHAPPY becomes 1 when the user hits DONE. USERHAPPY=0 while [ "$USERHAPPY" = 0 ] @@ -554,7 +554,14 @@ interactive_filesystems() { str="The following issues have been detected:\n" [ -n "$errors" ] && str="$str\n - Errors: $errors" [ -n "$warnings" ] && str="$str\n - Warnings: $warnings" - ask_yesno "$str\n Do you want to back to fix (one of) these issues?" || ALLOK=1 # TODO: we should ask the user if he wants to continue, return or abort. + [ -n "$errors" ] && str="$str\nIt is highly recommended you go back to fix at least the errors." + str="$str\nIf you hit cancel, we will abort here and go back to the menu" + if ask_option back "Issues detected. what do you want to do?" "$str" required back "go back to fix the issues" ignore "continue, ignoring the issues" + then + [ "$ANSWER_OPTION" == ignore ] && ALLOK=1 + else + return 1 + fi else ALLOK=1 fi -- cgit v1.2.3-54-g00ecf From ccff2e8c4ae4f0ee487b55fe708dced85d829f68 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sun, 8 Mar 2009 16:50:30 +0100 Subject: cleanup backup files when user is happy with the config --- src/core/libs/lib-ui-interactive.sh | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index 53e0a05..c013bb0 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -54,6 +54,8 @@ interactive_configure_system() fi done + # temporary backup files are not useful anymore past this point. + find "${var_TARGET_DIR}/etc/" -name '*~' -delete &>/dev/null } -- cgit v1.2.3-54-g00ecf From 383a16d3358ab0b06a63960bf49bad22c558b128 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sun, 8 Mar 2009 16:58:11 +0100 Subject: fix some return code incorrectness in interactive_configure_system --- src/core/libs/lib-ui-interactive.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index c013bb0..5442e1b 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -40,10 +40,10 @@ interactive_configure_system() "/etc/locale.gen" "Glibc Locales" \ "$var_MIRRORLIST" "Pacman Mirror List" \ "Root-Password" "Set the root password" \ - "Return" "Return to Main Menu" || FILE="Return" + "Done" "Return to Main Menu" || return 1 FILE=$ANSWER_OPTION - if [ "$FILE" = "Return" -o -z "$FILE" ]; then # exit + if [ "$FILE" = "Done" ]; then # exit break elif [ "$FILE" = "Root-Password" ]; then # non-file while true; do @@ -56,6 +56,7 @@ interactive_configure_system() # temporary backup files are not useful anymore past this point. find "${var_TARGET_DIR}/etc/" -name '*~' -delete &>/dev/null + return 0 } -- cgit v1.2.3-54-g00ecf From c8d426c97e9183425b9553340226da8133c9ede5 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sun, 8 Mar 2009 17:09:15 +0100 Subject: added notice and pacman.confto interactive_configure_system. See FS#11416 --- src/core/libs/lib-ui-interactive.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index 5442e1b..42a2fd5 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -26,8 +26,8 @@ interactive_configure_system() while true; do DEFAULT=no [ -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 + helptext="Note that if you want to change any file not listed here (unlikely) you can go to another tty and update ${var_TARGET_DIR}/etc/ yourself" + grep -q '^/dev/mapper' $TMP_FSTAB && helptext="$helptext\nDon'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" required \ "/etc/rc.conf" "System Config" \ "/etc/fstab" "Filesystem Mountpoints" \ @@ -38,6 +38,7 @@ interactive_configure_system() "/etc/hosts.deny" "Denied Network Services" \ "/etc/hosts.allow" "Allowed Network Services" \ "/etc/locale.gen" "Glibc Locales" \ + "/etc/pacman.conf" "Pacman.conf" \ "$var_MIRRORLIST" "Pacman Mirror List" \ "Root-Password" "Set the root password" \ "Done" "Return to Main Menu" || return 1 -- cgit v1.2.3-54-g00ecf From 4dd67fa4ffb704f695ace2b62f3a54ccf1d43ee9 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sun, 8 Mar 2009 17:33:31 +0100 Subject: automatically update hostname in /etc/hosts after updating /etc/rc.conf. See FS#11416 --- src/core/libs/lib-ui-interactive.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index 42a2fd5..b9d5469 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -53,6 +53,17 @@ interactive_configure_system() else #regular file $EDITOR ${var_TARGET_DIR}${FILE} fi + + # if user edited /etc/rc.conf, add the hostname to /etc/hosts if it's not already there. + # note that if the user edits rc.conf several times to change the hostname more then once, we will add them all to /etc/hosts. this is not perfect, but to avoid this, too much code would be required (feel free to prove me wrong :)) + if [ "$FILE" = "/etc/rc.conf" ] + then + HOSTNAME=`sed -n '/^HOSTNAME/s/HOSTNAME=//p' ${var_TARGET_DIR}${FILE} | sed 's/"//'` + if ! grep '127\.0\.0\.1' ${var_TARGET_DIR}/etc/hosts | grep -q "$HOSTNAME" + then + sed -i "s/127\.0\.0\.1.*/& $HOSTNAME/" ${var_TARGET_DIR}/etc/hosts + fi + fi done # temporary backup files are not useful anymore past this point. -- cgit v1.2.3-54-g00ecf From 177d1a660bbdd3f46e82bc888adc84cc785509a5 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sun, 8 Mar 2009 18:44:32 +0100 Subject: support multiple debug categories --- src/core/libs/lib-ui.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index fcb5c83..df48715 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -105,11 +105,17 @@ log () } -# $1 = category. one of MAIN, PROCEDURE, UI, UI-INTERACTIVE, FS, MISC, NETWORK, PACMAN, SOFTWARE +# $1 = one or more categories (separated by spaces) from: MAIN, PROCEDURE, UI, UI-INTERACTIVE, FS, MISC, NETWORK, PACMAN, SOFTWARE +# You should always at least specify where you are (main, procedure or the name of the lib) and optionally further specification: eg in a ui function that works with pacman. +# This is very useful in ui-interactive where we always work with something else. # $2 = string to log debug () { - [ "$1" == 'MAIN' -o "$1" == 'PROCEDURE' -o "$1" == 'UI' -o "$1" == 'UI-INTERACTIVE' -o "$1" == 'FS' -o "$1" == 'MISC' -o "$1" == 'NETWORK' -o "$1" == 'PACMAN' -o "$1" == 'SOFTWARE' ] || die_error "debug \$1 ($1) is not a valid debug category" + valid_cats=(MAIN PROCEDURE UI UI-INTERACTIVE FS MISC NETWORK PACMAN SOFTWARE) + for cat in $1 + do + check_is_in $cat "${valid_cats[@]}" || die_error "debug \$1 contains a value ($cat) which is not a valid debug category" + done [ -n "$2" ] || die_error "debug \$2 cannot be empty" mkdir -p $LOG_DIR || die_error "Cannot create log directory" -- cgit v1.2.3-54-g00ecf From 61bd867bb9fffc93a9feaffd00d7992d3bcc89c1 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sun, 8 Mar 2009 18:50:58 +0100 Subject: fix FS#12378 - bad network autoconfig in /etc/rc.conf when network on eth1 --- src/core/libs/lib-network.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-network.sh b/src/core/libs/lib-network.sh index 9ed96b2..85e597c 100644 --- a/src/core/libs/lib-network.sh +++ b/src/core/libs/lib-network.sh @@ -17,7 +17,6 @@ target_configure_network() sed -i "s#$INTERFACE 192.168.0.2#$INTERFACE $IPADDR#g" ${var_TARGET_DIR}/etc/rc.conf sed -i "s#netmask 255.255.255.0#netmask $SUBNET#g" ${var_TARGET_DIR}/etc/rc.conf sed -i "s#broadcast 192.168.0.255#broadcast $BROADCAST#g" ${var_TARGET_DIR}/etc/rc.conf - sed -i "s#INTERFACES=(eth0)#INTERFACES=($INTERFACE)#g" ${var_TARGET_DIR}/etc/rc.conf if [ "$GW" != "" ]; then sed -i "s#gw 192.168.0.1#gw $GW#g" ${var_TARGET_DIR}/etc/rc.conf sed -i "s#!gateway#gateway#g" ${var_TARGET_DIR}/etc/rc.conf @@ -26,6 +25,7 @@ target_configure_network() else sed -i "s#eth0=\"eth0.*#$INTERFACE=\"dhcp\"#g" ${var_TARGET_DIR}/etc/rc.conf fi + sed -i "s#INTERFACES=(eth0)#INTERFACES=($INTERFACE)#g" ${var_TARGET_DIR}/etc/rc.conf if [ "$PROXY_HTTP" != "" ]; then echo "export http_proxy=$PROXY_HTTP" >> ${var_TARGET_DIR}/etc/profile.d/proxy.sh; -- cgit v1.2.3-54-g00ecf From 293588673428d5e3c08d30b5a1a3b6246a5bec3a Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Tue, 10 Mar 2009 22:09:16 +0100 Subject: fix segfault caused by loop --- src/core/libs/lib-misc.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-misc.sh b/src/core/libs/lib-misc.sh index ef7a000..c30e4cb 100644 --- a/src/core/libs/lib-misc.sh +++ b/src/core/libs/lib-misc.sh @@ -50,7 +50,7 @@ wait_for () # $2 set (array) haystack check_is_in () { - [ -z "$1" ] && debug 'MISC' "check_is_in $1 $2" && die_error "check_is_in needs a non-empty needle as \$1 and a haystack as \$2!" # haystack can be empty though + [ -z "$1" ] && die_error "check_is_in needs a non-empty needle as \$1 and a haystack as \$2!(got: check_is_in '$1' '$2'" # haystack can be empty though NEEDLE=$1 HAYSTACK=$2 @@ -58,10 +58,8 @@ check_is_in () shift for element do - [[ $element = $pattern ]] && debug 'MISC' "Checking if $element = $pattern ..yes !" && return 0 - debug 'MISC' "Checking if $element = $pattern ... no" + [[ $element = $pattern ]] && return 0 done - debug 'MISC' "Check_is_in could not find $NEEDLE in $HAYSTACK" return 1 } -- cgit v1.2.3-54-g00ecf From 4897786b9d662dd45ee36d98de2aecdd3a8894bc Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Wed, 11 Mar 2009 21:38:57 +0100 Subject: abstracting some pacman logic --- src/core/libs/lib-pacman.sh | 27 +++++++++++++++++++++++++++ src/core/libs/lib-ui-interactive.sh | 8 ++++---- 2 files changed, 31 insertions(+), 4 deletions(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-pacman.sh b/src/core/libs/lib-pacman.sh index 2fc7663..48fb61b 100644 --- a/src/core/libs/lib-pacman.sh +++ b/src/core/libs/lib-pacman.sh @@ -132,3 +132,30 @@ pacman_what_is_this_for () ! [ -d /var/lib/pacman ] && mkdir -p /var/lib/pacman } +list_package_groups () +{ + $PACMAN_TARGET -Sg +} + + +# List the packages in one or more repos or groups. output is one or more lines, each line being like this: +# packagename [version, if $1=repo] +# $1 repo or group +# $2 one or more repo or group names +# TODO: check the validity of the specified names in $2 +list_packages () +{ + [ "$1" = repo -o "$2" = group ] || die_error "list_packages \$1 must be repo or group. not $1!" + [ "$1" = repo ] && $PACMAN_TARGET -Sl $2 + [ "$1" = group ] && $PACMAN_TARGET -Sg $2 +} + +# find out the group to which one or more packages belong +# $1 packages separated by spaces +# output format: multiple lines, each line like: +# +# TODO: check $1 +which_group () +{ + PACKAGE_GROUPS=`$PACMAN_TARGET -Si $1| awk '/^Name/{ printf("%s ",$3) } /^Group/{ print $3 }'` +} diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index b9d5469..9a49344 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -605,7 +605,7 @@ interactive_select_packages() { # show group listing for group selection, base is ON by default, all others are OFF local _catlist="base ^ ON" - for i in $($PACMAN_TARGET -Sg | sed "s/^base$/ /g"); do + for i in $(list_package_groups | sed "s/^base$/ /g"); do _catlist="${_catlist} ${i} - OFF" done @@ -614,10 +614,10 @@ interactive_select_packages() { # assemble a list of packages with groups, marking pre-selected ones # - local _pkgtmp="$($PACMAN_TARGET -Sl core | awk '{print $2}')" # all packages in core repository + local _pkgtmp="$(list_packages repo core | awk '{print $2}')" # all packages in core repository local _pkglist='' - $PACMAN_TARGET -Si $_pkgtmp | awk '/^Name/{ printf("%s ",$3) } /^Group/{ print $3 }' > $ANSWER + which_group $_pkgtmp while read pkgname pkgcat; do # check if this package is in a selected group # slightly ugly but sorting later requires newlines in the variable @@ -626,7 +626,7 @@ interactive_select_packages() { else _pkglist="$(echo -e "${_pkglist}\n${pkgname} ${pkgcat} OFF")" fi - done < $ANSWER + done <<< "$PACKAGE_GROUPS" # sort by category _pkglist="$(echo "$_pkglist" | sort -f -k 2)" -- cgit v1.2.3-54-g00ecf From 73557d9a9f04e454f166326822fb26740d1dbff1 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Wed, 11 Mar 2009 21:51:15 +0100 Subject: replace category by group. it was bad terminology. "group" is what we use in pacman --- src/core/libs/lib-ui-interactive.sh | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index 9a49344..33522d2 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -597,20 +597,22 @@ interactive_filesystems() { # returns: 1 on error interactive_select_packages() { - notify "Package selection is split into two stages. First you will select package categories that contain packages you may be interested in. Then you will be presented with a full list of packages for each category, allowing you to fine-tune.\n\n" + repos=`list_pacman_repos target` + notify "Package selection is split into two stages. First you will select package groups that contain packages you may be interested in. Then you will be presented with a full list of packages for each group, allowing you to fine-tune.\n\n + Note that right now the packages (and groups) selection is limited to the repos available at this time ($repos). One you have your Arch system up and running, you have access to more repositories and packages." # set up our install location if necessary and sync up # so we can get package lists target_prepare_pacman || ( show_warning 'Pacman preparation failure' "Pacman preparation failed! Check $LOG for errors." && return 1 ) # show group listing for group selection, base is ON by default, all others are OFF - local _catlist="base ^ ON" + local _grouplist="base ^ ON" for i in $(list_package_groups | sed "s/^base$/ /g"); do - _catlist="${_catlist} ${i} - OFF" + _grouplist="${_grouplist} ${i} - OFF" done - ask_checklist "Select Package Categories\nDO NOT deselect BASE unless you know what you're doing!" $_catlist || return 1 - _catlist=$ANSWER_CHECKLIST # _catlist now contains all categories (the tags from the dialog checklist) + ask_checklist "Select Package groups\nDO NOT deselect BASE unless you know what you're doing!" $_grouplist || return 1 + _grouplist=$ANSWER_CHECKLIST # _grouplist now contains all groups (the tags from the dialog checklist) # assemble a list of packages with groups, marking pre-selected ones # @@ -618,17 +620,17 @@ interactive_select_packages() { local _pkglist='' which_group $_pkgtmp - while read pkgname pkgcat; do + while read pkgname pkggroup; do # check if this package is in a selected group # slightly ugly but sorting later requires newlines in the variable - if [ "${_catlist/"\"$pkgcat\""/XXXX}" != "${_catlist}" ]; then - _pkglist="$(echo -e "${_pkglist}\n${pkgname} ${pkgcat} ON")" + if [ "${_grouplist/"\"$pkggroup\""/XXXX}" != "${_grouplist}" ]; then + _pkglist="$(echo -e "${_pkglist}\n${pkgname} ${pkggroup} ON")" else - _pkglist="$(echo -e "${_pkglist}\n${pkgname} ${pkgcat} OFF")" + _pkglist="$(echo -e "${_pkglist}\n${pkgname} ${pkggroup} OFF")" fi done <<< "$PACKAGE_GROUPS" - # sort by category + # sort by group _pkglist="$(echo "$_pkglist" | sort -f -k 2)" ask_checklist "Select Packages To Install." $_pkglist || return 1 -- 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') 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 e8d5e210a3f40f03809ec85ac9d19c2bb9e6c68b Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Wed, 11 Mar 2009 22:12:11 +0100 Subject: list_packages stupid bugfix --- src/core/libs/lib-pacman.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-pacman.sh b/src/core/libs/lib-pacman.sh index 48fb61b..a104cee 100644 --- a/src/core/libs/lib-pacman.sh +++ b/src/core/libs/lib-pacman.sh @@ -145,7 +145,7 @@ list_package_groups () # TODO: check the validity of the specified names in $2 list_packages () { - [ "$1" = repo -o "$2" = group ] || die_error "list_packages \$1 must be repo or group. not $1!" + [ "$1" = repo -o "$1" = group ] || die_error "list_packages \$1 must be repo or group. not $1!" [ "$1" = repo ] && $PACMAN_TARGET -Sl $2 [ "$1" = group ] && $PACMAN_TARGET -Sg $2 } -- 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') 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 122c7b94299080a049de507d8a1bc5d8ce2de78c Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Thu, 12 Mar 2009 19:33:22 +0100 Subject: todo update --- src/core/libs/lib-ui.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index df48715..a8c242b 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -7,7 +7,7 @@ # TODO: figure out something to make dia windows always big enough, yet fit nicely in the terminal -# Taken from setup. we store dialog output in a file. TODO: can't we do this with variables? ASKDEV +# Taken from setup. we store dialog output in a file. TODO: a variable would be cleaner 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 -- 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/libs') 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/libs') 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') 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 8ae2a7c43fb2ae4b6f01c57f35a526d5d32e3605 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Thu, 12 Mar 2009 22:03:18 +0100 Subject: follow_progress fix --- src/core/libs/lib-ui.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index c438dc2..57c0383 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -267,8 +267,8 @@ follow_progress () { [ -z "$1" ] && die_error "follow_progress needs a title!" [ -z "$2" ] && die_error "follow_progress needs a logfile to follow!" - [ "$var_UI_TYPE" = dia ] && { _dia_follow_progress "$1" "$2" ; return $? ; } - [ "$var_UI_TYPE" = cli ] && { _cli_follow_progress "$1" "$2" ; return $? ; } + [ "$var_UI_TYPE" = dia ] && { _dia_follow_progress "$@" ; return $? ; } + [ "$var_UI_TYPE" = cli ] && { _cli_follow_progress "$@" ; return $? ; } } -- 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') 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 d120e407654b5f1c88cb146511b9439b80190bb7 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Fri, 13 Mar 2009 17:51:38 +0100 Subject: move flowcontrol stuff into its own library --- src/aif.sh | 221 +-------------------------------------- src/core/libs/lib-flowcontrol.sh | 216 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 219 insertions(+), 218 deletions(-) create mode 100755 src/core/libs/lib-flowcontrol.sh (limited to 'src/core/libs') diff --git a/src/aif.sh b/src/aif.sh index 125b40d..3aaaca0 100755 --- a/src/aif.sh +++ b/src/aif.sh @@ -15,232 +15,17 @@ LOGFILE=$LOG_DIR/aif.log # load the lib-ui, it is one we need everywhere so we must load it early. source $LIB_CORE/libs/lib-ui.sh || ( echo "Something went wrong while sourcing library $LIB_CORE/libs/lib-ui.sh" >&2 && exit 2) - -###### Miscalleaneous functions ###### - -usage () -{ - msg="aif -p Select a procedure # If given, this *must* be the first option - -i Override interface type (optional) - -d Explicitly enable debugging (optional) - -l Explicitly enable logging to file (optional) - -h Help: show usage (optional)\n -If the procedurename starts with 'http://' it will be wget'ed. Otherwise it's assumed to be a procedure in the VFS tree -If the procedurename is prefixed with '/' it will be loaded from user module .\n -For more info, see the README which you can find in /usr/share/aif/docs\n -Available procedures: -==core== -`find $LIB_CORE/procedures -type f | sed \"s#$LIB_CORE/procedures/##\" | sort` -==user== -`find $LIB_USER/*/procedures -type f 2>/dev/null | sed \"s#$LIB_USER/\(.*\)/procedures/#\1/#\" | sort`" - [ -n "$procedure" ] && msg="$msg\nProcedure ($procedure) specific options:\n$var_ARGS_USAGE" - - echo -e "$msg" -} - - -###### Core functions ###### - - -# $1 module name -load_module () -{ - [ -z "$1" ] && die_error "load_module needs a module argument" - log "Loading module $1 ..." - path=$LIB_USER/"$1" - [ "$1" = core ] && path=$LIB_CORE - - for submodule in lib #procedure don't load procedures automatically! - do - if [ ! -d "$path/${submodule}s" ] - then - # ignore this problem for not-core modules - [ "$1" = core ] && die_error "$path/${submodule}s does not exist. something is horribly wrong with this installation" - else - shopt -s nullglob - for i in "$path/${submodule}s"/* - do - # I have the habit of editing files while testing, don't source my backup files! - [[ "$i" == *~ ]] && continue - - load_${submodule} "$1" "`basename "$i"`" - done - fi - done - -} - - -# $1 module name -# $2 procedure name -load_procedure() -{ - [ -z "$1" ] && die_error "load_procedure needs a module as \$1 and procedure as \$2" - [ -z "$2" ] && die_error "load_procedure needs a procedure as \$2" - if [ "$1" = 'http:' ] - then - log "Loading procedure $2 ..." - procedure=$RUNTIME_DIR/aif-procedure-downloaded-`basename $2` - wget "$2" -q -O $procedure >/dev/null || die_error "Could not download procedure $2" - else - log "Loading procedure $1/procedures/$2 ..." - procedure=$LIB_USER/"$1"/procedures/"$2" - [ "$1" = core ] && procedure=$LIB_CORE/procedures/"$2" - fi - [ -f "$procedure" ] && source "$procedure" || die_error "Something went wrong while sourcing procedure $procedure" -} - - -# $1 module name -# $2 library name -load_lib () -{ - [ -z "$1" ] && die_error "load_library needs a module als \$1 and library as \$2" - [ -z "$2" ] && die_error "load_library needs a library as \$2" - log "Loading library $1/libs/$2 ..." - lib=$LIB_USER/"$1"/libs/"$2" - [ "$1" = core ] && lib=$LIB_CORE/libs/"$2" - source $lib || die_error "Something went wrong while sourcing library $lib" -} - - -# $1 phase/worker -# $2 phase/worker name -# $3... extra args for phase/worker (optional) -execute () -{ - [ -z "$1" -o -z "$2" ] && debug 'MAIN' "execute $@" && die_error "Use the execute function like this: execute with type=phase/worker" - [ "$1" != phase -a "$1" != worker ] && debug 'MAIN' "execute $@" && die_error "execute's first argument must be a valid type (phase/worker)" - PWD_BACKUP=`pwd` - object=$1_$2 - - if [ "$1" = worker ] - then - log "*** Executing worker $2" - if type -t $object | grep -q function - then - shift 2 - $object "$@" - ret=$? - exit_var=exit_$object - read $exit_var <<< $ret # maintain exit status of each worker - else - die_error "$object is not defined!" - fi - elif [ "$1" = phase ] - then - log "******* Executing phase $2" - exit_var=exit_$object - read $exit_var <<< 0 - # TODO: for some reason the hack below does not work (tested in virtualbox), even though it really should. Someday I must get indirect array variables working and clean this up... - # debug 'MAIN' "\$1: $1, \$2: $2, \$object: $object, \$exit_$object: $exit_object" - # debug 'MAIN' "declare: `declare | grep -e "^${object}=" | cut -d"=" -f 2-`" - # props to jedinerd at #bash for this hack. - # eval phase=$(declare | grep -e "^${object}=" | cut -d"=" -f 2-) - #debug 'MAIN' "\$phase: $phase - ${phase[@]}" - unset phase - [ "$2" = preparation ] && phase=( "${phase_preparation[@]}" ) - [ "$2" = basics ] && phase=( "${phase_basics[@]}" ) - [ "$2" = system ] && phase=( "${phase_system[@]}" ) - [ "$2" = finish ] && phase=( "${phase_finish[@]}" ) - # worker_str contains the name of the worker and optionally any arguments - for worker_str in "${phase[@]}" - do - debug 'MAIN' "Loop iteration. \$worker_str: $worker_str" - execute worker $worker_str || read $exit_var <<< $? # assign last failing exit code to exit_phase_, if any. - done - ret=${!exit_var} - fi - - debug 'MAIN' "Execute(): $object exit state was $ret" - cd $PWD_BACKUP - return $ret -} - - -# check if a phase/worker executed sucessfully -# returns 0 if ok, the phase/workers' exit state otherwise (and returns 1 if not executed yet) -# $1 phase/worker -# $2 phase/worker name -ended_ok () -{ - [ -z "$1" -o -z "$2" ] && die_error "Use the ended_ok function like this: ended_ok with type=phase/worker" - [ "$1" != phase -a "$1" != worker ] && die_error "ended_ok's first argument must be a valid type (phase/worker)" - object=$1_$2 - exit_var=exit_$object - debug 'MAIN' "Ended_ok? -> Exit state of $object was: ${!exit_var} (if empty. it's not executed yet)" - [ "${!exit_var}" = '0' ] && return 0 - [ "${!exit_var}" = '' ] && return 1 - return ${!exit_var} -} - - -depend_module () -{ - load_module "$1" -} - - -depend_procedure () -{ - load_procedure "$1" "$2" -} - - -start_process () -{ - execute phase preparation - execute phase basics - execute phase system - execute phase finish -} - - -show_report () #TODO: abstract UI method (cli/dia) -{ - echo "Execution Report:" - echo "-----------------" - for phase in preparation basics system finish - do - object=phase_$phase - exit_var=exit_$object - ret=${!exit_var} - echo -n "Phase $phase: " - [ "$ret" = "0" ] && echo "Success" || echo "Failed" - eval phase_array=$(declare | grep -e "^${object}=" | cut -d"=" -f 2-) - for worker_str in "${phase_array[@]}" - do - worker=${worker_str%% *} - exit_var=exit_worker_$worker - ret=${!exit_var} - echo -n " > Worker $worker: " - [ "$ret" = "0" ] && echo "Success" || echo "Failed" - done - done -} +# load the lib-flowcontrol. we also need some of it's functions early (like usage()). +source $LIB_CORE/libs/lib-flowcontrol.sh || ( echo "Something went wrong while sourcing library $LIB_CORE/libs/lib-flowcontrol.sh" >&2 && exit 2) +# default function to process additional arguments. can be overridden by procedures. process_args () { true } -start_installer () -{ - log "################## START OF INSTALLATION ##################" - cleanup_runtime -} - - -# use this function to stop the installation procedure. -# $1 exit code (optional) -stop_installer () -{ - log "-------------- STOPPING INSTALLATION ----------" - cleanup_runtime - exit $1 -} ###### perform actual logic ###### diff --git a/src/core/libs/lib-flowcontrol.sh b/src/core/libs/lib-flowcontrol.sh new file mode 100755 index 0000000..8106310 --- /dev/null +++ b/src/core/libs/lib-flowcontrol.sh @@ -0,0 +1,216 @@ +#!/bin/bash + +usage () +{ + msg="aif -p Select a procedure # If given, this *must* be the first option + -i Override interface type (optional) + -d Explicitly enable debugging (optional) + -l Explicitly enable logging to file (optional) + -h Help: show usage (optional)\n +If the procedurename starts with 'http://' it will be wget'ed. Otherwise it's assumed to be a procedure in the VFS tree +If the procedurename is prefixed with '/' it will be loaded from user module .\n +For more info, see the README which you can find in /usr/share/aif/docs\n +Available procedures: +==core== +`find $LIB_CORE/procedures -type f | sed \"s#$LIB_CORE/procedures/##\" | sort` +==user== +`find $LIB_USER/*/procedures -type f 2>/dev/null | sed \"s#$LIB_USER/\(.*\)/procedures/#\1/#\" | sort`" + [ -n "$procedure" ] && msg="$msg\nProcedure ($procedure) specific options:\n$var_ARGS_USAGE" + + echo -e "$msg" +} + + +# $1 module name +load_module () +{ + [ -z "$1" ] && die_error "load_module needs a module argument" + log "Loading module $1 ..." + path=$LIB_USER/"$1" + [ "$1" = core ] && path=$LIB_CORE + + for submodule in lib #procedure don't load procedures automatically! + do + if [ ! -d "$path/${submodule}s" ] + then + # ignore this problem for not-core modules + [ "$1" = core ] && die_error "$path/${submodule}s does not exist. something is horribly wrong with this installation" + else + shopt -s nullglob + for i in "$path/${submodule}s"/* + do + # I have the habit of editing files while testing, don't source my backup files! + [[ "$i" == *~ ]] && continue + + load_${submodule} "$1" "`basename "$i"`" + done + fi + done + +} + + +# $1 module name +# $2 procedure name +load_procedure() +{ + [ -z "$1" ] && die_error "load_procedure needs a module as \$1 and procedure as \$2" + [ -z "$2" ] && die_error "load_procedure needs a procedure as \$2" + if [ "$1" = 'http:' ] + then + log "Loading procedure $2 ..." + procedure=$RUNTIME_DIR/aif-procedure-downloaded-`basename $2` + wget "$2" -q -O $procedure >/dev/null || die_error "Could not download procedure $2" + else + log "Loading procedure $1/procedures/$2 ..." + procedure=$LIB_USER/"$1"/procedures/"$2" + [ "$1" = core ] && procedure=$LIB_CORE/procedures/"$2" + fi + [ -f "$procedure" ] && source "$procedure" || die_error "Something went wrong while sourcing procedure $procedure" +} + + +# $1 module name +# $2 library name +load_lib () +{ + [ -z "$1" ] && die_error "load_library needs a module als \$1 and library as \$2" + [ -z "$2" ] && die_error "load_library needs a library as \$2" + log "Loading library $1/libs/$2 ..." + lib=$LIB_USER/"$1"/libs/"$2" + [ "$1" = core ] && lib=$LIB_CORE/libs/"$2" + source $lib || die_error "Something went wrong while sourcing library $lib" +} + + +# $1 phase/worker +# $2 phase/worker name +# $3... extra args for phase/worker (optional) +execute () +{ + [ -z "$1" -o -z "$2" ] && debug 'MAIN' "execute $@" && die_error "Use the execute function like this: execute with type=phase/worker" + [ "$1" != phase -a "$1" != worker ] && debug 'MAIN' "execute $@" && die_error "execute's first argument must be a valid type (phase/worker)" + PWD_BACKUP=`pwd` + object=$1_$2 + + if [ "$1" = worker ] + then + log "*** Executing worker $2" + if type -t $object | grep -q function + then + shift 2 + $object "$@" + ret=$? + exit_var=exit_$object + read $exit_var <<< $ret # maintain exit status of each worker + else + die_error "$object is not defined!" + fi + elif [ "$1" = phase ] + then + log "******* Executing phase $2" + exit_var=exit_$object + read $exit_var <<< 0 + # TODO: for some reason the hack below does not work (tested in virtualbox), even though it really should. Someday I must get indirect array variables working and clean this up... + # debug 'MAIN' "\$1: $1, \$2: $2, \$object: $object, \$exit_$object: $exit_object" + # debug 'MAIN' "declare: `declare | grep -e "^${object}=" | cut -d"=" -f 2-`" + # props to jedinerd at #bash for this hack. + # eval phase=$(declare | grep -e "^${object}=" | cut -d"=" -f 2-) + #debug 'MAIN' "\$phase: $phase - ${phase[@]}" + unset phase + [ "$2" = preparation ] && phase=( "${phase_preparation[@]}" ) + [ "$2" = basics ] && phase=( "${phase_basics[@]}" ) + [ "$2" = system ] && phase=( "${phase_system[@]}" ) + [ "$2" = finish ] && phase=( "${phase_finish[@]}" ) + # worker_str contains the name of the worker and optionally any arguments + for worker_str in "${phase[@]}" + do + debug 'MAIN' "Loop iteration. \$worker_str: $worker_str" + execute worker $worker_str || read $exit_var <<< $? # assign last failing exit code to exit_phase_, if any. + done + ret=${!exit_var} + fi + + debug 'MAIN' "Execute(): $object exit state was $ret" + cd $PWD_BACKUP + return $ret +} + + +# check if a phase/worker executed sucessfully +# returns 0 if ok, the phase/workers' exit state otherwise (and returns 1 if not executed yet) +# $1 phase/worker +# $2 phase/worker name +ended_ok () +{ + [ -z "$1" -o -z "$2" ] && die_error "Use the ended_ok function like this: ended_ok with type=phase/worker" + [ "$1" != phase -a "$1" != worker ] && die_error "ended_ok's first argument must be a valid type (phase/worker)" + object=$1_$2 + exit_var=exit_$object + debug 'MAIN' "Ended_ok? -> Exit state of $object was: ${!exit_var} (if empty. it's not executed yet)" + [ "${!exit_var}" = '0' ] && return 0 + [ "${!exit_var}" = '' ] && return 1 + return ${!exit_var} +} + + +depend_module () +{ + load_module "$1" +} + + +depend_procedure () +{ + load_procedure "$1" "$2" +} + + +start_process () +{ + execute phase preparation + execute phase basics + execute phase system + execute phase finish +} + + +show_report () #TODO: abstract UI method (cli/dia) +{ + echo "Execution Report:" + echo "-----------------" + for phase in preparation basics system finish + do + object=phase_$phase + exit_var=exit_$object + ret=${!exit_var} + echo -n "Phase $phase: " + [ "$ret" = "0" ] && echo "Success" || echo "Failed" + eval phase_array=$(declare | grep -e "^${object}=" | cut -d"=" -f 2-) + for worker_str in "${phase_array[@]}" + do + worker=${worker_str%% *} + exit_var=exit_worker_$worker + ret=${!exit_var} + echo -n " > Worker $worker: " + [ "$ret" = "0" ] && echo "Success" || echo "Failed" + done + done +} + + +start_installer () +{ + log "################## START OF INSTALLATION ##################" + cleanup_runtime +} + + +# use this function to stop the installation procedure. +# $1 exit code (optional) +stop_installer () +{ + log "-------------- STOPPING INSTALLATION ----------" + cleanup_runtime + exit $1 +} -- 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') 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 0daf3b0a8f4ca33d7146c94cd840131a97896b9b Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 14 Mar 2009 17:31:58 +0100 Subject: better modules stuff for encryption --- src/core/libs/lib-blockdevices-filesystems.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh index 4c725e1..721db85 100644 --- a/src/core/libs/lib-blockdevices-filesystems.sh +++ b/src/core/libs/lib-blockdevices-filesystems.sh @@ -24,8 +24,8 @@ -modprobe dm-crypt || show_warning modprobe 'Could not modprobe dm-crypt. no support for disk encryption' -modprobe aes-i586 || show_warning modprobe 'Could not modprobe aes-i586. no support for disk encryption' +modprobe -q dm-crypt || show_warning modprobe 'Could not modprobe dm-crypt. no support for disk encryption' +modprobe -q aes-i586 || modprobe -q aes-x86-64 || show_warning modprobe 'Could not modprobe aes-i586 or aes-x86-64. no support for disk encryption' -- cgit v1.2.3-54-g00ecf From efc611c1ad81c51e14ed61f37828721cfaa6a906 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 14 Mar 2009 18:16:38 +0100 Subject: fix for broken package selection --- src/core/libs/lib-ui-interactive.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index bce3790..693e2c6 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -619,7 +619,7 @@ interactive_select_packages() { local _pkgtmp="$(list_packages repo core | awk '{print $2}')" # all packages in core repository local _pkglist='' - which_group $_pkgtmp + which_group "$_pkgtmp" while read pkgname pkggroup; do # check if this package is in a selected group # slightly ugly but sorting later requires newlines in the variable -- cgit v1.2.3-54-g00ecf From 7050aa6c10d76b06fc1548b812589a61782166e0 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sun, 15 Mar 2009 12:35:09 +0100 Subject: fix for done_filesystems not being cleanup up after successfull rollback, causing problems when trying to make new filesystems after rollback + functionized fs properties setting --- TODO | 1 - src/core/libs/lib-blockdevices-filesystems.sh | 22 +++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) (limited to 'src/core/libs') diff --git a/TODO b/TODO index 10f23f6..82bc5f3 100644 --- a/TODO +++ b/TODO @@ -4,7 +4,6 @@ SHOWSTOPPERS: - datetime refactoring - grub menu.lst updating - squashfs errors when typing reboot after automatic procedure -- done_filesystems not being cleaned up on rollback CURRENT ISSUES: * use traps and initiate rollback when user wants to abort. see also http://www.davidpashley.com/articles/writing-robust-shell-scripts.html diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh index 721db85..e86fbc4 100644 --- a/src/core/libs/lib-blockdevices-filesystems.sh +++ b/src/core/libs/lib-blockdevices-filesystems.sh @@ -349,6 +349,19 @@ process_disk () partition $1 "$2" } +# $1 fs_string +parse_filesystem_string () +{ + fs="$1" + fs_type=` cut -d ';' -f 1 <<< $fs` + fs_create=` cut -d ';' -f 2 <<< $fs` + fs_mountpoint=` cut -d ';' -f 3 <<< $fs` + fs_mount=` cut -d ';' -f 4 <<< $fs` + fs_opts=` cut -d ';' -f 5 <<< $fs` + fs_label=` cut -d ';' -f 6 <<< $fs` + fs_params=` cut -d ';' -f 7 <<< $fs` +} + generate_filesystem_list () { @@ -359,13 +372,7 @@ generate_filesystem_list () then for fs in `sed 's/|/ /g' <<< $fs_string` # this splits multiple fs'es up, or just takes the one if there is only one (lvm vg's can have more then one lv) do - fs_type=` cut -d ';' -f 1 <<< $fs` - fs_create=` cut -d ';' -f 2 <<< $fs` - fs_mountpoint=` cut -d ';' -f 3 <<< $fs` - fs_mount=` cut -d ';' -f 4 <<< $fs` - fs_opts=` cut -d ';' -f 5 <<< $fs` - fs_label=` cut -d ';' -f 6 <<< $fs` - fs_params=` cut -d ';' -f 7 <<< $fs` + parse_filesystem_string "$fs" echo "$part $part_type $part_label $fs_type $fs_create $fs_mountpoint $fs_mount $fs_opts $fs_label $fs_params" >> $TMP_FILESYSTEMS done fi @@ -597,6 +604,7 @@ rollback_filesystems () fi [ -n "$warnings" ] && infofy "Rollback failed" disks 1 && show_warning "Rollback problems" "Some problems occurred while rolling back: $warnings.\n Thisk needs to be fixed before retrying disk/filesystem creation or restarting the installer" && return 1 infofy "Rollback succeeded" disks 1 + done_filesystems= BLOCK_ROLLBACK_USELESS=1 return 0 } -- cgit v1.2.3-54-g00ecf From 9c9206abdd83bd46dbc4b3c8dc6a9afec0d0f60e Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sun, 15 Mar 2009 12:52:00 +0100 Subject: prepare pacman first so we can show the repos in the message to the user + format fix --- src/core/libs/lib-ui-interactive.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index 693e2c6..7c59c61 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -597,13 +597,12 @@ interactive_filesystems() { # returns: 1 on error interactive_select_packages() { - repos=`list_pacman_repos target` - notify "Package selection is split into two stages. First you will select package groups that contain packages you may be interested in. Then you will be presented with a full list of packages for each group, allowing you to fine-tune.\n\n - Note that right now the packages (and groups) selection is limited to the repos available at this time ($repos). One you have your Arch system up and running, you have access to more repositories and packages." + # set up our install location if necessary and sync up so we can get package lists + target_prepare_pacman || ( show_warning 'Pacman preparation failure' "Pacman preparation failed! Check $LOG for errors." && return 1 ) - # set up our install location if necessary and sync up - # so we can get package lists - target_prepare_pacman || ( show_warning 'Pacman preparation failure' "Pacman preparation failed! Check $LOG for errors." && return 1 ) + repos=`list_pacman_repos target` + notify "Package selection is split into two stages. First you will select package groups that contain packages you may be interested in. Then you will be presented with a full list of packages for each group, allowing you to fine-tune.\n\n +Note that right now the packages (and groups) selection is limited to the repos available at this time ($repos). One you have your Arch system up and running, you have access to more repositories and packages." # show group listing for group selection, base is ON by default, all others are OFF local _grouplist="base ^ ON" -- cgit v1.2.3-54-g00ecf From 5f92067308ad179e92b90c9e4d2bac150d1eb615 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sun, 15 Mar 2009 20:20:48 +0100 Subject: fix for extraneaous " at end of hostname in /etc/hosts --- src/core/libs/lib-ui-interactive.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index 7c59c61..bae499d 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -58,7 +58,7 @@ interactive_configure_system() # note that if the user edits rc.conf several times to change the hostname more then once, we will add them all to /etc/hosts. this is not perfect, but to avoid this, too much code would be required (feel free to prove me wrong :)) if [ "$FILE" = "/etc/rc.conf" ] then - HOSTNAME=`sed -n '/^HOSTNAME/s/HOSTNAME=//p' ${var_TARGET_DIR}${FILE} | sed 's/"//'` + HOSTNAME=`sed -n '/^HOSTNAME/s/HOSTNAME=//p' ${var_TARGET_DIR}${FILE} | sed 's/"//g'` if ! grep '127\.0\.0\.1' ${var_TARGET_DIR}/etc/hosts | grep -q "$HOSTNAME" then sed -i "s/127\.0\.0\.1.*/& $HOSTNAME/" ${var_TARGET_DIR}/etc/hosts -- cgit v1.2.3-54-g00ecf From 49b6cbba082c7d9fd42d1a11713ad71ffebeaf27 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sun, 15 Mar 2009 22:15:35 +0100 Subject: reset previous FOLLOW_PID --- src/core/libs/lib-ui.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index dc207e6..50d087a 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -267,6 +267,7 @@ follow_progress () { [ -z "$1" ] && die_error "follow_progress needs a title!" [ -z "$2" ] && die_error "follow_progress needs a logfile to follow!" + FOLLOW_PID= [ "$var_UI_TYPE" = dia ] && { _dia_follow_progress "$@" ; return $? ; } [ "$var_UI_TYPE" = cli ] && { _cli_follow_progress "$@" ; return $? ; } } -- 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') 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 From dc3296c19e84370e714f522e033cfee5407ea029 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Wed, 25 Mar 2009 12:10:56 +0100 Subject: some debugging to help FS#13700 - grub menu.lst updating is broken --- src/core/libs/lib-blockdevices-filesystems.sh | 1 + src/core/libs/lib-ui-interactive.sh | 1 + 2 files changed, 2 insertions(+) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh index e86fbc4..596d7a9 100644 --- a/src/core/libs/lib-blockdevices-filesystems.sh +++ b/src/core/libs/lib-blockdevices-filesystems.sh @@ -692,6 +692,7 @@ process_filesystem () mount -t $fs_type $part $dst >$LOG 2>&1 || ( show_warning 'Mount' "Error mounting $part on $dst" ; return 1 ) if [ "$fs_mount" = target -a $fs_mountpoint = '/' ] then + debug FS "setting \$PART_ROOT to $part" PART_ROOT=$part fi fi diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index bae499d..be1f389 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -727,6 +727,7 @@ interactive_install_grub() { [ ! -f $grubmenu ] && show_warning "No grub?" "Error: Couldn't find $grubmenu. Is GRUB installed?" && return 1 # try to auto-configure GRUB... + debug 'UI-INTERACTIVE' "install_grub \$PART_ROOT $PART_ROOT \$GRUB_OK $GRUB_OK" if [ -n "$PART_ROOT" -a "$GRUB_OK" != '1' ] ; then GRUB_OK=0 grubdev=$(mapdev $PART_ROOT) -- cgit v1.2.3-54-g00ecf From 3285f43702e828899b76598478d8829b4b1d383d Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Wed, 25 Mar 2009 16:35:30 +0100 Subject: no need to set PART_ROOT twice --- src/core/libs/lib-ui-interactive.sh | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index be1f389..cb80c11 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -171,9 +171,6 @@ interactive_autoprepare() ask_yesno "$DISC will be COMPLETELY ERASED! Are you absolutely sure?" || return 1 - # we assume a /dev/hdX format (or /dev/sdX) - PART_ROOT="${DISC}3" - echo "$DISC $BOOT_PART_SIZE:ext2:+ $SWAP_PART_SIZE:swap $ROOT_PART_SIZE:$FSTYPE *:$FSTYPE" > $TMP_PARTITIONS echo "${DISC}1 raw no_label ext2;yes;/boot;target;no_opts;no_label;no_params" > $TMP_BLOCKDEVICES -- cgit v1.2.3-54-g00ecf From 893b21ee0c34958bc41928fb015a790dbf6b0ca8 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Fri, 27 Mar 2009 17:18:08 +0100 Subject: this should fix FS#13700 - grub menu.lst updating is broken --- src/core/libs/lib-blockdevices-filesystems.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/core/libs') diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh index 596d7a9..c1316f0 100644 --- a/src/core/libs/lib-blockdevices-filesystems.sh +++ b/src/core/libs/lib-blockdevices-filesystems.sh @@ -438,7 +438,7 @@ process_filesystems () # phase 2: mount all filesystems in the vfs in the correct order. (also swapon where appropriate) infofy "Phase 2: Mounting filesystems" disks - sort -t \ -k 6 $TMP_FILESYSTEMS | while read part part_type part_label fs_type fs_create fs_mountpoint fs_mount fs_opts fs_label fs_params + while read part part_type part_label fs_type fs_create fs_mountpoint fs_mount fs_opts fs_label fs_params do if [ "$fs_mountpoint" != no_mountpoint ] then @@ -449,7 +449,7 @@ process_filesystems () infofy "Swaponning $part" disks process_filesystem $part $fs_type no $fs_mountpoint $fs_mount $fs_opts $fs_label $fs_params || returncode=1 fi - done + done < <(sort -t \ -k 6 $TMP_FILESYSTEMS) BLOCK_ROLLBACK_USELESS=0 [ $returncode -eq 0 ] && infofy "Done processing filesystems/blockdevices" disks 1 && return 0 @@ -470,7 +470,7 @@ rollback_filesystems () infofy "Phase 1: Umounting all specified mountpoints" disks done_umounts= # We translate some devices back to their original (eg /dev/sda3+ -> /dev/sda3 for lvm PV's). No need to bother user twice for such devices. - sort -t \ -k 6 $TMP_FILESYSTEMS | tac | while read part part_type part_label fs_type fs_create fs_mountpoint fs_mount fs_opts fs_label fs_params + while read part part_type part_label fs_type fs_create fs_mountpoint fs_mount fs_opts fs_label fs_params do if [ "$fs_type" = swap ] then @@ -494,7 +494,7 @@ rollback_filesystems () fi fi fi - done + done < <(sort -t \ -k 6 $TMP_FILESYSTEMS | tac) # phase 2: destruct blockdevices listed in $BLOCK_DATA if they would exist already, in the correct order (first lvm LV, then VG, then PV etc) -- cgit v1.2.3-54-g00ecf