#!/bin/sh # $Id: setup,v 1.134 2007/01/08 21:54:01 tpowa Exp $ ANSWER="/tmp/.setup" TITLE="Arch Linux Installation" LOG="/dev/tty5" DESTDIR="/mnt" EDITOR= # name of the kernel image VMLINUZ="vmlinuz26" # pacman binary PACMAN="pacman.static" # sources SRC_READY=0 SYNC_SERVER= SYNC_PATH= # partitions PART_ROOT= PART_SWAP= PATH=$PATH:/tmp/bin:/tmp/usr/bin:/tmp/sbin:/tmp/usr/sbin # default filesystem specs (the + is bootable flag) # ::[:+] DEFAULTFS="/boot:32:ext2:+ swap:256:swap /:7500:ext3 /home:*:ext3" # install stages S_NET=0 S_PART=0 S_MKFS=0 S_MKFSAUTO=0 S_SELECT=0 S_INSTALL=0 S_LILO=0 S_GRUB=0 S_KERNEL=0 S_NEXTITEM="" abort() { dodialog yesno "Abort Installation?" 6 40 || return 0 if [ "$SRC_READY" = "1" -a "$MODE" = "cd" ]; then umount /src >/dev/null 2>&1 fi exit 0 } msg() { dodialog msgbox "$1" return 1 } dodialog() { # use this for msgbox, inputbox, yesno, infobox # # dodialog [height] [width] [other] # 26/3/06: added an option so that if [other] is default=no # the dialog will default to no # the new dialog's auto-sizing is pretty dumb, we can't trust it height=12 width=65 if [ "$3" != "" ]; then height=$3 fi if [ "$4" != "" ]; then width=$4 fi if [ "$5" == "default=no" ]; then dialog --defaultno --backtitle "$TITLE" --aspect 15 --$1 "$2" $height $width else dialog --backtitle "$TITLE" --aspect 15 --$1 "$2" $height $width $5 fi } domenu() { menutype=$1 ; shift text=$1 ; shift height=$1 ; shift width=$1 ; shift mheight=$1 ; shift dialog --backtitle "$TITLE" --$menutype "$text" $height $width $mheight $* } finddisks() { cd /sys/block # ide devices for dev in $(ls | egrep '^hd'); do if [ "$(cat $dev/device/media)" = "disk" ]; then if [ "$(dmesg | grep sectors | grep $dev)" ]; then echo "/dev/$dev" [ "$1" ] && echo $1 fi fi done #scsi/sata devices for dev in $(ls | egrep '^sd'); do if ! [ "$(cat $dev/device/type)" = "5" ]; then if [ "$(dmesg | grep sectors | grep $dev)" ]; then echo "/dev/$dev" [ "$1" ] && echo $1 fi fi done # cciss controllers if [ -d /dev/cciss ] ; then cd /dev/cciss for dev in $(ls | egrep -v 'p'); do echo "/dev/cciss/$dev" [ "$1" ] && echo $1 done fi cd - >/dev/null } findcdroms() { cd /sys/block # ide devices for dev in $(ls | egrep '^hd'); do if [ "$(cat $dev/device/media)" = "cdrom" ]; then echo "/dev/$dev" [ "$1" ] && echo $1 fi done # scsi/sata and other devices for dev in $(ls | egrep '^sd|^sr|^scd'); do if [ "$(cat $dev/device/type)" = "5" ]; then echo "/dev/$dev" [ "$1" ] && echo $1 fi done cd - >/dev/null } findpartitions() { for devpath in $(finddisks); do disk=$(echo $devpath | sed 's|.*/||') cd /sys/block/$disk for part in $disk*; do # check if not already assembled to a raid device if ! [ "$(cat /proc/mdstat 2>/dev/null | grep $part)" -o "$(fstype 2>/dev/null /dev/null | grep "5")" ]; then if [ -d $part ]; then echo "/dev/$part" [ "$1" ] && echo $1 fi fi done cd - >/dev/null done # include cciss devices #for devpath in $(ls /dev/mapper 2>/dev/null | grep -v control); do # echo "/dev/mapper/$devpath" # [ "$1" ] && echo $1 #done # include any mapped devices for devpath in $(ls /dev/mapper 2>/dev/null | grep -v control); do echo "/dev/mapper/$devpath" [ "$1" ] && echo $1 done # include any raid md devices for devpath in $(ls -d /dev/md* | grep '[0-9]' 2>/dev/null); do if cat /proc/mdstat | grep -qw $(echo $devpath | sed -e 's|/dev/||g'); then echo "$devpath" [ "$1" ] && echo $1 fi done # inlcude cciss controllers if [ -d /dev/cciss ] ; then cd /dev/cciss for dev in $(ls | egrep 'p'); do echo "/dev/cciss/$dev" [ "$1" ] && echo $1 done fi } get_grub_map() { rm /tmp/dev.map dodialog infobox "Generating GRUB device map...\nThis could take a while.\n\n Please be patient." $DESTDIR/sbin/grub --no-floppy --device-map /tmp/dev.map >/tmp/grub.log 2>&1 </proc/sys/kernel/printk ;; "off") echo 0 >/proc/sys/kernel/printk ;; esac } getdest() { [ "$DESTDIR" ] && return 0 dodialog inputbox "Enter the destination directory where your target system is mounted" 8 65 "/mnt" 2>$ANSWER || return 1 DESTDIR=$(cat $ANSWER) } geteditor() { dialog --backtitle "$TITLE" --menu "Select a Text Editor to Use" 10 35 3 \ "1" "vim" \ "2" "nano (easier)" 2>$ANSWER case $(cat $ANSWER) in "1") EDITOR="vi" ;; "2") EDITOR="nano" ;; *) EDITOR="nano" ;; esac } _mkfs() { local _domk=$1 local _device=$2 local _fstype=$3 local _dest=$4 local _mountpoint=$5 if [ "${_fstype}" = "swap" ]; then _mountpoint="swap" swapoff ${_device} >/dev/null 2>&1 if [ "${_domk}" = "yes" ]; then mkswap ${_device} >$LOG 2>&1 if [ $? != 0 ]; then msg "Error creating swap: mkswap ${_device}" return 1 fi fi swapon ${_device} >$LOG 2>&1 if [ $? != 0 ]; then msg "Error activating swap: swapon ${_device}" return 1 fi elif [ "${_fstype}" = "xfs" ]; then if [ "${_domk}" = "yes" ]; then mkfs.xfs -f ${_device} >$LOG 2>&1 if [ $? != 0 ]; then msg "Error creating filesystem: mkfs.xfs ${_device}" return 1 fi sleep 2 fi mkdir -p ${_dest}${_mountpoint} mount -t xfs ${_device} ${_dest}${_mountpoint} >$LOG 2>&1 if [ $? != 0 ]; then msg "Error mounting ${_dest}${_mountpoint}" return 1 fi elif [ "${_fstype}" = "jfs" ]; then if [ "${_domk}" = "yes" ]; then yes | mkfs.jfs ${_device} >$LOG 2>&1 if [ $? != 0 ]; then msg "Error creating filesystem: mkfs.jfs ${_device}" return 1 fi sleep 2 fi mkdir -p ${_dest}${_mountpoint} mount -t jfs ${_device} ${_dest}${_mountpoint} >$LOG 2>&1 if [ $? != 0 ]; then msg "Error mounting ${_dest}${_mountpoint}" return 1 fi elif [ "${_fstype}" = "reiserfs" ]; then if [ "${_domk}" = "yes" ]; then yes | mkreiserfs ${_device} >$LOG 2>&1 if [ $? != 0 ]; then msg "Error creating filesystem: mkreiserfs ${_device}" return 1 fi sleep 2 fi mkdir -p ${_dest}${_mountpoint} mount -t reiserfs ${_device} ${_dest}${_mountpoint} >$LOG 2>&1 if [ $? != 0 ]; then msg "Error mounting ${_dest}${_mountpoint}" return 1 fi elif [ "${_fstype}" = "ext2" ]; then if [ "${_domk}" = "yes" ]; then mke2fs "${_device}" >$LOG 2>&1 if [ $? != 0 ]; then msg "Error creating filesystem: mke2fs ${_device}" return 1 fi sleep 2 fi mkdir -p ${_dest}${_mountpoint} mount -t ext2 ${_device} ${_dest}${_mountpoint} >$LOG 2>&1 if [ $? != 0 ]; then msg "Error mounting ${_dest}${_mountpoint}" return 1 fi elif [ "${_fstype}" = "ext3" ]; then if [ "${_domk}" = "yes" ]; then mke2fs -j ${_device} >$LOG 2>&1 if [ $? != 0 ]; then msg "Error creating filesystem: mke2fs -j ${_device}" return 1 fi sleep 2 fi mkdir -p ${_dest}${_mountpoint} mount -t ext3 ${_device} ${_dest}${_mountpoint} >$LOG 2>&1 if [ $? != 0 ]; then msg "Error mounting ${_dest}${_mountpoint}" return 1 fi else msg "unknown fstype for ${_device}" return 1 fi # add to temp fstab echo -n "${_device} ${_mountpoint} ${_fstype} defaults 0 " >>/tmp/.fstab if [ "${_fstype}" = "swap" ]; then echo "0" >>/tmp/.fstab else echo "1" >>/tmp/.fstab fi } mksimplefs() { DEVICE=$1 FSSPECS=$2 sfdisk_input="" # we assume a /dev/hdX format (or /dev/sdX) dev=$DEVICE PART_SWAP="${dev}2" PART_ROOT="${dev}3" if [ "$S_MKFS" = "1" ]; then msg "You have already prepared your filesystems manually" return 0 fi # validate DEVICE if [ ! -b "$DEVICE" ]; then msg "Device '$DEVICE' is not valid" return 1 fi # validate DEST if [ ! -d "$DESTDIR" ]; then msg "Destination directory '$DESTDIR' is not valid" return 1 fi # /boot required if [ $(echo $FSSPECS | grep '/boot:' | wc -l) -ne 1 ]; then msg "Need exactly one boot partition" return 1 fi # swap required if [ $(echo $FSSPECS | grep 'swap:' | wc -l) -lt 1 ]; then msg "Need at least one swap partition" return 1 fi # / required if [ $(echo $FSSPECS | grep '/:' | wc -l) -ne 1 ]; then msg "Need exactly one root partition" return 1 fi if [ $(echo $FSSPECS | grep '/home:' | wc -l) -ne 1 ]; then msg "Need exactly one home partition" return 1 fi rm -f /tmp/.fstab # disable swap and all mounted partitions, umount / last! dodialog infobox "Disabling swapspace, unmounting already mounted disk devices..." swapoff -a >/dev/null 2>&1 umount $(mount | grep -v "${DESTDIR} " | grep "${DESTDIR}" | sed 's|\ .*||g') >/dev/null 2>&1 umount $(mount | grep "${DESTDIR} " | sed 's|\ .*||g') >/dev/null 2>&1 # setup input var for sfdisk for fsspec in $FSSPECS; do fssize=$(echo $fsspec | tr -d ' ' | cut -f2 -d:) if [ "$fssize" = "*" ]; then fssize_spec=';' else fssize_spec=",$fssize" fi fstype=$(echo $fsspec | tr -d ' ' | cut -f3 -d:) if [ "$fstype" = "swap" ]; then fstype_spec=",S" else fstype_spec="," fi bootflag=$(echo $fsspec | tr -d ' ' | cut -f4 -d:) if [ "$bootflag" = "+" ]; then bootflag_spec=",*" else bootflag_spec="" fi sfdisk_input="${sfdisk_input}${fssize_spec}${fstype_spec}${bootflag_spec}\n" done sfdisk_input=$(printf "$sfdisk_input") # invoke sfdisk printk off dodialog infobox "Partitioning $DEVICE" sfdisk $DEVICE -uM >$LOG 2>&1 <&1 > /dev/null; then _mkfs yes ${DEVICE}${part} "$fstype" "$DESTDIR" "$mountpoint" || return 1 fi let part=$part+1 done # make other filesystems let part=1 for fsspec in $FSSPECS; do mountpoint=$(echo $fsspec | tr -d ' ' | cut -f1 -d:) fstype=$(echo $fsspec | tr -d ' ' | cut -f3 -d:) if [ $(echo $mountpoint | tr -d ' ' | grep '^/$' | wc -l) -eq 0 ]; then _mkfs yes ${DEVICE}${part} "$fstype" "$DESTDIR" "$mountpoint" || return 1 fi let part=$part+1 done msg "Auto-prepare was successful" S_MKFSAUTO=1 } partition() { if [ "$S_MKFSAUTO" = "1" ]; then msg "You have already prepared your filesystems with Auto-prepare" return 0 fi # disable swap and all mounted partitions, umount / last! dodialog infobox "Disabling swapspace, unmounting already mounted disk devices..." swapoff -a >/dev/null 2>&1 umount $(mount | grep -v "${DESTDIR} " | grep "${DESTDIR}" | sed 's|\ .*||g') >/dev/null 2>&1 umount $(mount | grep "${DESTDIR} " | sed 's|\ .*||g') >/dev/null 2>&1 # # Select disk to partition # DISCS=$(finddisks _) DISCS="$DISCS OTHER -" dodialog msgbox "Available Disks:\n\n$(for i in $(finddisks); do dmesg | grep $(echo $i | sed 's#/dev/##g') | grep sectors | sort -u | cut -d')' -f1 |sed -e 's/ /|/g' -e 's/SCSI|device|//g' -e 's/(//g'; done)\n" domenu menu "Select the disk you want to partition" 14 55 7 $DISCS 2>$ANSWER || return 1 DISC=$(cat $ANSWER) if [ "$DISC" = "OTHER" ]; then dodialog inputbox "Enter the full path to the device you wish to partition" 8 65 "/dev/hda" 2>$ANSWER || return 1 DISC=$(cat $ANSWER) fi while [ "$DISC" != "DONE" ]; do # # Partition disc # dodialog 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 partition as you will need. NOTE: cfdisk may tell 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 cfdisk $DISC domenu menu "Select the disk you want to partition" 14 55 7 $DISCS DONE + 2>$ANSWER || return 1 DISC=$(cat $ANSWER) if [ "$DISC" = "OTHER" ]; then dodialog inputbox "Enter the full path to the device you wish to partition" 8 65 "/dev/hda" 2>$ANSWER || return 1 DISC=$(cat $ANSWER) fi done S_PART=1 } mountpoints() { if [ "$S_MKFSAUTO" = "1" ]; then msg "You have already prepared your filesystems with Auto-prepare" return 0 fi while [ "$PARTFINISH" != "DONE" ]; do : >/tmp/.fstab : >/tmp/.parts # Determine which filesystems are available insmod /lib/modules/$(uname -r)/kernel/fs/xfs/xfs.ko >/dev/null 2>&1 insmod /lib/modules/$(uname -r)/kernel/fs/jfs/jfs.ko >/dev/null 2>&1 FSOPTS="ext2 Ext2 ext3 Ext3" [ "$(which mkreiserfs)" ] && FSOPTS="$FSOPTS reiserfs Reiser3" [ "$(which mkfs.xfs)" ] && FSOPTS="$FSOPTS xfs XFS" [ "$(which mkfs.jfs)" ] && FSOPTS="$FSOPTS jfs JFS" # # Select mountpoints # dodialog msgbox "Available Disks:\n\n$(for i in $(finddisks); do dmesg | grep $(echo $i | sed 's#/dev/##g') | grep sectors | sort -u | cut -d')' -f1 |sed -e 's/ /|/g' -e 's/SCSI|device|//g' -e 's/(//g'; done)\n" PARTS=$(findpartitions _) domenu menu "Select the partition to use as swap" 21 50 13 NONE - $PARTS 2>$ANSWER || return 1 PART=$(cat $ANSWER) PARTS="$(echo $PARTS | sed -e "s#${PART}\ _##g")" PART_SWAP=$PART if [ "$PART_SWAP" != "NONE" ]; then DOMKFS="no" dodialog yesno "Would you like to create a filesystem on $PART?\n\n(This will overwrite existing data!)" && DOMKFS="yes" echo "$PART:swap:swap:$DOMKFS" >>/tmp/.parts fi domenu menu "Select the partition to mount as /" 21 50 13 $PARTS 2>$ANSWER || return 1 PART=$(cat $ANSWER) PARTS="$(echo $PARTS | sed -e "s#${PART}\ _##g")" PART_ROOT=$PART # Select root filesystem type domenu menu "Select a filesystem for $PART" 13 45 6 $FSOPTS 2>$ANSWER || return 1 FSTYPE=$(cat $ANSWER) DOMKFS="no" dodialog yesno "Would you like to create a filesystem on $PART?\n\n(This will overwrite existing data!)" && DOMKFS="yes" echo "$PART:$FSTYPE:/:$DOMKFS" >>/tmp/.parts # # Additional partitions # domenu menu "Select any additional partitions to mount under your new root (select DONE when finished)" 21 50 13 $PARTS DONE _ 2>$ANSWER || return 1 PART=$(cat $ANSWER) while [ "$PART" != "DONE" ]; do PARTS="$(echo $PARTS | sed -e "s#${PART}\ _##g")" # Select a filesystem type domenu menu "Select a filesystem for $PART" 13 45 6 $FSOPTS 2>$ANSWER || return 1 FSTYPE=$(cat $ANSWER) MP="" while [ "${MP}" = "" ]; do dodialog inputbox "Enter the mountpoint for $PART" 8 65 "/boot" 2>$ANSWER || return 1 MP=$(cat $ANSWER) if grep ":$MP:" /tmp/.parts; then dodialog msgbox "ERROR: You have defined 2 identical mountpoints! Please select another mountpoint." 8 65 MP="" fi done DOMKFS="no" dodialog yesno "Would you like to create a filesystem on $PART?\n\n(This will overwrite existing data!)" && DOMKFS="yes" echo "$PART:$FSTYPE:$MP:$DOMKFS" >>/tmp/.parts domenu menu "Select any additional partitions to mount under your new root" 21 50 13 $PARTS DONE _ 2>$ANSWER || return 1 PART=$(cat $ANSWER) done dodialog yesno "Would you like to create and mount the filesytems like this?\n\nSyntax\n------\nDEVICE:TYPE:MOUNTPOINT:FORMAT\n\n$(for i in $(cat /tmp/.parts); do echo "$i ";done)" 18 && PARTFINISH="DONE" done # disable swap and all mounted partitions dodialog infobox "Disabling swapspace, unmounting already mounted disk devices..." swapoff -a >/dev/null 2>&1 umount $(mount | grep -v "${DESTDIR} " | grep "${DESTDIR}" | sed 's|\ .*||g') >/dev/null 2>&1 umount $(mount | grep "${DESTDIR} " | sed 's|\ .*||g') >/dev/null 2>&1 for line in $(cat /tmp/.parts); do PART=$(echo $line | cut -d: -f 1) FSTYPE=$(echo $line | cut -d: -f 2) MP=$(echo $line | cut -d: -f 3) DOMKFS=$(echo $line | cut -d: -f 4) umount ${DESTDIR}${MP} if [ "$DOMKFS" = "yes" ]; then if [ "$FSTYPE" = "swap" ]; then dodialog infobox "Creating swapspace on $PART, activating..." else dodialog infobox "Creating $FSTYPE on $PART, mounting to ${DESTDIR}${MP}" fi _mkfs yes $PART $FSTYPE $DESTDIR $MP || return 1 else if [ "$FSTYPE" = "swap" ]; then dodialog infobox "Activating swapspace on $PART" else dodialog infobox "Mounting $PART to ${DESTDIR}${MP}" fi _mkfs no $PART $FSTYPE $DESTDIR $MP || return 1 fi sleep 1 done msg "Partitions were successfully mounted." #FSTAB_MODIFIED="" S_MKFS=1 } getsource() { if [ "$MODE" = "cd" ]; then dialog --backtitle "$TITLE" --menu "You can either install packages from an Arch Linux CD, or you can switch to another VC and manually mount the source media under /src. If you manually mount to /src, make sure the packages are available under /src/arch/pkg.\n\n" \ 15 55 2 \ "CD" "Mount the CD-ROM and install from there" \ "SRC" "I have manually mounted the source media" 2>$ANSWER || return 1 case $(cat $ANSWER) in "CD") # we may have leftover mounts... umount /src >/dev/null 2>&1 CDROMS=$(findcdroms _) if [ "$CDROMS" = "" ]; then msg "No CD drives were found" return 1 fi dodialog msgbox "Available CD drives:\n\n$(for i in $(findcdroms); do k=$(echo $i: | sed 's#/dev/##g'); dmesg | grep $k | grep "CD/"| cut -d, -f1 | sed 's/ /|/g';l=$(echo "$k"$(dmesg | grep $(dmesg | grep $(echo $k | sed 's#:##g') |grep CD- |cut -d\ -f2) | grep ^scsi | sed -e 's/ /|/g' | sed -e 's#.*CD-ROM##g' | sed -e 's#|||##g' | sed -e 's#||#|#g')); ! [ "$l" = "$k" ] && echo $l; done)\n" domenu menu "Select the CD drive that contains Arch packages" 14 55 7 $CDROMS 2>$ANSWER || return 1 CDROM=$(cat $ANSWER) dodialog infobox "Mounting $CDROM" mount -t iso9660 $CDROM /src >/dev/null 2>&1 if [ $? -gt 0 ]; then dodialog msgbox "Failed to mount $CDROM" return 1 fi SRC_READY=1 ;; "SRC") SRC_READY=2 ;; esac if [ ! -d /src/arch/pkg ]; then msg "Package directory /src/arch/pkg is missing!" return 1 fi if [ ! -d /src/arch/pkg/setup ]; then msg "Setup directory /src/arch/pkg/setup is missing!" return 1 fi fi if [ "$MODE" = "ftp" ]; then cd /arch MIRRORS=$(cat mirrors.txt | cut -d' ' -f1 | sed 's|$| _|g') domenu menu "Select an FTP mirror" 14 55 7 $MIRRORS "Custom" "_" 2>$ANSWER || return 1 SYNC_SERVER=$(cat $ANSWER) if [ "$SYNC_SERVER" = "Custom" ]; then dodialog inputbox "Enter the server hostname/ip" 8 65 "ftp.server.org" 2>$ANSWER || return 1 SYNC_SERVER=$(cat $ANSWER) if [ "`uname -m`" = "x86_64" ]; then dodialog inputbox "Enter the path to Arch Linux packages" 8 65 "/current/os/x86_64" 2>$ANSWER || return 1 else dodialog inputbox "Enter the path to Arch Linux packages" 8 65 "/current/os/i686" 2>$ANSWER || return 1 fi SYNC_PATH=$(cat $ANSWER) else SYNC_PATH=$(grep "^$SYNC_SERVER" mirrors.txt | cut -d' ' -f 2) fi SRC_READY=1 fi } prepare_pacman() { cd /tmp # somehow our root can get remounted as RO, which breaks this stage. mount -o remount,rw / >/dev/null 2>&1 if [ "$MODE" = "cd" ]; then if [ ! -f usr/bin/$PACMAN ]; then # Unpack and "install" pacman dodialog infobox "Unpacking pacman" tar zxf /src/arch/pkg/setup/pacman.pkg.tar.gz usr/bin/$PACMAN cd /tmp fi # Setup a pacman.conf in /etc echo "[current]" >/etc/pacman.conf echo "Server = file:///src/arch/pkg" >>/etc/pacman.conf # set up a symlink to fool pacman so it doesn't copy all the packages to the cache if [ ! -d $DESTDIR/var/cache/pacman/pkg ]; then mkdir -p $DESTDIR/var/cache/pacman >/dev/null 2>&1 rm -f $DESTDIR/var/cache/pacman/pkg >/dev/null 2>&1 ln -sf /src/arch/pkg $DESTDIR/var/cache/pacman/pkg >/dev/null 2>&1 fi fi if [ "$MODE" = "ftp" ]; then if [ ! -f usr/bin/$PACMAN ]; then # Download and "install" pacman dodialog infobox "Downloading pacman" snarf ftp://${SYNC_SERVER}${SYNC_PATH}/setup/pacman.pkg.tar.gz >$LOG 2>&1 || msg "Error downloading pacman! Try another server." || return 1 tar zxf pacman.pkg.tar.gz usr/bin/$PACMAN || msg "Error unpacking pacman binary! The tarball may be corrupt." || return 1 cd /tmp fi # Setup a pacman.conf in /etc echo "[current]" >/etc/pacman.conf echo "Server = ftp://${SYNC_SERVER}${SYNC_PATH}" >>/etc/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 export PATH=$PATH:/tmp/usr/bin dodialog infobox "Refreshing package database..." 6 45 $PACMAN --sync --refresh --root $DESTDIR >$LOG 2>&1 } cleanup_pacman() { if [ "$MODE" = "cd" ]; then rm -f $DESTDIR/var/cache/pacman/pkg >/dev/null 2>&1 fi } selectpkg() { if [ $SRC_READY -gt 0 -a "$MODE" = "ftp" ]; then dodialog yesno "Would you like to select a different server?" if [ $? -eq 0 ]; then getsource || return 1 fi else getsource || return 1 fi dodialog msgbox "Package selection is split into two stages. First you will select package categories that contain packages you may be interested in. Then you will be presented with a full list of packages in your selected categories, allowing you to fine-tune your selection.\n\nNOTE: It is recommended that you only install the BASE category from this setup, and wait until you have a fully working system before installing other applications." 18 70 if [ "$MODE" = "cd" ]; then PKGS="/src/arch/pkg/setup/packages.txt" fi if [ "$MODE" = "ftp" ]; then cd /tmp rm -f packages.txt dodialog infobox "Downloading package list..." snarf ftp://${SYNC_SERVER}${SYNC_PATH}/setup/packages.txt >$LOG 2>&1 if [ $? -gt 0 ]; then SRC_READY=0 msg "Error fetching package list from server" return 1 fi PKGS="packages.txt" fi if ! [ -f /tmp/.pkgcategory ]; then CHKLIST="base ^ ON" for category in $(cat $PKGS | sed 's|/.*$||g' | uniq | grep -v base | grep -v kernels); do CHKLIST="$CHKLIST $category - OFF" done else CHKLIST= for i in $(cat /tmp/.pkgcategory | sed 's|\"||g'); do CHKLIST="$CHKLIST $i ^ ON" done for category in $(cat $PKGS | sed 's|/.*$||g' | uniq | grep -v kernels); do grep $category /tmp/.pkgcategory > /dev/null 2>&1 || CHKLIST="$CHKLIST $category - OFF" done fi domenu checklist "Select Package Categories" 19 55 12 $CHKLIST 2>/tmp/.pkgcategory || return 1 SELECTALL="no" dodialog yesno "Select all packages by default?" && SELECTALL="yes" CHKLIST= for category in $(cat /tmp/.pkgcategory | sed 's|"||g'); do if [ "$category" = "x11-drivers" ]; then dodialog msgbox "NOTE:\n-------\nxf86-video-via and xf86-video-unichrome are disabled by default, please select the correct package you need and don't choose both! Else installation will fail!" fi tag="OFF" if [ "$category" = "base" -o "$SELECTALL" = "yes" ]; then tag="ON" fi list=$(cat $PKGS | grep "$category/" | grep -v 'xf86-video-unichrome' | grep -v 'xf86-video-via' | sed 's|^[a-z0-9-]*/||g' | sed "s|.pkg.tar.gz$| ($category) $tag|g" | sort) CHKLIST="$CHKLIST $list" tag="OFF" list=$(cat $PKGS | grep "$category/" | grep 'xf86-video-unichrome' | sed 's|^[a-z0-9-]*/||g' | sed "s|.pkg.tar.gz$| ($category) $tag|g" | sort) CHKLIST="$CHKLIST $list" list=$(cat $PKGS | grep "$category/" | grep 'xf86-video-via' | sed 's|^[a-z0-9-]*/||g' | sed "s|.pkg.tar.gz$| ($category) $tag|g" | sort) CHKLIST="$CHKLIST $list" done domenu checklist "Select Packages to install. Use SPACE to select." 19 60 12 $CHKLIST 2>/tmp/.pkglist || return 1 S_SELECT=1 } doinstall() { # count the packages to be installed #total=$(yes "n" | pacman --root $DESTDIR --sync $* 2>&1 | wc -w) #total=$(($total-9)) # begin install rm -f /tmp/pacman.lck rm -f /tmp/pacman.log # all pacman output goes to /tmp/pacman.log, which we tail into a dialog ( \ echo "Installing Packages..." >/tmp/pacman.log ; echo >>/tmp/pacman.log ; \ $PACMAN --noconfirm --root $DESTDIR --sync $(echo $* | sed 's|"||g') >>/tmp/pacman.log 2>&1 ; \ echo $? >/tmp/.pacman.retcode; \ echo >>/tmp/pacman.log; \ if [ "$(cat /tmp/.pacman.retcode)" -gt 0 ]; then echo "Package Installation FAILED." >>/tmp/pacman.log else echo "Package Installation Complete." >>/tmp/pacman.log fi ) & sleep 2 dialog --backtitle "$TITLE" --title " Installing... Please Wait " \ --no-kill --tailboxbg "/tmp/pacman.log" 18 70 2>/tmp/.pid while [ -f /tmp/pacman.lck ]; do sleep 1 done kill $(cat /tmp/.pid) if [ "$(cat /tmp/.pacman.retcode)" -gt 0 ]; then result="Installation Failed (see errors below)" retcode=1 else result="Installation Complete" retcode=0 fi dialog --backtitle "$TITLE" --title " $result " \ --exit-label "Continue" --textbox "/tmp/pacman.log" 18 70 # fix the stair-stepping that --tailboxbg leaves us with stty onlcr rm -f /tmp/.pacman.retcode return $retcode } installpkg() { if [ ! -f /tmp/.pkglist -o "$S_SELECT" != "1" ]; then msg "You must select packages first." return 1 fi if [ "$S_MKFS" != "1" -a "$S_MKFSAUTO" != "1" ]; then getdest fi msg "Package installation will begin now. You can watch the output in the progress window.\n\nNOTE: Pacman can take a few minutes to process dependencies if you've selected a large amount of packages. Please be patient. You can safely ignore useradd/groupadd pam errors that are shown during package installation." delpkg="no" LIST= for pkg in $(cat /tmp/.pkglist); do pkgname=${pkg%-*-*} LIST="$LIST $pkgname" done prepare_pacman if [ "$MODE" = "cd" ]; then doinstall $LIST if [ $? -gt 0 ]; then cleanup_pacman return 1 fi S_INSTALL=1 fi if [ "$MODE" = "ftp" ]; then dodialog yesno "Do you want to keep the downloaded packages? You can delete them later by running 'pacman -S --clean'" || delpkg="yes" dodialog infobox "Downloading packages. See $LOG for output." 6 55 $PACMAN --noconfirm --root $DESTDIR --sync --downloadonly $(echo $LIST | sed 's|"||g') >$LOG 2>&1 if [ $? -gt 0 ]; then dodialog msgbox "One or more packages failed to download. You can try again by re-selecting Install Packages from the main menu." 12 65 return 1 fi doinstall $LIST if [ $? -gt 0 ]; then cleanup_pacman return 1 fi if [ "$S_INSTALL" = "1" -a "$delpkg" = "yes" ]; then # clean up the cached package files that pacman leaves $PACMAN --root $DESTDIR --sync --clean --clean >$LOC 2>&1 fi S_INSTALL=1 fi sync # only modify fstab once else double entries happen #if [ "$FSTAB_MODIFIED" = "" ]; then if [ "$S_MKFS" = "1" -o "$S_MKFSAUTO" = "1" ]; then if [ -f /tmp/.fstab ]; then # clean fstab first from /dev entries sed -i -e '/^\/dev/d' $DESTDIR/etc/fstab # clean /mnt from old floppy,cd,dvd entries rm -r $DESTDIR/mnt/{cd*,dvd*,fl*} # add floppy,cd and dvd entries first for i in $(ls -d /dev/cdro* | grep -v "0"); do k=$(echo $i | sed -e 's|/dev/||g') echo "$i /mnt/$k iso9660 ro,user,noauto,unhide 0 0" >>$DESTDIR/etc/fstab # create dirs in /mnt mkdir -p $DESTDIR/mnt/$k done for i in $(ls -d /dev/dvd* | grep -v "0"); do k=$(echo $i | sed -e 's|/dev/||g') echo "$i /mnt/$k udf ro,user,noauto,unhide 0 0" >>$DESTDIR/etc/fstab # create dirs in /mnt mkdir -p $DESTDIR/mnt/$k done for i in $(ls -d /dev/fd[0-9] | grep -v "[0-9][0-9][0-9]"); do k=$(echo $i | sed -e 's|/dev/||g') echo "$i /mnt/$k vfat user,noauto 0 0" >>$DESTDIR/etc/fstab # create dirs in /mnt mkdir -p $DESTDIR/mnt/$k done sort /tmp/.fstab >>$DESTDIR/etc/fstab # FSTAB_MODIFIED=1 fi fi #fi cleanup_pacman } dokernel() { if [ $SRC_READY -eq 0 ]; then getsource || return 1 fi getdest || return 1 local KERNTARG= local SRCTARG= #if [ "$SRC_READY" = "1" ]; then # umount /src >/dev/null 2>&1 #fi dialog --backtitle "$TITLE" --menu "Select a kernel you would like to use" 14 55 7 \ "v2.6" "Kernel 2.6.x for IDE/SCSI systems" 2>$ANSWER || return 1 case $(cat $ANSWER) in "v2.6") KERNTARG="kernel26" ; VMLINUZ="vmlinuz26" ;; esac if [ "$KERNTARG" != "" ]; then prepare_pacman if [ "$MODE" = "ftp" ]; then dodialog infobox "Downloading $KERNTARG package. See $LOG for output." 6 55 $PACMAN --noconfirm --root $DESTDIR --sync --downloadonly $KERNTARG >$LOG 2>&1 if [ $? -gt 0 ]; then SRC_READY=0 msg "Kernel package failed to download." return 1 fi fi # mount proc/sysfs first, so mkinitrd can use auto-detection if it wants mount -t proc none $DESTDIR/proc mount -t sysfs none $DESTDIR/sys mount -o bind /dev $DESTDIR/dev doinstall $KERNTARG ret=$? umount $DESTDIR/proc $DESTDIR/sys $DESTDIR/dev cleanup_pacman fi if [ $ret -gt 0 ]; then msg "Failed to install the Linux kernel package." return 1 else sync S_KERNEL=1 msg "The kernel was successfully installed. Make sure to install a bootloader before you reboot." # fallback modifications USE_HWDETECT_RESULTS="" dodialog yesno "PRECONFIGURATION?\n-----------------\n\nUse 'hwdetect' results from Configuration dialog for /etc/mkinitcpio.d/kernel26-fallback.conf. \nThis ensures consistent ordering of your hard disk controllers.\n\nIt is recommended to say 'YES' here." && USE_HWDETECT_RESULTS="yes" if [ "$USE_HWDETECT_RESULTS" = "yes" ]; then [ -n "$HWDETECTHOSTCONTROLLER" ] && sed -i -e "s/^MODULES=.*/$HWDETECTHOSTCONTROLLER/g" ${DESTDIR}/etc/mkinitcpio.d/kernel26-fallback.conf HWDETECTHOOK="$(echo $HWDETECTHOOKS | sed -i 's/autodetect\ //g')" [ -n "$HWDETECTHOOK" ] && sed -i -e "s/^HOOKS=.*/$HWDETECTHOOK/g" ${DESTDIR}/etc/mkinitcpio.d/kernel26-fallback.conf fi msg "Before rebuilding the fallback image, you must review the configuration file. You will now be put into the editor. After you save your changes and exit the editor, the fallback image will be rebuilt." [ "$EDITOR" ] || geteditor $EDITOR ${DESTDIR}/etc/mkinitcpio.d/kernel26-fallback.conf mount -t proc none $DESTDIR/proc mount -t sysfs none $DESTDIR/sys mount -o bind /dev $DESTDIR/dev chroot ${DESTDIR} /sbin/mkinitcpio -p kernel26 umount $DESTDIR/proc $DESTDIR/sys $DESTDIR/dev fi return 0 } donetwork() { INTERFACE= ifaces=$(ifconfig -a | egrep "Ethernet" | cut -d' ' -f1 | sed 's|$| _|g') if [ "$ifaces" = "" ]; then dodialog yesno "Cannot find any ethernet interfaces. You probably haven't loaded\nyour network module yet. You have two options:\n\n 1) Probe for the correct module now.\n 2) Switch to another VC (ALT-F2) and load your module\n with the modprobe command, then switch back here (ALT-F1)\n and continue.\n\nIf you know which module you need, you should do Step 2 and\nselect NO below. If you don't know which module you need,\nchoose Step 1 by selecting YES below.\n\nProbe for network module?" 18 70 if [ $? -eq 0 ]; then probenic if [ $? -gt 0 ]; then return 1 fi fi ifaces=$(ifconfig -a | egrep "Ethernet" | cut -d' ' -f1 | sed 's|$| _|g') if [ "$ifaces" = "" ]; then msg "No network interfaces available." return 1 fi fi while [ "$INTERFACE" = "" ]; do dodialog msgbox "Available Ethernet Interfaces:\n$(ifconfig -a | egrep "Ethernet" | sed 's# #_#g')\n\nIf your ethernet interface is not listed,\n1) Probe for the correct module now.\n2) Switch to another VC (ALT-F2) and load your module with\n the modprobe command, then switch back here (ALT-F1)\n" dialog --backtitle "$TITLE" --extra-button --extra-label "Probe" --ok-label "Select" --menu "Select a network interface" 14 55 7 $ifaces 2>$ANSWER case $? in 1) return 1 ;; 0) INTERFACE=$(cat $ANSWER) ;; *) probenic ;; esac ifaces=$(ifconfig -a | egrep "Ethernet" | cut -d' ' -f1 | sed 's|$| _|g') done dodialog yesno "Do you want to use DHCP?" if [ $? -eq 0 ]; then dodialog infobox "Please wait. Polling for DHCP server on $INTERFACE..." dhcpcd $INTERFACE >$LOG 2>&1 || msg "Failed to run dhcpcd." || return 1 sleep 10 if [ ! $(ifconfig $INTERFACE | grep 'inet addr:') ]; then msg "DHCP request failed." || return 1 fi else NETPARAMETERS="" while [ "$NETPARAMETERS" = "" ]; do dodialog inputbox "Enter your IP address" 8 65 "192.168.0.2" 2>$ANSWER || return 1 IPADDR=$(cat $ANSWER) dodialog inputbox "Enter your netmask" 8 65 "255.255.255.0" 2>$ANSWER || return 1 SUBNET=$(cat $ANSWER) dodialog inputbox "Enter your gateway (optional)" 8 65 "192.168.0.1" 8 65 2>$ANSWER || return 1 GW=$(cat $ANSWER) dodialog inputbox "Enter your DNS server IP" 8 65 "192.168.0.1" 2>$ANSWER || return 1 DNS=$(cat $ANSWER) dodialog yesno "Are these settings correct?\n\nIP address: $IPADDR\nNetmask: $SUBNET\nGateway (optional): $GW\nDNS server: $DNS\n" case $? in 1) ;; 0) NETPARAMETERS="1" ;; esac done ifconfig $INTERFACE $IPADDR netmask $SUBNET up >$LOG 2>&1 || msg "Failed to setup $INTERFACE interface." || return 1 if [ "$GW" != "" ]; then route add default gw $GW >$LOG 2>&1 || msg "Failed to setup your gateway." || return 1 fi echo "nameserver $DNS" >/etc/resolv.conf fi ### Missing Proxy Configuration msg "The network is configured." S_NET=1 } probenic() { dodialog infobox "Looking for a matching ethernet module. Please wait..." printk off cd /lib/modules/$(uname -r)/kernel/drivers/net if [ $? -gt 0 ]; then msg "No ethernet modules were found!" printk on cd - return 1 fi # modules with no modalias exported! status kernel 2.6.18 NOTDETECTABLE="hp ne de4x5 wd cs89x0 eepro smc9194 seeq8005 ni52 ni65 ac3200 smc-ultra at1700 hp-plus depca eexpress 82596 de600 eth16i de620 lance ewrk3 e2100 lp486e 3c501 3c503 3c505 3c507 3c509 3c515 myri10ge" for mod in ${NOTDETECTABLE}; do modprobe $mod >/dev/null 2>&1 done ifconfig -a | egrep "Ethernet" >/dev/null 2>&1 if [ $? -gt 0 ]; then msg "No matching ethernet modules found." else msg "Probe succeeded. Your network module is loaded." fi printk on cd - } dolilo() { if [ ! -f $DESTDIR/etc/lilo.conf ]; then msg "Error: Couldn't find $DESTDIR/etc/lilo.conf. Is LILO installed?" return 1 fi # Try to auto-configure LILO... if [ "$PART_ROOT" != "" -a "$S_LILO" != "1" ]; then sed -i "s|vmlinuz24|vmlinuz|g" $DESTDIR/etc/lilo.conf sed -i "s|vmlinuz26|vmlinuz|g" $DESTDIR/etc/lilo.conf sed -i "s|vmlinuz|$VMLINUZ|g" $DESTDIR/etc/lilo.conf if [ "$VMLINUZ" = "vmlinuz26" -a ! "$(egrep '^[[:space:]]*+initrd' $DESTDIR/etc/lilo.conf)" ]; then sed -i "s|root=.*$|root=${PART_ROOT}|g" $DESTDIR/etc/lilo.conf fi fi DEVS=$(finddisks _) DEVS="$DEVS $(findpartitions _)" if [ "$DEVS" = "" ]; then msg "No hard drives were found" return 1 fi domenu menu "Select the boot device where the LILO bootloader will be installed (usually the MBR)" 14 55 7 $DEVS 2>$ANSWER || return 1 ROOTDEV=$(cat $ANSWER) sed -i "s|boot=.*$|boot=$ROOTDEV" $DESTDIR/etc/lilo.conf msg "Before installing LILO, you must review the configuration file. You will now be put into the editor. After you save your changes and exit the editor, LILO will be installed." [ "$EDITOR" ] || geteditor $EDITOR ${DESTDIR}/etc/lilo.conf dodialog infobox "Installing the LILO bootloader..." mount -t proc none $DESTDIR/proc mount -o bind /dev $DESTDIR/dev chroot $DESTDIR /sbin/lilo >$LOG 2>&1 if [ $? -gt 0 ]; then umount $DESTDIR/dev $DESTDIR/proc msg "Error installing LILO. (see $LOG for output)" return 1 fi umount $DESTDIR/dev $DESTDIR/proc msg "LILO was successfully installed." S_LILO=1 } dogrub() { get_grub_map if [ ! -f $DESTDIR/boot/grub/menu.lst ]; then msg "Error: Couldn't find $DESTDIR/boot/grub/menu.lst. Is GRUB installed?" return 1 fi # try to auto-configure GRUB... if [ "$PART_ROOT" != "" -a "$S_GRUB" != "1" ]; then grubdev=$(mapdev $PART_ROOT) # look for a separately-mounted /boot partition bootdev=$(mount | grep $DESTDIR/boot | cut -d' ' -f 1) if [ "$grubdev" != "" -o "$bootdev" != "" ]; then cp $DESTDIR/boot/grub/menu.lst /tmp/.menu.lst # remove the default entries by truncating the file at our little tag (#-*) head -n $(cat /tmp/.menu.lst | grep -n '#-\*' | cut -d: -f 1) /tmp/.menu.lst >$DESTDIR/boot/grub/menu.lst rm -f /tmp/.menu.lst echo "" >>$DESTDIR/boot/grub/menu.lst echo "# (0) Arch Linux" >>$DESTDIR/boot/grub/menu.lst echo "title Arch Linux" >>$DESTDIR/boot/grub/menu.lst subdir= if [ "$bootdev" != "" ]; then grubdev=$(mapdev $bootdev) else subdir="/boot" fi echo "root $grubdev" >>$DESTDIR/boot/grub/menu.lst echo "kernel $subdir/$VMLINUZ root=$PART_ROOT ro" >>$DESTDIR/boot/grub/menu.lst if [ "$VMLINUZ" = "vmlinuz26" ]; then echo "initrd $subdir/kernel26.img" >>$DESTDIR/boot/grub/menu.lst fi echo "" >>$DESTDIR/boot/grub/menu.lst # adding fallback/full image echo "# (1) Arch Linux" >>$DESTDIR/boot/grub/menu.lst echo "title Arch Linux Fallback" >>$DESTDIR/boot/grub/menu.lst echo "root $grubdev" >>$DESTDIR/boot/grub/menu.lst echo "kernel $subdir/$VMLINUZ root=$PART_ROOT ro" >>$DESTDIR/boot/grub/menu.lst if [ "$VMLINUZ" = "vmlinuz26" ]; then echo "initrd $subdir/kernel26-fallback.img" >>$DESTDIR/boot/grub/menu.lst fi echo "" >>$DESTDIR/boot/grub/menu.lst fi fi msg "Before installing GRUB, you must review the configuration file. You will now be put into the editor. After you save your changes and exit the editor, you can install GRUB." [ "$EDITOR" ] || geteditor $EDITOR ${DESTDIR}/boot/grub/menu.lst DEVS=$(finddisks _) DEVS="$DEVS $(findpartitions _)" if [ "$DEVS" = "" ]; then msg "No hard drives were found" return 1 fi domenu menu "Select the boot device where the GRUB bootloader will be installed (usually the MBR)" 14 55 7 $DEVS 2>$ANSWER || return 1 ROOTDEV=$(cat $ANSWER) dodialog infobox "Installing the GRUB bootloader..." cp -a $DESTDIR/usr/lib/grub/i386-pc/* $DESTDIR/boot/grub/ sync # look for a separately-mounted /boot partition bootpart=$(mount | grep $DESTDIR/boot | cut -d' ' -f 1) if [ "$bootpart" = "" ]; then if [ "$PART_ROOT" = "" ]; then dodialog inputbox "Enter the full path to your root device" 8 65 "/dev/hda3" 2>$ANSWER || return 1 bootpart=$(cat $ANSWER) else bootpart=$PART_ROOT fi fi bootpart=$(mapdev $bootpart) bootdev=$(mapdev $ROOTDEV) if [ "$bootpart" = "" ]; then msg "Error: Missing/Invalid root device: $bootpart" return 1 fi $DESTDIR/sbin/grub --no-floppy --batch >/tmp/grub.log 2>&1 <$LOG if grep "Error [0-9]*: " /tmp/grub.log >/dev/null; then msg "Error installing GRUB. (see $LOG for output)" return 1 fi msg "GRUB was successfully installed." S_GRUB=1 } mainmenu() { if [ -n "$S_NEXTITEM" ]; then DEFAULT="--default-item $S_NEXTITEM" else DEFAULT="" fi if [ "$MODE" = "ftp" ]; then dialog $DEFAULT --backtitle "$TITLE" --title " MAIN MENU " \ --menu "Use the UP and DOWN arrows to navigate menus. Use TAB to switch between buttons and ENTER to select." 15 55 8 \ "0" "Configure Network" \ "1" "Prepare Hard Drive" \ "2" "Select Packages" \ "3" "Install Packages" \ "4" "Configure System" \ "5" "Install Kernel" \ "6" "Install Bootloader" \ "7" "Exit Install" 2>$ANSWER else dialog $DEFAULT --backtitle "$TITLE" --title " MAIN MENU " \ --menu "Use the UP and DOWN arrows to navigate menus. Use TAB to switch between buttons and ENTER to select." 15 55 8 \ "1" "Prepare Hard Drive" \ "2" "Select Packages" \ "3" "Install Packages" \ "4" "Configure System" \ "5" "Install Kernel" \ "6" "Install Bootloader" \ "7" "Exit Install" 2>$ANSWER fi S_NEXTITEM="$(cat $ANSWER)" case $(cat $ANSWER) in "0") donetwork ;; "1") S_MKFSAUTO=0 S_MKFS=0 DONE=0 S_NEXTITEM="" while [ "$DONE" = "0" ]; do if [ -n "$S_NEXTITEM" ]; then DEFAULT="--default-item $S_NEXTITEM" else DEFAULT="" fi dialog $DEFAULT --backtitle "$TITLE" --menu "Prepare Hard Drive" 12 60 5 \ "1" "Auto-Prepare (erases the ENTIRE hard drive)" \ "2" "Partition Hard Drives" \ "3" "Set Filesystem Mountpoints" \ "4" "Return to Main Menu" 2>$ANSWER S_NEXTITEM="$(cat $ANSWER)" case $(cat $ANSWER) in "1") DISCS=$(finddisks) if [ $(echo $DISCS | wc -w) -gt 1 ]; then dodialog msgbox "Available Disks:\n\n$(for i in $(finddisks); do dmesg | grep $(echo $i | sed 's#/dev/##g') | grep sectors | sort -u | cut -d')' -f1 |sed -e 's/ /|/g' -e 's/SCSI|device|//g' -e 's/(//g'; done)\n" domenu menu "Select the hard drive to use" 14 55 7 $(finddisks _) 2>$ANSWER || return 1 DISC=$(cat $ANSWER) else DISC=$DISCS fi SET_DEFAULTFS="" while [ "$SET_DEFAULTFS" = "" ]; do FSOPTS="ext2 Ext2 ext3 Ext3" [ "$(which mkreiserfs)" ] && FSOPTS="$FSOPTS reiserfs Reiser3" [ "$(which mkfs.xfs)" ] && FSOPTS="$FSOPTS xfs XFS" [ "$(which mkfs.jfs)" ] && FSOPTS="$FSOPTS jfs JFS" dodialog inputbox "Enter the size (MegaByte/MB) of your /boot partition" 8 65 "32" 2>$ANSWER || return 1 BOOT_PART_SIZE="$(cat $ANSWER)" dodialog inputbox "Enter the size (MegaByte/MB) of your swap partition" 8 65 "256" 2>$ANSWER || return 1 SWAP_PART_SIZE=$(cat $ANSWER) dodialog inputbox "Enter the size (MegaByte/MB) of your / partition,\n the /home partition will take all the left space." 8 65 "7500" 2>$ANSWER || return 1 ROOT_PART_SIZE=$(cat $ANSWER) domenu menu "Select a filesystem for / and /home" 13 45 6 $FSOPTS 2>$ANSWER || return 1 FSTYPE=$(cat $ANSWER) REAL_DEFAULTFS=$(echo $DEFAULTFS | sed -e "s|/:7500:ext3|/:$ROOT_PART_SIZE:$FSTYPE|g" -e "s|/home:\*:ext3|/home:\*:$FSTYPE|g" -e "s|swap:256|swap:$SWAP_PART_SIZE|g" -e "s|/boot:32|/boot:$BOOT_PART_SIZE|g") echo $REAL_DEFAULTFS >> /tmp/debug dodialog yesno "$FSTYPE will be used for / and /home?" "" "" && SET_DEFAULTFS=1 done dodialog yesno "$DISC will be COMPLETELY ERASED! Are you absolutely sure?" "" "" "default=no" \ && mksimplefs $DISC "$REAL_DEFAULTFS" ;; "2") partition ;; "3") PARTFINISH="" mountpoints ;; *) DONE=1 ;; esac done S_NEXTITEM="1" ;; "2") selectpkg ;; "3") installpkg ;; "4") HWDETECT="" HWPARAMETER="" dodialog yesno "PRECONFIGURATION?\n-----------------\n\nUse 'hwdetect' for '/etc/rc.conf' and '/etc/mkinitcpio.conf'. \nThis ensures consistent ordering of your hard disk controllers and network devices.\n\nIt is recommended to say 'YES' here." && HWDETECT="yes" if [ "$HWDETECT" = "yes" ]; then if /usr/bin/vmware-detect; then HWPARAMETER="$HWPARAMETER --vmware" fi grep -qw ide-legacy /proc/cmdline && HWPARAMETER="$HWPARAMETER --ide-legacy" dodialog yesno "Do you need support for booting from usb devices?" "" "" default=no && HWPARAMETER="$HWPARAMETER --usb" dodialog yesno "Do you need support for booting from firewire devices?" "" "" default=no && HWPARAMETER="$HWPARAMETER --fw" dodialog yesno "Do you need support for booting from pcmcia devices?" "" "" default=no && HWPARAMETER="$HWPARAMETER --pcmcia" dodialog yesno "Do you need support for booting from nfs shares?" "" "" default=no && HWPARAMETER="$HWPARAMETER --nfs" dodialog yesno "Do you need support for booting from software raid arrays?" "" "" default=no && HWPARAMETER="$HWPARAMETER --raid" dodialog yesno "Do you need support for booting from lvm2 volumes?" "" "" default=no && HWPARAMETER="$HWPARAMETER --lvm2" dodialog yesno "Do you need support for booting from encrypted volumes?" "" "" default=no && HWPARAMETER="$HWPARAMETER --encrypt" # add always keymap HWPARAMETER="$HWPARAMETER --keymap" HWDETECTHOSTCONTROLLER="" HWDETECTHOOKS="" HWDETECTNET="" mount -t proc none $DESTDIR/proc mount -t sysfs none $DESTDIR/sys mount -o bind /dev $DESTDIR/dev HWDETECTHOSTCONTROLLER="$(hwdetect --hostcontroller $HWPARAMETER)" HWDETECTHOOKS="$(chroot ${DESTDIR} hwdetect --hooks $HWPARAMETER)" HWDETECTNET="$(hwdetect --net $HWPARAMETER)" umount $DESTDIR/proc $DESTDIR/sys $DESTDIR/dev [ -n "$HWDETECTHOSTCONTROLLER" ] && sed -i -e "s/^MODULES=.*/$HWDETECTHOSTCONTROLLER/g" ${DESTDIR}/etc/mkinitcpio.conf [ -n "$HWDETECTHOOKS" ] && sed -i -e "s/^HOOKS=.*/$HWDETECTHOOKS/g" ${DESTDIR}/etc/mkinitcpio.conf [ -n "$HWDETECTNET" ] && sed -i -e "s/^MODULES=.*/$HWDETECTNET/g" ${DESTDIR}/etc/rc.conf fi [ "$EDITOR" ] || geteditor DONE=0 FILE="" while [ "$EDITOR" != "" -a "$DONE" = "0" ]; do if [ -n "$FILE" ]; then DEFAULT="--default-item $FILE" else DEFAULT="" fi dialog $DEFAULT --backtitle "$TITLE" --menu "Configuration" 17 60 10 \ "/etc/rc.conf" "System Config" \ "/etc/hosts" "Network Hosts" \ "/etc/fstab" "Filesystem Mountpoints" \ "/etc/mkinitcpio.conf" "Initramfs Config" \ "/etc/modprobe.conf" "Kernel Modules (for 2.6.x)" \ "/etc/resolv.conf" "DNS Servers" \ "/etc/locale.gen" "Glibc Locales" \ "Root-Password" "Set the root password" \ "_" "Return to Main Menu" 2>$ANSWER FILE=$(cat $ANSWER) if [ "$FILE" = "_" -o "$FILE" = "" ]; then DONE=1 else if [ "$FILE" = "/etc/mkinitcpio.conf" ]; then dodialog msgbox "The mkinitcpio.conf file controls which modules will be placed into the initramfs for your system's kernel.\n\n- Non US keymap users should add 'keymap' to HOOKS= array\n- USB keyboard users should add 'usbinput' to HOOKS= array\n- If you install under VMWARE add 'BusLogic' to MODULES= array\n- raid, lvm2, encrypt are not enabled by default\n- 2 or more disk controllers, please specify the correct module\n loading order in MODULES= array \n\nMost of you will not need to change anything in this file.\n\nNOTE: Any changes to this file should be made BEFORE you select Install Kernel." 18 70 fi if ! [ "$FILE" = "Root-Password" ]; then $EDITOR ${DESTDIR}${FILE} else ROOTPW="" while [ "$ROOTPW" = "" ]; do chroot ${DESTDIR} passwd root && ROOTPW=1 done fi if [ "$FILE" = "/etc/locale.gen" ]; then chroot ${DESTDIR} locale-gen fi if [ "$FILE" = "/etc/rc.conf" ]; then TIMEZONE="" eval $(grep "^TIMEZONE" ${DESTDIR}/etc/rc.conf) if [ "$TIMEZONE" != "" -a -e ${DESTDIR}/usr/share/zoneinfo/$TIMEZONE ]; then cp ${DESTDIR}/usr/share/zoneinfo/$TIMEZONE ${DESTDIR}/etc/localtime fi fi fi done ;; "5") dokernel ;; "6") dialog --backtitle "$TITLE" --menu "Which bootloader would you like to use? Grub is the Arch default.\n\n" \ 10 55 2 \ "GRUB" "Use the GRUB bootloader (default)" \ "LILO" "Use the LILO bootloader" 2>$ANSWER case $(cat $ANSWER) in "GRUB") dogrub ;; "LILO") dolilo ;; esac ;; "7") if [ "$SRC_READY" = "1" -a "$MODE" = "cd" ]; then umount /src >/dev/null 2>&1 fi echo "" echo "If the install finished successfully, you can now type 'reboot'" echo "to restart the system." echo "" exit 0 ;; *) abort ;; esac } dodialog msgbox "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 VC5 console (ALT-F5). ALT-F1 will bring you back here." 14 65 dialog --backtitle "$TITLE" --menu "Please select an installation source" 10 35 3 \ "1" "CD-ROM or OTHER SOURCE" \ "2" "FTP" 2>$ANSWER || abort case $(cat $ANSWER) in "1") MODE="cd" ;; "2") MODE="ftp" ;; esac if [ "$MODE" = "cd" ]; then TITLE="Arch Linux CDROM or OTHER SOURCE Installation" else TITLE="Arch Linux FTP Installation" dodialog msgbox "If you wish to load your ethernet modules manually, please do so now (consoles 1 thru 4 are active)." 12 65 fi loop() { while $(/bin/true); do mainmenu done } loop exit 0