summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/libs/lib-pacman.sh79
-rw-r--r--src/core/libs/lib-software.sh5
-rw-r--r--src/core/libs/lib-ui-interactive.sh76
-rw-r--r--src/core/libs/lib-ui.sh12
-rw-r--r--src/core/procedures/base~161
-rw-r--r--src/core/procedures/interactive100
6 files changed, 313 insertions, 120 deletions
diff --git a/src/core/libs/lib-pacman.sh b/src/core/libs/lib-pacman.sh
index 4f64794..36750b0 100644
--- a/src/core/libs/lib-pacman.sh
+++ b/src/core/libs/lib-pacman.sh
@@ -96,82 +96,3 @@ pacman_what_is_this_for ()
! [ -d /var/lib/pacman ] && mkdir -p /var/lib/pacman
}
-
-
-# select_mirror(). taken from setup. TODO: get the UI code out of here
-# Prompt user for preferred mirror and set $var_SYNC_URL
-#
-# args: none
-# returns: nothing
-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))://[^/]*' "${MIRRORLIST}" | sed 's|$| _|g')
- _dia_DIALOG --menu "Select an FTP/HTTP mirror" 14 55 7 \
- $MIRRORS \
- "Custom" "_" 2>$ANSWER || return 1
- local _server=$(cat $ANSWER)
- if [ "${_server}" = "Custom" ]; then
- _dia_DIALOG --inputbox "Enter the full URL to core repo." 8 65 \
- "ftp://ftp.archlinux.org/core/os/i686" 2>$ANSWER || return 1
- var_SYNC_URL=$(cat $ANSWER)
- else
- # Form the full URL for our mirror by grepping for the server name in
- # our mirrorlist and pulling the full URL out. Substitute 'core' in
- # for the repository name, and ensure that if it was listed twice we
- # only return one line for the mirror.
- var_SYNC_URL=$(egrep -o "${_server}.*" "${MIRRORLIST}" | sed 's/\$repo/core/g' | head -n1)
- fi
- echo "Using mirror: $var_SYNC_URL" >$LOG
-}
-
-# select_source(). taken from setup. TODO: decouple ui
-# displays installation source selection menu
-# and sets up relevant config files
-#
-# params: none
-# returns: nothing
-select_source()
-{
- DIALOG --menu "Please select an installation source" 10 35 3 \
- "1" "CD-ROM or OTHER SOURCE" \
- "2" "FTP/HTTP" 2>$ANSWER
-
- case $(cat $ANSWER) in
- "1")
- MODE="cd"
- ;;
- "2")
- MODE="ftp"
- ;;
- esac
-
- if [ "$MODE" = "cd" ]; then
- TITLE="Arch Linux CDROM or OTHER SOURCE Installation"
- DIALOG --msgbox "Packages included on this disk have been mounted to /src/core/pkg. If you wish to use your own packages from another source, manually mount them there." 0 0
- if [ ! -d /src/core/pkg ]; then
- DIALOG --msgbox "Package directory /src/core/pkg is missing!" 0 0
- return 1
- fi
- echo "Using CDROM for package installation" >$LOG
- else
- TITLE="Arch Linux FTP/HTTP Installation"
- DIALOG --msgbox "If you wish to load your ethernet modules manually, please do so now in another terminal." 12 65
- while true; do
- DIALOG --menu "FTP Installation" 10 35 3 \
- "0" "Setup Network" \
- "1" "Choose Mirror" \
- "2" "Return to Main Menu" 2>$ANSWER
-
- case "$(cat $ANSWER)" in
- "0")
- donetwork ;;
- "1")
- select_mirror ;;
- *)
- break ;;
- esac
- done
- fi
- S_SRC=1
-}
diff --git a/src/core/libs/lib-software.sh b/src/core/libs/lib-software.sh
index 96ff5ab..52e1d63 100644
--- a/src/core/libs/lib-software.sh
+++ b/src/core/libs/lib-software.sh
@@ -21,7 +21,7 @@ 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." 0 0
+ notify "Package installation will begin now. You can watch the output in the progress window. Please be patient."
target_specialfs on
run_background pacman-installpkg "$PACMAN_TARGET -S $PACKAGES" /tmp/pacman.log
follow_progress " Installing... Please Wait " /tmp/pacman.log
@@ -43,8 +43,11 @@ installpkg() {
target_specialfs off
sync
+
+ return 0
}
+
# auto_locale(). taken from setup
# enable glibc locales from rc.conf and build initial locale DB
target_configure_inital_locale()
diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh
index c8216dd..559afad 100644
--- a/src/core/libs/lib-ui-interactive.sh
+++ b/src/core/libs/lib-ui-interactive.sh
@@ -1,4 +1,5 @@
#!/bin/sh
+#TODO: get backend code out of here!!
interactive_partition() {
_umountall
@@ -19,9 +20,10 @@ interactive_partition() {
# Leave our loop if the user is done partitioning
[ "$DISC" = "DONE" ] && break
# Partition disc
- DIALOG --msgbox "Now you'll be put into the cfdisk program where you can partition your hard drive. You should make a swap partition and as many data partitions as you will need. NOTE: cfdisk may ttell you to reboot after creating partitions. If you need to reboot, just re-enter this install program, skip this step and go on to step 2." 18 70
+ notify "Now you'll be put into the cfdisk program where you can partition your hard drive. You should make a swap partition and as many data partitions as you will need. NOTE: cfdisk may ttell you to reboot after creating partitions. If you need to reboot, just re-enter this install program, skip this step and go on to step 2."
cfdisk $DISC
done
+ return 0
}
@@ -286,7 +288,8 @@ EOF
return 0
}
-mountpoints() {
+
+interactive_mountpoints() {
while [ "$PARTFINISH" != "DONE" ]; do
: >/tmp/.fstab
: >/tmp/.parts
@@ -376,6 +379,7 @@ mountpoints() {
done
notify "Partitions were successfully mounted."
+ return 0
}
# select_packages()
@@ -430,12 +434,11 @@ interactive_select_packages() {
}
-# donetwork()
# Hand-hold through setting up networking
#
# args: none
# returns: 1 on failure
-interactive_donetwork() {
+interactive_runtime_network() {
INTERFACE=""
S_DHCP=""
local ifaces
@@ -509,7 +512,7 @@ interactive_donetwork() {
}
-interactive_dogrub() {
+interactive_install_grub() {
get_grub_map
local grubmenu="$TARGET_DIR/boot/grub/menu.lst"
if [ ! -f $grubmenu ]; then
@@ -630,3 +633,66 @@ EOF
}
+# select_source(). taken from setup. TODO: decouple ui
+# displays installation source selection menu
+# and sets up relevant config files
+#
+# params: none
+# returns: nothing
+interactive_select_source()
+{
+ DIALOG --menu "Please select an installation source" 10 35 3 \
+ "1" "CD-ROM or OTHER SOURCE" \
+ "2" "FTP/HTTP" 2>$ANSWER
+
+ case $(cat $ANSWER) in
+ "1")
+ var_PKG_SOURCE_TYPE="cd"
+ ;;
+ "2")
+ var_PKG_SOURCE_TYPE="ftp"
+ ;;
+ esac
+
+ if [ "$var_PKG_SOURCE_TYPE" = "cd" ]; then
+ TITLE="Arch Linux CDROM or OTHER SOURCE Installation"
+ notify "Packages included on this disk have been mounted to /src/core/pkg. If you wish to use your own packages from another source, manually mount them there."
+ if [ ! -d /src/core/pkg ]; then
+ notify "Package directory /src/core/pkg is missing!"
+ return 1
+ fi
+ echo "Using CDROM for package installation" >$LOG
+ else
+ TITLE="Arch Linux FTP/HTTP Installation"
+ notify "If you wish to load your ethernet modules manually, please do so now in an another terminal."
+ fi
+ return 0
+}
+
+
+# select_mirror(). taken from setup.
+# Prompt user for preferred mirror and set $var_SYNC_URL
+#
+# args: none
+# returns: nothing
+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))://[^/]*' "${MIRRORLIST}" | sed 's|$| _|g')
+ _dia_DIALOG --menu "Select an FTP/HTTP mirror" 14 55 7 \
+ $MIRRORS \
+ "Custom" "_" 2>$ANSWER || return 1
+ local _server=$(cat $ANSWER)
+ if [ "${_server}" = "Custom" ]; then
+ _dia_DIALOG --inputbox "Enter the full URL to core repo." 8 65 \
+ "ftp://ftp.archlinux.org/core/os/i686" 2>$ANSWER || return 1
+ var_SYNC_URL=$(cat $ANSWER)
+ else
+ # Form the full URL for our mirror by grepping for the server name in
+ # our mirrorlist and pulling the full URL out. Substitute 'core' in
+ # for the repository name, and ensure that if it was listed twice we
+ # only return one line for the mirror.
+ var_SYNC_URL=$(egrep -o "${_server}.*" "${MIRRORLIST}" | sed 's/\$repo/core/g' | head -n1)
+ fi
+ echo "Using mirror: $var_SYNC_URL" >$LOG
+}
diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh
index 6a17877..f012f05 100644
--- a/src/core/libs/lib-ui.sh
+++ b/src/core/libs/lib-ui.sh
@@ -137,18 +137,6 @@ _dia_getavaildisks()
}
-# taken from setup code. edited to echo the choice, not perform it
-# TODO: also an ugly function
-_dia_ask_bootloader()
-{
- _dia_DIALOG --colors --menu "Which bootloader would you like to use? Grub is the Arch default.\n\n" \
- 10 65 2 \
- "GRUB" "Use the GRUB bootloader (default)" \
- "None" "\Zb\Z1Warning\Z0\ZB: you must install your own bootloader!" 2>$ANSWER
- cat $ANSWER
-}
-
-
_dia_follow_progress ()
{
title=$1
diff --git a/src/core/procedures/base~ b/src/core/procedures/base~
new file mode 100644
index 0000000..74d6c00
--- /dev/null
+++ b/src/core/procedures/base~
@@ -0,0 +1,161 @@
+#!/bin/bash
+
+var_DEFAULTFS="/boot:32:ext2:+ swap:256:swap /:7500:ext3 /home:*:ext3"
+var_TARGET_DIR="/mnt"
+var_RUNTIME_PACKAGES=
+var_PKG_FILE=/home/arch/fifa/runtime/package-list
+var_UI_TYPE="cli" # set to cli or dia for dialog
+
+###### Phases ( can be overridden by more specific procedures) ######
+
+phase_preparation ()
+{
+ execute worker select_source
+ execute worker runtime_network
+ execute worker runtime_packages
+}
+
+
+phase_basics ()
+{
+ execute worker set_clock
+ execute worker prepare_disks
+}
+
+
+phase_system ()
+{
+ execute worker package_list
+ execute worker install_packages
+ execute worker auto_fstab #TODO: exact names of these 3
+ execute worker auto_network
+ execute worker auto_locale
+ execute worker configure_system
+ execute worker mkinitcpio
+ execute worker locales
+ execute worker install_bootloader
+}
+
+
+phase_finish ()
+{
+ true
+}
+
+
+
+###### Workers ( can be overridden by more specific procedures) ######
+worker_select_source ()
+{
+ var_PKG_SOURCE_TYPE='cd'
+ var_FILE_URL="file:///src/core/pkg"
+ var_SYNC_URL=
+ var_MIRRORLIST="/etc/pacman.d/mirrorlist"
+ # if you override to use ftp (or ask user and he chooses ftp) don't forget to configure the network and to select_mirrors
+}
+
+
+worker_runtime_network ()
+{
+ #network is assumed to be functional for now because we do it first with /arch/setup. once that falls away, we'll need to implement it here
+ true
+}
+
+
+worker_runtime_packages ()
+{
+ for pkg in $var_RUNTIME_PACKAGES
+ do
+ $PACMAN -Sy --noconfirm --needed $pkg
+ done
+}
+
+
+worker_set_clock ()
+{
+ HARDWARECLOCK=utc
+ TIMEZONE=`tzselect`
+ HWCLOCK_PARAMS=" --utc"
+ if [ "$TIMEZONE" != "" -a -e "/usr/share/zoneinfo/$TIMEZONE" ]
+ then
+ cp "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime
+ fi
+ /sbin/hwclock --hctosys $HWCLOCK_PARAMS --noadjfile
+ #TODO: user must set date/time and store it
+}
+
+
+worker_prepare_disks ()
+{
+ partition # use lib-archboot function by default
+ # in official installer: autoprepare or diy first partitions, then mountpoints
+}
+
+
+# Put the list of packages to be installed in $var_PKG_FILE
+worker_package_list ()
+{
+ #TODO: sensible list of packages
+ true
+}
+
+
+worker_install_packages ()
+{
+ target_special_fs on
+ target_prepare_pacman
+ [ ! -f $var_PKG_FILE ] && die_error "No package file available!"
+ PKGLIST=`cat $var_PKG_FILE`
+ #TODO: what if $var_PKG_FILE is empty? we should die_error because that's probably not what the user wants.. or can it? will pacman complain?
+ $PACMAN_TARGET -Sy $PKGLIST || die_error "Package installation FAILED."
+ target_special_fs off
+}
+
+
+worker_auto_fstab ()
+{
+ if [ "$S_MKFS" = "1" -o "$S_MKFSAUTO" = "1" ]; then
+ target_configure_fstab
+ fi
+}
+
+
+worker_auto_network ()
+{
+ [ "$S_DHCP" = 1 ] && target_configure_network dhcp "$PROXY_HTTP" "$PROXY_FTP"
+ [ "$S_DHCP" != 1 ] && target_configure_network fixed "$PROXY_HTTP" "$PROXY_FTP"
+}
+
+
+worker_auto_locale ()
+{
+ target_configure_inital_locale
+}
+
+
+worker_configure_system ()
+{
+ #TODO: what to do here?
+ true
+}
+
+
+worker_mkinitcpio ()
+{
+ #TODO:check that this is the right command when projects.archlinux.org is back up
+ run_mkinitcpio
+}
+
+
+worker_locales ()
+{
+ #TODO:what to do here? didn't we already do them?
+ true
+}
+
+
+worker_install_bootlader ()
+{
+ #TODO: ask which disk, install grub on it
+ true
+}
diff --git a/src/core/procedures/interactive b/src/core/procedures/interactive
index 1f576da..bd82258 100644
--- a/src/core/procedures/interactive
+++ b/src/core/procedures/interactive
@@ -1,4 +1,9 @@
#!/bin/sh
+depend_procedure core base # esp for auto_{network,locale,fstab} workers
+
+
+# This is a port of the original /arch/setup script. It doesn't use fifa phases but uses it's own menu-based flow (phase) control
+
TARGET_DIR="/mnt"
EDITOR=
@@ -44,6 +49,9 @@ start_process ()
You can view all output from commands by viewing your VC7 console (ALT-F7). \
ALT-F1 will bring you back here."
+ # menu item tracker- autoselect the next item
+ NEXTITEM=""
+
while true
do
mainmenu
@@ -52,14 +60,6 @@ start_process ()
}
-phase_preparation ()
-{
- #TODO: when does grub device map happen in official installer?
- execute worker runtime_packages
- notify "Generating GRUB device map...\nThis could take a while.\n\n Please be patient."
- get_grub_map
-}
-
mainmenu()
{
if [ -n "$NEXTITEM" ]; then
@@ -80,19 +80,39 @@ mainmenu()
NEXTITEM="$(cat $ANSWER)"
case $(cat $ANSWER) in
"0")
- select_source ;;
+ execute worker select_source ; ret=$?
+ if [ $ret -eq 0 -a "$var_PKG_SOURCE_TYPE" = "ftp" ]; then
+ while true; do
+ DIALOG --menu "FTP Installation" 10 35 3 \
+ "0" "Setup Network (Make sure the network is ok before continuing" \
+ "1" "Choose Mirror" \
+ "2" "Return to Main Menu" 2>$ANSWER
+ case "$(cat $ANSWER)" in
+ "0")
+ execute worker runtime_network && S_NET=1;;
+ "1")
+ execute worker select_mirror ;;
+ *)
+ break ;;
+ esac
+ done
+ fi
+ [ $ret -eq 0 ] && S_SRC=1 && execute worker runtime_packages ;;
"1")
- set_clock ;;
+ execute worker set_clock && S_CLOCK=1 ;;
"2")
- prepare_harddrive ;;
+ execute worker prepare_disks ;; # stage set vars set in the worker
"3")
- select_packages ;;
+ execute worker package_list && S_SELECT=1 ;;
"4")
- installpkg ;;
+ execute worker install_packages && S_INSTALL=1 && { execute worker auto_fstab; execute worker auto_network; execute worker auto_locale; } ;;
"5")
- configure_system ;;
+ execute worker configure_system && S_CONFIG=1 && { execute worker mkinitcpio; execute worker locales; } ;;
"6")
- install_bootloader ;;
+ _dia_DIALOG --colors --menu "Which bootloader would you like to use? Grub is the Arch default.\n\n" 10 65 2 \
+ "GRUB" "Use the GRUB bootloader (default)" \
+ "None" "\Zb\Z1Warning\Z0\ZB: you must install your own bootloader!" 2>$ANSWER
+ execute worker install_bootloader "`cat $ANSWER`";;
"7")
echo ""
echo "If the install finished successfully, you can now type 'reboot'"
@@ -130,11 +150,11 @@ configure_system()
run_mkinitcpio
target_locale-gen
- S_CONFIG=1
+
}
-prepare_harddrive()
+worker_prepare_disks()
{
S_MKFSAUTO=0
S_MKFS=0
@@ -182,7 +202,7 @@ prepare_harddrive()
# params: none
set_clock()
{
- interactive_set_clock && S_CLOCK=1
+ interactive_set_clock
}
#[ $S_SELECT -eq 0 ] && install_pkg && S_INSTALL=1 # user must first select, then install
@@ -193,11 +213,23 @@ set_clock()
#auto_network
#auto_locale
+worker_select_source ()
+{
+ #TODO: integrate setup-like source selecter here
+ var_PKG_SOURCE_TYPE=
+ var_FILE_URL="file:///src/core/pkg"
+ var_SYNC_URL=
+ var_MIRRORLIST="/etc/pacman.d/mirrorlist"
+ # if you override to use ftp (or ask user and he chooses ftp) don't forget to configure the network and to select_mirrors
+ interactive_select_source && S_SRC=1 && return 0
+ return 1
+}
+
# select_packages()
# prompts the user to select packages to install
-select_packages() {
+worker_package_list() {
# step dependencies
if [ $S_SRC -eq 0 ]; then
DIALOG --msgbox "You must select an installation source!" 0 0
@@ -210,14 +242,24 @@ select_packages() {
DIALOG --yesno "WARNING: Running this stage again will result in the loss of previous package selections.\n\nDo you wish to continue?" 10 50 || return 1
fi
- interactive_select_packages && S_SELECT=1
+ interactive_select_packages
+}
+
+
+worker_install_packages ()
+{
+ if [ $S_SELECT -eq 0 ]; then
+ DIALOG --msgbox "You must select packages first." 0 0
+ return 1
+ fi
+ installpkg && return 0
+ return 1
}
-# donetwork()
# Hand-hold through setting up networking
-donetwork() {
- interactive_donetwork && S_NET=1
+worker_runtime_network() {
+ interactive_runtime_network
}
@@ -226,6 +268,18 @@ dogrub() {
}
+worker_select_mirror ()
+{
+ interactive_select_mirror
+}
+
+# $1 which one
+worker_install_bootloader ()
+{
+ [ "$1" = grub ] && interactive_install_grub && S_BOOT=grub
+ [ "$1" != grub ] && S_BOOT="$1"
+}
+
# exit if network wasn't configured in installer
# if [ $S_NET -eq 0 ]; then
# return 1