summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorDieter Plaetinck <dieter@plaetinck.be>2009-02-22 17:29:59 +0100
committerDieter Plaetinck <dieter@plaetinck.be>2009-02-22 17:29:59 +0100
commit71f5510aaaa20ae5ae9c773dca12028bd96aafdf (patch)
treec3dee60f77a5c2954bf0a9a4e73befd0b916460e /src/core
parentf9126402b343aea8f2766bc16c10577b833b6703 (diff)
parentf4bd7c36b44da0c9a5985868aa8b0183cd4414c8 (diff)
pull in a shitload of fixes and some features from the experimental branch
Diffstat (limited to 'src/core')
-rw-r--r--src/core/libs/lib-blockdevices-filesystems.sh13
-rw-r--r--src/core/libs/lib-misc.sh13
-rw-r--r--src/core/libs/lib-network.sh16
-rw-r--r--src/core/libs/lib-pacman.sh8
-rw-r--r--src/core/libs/lib-software.sh4
-rw-r--r--src/core/libs/lib-ui-interactive.sh38
-rw-r--r--src/core/libs/lib-ui.sh2
-rw-r--r--src/core/procedures/automatic135
-rw-r--r--src/core/procedures/base26
-rw-r--r--src/core/procedures/interactive20
-rw-r--r--src/core/procedures/partial-configure-network7
-rw-r--r--src/core/procedures/partial-disks32
-rw-r--r--src/core/procedures/quickinst106
13 files changed, 359 insertions, 61 deletions
diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh
index 5fa0815..3b43541 100644
--- a/src/core/libs/lib-blockdevices-filesystems.sh
+++ b/src/core/libs/lib-blockdevices-filesystems.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
# FORMAT DEFINITIONS:
@@ -649,7 +649,7 @@ process_filesystem ()
reiserfs) yes | mkreiserfs $part $opts >$LOG 2>&1; ret=$? ;;
ext2) mke2fs "$part" $opts >$LOG 2>&1; ret=$? ;;
ext3) mke2fs -j $part $opts >$LOG 2>&1; ret=$? ;;
- ext4) mkfs.ext4 $part $opts >$LOG 2>&1; ret=$? ;;
+ ext4) mkfs.ext4 $part $opts >$LOG 2>&1; ret=$? ;; #TODO: installer.git uses mke2fs -t ext4 -O dir_index,extent,uninit_bg , which is best?
vfat) mkfs.vfat $part $opts >$LOG 2>&1; ret=$? ;;
swap) mkswap $part $opts >$LOG 2>&1; ret=$? ;;
dm_crypt) [ -z "$fs_params" ] && fs_params='-c aes-xts-plain -y -s 512';
@@ -739,6 +739,8 @@ get_filesystem_program ()
# $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
+# 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)"
@@ -749,8 +751,9 @@ get_blockdevice_size ()
BLOCKDEVICE_SIZE=$(hdparm -I $1 | grep -F '1000*1000' | sed "s/^.*:[ \t]*\([0-9]*\) MBytes.*$/\1/")
elif [ "$standard" = IEC ]
then
- blocks=`fdisk -s $1` || show_warning "Fdisk problem" "Something failed when trying to do fdisk -s $1"
- #NOTE: 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
- BLOCKDEVICE_SIZE=$(($blocks/1024))
+ #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))
fi
}
diff --git a/src/core/libs/lib-misc.sh b/src/core/libs/lib-misc.sh
index 29e4c2e..01c291f 100644
--- a/src/core/libs/lib-misc.sh
+++ b/src/core/libs/lib-misc.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
# run a process in the background, and log it's stdout and stderr to a specific logfile
@@ -14,7 +14,7 @@ run_background ()
debug "run_background called. identifier: $1, command: $2, logfile: $3"
( \
- touch $RUNTIME_DIR/$1-running
+ touch $RUNTIME_DIR/.$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/.$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/.$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
@@ -62,8 +62,9 @@ check_is_in ()
}
-# cleans up file in the runtime directory who can be deleted
+# cleans up file in the runtime directory who can be deleted, make dir first if needed
cleanup_runtime ()
{
+ mkdir -p $RUNTIME_DIR || die_error "Cannot create $RUNTIME_DIR"
rm -rf $RUNTIME_DIR/.dia* &>/dev/null
-} \ No newline at end of file
+}
diff --git a/src/core/libs/lib-network.sh b/src/core/libs/lib-network.sh
index ab91069..9ed96b2 100644
--- a/src/core/libs/lib-network.sh
+++ b/src/core/libs/lib-network.sh
@@ -13,18 +13,18 @@ target_configure_network()
PROXY_HTTP="$2"
PROXY_FTP="$3"
if [ "$1" = fixed ]; then
- sed -i "s#eth0=\"eth0#$INTERFACE=\"$INTERFACE#g" ${var_TARGET_DIR}/etc/rc.conf
- sed -i "s# 192.168.0.2 # $IPADDR #g" ${var_TARGET_DIR}/etc/rc.conf
- sed -i "s# 255.255.255.0 # $SUBNET #g" ${var_TARGET_DIR}/etc/rc.conf
- sed -i "s# 192.168.0.255\"# $BROADCAST\"#g" ${var_TARGET_DIR}/etc/rc.conf
- sed -i "s#eth0)#$INTERFACE)#g" ${var_TARGET_DIR}/etc/rc.conf
+ sed -i "s#eth0=\"eth0#$INTERFACE=\"$INTERFACE#g" ${var_TARGET_DIR}/etc/rc.conf
+ 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
+ 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
fi
echo "nameserver $DNS" >> ${var_TARGET_DIR}/etc/resolv.conf
else
- sed -i "s#eth0=\"eth0.*#$INTERFACE=\"dhcp\"#g" ${var_TARGET_DIR}/etc/rc.conf
+ sed -i "s#eth0=\"eth0.*#$INTERFACE=\"dhcp\"#g" ${var_TARGET_DIR}/etc/rc.conf
fi
if [ "$PROXY_HTTP" != "" ]; then
diff --git a/src/core/libs/lib-pacman.sh b/src/core/libs/lib-pacman.sh
index f318aa8..4497074 100644
--- a/src/core/libs/lib-pacman.sh
+++ b/src/core/libs/lib-pacman.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
# taken and slightly modified from the quickinst script.
# don't know why one should need a static pacman because we already have a working one on the livecd.
@@ -78,7 +78,7 @@ do
then
add_pacman_repo target ${repo} "Include = $var_MIRRORLIST"
else
- add_pacman_repo target ${repo} "Server = ${serverurl}"
+ 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
@@ -86,7 +86,7 @@ done
[ ! -d "${var_TARGET_DIR}/var/lib/pacman" ] && mkdir -m 755 -p "${var_TARGET_DIR}/var/lib/pacman"
infofy "Refreshing package database..."
- $PACMAN_TARGET -Sy >$LOG 2>&1 || return 1
+ $PACMAN_TARGET -Sy >$LOG 2>&1 || return 1 #TODO: make sure this also goes into the logfile. actually we should do this for many commands.
return 0
}
@@ -97,7 +97,7 @@ list_pacman_repos ()
[ "$1" != runtime -a "$1" != target ] && die_error "list_pacman_repos needs target/runtime argument"
[ "$1" = target ] && conf=/tmp/pacman.conf
[ "$1" = runtime ] && conf=/etc/pacman.conf
- grep '\[.*\]' $conf | grep -v options | sed 's/\[//g' | sed 's/\]//g'
+ grep '\[.*\]' $conf | grep -v options | grep -v '^#' | sed 's/\[//g' | sed 's/\]//g'
}
diff --git a/src/core/libs/lib-software.sh b/src/core/libs/lib-software.sh
index 6b4a1a8..726d20f 100644
--- a/src/core/libs/lib-software.sh
+++ b/src/core/libs/lib-software.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
TMP_MKINITCPIO_LOG=$RUNTIME_DIR/mkinitcpio.log
TMP_PACMAN_LOG=$RUNTIME_DIR/pacman.log
@@ -26,7 +26,7 @@ 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 -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
diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh
index 70ef739..8fdc5dc 100644
--- a/src/core/libs/lib-ui-interactive.sh
+++ b/src/core/libs/lib-ui-interactive.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
#TODO: get backend code out of here!!
@@ -709,11 +709,8 @@ interactive_install_grub() {
bootdev=$(mount | grep $var_TARGET_DIR/boot | cut -d' ' -f 1)
if [ "$grubdev" != "" -o "$bootdev" != "" ]; then
subdir=
- if [ "$bootdev" != "" ]; then
- grubdev=$(mapdev $bootdev)
- else
- subdir="/boot"
- fi
+ [ -n "$bootdev" ] && grubdev=$(mapdev $bootdev) || subdir="/boot"
+
# keep the file from being completely bogus
if [ "$grubdev" = "DEVICE NOT FOUND" ]; then
notify "Your root boot device could not be autodetected by setup. Ensure you adjust the 'root (hd0,0)' line in your GRUB config accordingly."
@@ -867,29 +864,32 @@ interactive_select_mirror() {
ask_option no "Mirror selection" "Select an FTP/HTTP mirror" $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/i686" || return 1
- var_SYNC_URL=$ANSWER_STRING
+ ask_string "Enter the full URL to core repo." "ftp://ftp.archlinux.org/core/os/$var_ARCH" || return 1
+ var_SYNC_URL=${ANSWER_STRING/\/core\///\$repo/} #replace '/core/' by '/$repo/'
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}.*" "${var_MIRRORLIST}" | sed 's/\$repo/core/g' | head -n1)
+ # our mirrorlist and pulling the full URL out.
+ # Ensure that if it was listed twice we only return one line for the mirror.
+ var_SYNC_URL=$(egrep -o "${_server}.*" "${var_MIRRORLIST}" | head -n1)
fi
echo "Using mirror: $var_SYNC_URL" >$LOG
}
-# geteditor(). taken from original setup code.
+# geteditor().
# prompts the user to choose an editor
# sets EDITOR global variable
#
interactive_get_editor() {
- ask_option no "Text editor selection" "Select a Text Editor to Use" \
- "1" "nano (easier)" \
- "2" "vi"
+ unset EDITOR_OPTS
+ 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[@]}"
+ #TODO: this code could be a little bit cleaner.
case $ANSWER_OPTION in
- "1") EDITOR="nano" ;;
- "2") EDITOR="vi" ;;
- *) EDITOR="nano" ;;
+ "nano") EDITOR="nano" ;;
+ "joe") EDITOR="joe" ;;
+ "vi") EDITOR="vi" ;;
+ *) EDITOR="nano" ;;
esac
}
diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh
index ac73b3e..2315394 100644
--- a/src/core/libs/lib-ui.sh
+++ b/src/core/libs/lib-ui.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
# 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
diff --git a/src/core/procedures/automatic b/src/core/procedures/automatic
new file mode 100644
index 0000000..3c93167
--- /dev/null
+++ b/src/core/procedures/automatic
@@ -0,0 +1,135 @@
+#!/bin/bash
+# This procedure is EARLY in development!!
+# This is a procedure for automatic deployment/installation/configuration of systems. # TODO: document! (readme, notes about deployment profiles, examples, ...)
+
+# 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/..?
+
+depend_procedure core base
+
+var_OPTS_STRING="c:"
+var_ARGS_USAGE="-c <config>: Specify a configfile (profile) to be used (optional)" #if we need some settings that we're missing, we'll ask for them
+
+phase_preparation+=(runtime_settings)
+phase_preparation+=(msg_automatic) # this can happen probably a bit earlier..
+phase_preparation+=(fetch_configs)
+process_args ()
+{
+ if [ "$1" = '-c' ]
+ then
+ [ -z "$2" ] && die_error "You must specify a config"
+ source $2 || die_error "Could not source config $2"
+ else
+ usage
+ exit 5
+ fi
+}
+
+
+worker_intro ()
+{
+ notify "Automatic procedure running..."
+}
+
+
+worker_configure ()
+{
+ var_UI_TYPE=${arg_ui_type:-cli}
+}
+
+
+# not used
+worker_msg_manual ()
+{
+ notify "A few manual things need to happen first..."
+}
+
+
+worker_msg_automatic ()
+{
+ notify "**** From now on. everything will be automatic. Enjoy the show!" # not true: you need pass for dm_crypt
+}
+
+
+worker_fetch_configs ()
+{
+ true
+}
+
+
+worker_runtime_network ()
+{
+ if ask_yesno "Do you want to (re)-configure your networking?"
+ then
+ interactive_runtime_network
+ else
+ infofy "Ok. skipping network config"
+ fi
+}
+
+
+# Check if we have all needed settings loaded from the profile
+worker_runtime_settings ()
+{
+ if check_is_in $var_RUNTIME_PACKAGES svn
+ 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
+ then
+ # Maybe more stuff later
+ true
+ fi
+ [ -z "$HOSTNAME" ] && ask_string "Hostname of target system?" && HOSTNAME=$ANSWER_STRING
+
+ return 0
+}
+
+
+worker_prepare_disks ()
+{
+ process_disks || die_error "Could not process_disks"
+ if ! process_filesystems
+ then
+ show_warning "Could not process_filesystems"
+ txt='also failed to execute properly'
+ rollback_filesystems && txt='ended successfully'
+ die_error "Something failed while processing the filesystem. A rollback was executed, which $txt"
+ fi
+ infofy "Partitions and filesystems made successfully"
+
+ # TODO: fstab? auto-add to fstab with libs? auto mkdir's on target_dir?
+ true
+}
+
+
+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
+}
+
+
+worker_set_clock ()
+{
+ #timezone="Europe/Brussels"
+ #Not doing anything. hwclock is set already and configs are coming from svn anyway..
+ true
+}
+
+
+worker_install_bootloader ()
+{
+ install-grub /dev/sda
+}
+
+
+worker_runtime_yaourt ()
+{
+ _yaourt_replace_pacman
+}
+
diff --git a/src/core/procedures/base b/src/core/procedures/base
index fa88210..c22a01c 100644
--- a/src/core/procedures/base
+++ b/src/core/procedures/base
@@ -3,10 +3,13 @@
#TODO: make this profile work on itself, eg some stuff from inheriting profiles should be moved in, stuff implemented etc
var_DEFAULTFS="/boot:32:ext2:+ swap:256:swap /:7500:ext3 /home:*:ext3"
var_TARGET_DIR="/mnt" # When overriding this, do _not_ add a trailing /. It's not needed and maybe you could even break something
+var_RUNTIME_REPOSITORIES= # array like this ('name1' 'location of repo 1' ['name2' 'location of repo2',..])
var_RUNTIME_PACKAGES=
-var_PKG_FILE=$RUNTIME_DIR/package-list
+var_PKG_FILE=$RUNTIME_DIR/package-list # not used by default in base/interactive. can be used by custom procedures or profiles for the automatic procedure
var_MIRRORLIST="/etc/pacman.d/mirrorlist"
var_UI_TYPE="cli" # set to cli or dia for dialog
+var_ARCH=`uname -m` #i686 or x86_64. NOTE: this assumes you want to install the same arch as the installation environment you're using. maybe we could decouple those someday..
+[ -z "$var_ARCH" ] && die_error "Could not determine your architecture"
###### Phases ( can be overridden by more specific procedures) ######
phase_preparation=(\
@@ -15,6 +18,7 @@ phase_preparation=(\
sysprep \
select_source \
runtime_network \
+ runtime_repositories \
runtime_packages)
phase_basics=(\
@@ -32,7 +36,6 @@ phase_system=(\
locales \
install_bootloader)
-
phase_finish=(msg_report)
@@ -64,7 +67,7 @@ worker_select_source ()
{
var_PKG_SOURCE_TYPE='cd'
var_FILE_URL="file:///src/core/pkg"
- var_SYNC_URL=
+ 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
}
@@ -76,6 +79,17 @@ worker_runtime_network ()
}
+worker_runtime_repositories ()
+{
+ for i in `seq 0 $((${#var_RUNTIME_REPOSITORIES[@]}/2-1))`
+ do
+ repo=${var_RUNTIME_REPOSITORIES[$(($i*2))]}
+ location=${var_RUNTIME_REPOSITORIES[$(($i*2+1))]}
+ list_pacman_repos runtime | grep -q $repo || add_pacman_repo runtime $repo "$location"
+ done
+}
+
+
worker_runtime_packages ()
{
for pkg in $var_RUNTIME_PACKAGES
@@ -152,6 +166,12 @@ worker_locales ()
}
+worker_initialtime ()
+{
+ cp /etc/localtime ${var_TARGET_DIR}/etc/localtime
+}
+
+
worker_install_bootlader ()
{
#TODO: ask which disk, install grub on it
diff --git a/src/core/procedures/interactive b/src/core/procedures/interactive
index dc1bf2b..051d187 100644
--- a/src/core/procedures/interactive
+++ b/src/core/procedures/interactive
@@ -1,11 +1,9 @@
-#!/bin/sh
+#!/bin/bash
depend_procedure core base # esp for auto_{network,locale,fstab}, intro and set_clock workers
# This is a port of the original /arch/setup script. It doesn't use aif phases but uses it's own menu-based flow (phase) control
-
-var_TARGET_DIR="/mnt"
EDITOR=
BLOCK_ROLLBACK_USELESS=1
@@ -21,7 +19,7 @@ PART_ROOT=
DEFAULTFS="/boot:32:ext2:+ swap:256:swap /:7500:ext3 /home:*:ext3"
worker_select_source_title='Select Source'
-worker_runtime_network_title='Setup Network (Make sure the network is ok before continuing'
+worker_runtime_network_title='Setup Network'
worker_select_mirror_title='Choose Mirror'
worker_set_clock_title='Set clock'
worker_prepare_disks_title='Prepare Hard Drive(s)'
@@ -83,7 +81,8 @@ mainmenu()
execute worker auto_locale ; } && NEXTITEM=6 ;;
"6")
check_depend worker install_packages && execute worker configure_system && { execute worker mkinitcpio ; \
- execute worker locales ; } && NEXTITEM=7 ;; #TODO: why is next item 4 if $?=0?. maybe fixed now
+ execute worker locales ;
+ execute worker initialtime ; } && NEXTITEM=7 ;; #TODO: why is next item 4 if $?=0?. maybe fixed now
"7")
check_depend worker configure_system && execute worker install_bootloader && NEXTITEM=8 ;;
"8")
@@ -97,7 +96,7 @@ mainmenu()
select_source_extras_menu ()
{
while true; do
- ask_option no "FTP Installation" '' \
+ ask_option no "FTP Installation" 'Make sure the network is ok before continuing the installer' \
"1" "$worker_runtime_network_title" \
"2" "$worker_select_mirror_title" \
"3" "Return to Main Menu"
@@ -114,15 +113,16 @@ worker_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 "${SYNC_URL}" != "" ]; then
- debug "Adding choosen mirror (${SYNC_URL}) to ${var_TARGET_DIR}/$var_MIRRORLIST"
- mirrorlist=`awk "BEGIN { printf(\"# Mirror used during installation\nServer = "${SYNC_URL}"\n\n\") } 1 " "${var_TARGET_DIR}/$var_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"
+ 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
# /etc/rc.conf
# Make sure timezone and utc info are what we want
- sed -i -e "s/^TIMEZONE=.*/TIMEZONE=\"$TIMEZONE\"/g" \
+ # NOTE: If a timezone string never contains more then 1 slash, we can use ${TIMEZONE/\//\\/}
+ sed -i -e "s/^TIMEZONE=.*/TIMEZONE=\"${TIMEZONE//\//\\/}\"/g" \
-e "s/^HARDWARECLOCK=.*/HARDWARECLOCK=\"$HARDWARECLOCK\"/g" \
${var_TARGET_DIR}/etc/rc.conf
diff --git a/src/core/procedures/partial-configure-network b/src/core/procedures/partial-configure-network
new file mode 100644
index 0000000..a2542b6
--- /dev/null
+++ b/src/core/procedures/partial-configure-network
@@ -0,0 +1,7 @@
+#!/bin/bash
+depend_procedure core interactive
+
+start_process ()
+{
+ execute worker runtime_network
+} \ No newline at end of file
diff --git a/src/core/procedures/partial-disks b/src/core/procedures/partial-disks
new file mode 100644
index 0000000..8f17e33
--- /dev/null
+++ b/src/core/procedures/partial-disks
@@ -0,0 +1,32 @@
+#!/bin/bash
+depend_procedure core base
+
+var_OPTS_STRING="o:"
+var_ARGS_USAGE="-o process/rollback: Operation: process the blockdevice layer or roll it back?"
+
+process_args ()
+{
+ if [ "$1" = '-o' ]
+ then
+ [ "$2" != process -a "$2" != rollback ] && die_error "You must specify 'process' or 'rollback'"
+ OPERATION=$2
+ else
+ usage
+ exit 5
+ fi
+}
+
+
+start_process ()
+{
+ [ -z "$OPERATION" ] && usage && exit 5
+
+ if [ "$OPERATION" = process ]
+ then
+ process_disks
+ process_filesystems
+ elif [ "$OPERATION" = rollback ]
+ then
+ rollback_filesystems
+ fi
+} \ No newline at end of file
diff --git a/src/core/procedures/quickinst b/src/core/procedures/quickinst
index 9e92c03..b95bfa4 100644
--- a/src/core/procedures/quickinst
+++ b/src/core/procedures/quickinst
@@ -1,7 +1,107 @@
-#!/bin/sh
+#!/bin/bash
+depend_procedure core base
-quickinst_finished ()
+# This is a port of the original /arch/quickinst script.
+
+# TODO: nowhere rely on /tmp
+
+
+# TODO: find a way to make profilespecific arguments and usage function work (see src/aif.sh)
+usage() {
+ echo "quickinst <install_mode> <destdir> <package_directory|server_url>"
+ echo
+ echo "This script is for users who would rather partition/mkfs/mount their target"
+ echo "media manually than go through the routines in the setup script."
+ echo
+ echo "First make sure you have all your filesystems mounted under <destdir>."
+ echo "e.g. mount -t iso9660 /dev/sdc or /dev/sr0 (for new naming sheme) /src "
+ echo "Then run this script to install all base packages to <destdir>."
+ echo
+ if [ -e /usr/bin/wget ]; then
+ echo "<install_mode> must be either 'ftp' or 'cd'"
+ else
+ echo "<install_mode> must be 'cd'"
+ fi
+ echo
+ echo "Examples:"
+ if [ -e /usr/bin/wget ]; then
+ echo " quickinst ftp /mnt ftp://ftp.archlinux.org/core/os/$var_ARCH"
+ fi
+
+ echo " quickinst cd /mnt /src/core/pkg"
+ echo ""
+ exit 0
+}
+
+
+# TODO: implement correctly
+worker_configure ()
{
+# var_PKG_SOURCE_TYPE
+# var_TARGET_DIR
+# var_FILE_URL or var_SYNC_URL
+}
+
+# TODO: clean up everything below this
+
+PACMAN=
+[ -f /tmp/usr/bin/pacman.static ] && PACMAN=/tmp/usr/bin/pacman.static
+[ -f /usr/bin/pacman.static ] && PACMAN=/usr/bin/pacman.static
+if [ "$PACMAN" = "" ]; then
+ cd /tmp
+ if [ "$INSTMODE" = "ftp" ]; then
+ echo "Downloading pacman..."
+ wget $PKGARG/pacman*.pkg.tar.gz
+ if [ $? -gt 0 ]; then
+ echo "error: Download failed"
+ exit 1
+ fi
+ tar -xzf pacman*.pkg.tar.gz
+ elif [ "$INSTMODE" = "cd" ]; then
+ echo "Unpacking pacman..."
+ tar -xzf $PKGARG/pacman*.pkg.tar.gz
+ fi
+fi
+[ -f /tmp/usr/bin/pacman.static ] && PACMAN=/tmp/usr/bin/pacman.static
+if [ "$PACMAN" = "" ]; then
+ echo "error: Cannot find the pacman.static binary!"
+ exit 1
+fi
+
+if [ "$INSTMODE" = "ftp" ]; then
+ echo "[core]" >/tmp/pacman.conf
+ echo "Server = $PKGARG" >>/tmp/pacman.conf
+ mkdir -p $DESTDIR/var/cache/pacman/pkg /var/cache/pacman >/dev/null 2>&1
+ rm -f /var/cache/pacman/pkg >/dev/null 2>&1
+ ln -sf $DESTDIR/var/cache/pacman/pkg /var/cache/pacman/pkg >/dev/null 2>&1
+fi
+
+if [ "$INSTMODE" = "cd" ]; then
+ echo "[core]" >/tmp/pacman.conf
+ echo "Server = file://$PKGARG" >>/tmp/pacman.conf
+ mkdir -p $DESTDIR/var/cache/pacman/pkg /var/cache/pacman >/dev/null 2>&1
+ rm -f /var/cache/pacman/pkg >/dev/null 2>&1
+ ln -sf $PKGARG /var/cache/pacman/pkg >/dev/null 2>&1
+fi
+
+! [ -d $DESTDIR/var/lib/pacman ] && mkdir -p $DESTDIR/var/lib/pacman
+! [ -d /var/lib/pacman ] && mkdir -p /var/lib/pacman
+# mount proc/sysfs first, so mkinitrd can use auto-detection if it wants
+! [ -d $DESTDIR/proc ] && mkdir $DESTDIR/proc
+! [ -d $DESTDIR/sys ] && mkdir $DESTDIR/sys
+! [ -d $DESTDIR/dev ] && mkdir $DESTDIR/dev
+mount -t proc none $DESTDIR/proc
+mount -t sysfs none $DESTDIR/sys
+mount -o bind /dev $DESTDIR/dev
+$PACMAN -r $DESTDIR --config /tmp/pacman.conf -Sy base
+umount $DESTDIR/proc $DESTDIR/sys $DESTDIR/dev
+if [ $? -gt 0 ]; then
+ echo
+ echo "Package installation FAILED."
+ echo
+ exit 1
+fi
+
echo
echo "Package installation complete."
echo
@@ -37,4 +137,4 @@ echo
echo "Then exit your chroot shell, edit $DESTDIR/etc/fstab and"
echo "$DESTDIR/etc/rc.conf, and reboot!"
echo
-}
+exit 0