summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNicolás Reynolds <fauno@kiwwwi.com.ar>2011-08-16 21:03:12 -0300
committerNicolás Reynolds <fauno@kiwwwi.com.ar>2011-08-16 21:03:12 -0300
commit4f2c12cb85411e4702e3a6b29f847b08447ef0f0 (patch)
tree703eb04e60160c82fb3d3a2fc4af64dd8d67222d /src
parent74eb858cd962a3178724b83cefa8f43baaffa1ef (diff)
parent13c8c0813328eb8f52b03b3c53a32f1f40558021 (diff)
Merge branch 'master' of https://projects.archlinux.org/git/aif
Conflicts: doc/official_installation_guide_en
Diffstat (limited to 'src')
-rwxr-xr-xsrc/aif.sh2
-rw-r--r--src/core/libs/lib-blockdevices-filesystems.sh13
-rwxr-xr-xsrc/core/libs/lib-flowcontrol.sh14
-rw-r--r--src/core/libs/lib-misc.sh8
-rw-r--r--src/core/libs/lib-network.sh54
-rw-r--r--src/core/libs/lib-software.sh5
-rw-r--r--src/core/libs/lib-ui-interactive.sh157
-rw-r--r--src/core/procedures/automatic4
-rw-r--r--src/core/procedures/base5
9 files changed, 195 insertions, 67 deletions
diff --git a/src/aif.sh b/src/aif.sh
index ee93d88..d1d0a3c 100755
--- a/src/aif.sh
+++ b/src/aif.sh
@@ -146,4 +146,4 @@ start_installer
start_process
-stop_installer
+stop_installer $?
diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh
index 170779d..2ea32e6 100644
--- a/src/core/libs/lib-blockdevices-filesystems.sh
+++ b/src/core/libs/lib-blockdevices-filesystems.sh
@@ -73,7 +73,7 @@ fs_on[lvm-pv]=${fs_on_lvm_pv[@]}
fs_on[lvm-vg]=${fs_on_lvm_vg[@]}
fs_on[dm_crypt]=${fs_on_dm_crypt[@]}
-fs_mountable=(ext2 ext3 ext4 nilfs2 xfs jfs vfat reiserfs)
+fs_mountable=(btrfs ext2 ext3 ext4 nilfs2 xfs jfs vfat reiserfs)
fs_label_mandatory=('lvm-vg' 'lvm-lv' 'dm_crypt')
fs_label_optional=('swap' 'ext2' 'ext3' 'ext4' 'reiserfs' 'nilfs2' 'xfs' 'jfs' 'vfat')
@@ -94,7 +94,8 @@ get_possible_fs () {
true
}
-supported_bootloaders=('grub')
+syslinux_supported_fs=('ext2' 'ext3' 'ext4' 'btrfs' 'vfat')
+supported_bootloaders=('syslinux' 'grub')
# procedural code from quickinst functionized and fixed.
# there were functions like this in the setup script too, with some subtle differences. see below
@@ -244,8 +245,10 @@ finddisks() {
}
-# find usable blockdevices, both partionable or not (i.e. partitions themselves)
-# $1 extra things to echo for each partition (optional) (backslash escapes will get interpreted)
+# find usable blockdevices: RAID + LVM volumes, partitioned and unpartitioned devices
+# Exclude devices/partitions that are part of a RAID or LVM volume
+# Exclude root block devices (ex. sda) that are partitioned
+# $1 extra things to echo for each device (optional) (backslash escapes will get interpreted)
find_usable_blockdevices() {
shopt -s nullglob
@@ -574,7 +577,7 @@ process_filesystems ()
done < $TMP_FILESYSTEMS
[ $open_items -eq 0 ] && break
done
- [ $open_items -eq 1 ] && show_warning "Filesystem/blockdevice processor problem" "Warning: Could not create all needed filesystems. Either the underlying blockdevices didn't became available in 10 iterations, or process_filesystem failed" && returncode=1
+ [ $open_items -eq 1 ] && show_warning "Filesystem/blockdevice processor problem" "Warning: Could not create all needed filesystems. Either the underlying blockdevices didn't appear in 10 iterations, or process_filesystem failed" && returncode=1
diff --git a/src/core/libs/lib-flowcontrol.sh b/src/core/libs/lib-flowcontrol.sh
index 4f3bbfa..0e336f4 100755
--- a/src/core/libs/lib-flowcontrol.sh
+++ b/src/core/libs/lib-flowcontrol.sh
@@ -170,10 +170,12 @@ depend_procedure ()
start_process ()
{
- execute phase preparation
- execute phase basics
- execute phase system
- execute phase finish
+ ret=0
+ execute phase preparation || ret=$?
+ execute phase basics || ret=$?
+ execute phase system || ret=$?
+ execute phase finish || ret=$?
+ return $ret
}
@@ -212,11 +214,11 @@ start_installer ()
# use this function to stop the installation procedure.
-# $1 exit code (optional)
+# $1 exit code (optional, defaults to 0)
stop_installer ()
{
log "-------------- STOPPING INSTALLATION ----------"
cleanup_runtime
[ "$var_UI_TYPE" = dia ] && clear
- exit $1
+ exit ${1:-0}
}
diff --git a/src/core/libs/lib-misc.sh b/src/core/libs/lib-misc.sh
index 2dee841..f9fd06a 100644
--- a/src/core/libs/lib-misc.sh
+++ b/src/core/libs/lib-misc.sh
@@ -165,6 +165,14 @@ target_configure_time () {
${var_TARGET_DIR}/etc/rc.conf
}
+target_localtime () {
+ if [ -f /etc/localtime ]
+ then
+ cp /etc/localtime ${var_TARGET_DIR}/etc/localtime || return 1
+ fi
+ return 0
+}
+
# apped string after last line matching regex in a file.
# $1 regex
# $2 string (can contain "\n", "\t" etc)
diff --git a/src/core/libs/lib-network.sh b/src/core/libs/lib-network.sh
index 03d5361..3e7914b 100644
--- a/src/core/libs/lib-network.sh
+++ b/src/core/libs/lib-network.sh
@@ -8,52 +8,44 @@ target_configure_network()
{
# networking setup could have happened in a separate process (eg partial-configure-network),
# so check if the settings file was created to be sure
- if [ -f $RUNTIME_DIR/aif-network-settings ]; then
+ if [[ -f "$RUNTIME_DIR/aif-network-settings" ]]; then
debug NETWORK "Configuring network settings on target system according to installer settings"
- source $RUNTIME_DIR/aif-network-settings 2>/dev/null || return 1
+ source "$RUNTIME_DIR/aif-network-settings" 2>/dev/null || return 1
- IFO=${INTERFACE_PREV:-eth0} # old iface: a previously entered one, or the arch default
IFN=${INTERFACE:-eth0} # new iface: a specified one, or the arch default
- # comment out any existing uncommented entries, whether specified by us, or arch defaults.
- for var in eth0 $IFO INTERFACES gateway ROUTES
- do
- sed -i "s/^$var=/#$var=/" ${var_TARGET_DIR}/etc/rc.conf || return 1
- done
- sed -i "s/^nameserver/#nameserver/" ${var_TARGET_DIR}/etc/resolv.conf || return 1
- if [ -f ${var_TARGET_DIR}/etc/profile.d/proxy.sh ]
- then
- sed -i "s/^export/#export/" ${var_TARGET_DIR}/etc/profile.d/proxy.sh || return 1
+ sed -i "s/^nameserver/#nameserver/" "${var_TARGET_DIR}/etc/resolv.conf" || return 1
+ if [[ -f "${var_TARGET_DIR}/etc/profile.d/proxy.sh" ]]; then
+ sed -i "s/^export/#export/" "${var_TARGET_DIR}/etc/profile.d/proxy.sh" || return 1
fi
- if [ "$DHCP" = 0 ] ; then
- local line="$IFN=\"$IFN ${IPADDR:-192.168.0.2} netmask ${SUBNET:-255.255.255.0} broadcast ${BROADCAST:-192.168.0.255}\""
- append_after_last "/$IFO\|eth0/" "$line" ${var_TARGET_DIR}/etc/rc.conf || return 1
+ sed -i "s/^\(interface\)=/\1=$IFN/" "${var_TARGET_DIR}/etc/rc.conf" || return 1
+ if (( ! DHCP )); then
+ sed -i "s/^\(address\)=/\1=$IPADDR/;s/^\(netmask\)=/\1=$SUBNET/" "${var_TARGET_DIR}/etc/rc.conf"
- if [ -n "$GW" ]; then
- append_after_last "/gateway/" "gateway=\"default gw $GW\"" ${var_TARGET_DIR}/etc/rc.conf || return 1
- append_after_last "/ROUTES/" "ROUTES=(gateway)" ${var_TARGET_DIR}/etc/rc.conf || return 1
+ if [[ $BROADCAST ]]; then
+ sed -i "s/^\(broadcast\)=/\1=$BROADCAST/" "${var_TARGET_DIR}/etc/rc.conf" || return 1
fi
- if [ -n "$DNS" ]
- then
- echo "nameserver $DNS" >> ${var_TARGET_DIR}/etc/resolv.conf || return 1
+
+ if [[ $GW ]]; then
+ sed -i "s/^\(gateway\)=/\1=$GW/" "${var_TARGET_DIR}/etc/rc.conf" || return 1
fi
- else
- append_after_last "/$IFO\|eth0/" "$IFN=\"dhcp\"" ${var_TARGET_DIR}/etc/rc.conf || return 1
- fi
- append_after_last "/$IFO\|eth0/" "INTERFACES=($IFN)" ${var_TARGET_DIR}/etc/rc.conf || return 1
+ if [[ $DNS ]]; then
+ echo "nameserver $DNS" >> "${var_TARGET_DIR}/etc/resolv.conf" || return 2
+ fi
+ fi
- if [ -n "$PROXY_HTTP" ]; then
- echo "export http_proxy=$PROXY_HTTP" >> ${var_TARGET_DIR}/etc/profile.d/proxy.sh || return 1
- chmod a+x ${var_TARGET_DIR}/etc/profile.d/proxy.sh || return 1
+ if [[ $PROXY_HTTP ]]; then
+ echo "export http_proxy=$PROXY_HTTP" >> "${var_TARGET_DIR}/etc/profile.d/proxy.sh" || return 1
+ chmod a+x "${var_TARGET_DIR}/etc/profile.d/proxy.sh" || return 1
fi
- if [ -n "$PROXY_FTP" ]; then
- echo "export ftp_proxy=$PROXY_FTP" >> ${var_TARGET_DIR}/etc/profile.d/proxy.sh || return 1
- chmod a+x ${var_TARGET_DIR}/etc/profile.d/proxy.sh || return 1
+ if [[ $PROXY_FTP ]]; then
+ echo "export ftp_proxy=$PROXY_FTP" >> "${var_TARGET_DIR}/etc/profile.d/proxy.sh" || return 1
+ chmod a+x "${var_TARGET_DIR}/etc/profile.d/proxy.sh" || return 1
fi
else
debug NETWORK "Skipping Host Network Configuration - aif-network-settings not found"
diff --git a/src/core/libs/lib-software.sh b/src/core/libs/lib-software.sh
index bb84621..17102bb 100644
--- a/src/core/libs/lib-software.sh
+++ b/src/core/libs/lib-software.sh
@@ -8,7 +8,7 @@ target_run_mkinitcpio()
{
target_special_fs on
- run_controlled mkinitcpio "chroot $var_TARGET_DIR /sbin/mkinitcpio -p kernel26" $TMP_MKINITCPIO_LOG "Rebuilding initcpio images ..."
+ run_controlled mkinitcpio "chroot $var_TARGET_DIR /sbin/mkinitcpio -p linux" $TMP_MKINITCPIO_LOG "Rebuilding initcpio images ..."
target_special_fs off
@@ -18,8 +18,7 @@ target_run_mkinitcpio()
}
-# installpkg(). taken from setup. modified bigtime
-# performs package installation to the target system
+# perform package installation to the target system
installpkg() {
ALL_PACKAGES=
[ -n "$var_TARGET_GROUPS" ] && ALL_PACKAGES=`list_packages group "$var_TARGET_GROUPS" | awk '{print $2}'`
diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh
index 9399e59..4caf4bc 100644
--- a/src/core/libs/lib-ui-interactive.sh
+++ b/src/core/libs/lib-ui-interactive.sh
@@ -2,7 +2,9 @@
# A library which allows you to do backend stuff by using user interfaces
# Global Variables
-grubmenu="/boot/grub/menu.lst" # be sure to override this if you have it somewhere else
+# Be sure to override these if you have the configuration file elsewhere
+grubmenu="/boot/grub/menu.lst"
+syslinuxmenu="/boot/syslinux/syslinux.cfg"
# check if a worker has completed successfully. if not -> tell user he must do it + return 1
# if ok -> don't warn anything and return 0
@@ -42,7 +44,7 @@ postconfigure_target () {
local failed=()
target_run_mkinitcpio || failed+=('mkinitcpio creation')
target_locale-gen || failed+=('locale generation')
- cp /etc/localtime ${var_TARGET_DIR}/etc/localtime || failed+=('localtime copying')
+ target_localtime || failed+=('localtime copying')
[ ${#failed[@]} -gt 0 ] && warn_failed 'Postconfigure' "${failed[@]}" && return 1
return 0
}
@@ -72,8 +74,6 @@ interactive_configure_system()
"/etc/modprobe.d/modprobe.conf" "Kernel Modules"
"/etc/resolv.conf" "DNS Servers"
"/etc/hosts" "Network Hosts"
- "/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"
@@ -120,14 +120,23 @@ interactive_configure_system()
interactive_timezone () {
ask_timezone || return 1
TIMEZONE=$ANSWER_TIMEZONE
- inform "Setting Timezone to $TIMEZONE"
- if [ -n "$TIMEZONE" -a -e "/usr/share/zoneinfo/$TIMEZONE" ]
+ return 0
+}
+
+# this should be executed, whether the user changed $TIMEZONE or not
+copy_timezone_file () {
+ if [ -z "$TIMEZONE" ]
then
- # This changes probably also the systemtime (UTC->$TIMEZONE)!
- # localtime users will have a false time after that!
- /bin/rm -f /etc/localtime || return 1
- /bin/cp "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime || return 1
+ debug UI-INTERACTIVE "\$TIMEZONE is empty, not creating/updating /etc/localtime"
+ return 0
fi
+ debug UI-INTERACTIVE "Setting Timezone to $TIMEZONE"
+ local file="/usr/share/zoneinfo/$TIMEZONE"
+ [ -e "$file" ] || die_error "No such timezone file: $file, did you choose a non-existing timezone?"
+ # This changes probably also the systemtime (UTC->$TIMEZONE)!
+ # localtime users will have a false time after that!
+ /bin/rm -f /etc/localtime || return 1
+ /bin/cp "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime || return 1
return 0
}
@@ -744,7 +753,8 @@ them for your convenience"
done
ask_option no "Choose bootloader" "Which bootloader would you like to use?" optional \
- "grub" "GRUB bootloader"
+ "grub" "GRUB bootloader" \
+ "syslinux" "Syslinux bootloader (${syslinux_supported_fs[*]})"
bootloader=$ANSWER_OPTION
@@ -761,7 +771,7 @@ them for your convenience"
# build the list of options, sorted primarily by group, then by packagename (this is already). marking where appropriate
local pkglist=()
- needed_pkgs=("${needed_pkgs_fs[@]}")
+ needed_pkgs+=("${needed_pkgs_fs[@]}")
while read pkgname pkgver pkggroup pkgdesc; do
mark=OFF
if check_is_in "$pkggroup" "${grouplist[@]}" || check_is_in $pkgname "${needed_pkgs[@]}"; then
@@ -875,6 +885,8 @@ interactive_install_bootloader () {
if [[ $bootloader = grub ]]; then
GRUB_OK=0
interactive_grub || return 1
+ elif [[ $bootloader = syslinux ]]; then
+ interactive_syslinux || return 1
else
show_warning 'No Bootloader' 'You did not select a bootloader. No bootloader will be installed.'
fi
@@ -913,7 +925,7 @@ interactive_grub() {
# Create and edit the grub menu.lst
interactive_bootloader_menu "grub" $grubmenu
- DEVS="$(find_usable_blockdevices '_ ')"
+ DEVS="$(finddisks '_ ')"
if [ "$DEVS" = " " ]; then
notify "No hard drives were found"
return 1
@@ -1081,14 +1093,14 @@ generate_grub_menulst() {
# (0) Parabola GNU/Linux-Libre
title Parabola GNU/Linux-Libre
root $grubdev
-kernel $subdir/vmlinuz26 $kernel_parameters
-initrd $subdir/kernel26.img
+kernel $subdir/vmlinuz-linux $kernel_parameters
+initrd $subdir/initramfs-linux.img
# (1) Parabola GNU/Linux-Libre
title Parabola GNU/Linux-Libre Fallback
root $grubdev
-kernel $subdir/vmlinuz26 $kernel_parameters
-initrd $subdir/kernel26-fallback.img
+kernel $subdir/vmlinuz-linux $kernel_parameters
+initrd $subdir/initramfs-linux-fallback.img
EOF
}
@@ -1134,11 +1146,120 @@ EOF
fi
}
+interactive_syslinux() {
+ debug FS "starting interactive_syslinux"
+
+ # Find and Store the device that has the root filesystem
+ get_device_with_mount '/' || return 1
+ PART_ROOT="$ANSWER_DEVICE"
+
+ # Gets boot device
+ get_device_with_mount '/boot'
+ bootdev="$ANSWER_DEVICE"
+
+ # Check to see if /boot or / (root) has a valid FS type and set bootpart
+ # bootpart == device with /boot dir
+ if [[ $bootdev ]]; then
+ filesystem="$(awk '/ \/boot /{print $4}' $TMP_FILESYSTEMS)"
+ debug FS "$bootdev - FS type: $filesystem"
+
+ local bootpart="$bootdev"
+ else
+ filesystem="$(awk '/ \/ /{print $4}' $TMP_FILESYSTEMS)"
+ debug FS "$PART_ROOT - FS type: $filesystem"
+
+ local bootpart="$PART_ROOT"
+ fi
+
+ if ! check_is_in "$filesystem" "${syslinux_supported_fs[@]}"; then
+ show_warning "Invalid FS" "Error: Syslinux does not support $filesystem.\n\nThe following filesystems are supported:\n ${syslinux_supported_fs[@]}"
+ return 1
+ fi
+
+ # remove default entries by truncating file at our little tag (#-*)
+ sed -i -e '/#-\*/q' "$syslinuxmenu"
+
+ # Generate menu and prompt user to edit it
+ interactive_bootloader_menu "syslinux" "$syslinuxmenu"
+
+ if device_is_raid "$bootpart"; then
+ debug FS "Software RAID detected"
+ local onraid=true
+ fi
+
+ debug FS "Installing Syslinux ($var_TARGET_DIR/usr/sbin/syslinux-install_update -i -c /mnt)"
+ inform "Installing Syslinux..."
+ if ! "$var_TARGET_DIR/usr/sbin/syslinux-install_update" -i -c /mnt >$LOG 2>&1; then
+ debug FS "FAILED: syslinux-install_update -i -c /mnt failed"
+ show_warning "FAILED" "syslinux-install_update -i -c /mnt failed"
+ return 1
+ fi
+
+ if ask_yesno "Set boot flag(s) and install the Syslinux MBR?" yes; then
+ inform "Setting Boot Flag(s)...\nThis could take a while. Please be patient.\n\n" syslinuxprog
+ if "$var_TARGET_DIR/usr/sbin/syslinux-install_update" -a -c /mnt >$LOG 2>&1; then
+ debug FS "Successfully set boot flag(s)"
+ else
+ debug FS "Failde to set boot flag(s). syslinux-install_update -a failed with Error Code - $?"
+ show_warning "FAILED" "Failed to set boot flag(s). MBR not installed" && return 1
+ fi
+
+ inform "Installing Syslinux MBR..." syslinuxprog
+ if "$var_TARGET_DIR/usr/sbin/syslinux-install_update" -m -c /mnt >$LOG 2>&1; then
+ debug FS "Successfully installed MBR(s)"
+ else
+ debug FS "Failed to install MBR. syslinux-install_update -m failed with Error Code - $?"
+ show_warning "FAILED" "Failed to install the MBR!" && return 1
+ fi
+ fi
+ notify "Syslinux Installation Successful"
+}
+
+generate_syslinux_menu () {
+ get_kernel_parameters || return
+
+ cat >>$syslinuxmenu <<EOF
+
+# (0) Arch Linux
+LABEL arch
+ MENU LABEL Arch Linux
+ LINUX ../vmlinuz26
+ APPEND $kernel_parameters
+ INITRD ../kernel26.img
+
+# (1) Arch Linux Fallback
+LABEL archfallback
+ MENU LABEL Arch Linux Fallback
+ LINUX ../vmlinuz26
+ APPEND $kernel_parameters
+ INITRD ../kernel26-fallback.img
+
+# (2) Windows
+#LABEL windows
+#COM32 chain.c32
+#APPEND hd0 0
+
+LABEL hdt
+ MENU LABEL HDT (Hardware Detection Tool)
+ COM32 hdt.c32
+
+LABEL reboot
+ MENU LABEL Reboot
+ COM32 reboot.c32
+
+LABEL off
+ MENU LABEL Power Off
+ COMBOOT poweroff.com
+EOF
+}
+
# $1 - Bootloader Name
# $2 - Bootloader Configuration Files
interactive_bootloader_menu() {
if [[ $1 = grub ]]; then
- generate_grub_menulst
+ generate_grub_menulst || return
+ elif [[ $1 = syslinux ]]; then
+ generate_syslinux_menu || return
fi
grep -q '^/dev/mapper' $TMP_FSTAB && local helptext=" /dev/mapper/ users: Pay attention to the kernel line!"
diff --git a/src/core/procedures/automatic b/src/core/procedures/automatic
index 407a35b..ce773e1 100644
--- a/src/core/procedures/automatic
+++ b/src/core/procedures/automatic
@@ -102,8 +102,8 @@ worker_install_packages ()
worker_set_clock ()
{
- #TODO implement this
- true
+ # uses $TIMEZONE, clock itself remains untouched.
+ copy_timezone_file
}
diff --git a/src/core/procedures/base b/src/core/procedures/base
index 6f8ed0c..1f9e6a8 100644
--- a/src/core/procedures/base
+++ b/src/core/procedures/base
@@ -11,6 +11,7 @@ var_UI_TYPE="cli" # set to cli or dia for dialog
var_ARCH=`uname -m` #i686 or x86_64. NOTE: this assumes you want to install the same arch as the installation environment you're using. maybe we could decouple those someday..
[ -z "$var_ARCH" ] && die_error "Could not determine your architecture"
grubmenu="$var_TARGET_DIR$grubmenu"
+syslinuxmenu="$var_TARGET_DIR$syslinuxmenu"
###### Phases ( can be overridden by more specific procedures) ######
phase_preparation=(\
@@ -104,13 +105,14 @@ worker_runtime_packages ()
worker_set_clock ()
{
local default=no
+ local timezone_file_copied=0
while true; do
ask_option $default "Date/time configuration" '' required \
"1" "Select region and timezone" \
"2" "Set time and date" \
"3" "Return to Main Menu" || return 1
case $ANSWER_OPTION in
- "1") execute worker interactive_timezone && default=2 || return 1 ;;
+ "1") execute worker interactive_timezone && copy_timezone_file && timezone_file_copied=1 && default=2 || return 1 ;;
"2") if check_depend worker interactive_timezone
then
execute worker interactive_time && default=3 || return 1
@@ -118,6 +120,7 @@ worker_set_clock ()
"3") break ;;
esac
done
+ [ $timezone_file_copied -eq 1 ] || copy_timezone_file || return 1
return 0
}