#!/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 EDITOR= BLOCK_ROLLBACK_USELESS=1 # clock HARDWARECLOCK= TIMEZONE= # partitions PART_ROOT= # default filesystem specs (the + is bootable flag) # ::[:+] DEFAULTFS="/boot:32:ext2:+ swap:256:swap /:7500:ext3 /home:*:ext3" worker_select_source_title='Select Source' 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)' worker_package_list_title='Select Packages' worker_install_packages_title='Install Packages' worker_configure_system_title='Configure System' worker_install_bootloader_title='Install Bootloader' start_process () { ##################### ## begin execution ## execute worker configure execute worker intro execute worker sysprep # menu item tracker- autoselect the next item NEXTITEM="1" while true do mainmenu done } mainmenu() { default=no [ -n "$NEXTITEM" ] && default="$NEXTITEM" #TODO: why does a '2' appear instead of '' ?? ask_option $default "MAIN MENU" '' required \ "1" "$worker_select_source_title" \ "2" "$worker_set_clock_title" \ "3" "$worker_prepare_disks_title" \ "4" "$worker_package_list_title" \ "5" "$worker_install_packages_title" \ "6" "$worker_configure_system_title" \ "7" "$worker_install_bootloader_title" \ "8" "Exit Install" case $ANSWER_OPTION in "1") execute worker select_source; ret=$?; [ $ret -eq 0 -a "$var_PKG_SOURCE_TYPE" = ftp ] && select_source_extras_menu [ $ret -eq 0 ] && execute worker runtime_packages && NEXTITEM=2 ;; "2") execute worker set_clock && NEXTITEM=3 ;; "3") execute worker prepare_disks && NEXTITEM=4 ;; "4") check_depend worker prepare_disks && \ check_depend worker select_source && execute worker package_list && NEXTITEM=5 ;; "5") check_depend worker package_list && \ check_depend worker select_source && execute worker install_packages && { execute worker auto_fstab ; \ ended_ok worker runtime_network && execute worker auto_network ; \ execute worker auto_locale ; \ execute worker auto_keymap_font; } && NEXTITEM=6 ;; "6") check_depend worker install_packages && execute worker configure_system && { execute worker mkinitcpio ; \ 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") notify "If the install finished successfully, you can now type 'reboot' to restart the system." && stop_installer ;; *) ask_yesno "Abort Installation?" && stop_installer ;; esac } select_source_extras_menu () { while true; do ask_option no "FTP Installation" 'Make sure the network is ok before continuing the installer' required \ #TODO: display the "make sure network is okay" in a better way "1" "$worker_runtime_network_title" \ "2" "$worker_select_mirror_title" \ "3" "Return to Main Menu" [ "$ANSWER_OPTION" = 1 ] && execute worker runtime_network [ "$ANSWER_OPTION" = 2 ] && execute worker select_mirror [ "$ANSWER_OPTION" = 3 ] && break done } worker_configure_system() { ## PREPROCESSING ## #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 debug 'PROCEDURE' "Adding choosen mirror (${var_SYNC_URL}) to ${var_TARGET_DIR}/$var_MIRRORLIST" mirrorlist=`awk "BEGIN { printf(\"# Mirror used during installation\nServer = "${var_SYNC_URL}"\n\n\") } 1 " "${var_TARGET_DIR}/$var_MIRRORLIST"` echo "$mirrorlist" > "${var_TARGET_DIR}/$var_MIRRORLIST" #TODO: test this, this may not work fi # /etc/rc.conf # Make sure timezone and utc info are what we want # 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 interactive_configure_system && return 0 return 1 } worker_prepare_disks() { DONE=0 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" while [ "$DONE" = "0" ] do rollbackstr=" (you don't need to do this)" [ "$BLOCK_ROLLBACK_USELESS" = "0" ] && rollbackstr=" (this will revert your last changes)" default=no [ -n "$NEXTITEM" ] && default="$NEXTITEM" #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" \ "4" "Rollback last filesystem changes$rollbackstr" \ "5" "Return to Main Menu" case $ANSWER_OPTION in "1") [ "$BLOCK_ROLLBACK_USELESS" = "0" ] && ask_yesno "You should probably rollback your last changes first, otherwise this will probably fail. Go back to menu to do rollback?" && NEXTITEM=4 && break; interactive_autoprepare && NEXTITEM=5 && ret=0 && DISK_CONFIG_TYPE=auto;; #TODO: for some reason. if this completes $?=0, next item will be 1 :/ "2") [ "$BLOCK_ROLLBACK_USELESS" = "0" ] && ask_yesno "You should probably rollback your last changes first, otherwise this will probably fail. Go back to menu to do rollback?" && NEXTITEM=4 && break; interactive_partition && ret=1 && NEXTITEM=3 && DISK_CONFIG_TYPE=manual ;; "3") [ "$BLOCK_ROLLBACK_USELESS" = "0" ] && ask_yesno "You should probably rollback your last changes first, otherwise this will probably fail. Go back to menu to do rollback?" && NEXTITEM=4 && break; PARTFINISH="" interactive_filesystems && ret=0 && NEXTITEM=5 && DISK_CONFIG_TYPE=manual ;; "4") if [ "$BLOCK_ROLLBACK_USELESS" = "1" ] then ask_yesno "It seems like you haven't partitioned/formatted/mounted anything yet (or rolled back already). This operation is useless (unless the installer is buggy), but it doesn't harm. Do you want to continue?" || NEXTITEM=5 fi if [ $? -eq 0 -o "$BLOCK_ROLLBACK_USELESS" = "0" ] then if rollback_filesystems #TODO: this part doesn't belong here. move it to ui-interactive. (interactive_rollback) then infofy "Rollback succeeded" else show_warning "Rollback failed" "Rollback failed" fi fi ;; *) DONE=1 ;; esac done return $ret } worker_select_source () { #TODO: how to handle user going here again? discard previous settings, warn him that he already done it? interactive_select_source && return 0 return 1 } worker_intro () { notify "Welcome to the Arch Linux Installation program. The install\ process is fairly straightforward, and you should run through the options in\ the order they are presented. If you are unfamiliar with partitioning/making\ filesystems, you may want to consult some documentation before continuing.\ You can view all output from commands by viewing your VC7 console (ALT-F7).\ ALT-F1 will bring you back here." } worker_configure () { var_UI_TYPE=${arg_ui_type:-dia} } # select_packages() # prompts the user to select packages to install worker_package_list() { # if selection has been done before, warn about loss of input and let the user exit gracefully ended_ok worker package_list && ! ask_yesno "WARNING: Running this stage again will result in the loss of previous package selections.\n\nDo you wish to continue?" && return 0 interactive_select_packages } worker_install_packages () { installpkg && return 0 return 1 } # Hand-hold through setting up networking worker_runtime_network() { interactive_runtime_network } worker_select_mirror () { interactive_select_mirror } worker_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!" bl=`tr '[:upper:]' '[:lower:]' <<< "$ANSWER_OPTION"` [ "$bl" != grub ] && return 0 interactive_install_grub } worker_auto_network () { ask_yesno "Do you want to use the network settings from the installer in rc.conf and resolv.conf?\n\nIf you used Proxy settings, they will be written to /etc/profile.d/proxy.sh" || return 0 [ "$S_DHCP" = 1 ] && target_configure_network dhcp "$PROXY_HTTP" "$PROXY_FTP" [ "$S_DHCP" != 1 ] && target_configure_network fixed "$PROXY_HTTP" "$PROXY_FTP" }