diff options
author | Dieter Plaetinck <dieter@plaetinck.be> | 2009-03-29 18:16:42 +0200 |
---|---|---|
committer | Dieter Plaetinck <dieter@plaetinck.be> | 2009-03-29 18:16:42 +0200 |
commit | ef2290b0e31c285267bba9dde3634b628df0ebf0 (patch) | |
tree | de627bb47c87f535ad7eea5d7b3da9bc2cbef3c7 /src/core/procedures | |
parent | 71f5510aaaa20ae5ae9c773dca12028bd96aafdf (diff) | |
parent | ff1bc0cd6060d0a23911f1ef25633f706a9af619 (diff) |
Merge branch 'experimental'2009.03.29
Diffstat (limited to 'src/core/procedures')
-rw-r--r-- | src/core/procedures/automatic | 116 | ||||
-rw-r--r-- | src/core/procedures/base | 40 | ||||
-rw-r--r-- | src/core/procedures/interactive | 14 | ||||
-rw-r--r-- | src/core/procedures/partial-keymap | 7 | ||||
-rw-r--r-- | src/core/procedures/quickinst | 140 |
5 files changed, 103 insertions, 214 deletions
diff --git a/src/core/procedures/automatic b/src/core/procedures/automatic index 3c93167..b0e327a 100644 --- a/src/core/procedures/automatic +++ b/src/core/procedures/automatic @@ -1,24 +1,32 @@ #!/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, ...) +# check /usr/share/aif/examples for some example config files. +# This procedure can easily replace the old quickinst script if you look at the "generic install" config file +# Look at the base procedure to see the phases and which workers they'll execute. +# It should be: +# phase_preparation=(configure intro sysprep select_source runtime_network runtime_repositories runtime_packages) +# phase_basics=(set_clock prepare_disks) +# phase_system=(package_list install_packages auto_fstab auto_networkTODO auto_locale auto_keymap_font configure_system mkinitcpio locales install_bootloader) +# phase_finish=(msg_report) # 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/..? +# TODO: for worker_configure_system, we probably want the user to specify hostname, root pass etc. +# TODO: implement setting hostname, keymap, consolefont, network settings +# for a list of recognized variables, see examples/generic-install-on-sda 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) +var_ARGS_USAGE="-c <config>: Specify a configfile (profile) to be used" +var_AUTOMATIC_PROFILE="" +# TODO: if the user does aif -p automatic -c, then $1 is ":-" ??? if you do -c <something> then it's ok. process_args () { if [ "$1" = '-c' ] then [ -z "$2" ] && die_error "You must specify a config" - source $2 || die_error "Could not source config $2" + var_AUTOMATIC_PROFILE=$2 else usage exit 5 @@ -28,69 +36,51 @@ process_args () worker_intro () { - notify "Automatic procedure running..." + notify "Automatic procedure running profile $var_AUTOMATIC_PROFILE ..." } worker_configure () { var_UI_TYPE=${arg_ui_type:-cli} + [ -z "$var_AUTOMATIC_PROFILE" ] && die_error "You must specify a config file to use this procedure" + source $var_AUTOMATIC_PROFILE || die_error "Could not source config $var_AUTOMATIC_PROFILE" + # Check mandatory options + [ -z "$PARTITIONS" ] && die_error "You did not specify a partition scheme" + [ -z "$BLOCKDATA" ] && die_error "You did not specify a partition scheme" + [ -z "$GRUB_DEVICE" ] && die_error "You did not specify a grub device" + # initialize internal variables based on variables set by the user (some of the vars are handled in other workers): + var_RUNTIME_REPOSITORIES=$RUNTIME_REPOSITORIES + var_RUNTIME_PACKAGES=$RUNTIME_PACKAGES + var_GRUB_DEVICE=$GRUB_DEVICE + var_PARTITIONS=$PARTITIONS + var_BLOCKDATA=$BLOCKDATA } - -# 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 () +worker_select_source () { - true + var_PKG_SOURCE_TYPE=${SOURCE:-cd} + var_FILE_URL=${FILE_URL:-file:///src/core/pkg} + var_SYNC_URL=${SYNC_URL:-} } - 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 + true # for now. we assume the user has taken care of this himself already. doing this interactively wouldn't be a good default anyway. + # maybe check if network works, if not, try dhcp. let user override by using a static config in his config file + #if ask_yesno "Do you want to (re)-configure your networking?" + #then + # interactive_runtime_network + #else + # infofy "Ok. skipping network config" + #fi } worker_prepare_disks () { + echo "$var_PARTITIONS" > $TMP_PARTITIONS + echo "$var_BLOCKDATA" > $TMP_BLOCKDEVICES process_disks || die_error "Could not process_disks" if ! process_filesystems then @@ -105,31 +95,35 @@ worker_prepare_disks () true } +worker_package_list () +{ + var_TARGET_PACKAGES=$TARGET_PACKAGES + var_TARGET_GROUPS=$TARGET_GROUPS + [ -z "$var_TARGET_PACKAGES" -a -z "$var_TARGET_GROUPS" ] && var_TARGET_GROUPS=base +} + 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.. + #TODO implement this true } -worker_install_bootloader () -{ - install-grub /dev/sda +worker_auto_network () { + # temporary override because i need to implement this + true } -worker_runtime_yaourt () +worker_install_bootloader () { - _yaourt_replace_pacman + grub-install $var_GRUB_DEVICE --root-directory=/mnt } - diff --git a/src/core/procedures/base b/src/core/procedures/base index c22a01c..6d99421 100644 --- a/src/core/procedures/base +++ b/src/core/procedures/base @@ -5,7 +5,7 @@ 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 # not used by default in base/interactive. can be used by custom procedures or profiles for the automatic procedure +var_PKG_FILE=$RUNTIME_DIR/aif-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.. @@ -31,6 +31,7 @@ phase_system=(\ auto_fstab \ auto_network \ auto_locale \ + auto_keymap_font \ configure_system \ mkinitcpio \ locales \ @@ -101,7 +102,29 @@ worker_runtime_packages () worker_set_clock () { - interactive_set_clock + while true; do + default=no + [ -n "$NEXTITEM" ] && default="$NEXTITEM" + ask_option $default "Date/time configuration" '' required \ + "1" "Select region and timezone" \ + "2" "Set time and date" \ + "3" "Return to Main Menu" + [ "$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 + done +} + + +worker_interactive_timezone () +{ + interactive_timezone +} + + +worker_interactive_time () +{ + interactive_time } @@ -112,18 +135,16 @@ worker_prepare_disks () } -# Put the list of packages to be installed in $TARGET_PACKAGES +# Put the list of packages to be installed in $var_TARGET_PACKAGES and $var_TARGET_GROUPS worker_package_list () { - #TODO: sensible list of packages. maybe just 'base' - true + var_TARGET_GROUPS=base } worker_install_packages () { target_prepare_pacman core #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 } @@ -143,10 +164,15 @@ worker_auto_network () worker_auto_locale () { - target_configure_inital_locale + target_configure_initial_locale } +worker_auto_keymap_font () +{ + target_configure_initial_keymap_font +} + worker_configure_system () { #TODO: what to do here? diff --git a/src/core/procedures/interactive b/src/core/procedures/interactive index 051d187..86e3d63 100644 --- a/src/core/procedures/interactive +++ b/src/core/procedures/interactive @@ -53,7 +53,7 @@ mainmenu() [ -n "$NEXTITEM" ] && default="$NEXTITEM" #TODO: why does a '2' appear instead of '' ?? - ask_option $default "MAIN MENU" '' \ + ask_option $default "MAIN MENU" '' required \ "1" "$worker_select_source_title" \ "2" "$worker_set_clock_title" \ "3" "$worker_prepare_disks_title" \ @@ -78,7 +78,8 @@ mainmenu() 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 ; } && NEXTITEM=6 ;; + 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 ; @@ -96,7 +97,7 @@ mainmenu() select_source_extras_menu () { while true; do - ask_option no "FTP Installation" 'Make sure the network is ok before continuing the installer' \ + 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" @@ -114,7 +115,7 @@ worker_configure_system() # /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 "Adding choosen mirror (${var_SYNC_URL}) to ${var_TARGET_DIR}/$var_MIRRORLIST" + 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 @@ -147,7 +148,8 @@ worker_prepare_disks() default=no [ -n "$NEXTITEM" ] && default="$NEXTITEM" - ask_option $default "Prepare Hard Drive" '' \ + #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" \ @@ -246,7 +248,7 @@ worker_select_mirror () worker_install_bootloader () { - ask_option Grub "Choose bootloader" "Which bootloader would you like to use? Grub is the Arch default." \ + 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!" diff --git a/src/core/procedures/partial-keymap b/src/core/procedures/partial-keymap new file mode 100644 index 0000000..ad81727 --- /dev/null +++ b/src/core/procedures/partial-keymap @@ -0,0 +1,7 @@ +#!/bin/bash + +start_process () +{ + var_UI_TYPE=dia + set_keymap +} diff --git a/src/core/procedures/quickinst b/src/core/procedures/quickinst deleted file mode 100644 index b95bfa4..0000000 --- a/src/core/procedures/quickinst +++ /dev/null @@ -1,140 +0,0 @@ -#!/bin/bash -depend_procedure core base - -# 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 -echo "Please install a bootloader. Edit the appropriate config file for" -echo "your loader, and chroot into your system to install it into the" -echo "boot sector:" -echo " # mount -o bind /dev $DESTDIR/dev" -echo " # mount -t proc none $DESTDIR/proc" -echo " # mount -t sysfs none $DESTDIR/sys" -echo " # chroot $DESTDIR /bin/bash" -echo -echo "For GRUB:" -echo " # install-grub /dev/sda /dev/sdaX (replace with your boot partition)" -echo " (or install manually by invoking the GRUB shell)" -echo "HINT XFS FILESYSTEM:" -echo "If you have created xfs filesystems, freeze them before and unfreeze them after" -echo "installing grub (outside the chroot):" -echo "- freeze:" -echo " # xfs_freeze -f $DESTDIR/boot" -echo " # xfs_freeze -f $DESTDIR/" -echo "- unfreeze:" -echo " # xfs_freeze -u $DESTDIR/boot" -echo " # xfs_freeze -u $DESTDIR/" -echo -echo "For LILO:" -echo " # lilo" -echo -echo "Next step, initramfs setup:" -echo "Edit your /etc/mkinitcpio.conf and /etc/mkinitcpio.d/kernel26-fallback.conf" -echo "to fit your needs. After that run:" -echo "# mkinitcpio -p kernel26" -echo -echo "Then exit your chroot shell, edit $DESTDIR/etc/fstab and" -echo "$DESTDIR/etc/rc.conf, and reboot!" -echo -exit 0 |