summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/libs/lib-blockdevices-filesystems.sh74
-rwxr-xr-xsrc/core/libs/lib-flowcontrol.sh6
-rw-r--r--src/core/libs/lib-pacman.sh12
-rw-r--r--src/core/libs/lib-software.sh2
-rw-r--r--src/core/libs/lib-ui-interactive.sh199
-rw-r--r--src/core/libs/lib-ui.sh32
-rw-r--r--src/core/procedures/base4
-rw-r--r--src/core/procedures/interactive7
8 files changed, 222 insertions, 114 deletions
diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh
index 3511557..a4bc534 100644
--- a/src/core/libs/lib-blockdevices-filesystems.sh
+++ b/src/core/libs/lib-blockdevices-filesystems.sh
@@ -4,6 +4,8 @@
# FORMAT DEFINITIONS:
# -- formats used to interface with this library --
+# these files will persist during the entire aif session (and even after stopping aif)
+# so you can use them to retrieve data from them (or use functions in this library to do that for you)
# $TMP_PARTITIONS
# one line per partition, blockdevice + partioning string for sfdisk. See docs for function partition for more info.
# $TMP_BLOCKDEVICES
@@ -76,6 +78,53 @@ target_umountall()
done
}
+# tells you which blockdevice is configured for the specific mountpoint
+# $1 mountpoint
+get_device_with_mount () {
+ ANSWER_DEVICE=`grep ";$1;" $TMP_BLOCKDEVICES 2>/dev/null | cut -d ' ' -f1`
+ [ -n "$ANSWER_DEVICE" ] # set correct exit code
+}
+
+# gives you a newline separated list of the blockdevice that hosts a certain filesystem, and below it, all underlying blockdevices supporting it, with also the blockdevice type.
+# example:
+# get_anchestors_mount ';/;' (suppose '/' is a filesystem on top of lvm on top of dm_crypt, you will get something like):
+# /dev/mapper/cryptpool-cryptroot lvm-lv
+# /dev/mapper/cryptpool lvm-vg
+# /dev/mapper/sda2crypt+ lvm-pv
+# /dev/mapper/sda2crypt dm_crypt
+# /dev/sda2 raw
+# $1 a "recognizer": a string that will match the filesystem section uniquely (using egrep), such as ';<mountpoint>;' or other specific attributes of the hosted filesystem(s)
+get_anchestors_mount () {
+ debug 'FS' "Finding anchestor for: $1"
+ local buffer=
+ read block type leftovers <<< `egrep "$1" $TMP_BLOCKDEVICES 2>/dev/null`
+ [ -z "$type" ] && return 1
+ buffer="$block $type"
+ if [ $type != 'raw' ]
+ then
+ if [ $type == lvm-lv ]
+ then
+ lv=`echo $block | sed 's/.*-//'` # /dev/mapper/cryptpool-cryptroot -> cryptroot. TODO: this may give unexpected behavior of LV has a '-' in its name
+ recognizer="lvm-lv;(yes|no);no_mountpoint;[^;]{1,};[^;]{1,};$lv;[^;]{1,}"
+ elif [ $type == lvm-vg ]
+ then
+ recognizer="lvm-vg;(yes|no);no_mountpoint;[^;]{1,};[^;]{1,};`basename $block`;[^;]{1,}"
+ elif [ $type == lvm-pv ]
+ then
+ # here we cheat a bit: we cannot match the FS section because usually we don't give a PV recognizable attributes, but since we name a PV as blockdevice + '+' we can match the blockdevice
+ recognizer="^${block/+/} .* lvm-pv;"
+ elif [ $type == dm_crypt ]
+ then
+ recognizer="dm_crypt;(yes|no);no_mountpoint;[^;]{1,};[^;]{1,};`basename $block`;[^;]{1,}"
+ fi
+ get_anchestors_mount "$recognizer" && buffer="$buffer
+$ANSWER_DEVICES"
+ fi
+ debug 'FS' "Found anchestors: $ANSWER_DEVICES"
+ ANSWER_DEVICES=$buffer
+ [ -n "$ANSWER_DEVICES" ]
+}
+
# taken from setup script, modified for separator control
# $1 set to 1 to echo a newline after device instead of a space (optional)
@@ -506,14 +555,24 @@ rollback_filesystems ()
# -> easier (implemented)
- infofy "Phase 2: destructing specified blockdevices" disks
+ infofy "Phase 2: destructing relevant blockdevices" disks
for i in `seq 1 10`
do
open_items=0
- while read part part_type part_label fs_string # $fs_string can be ignored
+ while read part part_type part_label fs_string
do
+
real_part=${part/+/}
- if [ "$part_type" = dm_crypt ] # Can be in use for: lvm-pv or raw. we don't need to care about raw (it will be unmounted so it can be destroyed)
+
+ # do not destroy a blockdevice if it hosts one or more filesystems that were set to not recreate
+ # fs_string = one or more "$fs_type;$fs_create;$fs_mountpoint;target;$fs_opts;$fs_label;$fs_params", separated by ':'
+ # there is probably a nice regex to check this but i'm bad at regexes.
+ if echo "$fs_string" | grep -q ';yes;/' || echo "$fs_string" | grep -q ';yes;no_mountpoint'
+ then
+ infofy "Skipping destruction of $part ($part_type) because one of the filesystems on it contains data you want to keep"
+ # TODO: it's possible that if we don't clear a blockdevice here because there is something on it with valuable data, that this blockdevice itself is hosted on some other blockdevice (eg lvm VG,PV or dm_crypt), \
+ # that blockdevice cannot be cleared as well because it depends on this one, so after 10 iterations the user will get a warning that not everything is cleared. so we should fix this someday.
+ elif [ "$part_type" = dm_crypt ] # Can be in use for: lvm-pv or raw. we don't need to care about raw (it will be unmounted so it can be destroyed)
then
if [ -b $real_part ] && cryptsetup status $real_part &>/dev/null # don't use 'isLuks' it only works for the "underlying" device (eg in /dev/sda1 -> luksOpen -> /dev/mapper/foo, isLuks works only on the former. status works on the latter too)
then
@@ -649,7 +708,7 @@ process_filesystem ()
fi
[ -z "$fs_label" ] && [ "$fs_type" = lvm-vg -o "$fs_type" = lvm-pv ] && fs_label=default #TODO. implement the incrementing numbers label for lvm vg's and lv's
- ret=0
+ local ret=0
#TODO: health checks on $fs_params etc
case ${fs_type} in #TODO: implement label, opts etc decently
xfs) mkfs.xfs -f $part $opts >$LOG 2>&1; ret=$? ;;
@@ -691,11 +750,6 @@ process_filesystem ()
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 = '/' ]
- then
- debug FS "setting \$PART_ROOT to $part"
- PART_ROOT=$part
- fi
fi
fi
@@ -794,7 +848,7 @@ mdraid_is-raid ()
# $1 md raid blockdevice (ex: /dev/md0)
# return the array member device which is slave 0 in the given array
# ex: /dev/md0 is an array with /dev/sda1, /dev/sdb1,
-# so we would return /dev/sda1 as slave 0
+# so we would return /dev/sda1 as slave 0
#
# This procedure is used to determine the grub value for root, ex: (hd0,0)
mdraid_slave0 ()
diff --git a/src/core/libs/lib-flowcontrol.sh b/src/core/libs/lib-flowcontrol.sh
index 64e7f2b..078a33d 100755
--- a/src/core/libs/lib-flowcontrol.sh
+++ b/src/core/libs/lib-flowcontrol.sh
@@ -100,7 +100,7 @@ execute ()
then
shift 2
$object "$@"
- ret=$?
+ local ret=$?
exit_var=exit_$object
read $exit_var <<< $ret # maintain exit status of each worker
else
@@ -128,7 +128,7 @@ execute ()
debug 'MAIN' "Loop iteration. \$worker_str: $worker_str"
execute worker $worker_str || read $exit_var <<< $? # assign last failing exit code to exit_phase_<phasename>, if any.
done
- ret=${!exit_var}
+ local ret=${!exit_var}
fi
debug 'MAIN' "Execute(): $object exit state was $ret"
@@ -183,7 +183,7 @@ show_report () #TODO: abstract UI method (cli/dia)
do
object=phase_$phase
exit_var=exit_$object
- ret=${!exit_var}
+ local ret=${!exit_var}
echo -n "Phase $phase: "
[ "$ret" = "0" ] && echo "Success" || echo "Failed"
eval phase_array=$(declare | grep -e "^${object}=" | cut -d"=" -f 2-)
diff --git a/src/core/libs/lib-pacman.sh b/src/core/libs/lib-pacman.sh
index 19e2eca..3932640 100644
--- a/src/core/libs/lib-pacman.sh
+++ b/src/core/libs/lib-pacman.sh
@@ -9,7 +9,7 @@ assure_pacman_static ()
[ -f /usr/bin/pacman.static ] && PACMAN_STATIC=/usr/bin/pacman.static
if [ "$PACMAN_STATIC" = "" ]; then
cd /tmp
- if [ "$var_PKG_SOURCE_TYPE" = "ftp" ]; then
+ if [ "$var_PKG_SOURCE_TYPE" = "net" ]; then
echo "Downloading pacman..."
wget $PKGARG/pacman*.pkg.tar.gz
if [ $? -gt 0 ]; then
@@ -30,12 +30,12 @@ assure_pacman_static ()
}
-# taken from the quickinst script. cd/ftp code merged together
+# taken from the quickinst script. cd/net code merged together
target_write_pacman_conf ()
{
PKGFILE=/tmp/packages.txt
echo "[core]" >/tmp/pacman.conf
- if [ "$var_PKG_SOURCE_TYPE" = "ftp" ]
+ if [ "$var_PKG_SOURCE_TYPE" = "net" ]
then
wget $PKG_SOURCE/packages.txt -O /tmp/packages.txt || die_error " Could not fetch package list from server"
echo "Server = $PKGARG" >>/tmp/pacman.conf
@@ -48,7 +48,7 @@ target_write_pacman_conf ()
fi
mkdir -p $var_TARGET_DIR/var/cache/pacman/pkg /var/cache/pacman &>/dev/null
rm -f /var/cache/pacman/pkg &>/dev/null
- [ "$var_PKG_SOURCE_TYPE" = "ftp" ] && ln -sf $var_TARGET_DIR/var/cache/pacman/pkg /var/cache/pacman/pkg &>/dev/null
+ [ "$var_PKG_SOURCE_TYPE" = "net" ] && ln -sf $var_TARGET_DIR/var/cache/pacman/pkg /var/cache/pacman/pkg &>/dev/null
[ "$var_PKG_SOURCE_TYPE" = "cd" ] && ln -sf $PKGARG /var/cache/pacman/pkg &>/dev/null
}
@@ -60,7 +60,7 @@ target_write_pacman_conf ()
# returns: 1 on error
target_prepare_pacman() {
[ "$var_PKG_SOURCE_TYPE" = "cd" ] && local serverurl="${var_FILE_URL}"
- [ "$var_PKG_SOURCE_TYPE" = "ftp" ] && local serverurl="${var_SYNC_URL}"
+ [ "$var_PKG_SOURCE_TYPE" = "net" ] && local serverurl="${var_SYNC_URL}"
[ -z "$1" ] && repos=core
[ -n "$1" ] && repos="$@"
@@ -73,7 +73,7 @@ EOF
for repo in $repos
do
- #TODO: this is a VERY, VERY dirty hack. we fall back to ftp for any non-core repo because we only have core on the CD. also user maybe didn't pick a mirror yet
+ #TODO: this is a VERY, VERY dirty hack. we fall back to net for any non-core repo because we only have core on the CD. also user maybe didn't pick a mirror yet
if [ "$repo" != core ]
then
add_pacman_repo target ${repo} "Include = $var_MIRRORLIST"
diff --git a/src/core/libs/lib-software.sh b/src/core/libs/lib-software.sh
index c378577..6b0527f 100644
--- a/src/core/libs/lib-software.sh
+++ b/src/core/libs/lib-software.sh
@@ -14,6 +14,7 @@ run_mkinitcpio()
target_special_fs off
# alert the user to fatal errors
+ # TODO: on the next line, bash gives '[: -ne: unary operator expected'. seen on 2009-07-21
[ $mkinitcpio_exitcode -ne 0 ] && show_warning "MKINITCPIO FAILED - SYSTEM MAY NOT BOOT" "$TMP_MKINITCPIO_LOG" text
return $mkinitcpio_exitcode
}
@@ -48,6 +49,7 @@ installpkg() {
run_controlled pacman_installpkg "$PACMAN_TARGET --noconfirm -S $ALL_PACKAGES" $TMP_PACMAN_LOG "Installing... Please Wait"
local _result=''
+ # TODO: on the next line, bash gives '[: -ne: unary operator expected'. seen on 2009-07-21
if [ ${pacman_installpkg_exitcode} -ne 0 ]; then
_result="Installation Failed (see errors below)"
echo -e "\nPackage Installation FAILED." >>$TMP_PACMAN_LOG
diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh
index cb79893..f765d59 100644
--- a/src/core/libs/lib-ui-interactive.sh
+++ b/src/core/libs/lib-ui-interactive.sh
@@ -19,7 +19,10 @@ check_depend ()
interactive_configure_system()
{
- [ "$EDITOR" ] || interactive_get_editor
+ if [ -z "$EDITOR" ]
+ then
+ interactive_get_editor || return 1
+ fi
FILE=""
## PREPROCESSING ##
@@ -27,7 +30,7 @@ interactive_configure_system()
#TODO: only need to do this once. check 'ended_ok worker configure_system' is not good because this could be done already even if worker did not exit 0
# /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
+ if [ "$var_PKG_SOURCE_TYPE" = "net" -a "${var_SYNC_URL}" != "" ]; then
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
@@ -40,12 +43,32 @@ interactive_configure_system()
-e "s/^HARDWARECLOCK=.*/HARDWARECLOCK=\"$HARDWARECLOCK\"/g" \
${var_TARGET_DIR}/etc/rc.conf
+ # prepare HOOKS in mkinitcpio.conf for lvm/dm_crypt users
+ if get_anchestors_mount ';/;'
+ then
+ hooks=`echo "$ANSWER_DEVICES" | cut -d ' ' -f2 | egrep 'lvm-lv|dm_crypt' | sed -e 's/lvm-lv/lvm2/' -e 's/dm_crypt/encrypt/' | tac`
+ hooks=`echo $hooks`
+ [ -n "$hooks" ] && sed -i "/^HOOKS/ s/filesystems/$hooks filesystems/" ${var_TARGET_DIR}/etc/mkinitcpio.conf
+ fi
+ # if keymap/usbinput are not in mkinitcpio.conf, but encrypt is, we should probably add it
+ if line=`grep ^HOOKS ${var_TARGET_DIR}/etc/mkinitcpio.conf | grep encrypt`
+ then
+ if ! echo "$line" | grep -q keymap
+ then
+ sed -i '/^HOOKS/ s/encrypt/keymap encrypt/' ${var_TARGET_DIR}/etc/mkinitcpio.conf
+ fi
+ if ! echo "$line" | grep -q usbinput
+ then
+ sed -i '/^HOOKS/ s/keymap/usbinput keymap/' ${var_TARGET_DIR}/etc/mkinitcpio.conf
+ fi
+ fi
+
# main menu loop
while true; do
DEFAULT=no
[ -n "$FILE" ] && DEFAULT="$FILE"
- 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/<filename> 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
+ helptext="\nNote that if you want to change any file not listed here (unlikely) you can go to another tty and update ${var_TARGET_DIR}/etc/<filename> yourself"
+ grep -q '^/dev/mapper' $TMP_FSTAB && helptext="$helptext\n/dev/mapper/ users: Pay attention to HOOKS in mkinitcpio.conf"
ask_option $DEFAULT "Configuration" "$helptext" required \
"/etc/rc.conf" "System Config" \
"/etc/fstab" "Filesystem Mountpoints" \
@@ -123,7 +146,7 @@ interactive_time () {
type ntpdate &>/dev/null && EXTRA=('ntp' 'Set time and date using ntp')
ask_option $default "Date/time configuration" "According to your settings and your hardwareclock, the date should now be $current. If this is incorrect, you can correct this now" required \
- "${EXTRA[@]}" "manual" "Set time and date manually" "return" "Looks good. back to main menu"
+ "${EXTRA[@]}" "manual" "Set time and date manually" "return" "Looks good. back to main menu" || return 1
if [ "$ANSWER_OPTION" = ntp ]
then
if ntpdate pool.ntp.org >/dev/null
@@ -152,7 +175,7 @@ interactive_time () {
interactive_prepare_disks ()
{
DONE=0
- ret=1 # 1 means unsuccessful. 0 for ok
+ local ret=1 # 1 means unsuccessful. 0 for ok
NEXTITEM=
DISK_CONFIG_TYPE=
[ "$BLOCK_ROLLBACK_USELESS" = "0" ] && show_warning "Rollback may be needed" "It seems you already went here. You should probably rollback previous changes before reformatting, otherwise stuff will probably fail"
@@ -165,11 +188,11 @@ interactive_prepare_disks ()
#TODO: inform user (using dialog's --item-help or so) that autoprepare uses 1 disk and uses it in a "fairly regular" (though somewhat customizable) manner.
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" \
+ "1" "Auto-Prepare (erases an ENTIRE hard drive and sets up partitions, filesystems and mountpoints)" \
+ "2" "Manually Partition Hard Drives" \
+ "3" "Manually Configure block devices, filesystems and mountpoints" \
"4" "Rollback last filesystem changes$rollbackstr" \
- "5" "Return to Main Menu"
+ "5" "Return to Main Menu" || return 1
case $ANSWER_OPTION in
"1")
@@ -199,7 +222,7 @@ interactive_prepare_disks ()
fi
fi
;;
- *)
+ "5")
DONE=1 ;;
esac
done
@@ -354,8 +377,8 @@ interactive_filesystem ()
local old_fs_label=$fs_label
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) ?" required \
+ ask_option edit "Change $fs_type filesystem settings on $part ?" \
+ "Change $fs_type filesystem settings (create:$fs_create, 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
@@ -367,7 +390,6 @@ interactive_filesystem ()
if [ "$NEW_FILESYSTEM" != no_fs ]
then
# Possible filesystems/software layers on partitions/block devices
-
# name on top of mountpoint? label? DM device? theoretical device? opts? special params?
# swap raw/lvm-lv/dm_crypt no no no no no no
@@ -399,6 +421,9 @@ interactive_filesystem ()
[ $part_type = lvm-vg ] && which `get_filesystem_program lvm-lv` &>/dev/null && FSOPTS="$FSOPTS lvm-lv LVM_Logical_Volume"
[ $part_type = raw -o $part_type = lvm-lv ] && which `get_filesystem_program dm_crypt` &>/dev/null && FSOPTS="$FSOPTS dm_crypt DM_crypt_Volume"
+ fs_create=no
+ ask_yesno "Do you want to have this filesystem re(created) ? If not, make sure there already is a filesystem!" && fs_create=yes
+
# determine FS
fsopts=($FSOPTS);
if [ ${#fsopts[*]} -lt 4 ] # less then 4 words in the $FSOPTS string. eg only one option
@@ -408,7 +433,9 @@ interactive_filesystem ()
else
default=
[ -n "$fs_type" ] && default="--default-item $fs_type"
- ask_option no "Select filesystem" "Select a filesystem for $part:" required $FSOPTS || return 1
+ extratext="Select a filesystem for $part:"
+ [ "$fs_create" == no ] && extratext="Select which filesystem $part is. Make sure you get this right" #otherwise he'll be screwed when we try to mount it :)
+ ask_option no "Select filesystem" "$extratext" required $FSOPTS || return 1
fs_type=$ANSWER_OPTION
fi
@@ -427,7 +454,7 @@ interactive_filesystem ()
fi
# ask label, if relevant
- if [ "$fs_type" = lvm-vg -o "$fs_type" = lvm-lv -o "$fs_type" = dm_crypt ]
+ if [ "$fs_create" == yes ] && [ "$fs_type" = lvm-vg -o "$fs_type" = lvm-lv -o "$fs_type" = dm_crypt ]
then
default=
[ -n "$fs_label" ] && default="$fs_label"
@@ -436,7 +463,7 @@ interactive_filesystem ()
fi
# ask special params, if relevant
- if [ "$fs_type" = lvm-vg ]
+ if [ "$fs_create" == yes ] && [ "$fs_type" = lvm-vg ]
then
# add $part to $fs_params if it's not in there because the user wants this enabled by default. TODO: we should find something out so you can't disable $part. (would be weird to have a vg listed on $part and not have $part it fs_params)
pv=${part/+/}
@@ -460,7 +487,7 @@ interactive_filesystem ()
fs_params="$(sed 's/ /:/' <<< "$ANSWER_CHECKLIST")" #replace spaces by colon's, we cannot have spaces anywhere in any string
fi
fi
- if [ "$fs_type" = lvm-lv ]
+ if [ "$fs_create" == yes ] && [ "$fs_type" = lvm-lv ]
then
[ -z "$fs_params" ] && default='5000'
[ -n "$fs_params" ] && default="$fs_params"
@@ -468,7 +495,7 @@ interactive_filesystem ()
# 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 ]
+ if [ "$fs_create" == yes ] && [ "$fs_type" = dm_crypt ]
then
[ -z "$fs_params" ] && default='-c aes-xts-plain -y -s 512'
[ -n "$fs_params" ] && default="${fs_params//_/ }"
@@ -477,18 +504,21 @@ interactive_filesystem ()
fi
# ask opts
- default=
- [ -n "$fs_opts" ] && default="$fs_opts"
- program=`get_filesystem_program $fs_type`
- ask_string "Enter any additional opts for $program" "$default" 0
- fs_opts=$(sed 's/ /_/g' <<< "$ANSWER_STRING") #TODO: clean up all whitespace (tabs and shit)
+ if [ "$fs_create" == yes ]
+ then
+ default=
+ [ -n "$fs_opts" ] && default="$fs_opts"
+ program=`get_filesystem_program $fs_type`
+ ask_string "Enter any additional opts for $program" "$default" 0
+ fs_opts=$(sed 's/ /_/g' <<< "$ANSWER_STRING") #TODO: clean up all whitespace (tabs and shit)
+ fi
[ -z "$fs_type" ] && fs_type=no_type
[ -z "$fs_mountpoint" ] && fs_mountpoint=no_mountpoint
[ -z "$fs_opts" ] && fs_opts=no_opts
[ -z "$fs_label" ] && fs_label=no_label
[ -z "$fs_params" ] && fs_params=no_params
- NEW_FILESYSTEM="$fs_type;yes;$fs_mountpoint;target;$fs_opts;$fs_label;$fs_params" #TODO: make re-creation yes/no asking available in this UI.
+ NEW_FILESYSTEM="$fs_type;$fs_create;$fs_mountpoint;target;$fs_opts;$fs_label;$fs_params"
# add new theoretical blockdevice, if relevant
new_device=
@@ -771,11 +801,13 @@ interactive_runtime_network() {
IPADDR=$ANSWER_STRING
ask_string "Enter your netmask" "255.255.255.0" || return 1
SUBNET=$ANSWER_STRING
- ask_string "Enter your broadcast" "192.168.0.255" || return 1
+ ask_string "Enter your broadcast" "$(sed 's/\.[^.]*$/\.255/' <<< $IPADDR)" || return 1
BROADCAST=$ANSWER_STRING
- ask_string "Enter your gateway (optional)" "192.168.0.1" 0 || return 1
+ ask_string "Enter your gateway (optional)" "$(sed 's/\.[^.]*$/\.1/' <<< $IPADDR)" 0 || return 1
GW=$ANSWER_STRING
- ask_string "Enter your DNS server IP" "192.168.0.1" || return 1
+ [ -n "$GW" ] && default_dns="$GW"
+ [ -z "$GW" ] && default_dns="$(sed 's/\.[^.]*$/\.1/' <<< $IPADDR)"
+ ask_string "Enter your DNS server IP" "$default_dns" || return 1
DNS=$ANSWER_STRING
ask_string "Enter your HTTP proxy server, for example:\nhttp://name:port\nhttp://ip:port\nhttp://username:password@ip:port\n\n Leave the field empty if no proxy is needed to install." "" 0 || return 1
PROXY_HTTP=$ANSWER_STRING
@@ -815,7 +847,7 @@ interactive_runtime_network() {
interactive_install_bootloader () {
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!"
+ "None" "\Zb\Z1Warning\Z0\ZB: you must install your own bootloader!" || return 1
bl=`tr '[:upper:]' '[:lower:]' <<< "$ANSWER_OPTION"`
[ "$bl" != grub ] && return 0
@@ -828,12 +860,12 @@ interactive_grub() {
local grubmenu="$var_TARGET_DIR/boot/grub/menu.lst"
[ ! -f $grubmenu ] && show_warning "No grub?" "Error: Couldn't find $grubmenu. Is GRUB installed?" && return 1
- gblog="/tmp/gb.log"
- echo "Start grub" > $gblog
+ debug FS "starting interactive_grub"
# 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
+ if get_device_with_mount '/' && [ "$GRUB_OK" != '1' ] ; then
GRUB_OK=0
+ PART_ROOT=$ANSWER_DEVICE
# look for a separately-mounted /boot partition
# This could be used better, maybe we use a better variable name cause
# we use this later in many things in workflow.
@@ -850,7 +882,7 @@ interactive_grub() {
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
onraid=true
- echo "onraid is selected" >> $gblog
+ debug FS "onraid is selected"
fi
fi
# Create and edit the grub menu.lst
@@ -966,9 +998,9 @@ interactive_grub() {
}
interactive_grub_menulst() {
-
- local _rootpart="${PART_ROOT}"
- local _uuid="$(getuuid ${PART_ROOT})"
+ get_device_with_mount '/' || return 1
+ local _rootpart=$ANSWER_DEVICE
+ local _uuid="$(getuuid ${_rootpart})"
# attempt to use a UUID if the root device has one
if [ -n "${_uuid}" ]; then
_rootpart="/dev/disk/by-uuid/${_uuid}"
@@ -989,19 +1021,19 @@ interactive_grub_menulst() {
# wrong with menu.lst settings (wrong boot device or wrong root=/device)
# he better should re-run the interactive grub install and select correct
# settings.
- echo "Grub Part_root: "$PART_ROOT >> $gblog
- echo "Grub bootdev: "$bootdev >> $gblog
+ debug FS "Grub _rootpart: ${_rootpart}"
+ debug FS "Grub bootdev: "$bootdev
# No seperate /boot partition
if [ -z $bootdev ]; then
# Special handling on md raid
if [ $onraid ]; then
- grubdev=$(mapdev $(mdraid_slave0 $PART_ROOT))
- echo "onraid no sep boot slave0: "$(mdraid_slave0 $PART_ROOT) >> $gblog
- echo "onraid no sep boot grubdev: "$grubdev >> $gblog
+ grubdev=$(mapdev $(mdraid_slave0 ${_rootpart}))
+ debug FS "onraid no sep boot slave0: "$(mdraid_slave0 ${_rootpart})
+ debug FS "onraid no sep boot grubdev: "$grubdev
else
# No raid
- grubdev=$(mapdev $PART_ROOT)
- echo "no sep boot grubdev: "$grubdev >> $gblog
+ grubdev=$(mapdev ${_rootpart})
+ debug FS "no sep boot grubdev: "$grubdev
fi
# Without seperate /boot partiton we have to specify this path
subdir="/boot"
@@ -1010,12 +1042,12 @@ interactive_grub_menulst() {
# Special handling on md raid
if [ $onraid ]; then
grubdev=$(mapdev $(mdraid_slave0 $bootdev))
- echo "onraid with sep boot slave0: "$(mdraid_slave0 $bootdev) >> $gblog
- echo "onraid with sep boot grubdev: "$grubdev >> $gblog
+ debug FS "onraid with sep boot slave0: "$(mdraid_slave0 $bootdev)
+ debug FS "onraid with sep boot grubdev: "$grubdev
else
# No raid
grubdev=$(mapdev $bootdev)
- echo "onraid with sep boot grubdev: "$grubdev >> $gblog
+ debug FS "onraid with sep boot grubdev: "$grubdev
fi
fi
# Now that we have our grub-legacy root device (grubdev).
@@ -1026,18 +1058,47 @@ interactive_grub_menulst() {
fi
# remove default entries by truncating file at our little tag (#-*)
sed -i -e '/#-\*/q' $grubmenu
+
+ # handle dmraid/mdadm,lvm,dm_crypt etc. replace entries where needed automatically
+ debug 'FS' 'Grub kernel line? Assuming "/ on raw" or "/ on lvm on raw" as default'
+ kernel="kernel $subdir/vmlinuz26 root=${_rootpart} ro"
+ if get_anchestors_mount ';/;'
+ then
+ if echo "$ANSWERS_DEVICES" | sed -n '1p' | grep -q 'dm_crypt$' && echo "$ANSWERS_DEVICES" | sed -n '2p' | grep -q 'raw$'
+ then
+ debug 'FS' 'Grub kernel line? Found / on dm_crypt on raw'
+ raw_device=`echo "$ANSWERS_DEVICES" | sed -n '2p' | cut -d ' ' -f1`
+ kernel="kernel $subdir/vmlinuz26 root=$raw_device ro"
+ elif echo "$ANSWERS_DEVICES" | sed -n '1p' | grep -q 'lvm-lv$' && echo "$ANSWERS_DEVICES" | sed -n '4p' | grep -q 'dm_crypt$' && echo "$ANSWERS_DEVICES" | sed -n '5p' | grep -q 'raw$'
+ then
+ debug 'FS' 'Grub kernel line? Found / on lvm on dm_crypt on raw'
+ lv_device=`echo "$ANSWERS_DEVICES" | sed -n '1p' | cut -d ' ' -f1`
+ vg_device=`echo "$ANSWERS_DEVICES" | sed -n '2p' | cut -d ' ' -f1`
+ crypt_device=`echo "$ANSWERS_DEVICES" | sed -n '4p' | cut -d ' ' -f1`
+ kernel="kernel $subdir/vmlinuz26 root=$lv_device cryptdevice=$crypt_device:`basename $vgdevice` ro"
+ elif echo "$ANSWERS_DEVICES" | sed -n '1p' | grep -q 'dm_crypt$' && echo "$ANSWERS_DEVICES" | sed -n '2p' | grep -q 'lvm-lv$' && echo "$ANSWERS_DEVICES" | sed -n '5p' | grep -q 'raw$'
+ then
+ debug 'FS' 'Grub kernel line? Found / on dm_crypt on lvm on raw'
+ crypt_device=`echo "$ANSWERS_DEVICES" | sed -n '1p' | cut -d ' ' -f1`
+ lv_device=`echo "$ANSWERS_DEVICES" | sed -n '2p' | cut -d ' ' -f1`
+ kernel=" kernel $subdir/vmlinuz26 root=$crypt_device cryptdevice=$lv_device:root ro"
+ else
+ debug 'FS' 'Grub kernel line? Could not figure this one out'
+ show_warning "Disk setup detection" "Could not figure out what kind of disk setup you are using. Are you using some really fancy dm_crypt/lvm/softraid setup? Please file a bug for this and supply all files from /tmp/aif/"
+ fi
+ fi
cat >>$grubmenu <<EOF
# (0) Arch Linux
title Arch Linux
root $grubdev
-kernel $subdir/vmlinuz26 root=${_rootpart} ro
+$kernel
initrd $subdir/kernel26.img
# (1) Arch Linux
title Arch Linux Fallback
root $grubdev
-kernel $subdir/vmlinuz26 root=${_rootpart} ro
+$kernel
initrd $subdir/kernel26-fallback.img
# (2) Windows
@@ -1047,19 +1108,18 @@ initrd $subdir/kernel26-fallback.img
#chainloader +1
EOF
- notify "Before installing GRUB, you must review the configuration file. You will now be put into the editor. After you save your changes and exit the editor, you can install GRUB."
- [ -n "$EDITOR" ] || interactive_get_editor
+ helptext=
+ grep -q '^/dev/mapper' $TMP_FSTAB && helptext=" /dev/mapper/ users: Pay attention to the kernel line!"
+ notify "Before installing GRUB, you must review the configuration file. You will now be put into the editor. After you save your changes and exit the editor, you can install GRUB.$helptext"
+ if [ -z "$EDITOR" ]
+ then
+ interactive_get_editor || return 1
+ fi
$EDITOR $grubmenu
}
interactive_grub_install () {
- #TODO: handle dmraid/mdadm,lvm,dm_crypt etc. replace entries where needed
- # / on dm_crypt -> no substitution needed: specify physical device that hosts the encrypted /
- # / on lvm -> root=/dev/mapper/<volume-group>-<logical-volume-root> resume=/dev/mapper/<volume-group>-<logical-volume-swap>
- # / on lvm on dm_crypt -> root=/dev/mapper/<volume-group>-<logical-volume-root> cryptdevice=/dev/<luks-part>:<volume-group>
- # / on dm_crypt on lvm -> specify the lvm device that hosts the encrypted /
- # ...
-
+ debug FS "interactive_grub_install called. P1 = $1, P2 = $2, P3 = $3"
# $1 = bootpart
# $2 = bootdev
# $3 = boothd
@@ -1082,12 +1142,9 @@ interactive_grub_install () {
return 1
fi
local boothd=$3
- echo "P1: $1" >> $gblog
- echo "P2: $2" >> $gblog
- echo "P3: $3" >> $gblog
- echo "bootpart: $bootpart" >> $gblog
- echo "bootdev: $bootdev" >> $gblog
- echo "boothd: $boothd" >> $gblog
+ debug FS "bootpart: $bootpart"
+ debug FS "bootdev: $bootdev"
+ debug FS "boothd: $boothd"
#return 0
$var_TARGET_DIR/sbin/grub --no-floppy --batch >/tmp/grub.log 2>&1 <<EOF
@@ -1117,12 +1174,12 @@ interactive_select_source()
var_SYNC_URL=
ask_option no "Source selection" "Please select an installation source" required \
- "1" "CD-ROM or OTHER SOURCE" \
- "2" "FTP/HTTP" || return 1
+ "cd" "CD-ROM or OTHER SOURCE" \
+ "net" "NET (FTP/HTTP)" || return 1
case $ANSWER_OPTION in
- "1") var_PKG_SOURCE_TYPE="cd" ;;
- "2") var_PKG_SOURCE_TYPE="ftp" ;;
+ "cd") var_PKG_SOURCE_TYPE="cd" ;;
+ "net") var_PKG_SOURCE_TYPE="net" ;;
esac
if [ "$var_PKG_SOURCE_TYPE" = "cd" ]; then
@@ -1134,7 +1191,7 @@ interactive_select_source()
fi
echo "Using CDROM for package installation" >$LOG
else
- TITLE="Arch Linux FTP/HTTP Installation"
+ TITLE="Arch Linux NET (FTP/HTTP) Installation"
notify "If you wish to load your ethernet modules manually, please do so now in an another terminal."
fi
return 0
@@ -1173,7 +1230,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" required "${EDITOR_OPTS[@]}"
+ ask_option nano "Text editor selection" "Select a Text Editor to Use" required "${EDITOR_OPTS[@]}" || return 1
#TODO: this code could be a little bit cleaner.
case $ANSWER_OPTION in
"nano") EDITOR="nano" ;;
@@ -1187,10 +1244,10 @@ interactive_get_editor() {
select_source_extras_menu ()
{
while true; do
- ask_option no "FTP Installation" "Make sure the network is ok and you've selected a mirror before continuing the installer" required \
+ ask_option no "NET (HTTP/FTP) Installation" "Make sure the network is ok and you've selected a mirror before continuing the installer" required \
"1" "$worker_runtime_network_title" \
"2" "$worker_select_mirror_title" \
- "3" "Return to Main Menu"
+ "3" "Return to Main Menu" || return 1
[ "$ANSWER_OPTION" = 1 ] && execute worker runtime_network
[ "$ANSWER_OPTION" = 2 ] && execute worker select_mirror
[ "$ANSWER_OPTION" = 3 ] && break
diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh
index 82d11f3..c02b994 100644
--- a/src/core/libs/lib-ui.sh
+++ b/src/core/libs/lib-ui.sh
@@ -169,17 +169,15 @@ ask_timezone ()
REGIONS="$REGIONS $i -"
done
while true; do
- ask_option no "Please select a region" '' required $REGIONS
+ ask_option no "Please select a region" '' required $REGIONS || return 1
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" '' required $ZONES
- zone=$ANSWER_OPTION
- [ $? -eq 0 ] && ANSWER_TIMEZONE="$region/$zone" && return
- fi
+ 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" '' required $ZONES || return 1
+ zone=$ANSWER_OPTION
+ ANSWER_TIMEZONE="$region/$zone" && return
done
}
@@ -323,7 +321,7 @@ _dia_ask_checklist ()
shift 3
done
_dia_dialog --checklist "$str" 0 0 0 $list 2>$ANSWER
- ret=$?
+ local ret=$?
ANSWER_CHECKLIST=`cat $ANSWER`
debug 'UI' "_dia_ask_checklist: user checked ON: $ANSWER_CHECKLIST"
return $ret
@@ -356,7 +354,7 @@ _dia_ask_number ()
[ -n $3 -a $3 != '0' ] && str2="$str2 max $3"
[ -n "$str2" ] && str="$str ( $str2 )"
_dia_dialog --inputbox "$str" 0 0 $4 2>$ANSWER
- ret=$?
+ local ret=$?
ANSWER_NUMBER=`cat $ANSWER`
if [[ $ANSWER_NUMBER = *[^0-9]* ]] #TODO: handle exit state
then
@@ -395,7 +393,7 @@ _dia_ask_option ()
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" 0 0 0 "$@" 2>$ANSWER
- ret=$?
+ local ret=$?
ANSWER_OPTION=`cat $ANSWER`
debug 'UI' "dia_ask_option: ANSWER_OPTION: $ANSWER_OPTION, returncode (skip/cancel): $ret ($DIA_MENU_TITLE)"
[ $TYPE == required ] && return $ret
@@ -415,7 +413,7 @@ _dia_ask_password ()
fi
_dia_dialog --passwordbox "Enter your $type_l password" 8 65 "$2" 2>$ANSWER
- ret=$?
+ local ret=$?
[ -n "$type_u" ] && read ${type_u}_PASSWORD < $ANSWER
[ -z "$type_u" ] && read PASSWORD < $ANSWER
cat $ANSWER
@@ -428,7 +426,7 @@ _dia_ask_string ()
{
exitcode=${3:-1}
_dia_dialog --inputbox "$1" 0 0 "$2" 2>$ANSWER
- ret=$?
+ local ret=$?
ANSWER_STRING=`cat $ANSWER`
debug 'UI' "_dia_ask_string: user entered $ANSWER_STRING"
[ -z "$ANSWER_STRING" ] && return $exitcode
@@ -445,7 +443,7 @@ _dia_ask_yesno ()
# If $2 contains an explicit 'no' we set defaultno for yesno dialog
[ "$2" == "no" ] && default="--defaultno"
dialog $default --yesno "$str" $height 55 # returns 0 for yes, 1 for no
- ret=$?
+ local ret=$?
[ $ret -eq 0 ] && debug 'UI' "dia_ask_yesno: User picked YES"
[ $ret -gt 0 ] && debug 'UI' "dia_ask_yesno: User picked NO"
return $ret
@@ -564,7 +562,7 @@ _cli_ask_option ()
[ -n "$DEFAULT" ] && echo -n " > [ $DEFAULT ] "
[ -z "$DEFAULT" ] && echo -n " > "
read ANSWER_OPTION
- ret=0
+ local ret=0
[ -z "$ANSWER_OPTION" -a -n "$DEFAULT" ] && ANSWER_OPTION="$DEFAULT"
[ "$ANSWER_OPTION" == CANCEL ] && ret=1 && ANSWER_OPTION=
[ "$ANSWER_OPTION" == SKIP ] && ret=0 && ANSWER_OPTION=
diff --git a/src/core/procedures/base b/src/core/procedures/base
index 7d56b09..fb7a60f 100644
--- a/src/core/procedures/base
+++ b/src/core/procedures/base
@@ -69,7 +69,7 @@ worker_select_source ()
var_PKG_SOURCE_TYPE='cd'
var_FILE_URL="file:///src/core/pkg"
var_SYNC_URL= # optional, points to a repository string something like ftp://ftp.belnet.be/mirror/archlinux.org/$repo/os/i686 (eg the same format as what you find in /etc/pacman.conf)
- # if you override to use ftp (or ask user and he chooses ftp) don't forget to configure the network and to select_mirrors
+ # if you override var_PKG_SOURCE_TYPE to 'net' (or ask user and he chooses ftp) don't forget to configure the network and to select_mirrors
}
@@ -115,7 +115,7 @@ worker_set_clock ()
ask_option $default "Date/time configuration" '' required \
"1" "Select region and timezone" \
"2" "Set time and date" \
- "3" "Return to Main Menu"
+ "3" "Return to Main Menu" || return 1
[ "$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
diff --git a/src/core/procedures/interactive b/src/core/procedures/interactive
index 3cd535e..240b4bf 100644
--- a/src/core/procedures/interactive
+++ b/src/core/procedures/interactive
@@ -11,9 +11,6 @@ BLOCK_ROLLBACK_USELESS=1
HARDWARECLOCK=
TIMEZONE=
-# partitions
-PART_ROOT=
-
# default filesystem specs (the + is bootable flag)
# <mountpoint>:<partsize>:<fstype>[:+]
DEFAULTFS="/boot:32:ext2:+ swap:256:swap /:7500:ext3 /home:*:ext3"
@@ -64,8 +61,8 @@ mainmenu()
"8" "Exit Install"
case $ANSWER_OPTION in
"1")
- execute worker select_source; ret=$?; [ $ret -eq 0 -a "$var_PKG_SOURCE_TYPE" = ftp ] && execute worker select_source_extras_menu
- [ $ret -eq 0 ] && execute worker runtime_packages && NEXTITEM=2 ;;
+ execute worker select_source; local ret=$?; [ $ret -eq 0 -a "$var_PKG_SOURCE_TYPE" = net ] && execute worker select_source_extras_menu
+ [ $ret -eq 0 ] && execute worker runtime_packages && NEXTITEM=2 ;;
"2")
execute worker set_clock && NEXTITEM=3 ;;