#!/bin/bash # # X-Amiga install script # Version 2007-10 # # Requires Xdialog, mktemp, vbetest (from lrmi), fdisk, sfdisk, imagemagick, splashutils, beep TITLE="X-AMIGA Installer" INSTALLER=/installer # Location of installer PACKAGES=$INSTALLER/packages # Location of packages MNT=/mnt # Location of target device(s) MEDIA=/mnt # Location of cdrom/usb devices XTARGET=$MNT/xamiga # Target for Linux files ATARGET=$MNT/amiga # Target for Amiga-specific files XAHOME=$XTARGET/home/xamiga # Home folder for xamiga user LIST=`mktemp -d` # Installer-generated files (mktemp allows safe temporary file creation) BUILD=`mktemp -d` # Build directory (copied to $XTARGET) mkdir -p $BUILD/boot/grub $BUILD/usr/bin $BUILD/etc/init.d $BUILD/etc/splash/xamiga/images umount $ATARGET $XTARGET 2>/dev/null # Need to unmount in case installer is being re-run rmdir $ATARGET 2>/dev/null [ -d $XTARGET ] || mkdir $XTARGET BOOTLDR="None" welcome() { # Initial 'welcome' screen Xdialog --title "$TITLE" --backtitle "Welcome!" --buttons-style text \ --msgbox "This installer will set up X-Amiga on your computer.\n\nNo changes will be made to your system until you press the 'Install' button at the end.\n\nPress 'OK' to continue.\n" 0 0 test $? = 255 && exit_installer } partition() { # Partition hard drive Xdialog --title "$TITLE" --backtitle "1 - Partitioning" --buttons-style text \ --msgbox "X-Amiga needs a free partition or hard drive.\n\nThis must be a Linux partition (type 83).\n\nThis installer assumes that your hard drive has already been partitioned.\nIf not, use the Partition Editor BEFORE going on to the next step.\n" 0 0 test $? = 255 && exit_installer # Produce list of drives in form /dev/hdx # sed erases everything after : sfdisk -s | grep ^/dev | sed 's/:.*//' > $LIST/drives } install_dest() { # Select X-Amiga (Linux) destination # Create list of Linux partitions from target's partition table # sed erases everything after 1st space fdisk -l | grep "^/dev.* 83 " | sed 's/ .*//' > $LIST/partitions tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$ trap "rm -f $tempfile" 0 1 2 5 15 Xdialog --title "$TITLE" --backtitle "2 - Install destination" --cancel-label "Skip" --buttons-style text \ --combobox "Where would you like to install X-Amiga? (eg. /dev/hda1)\n" 0 0 $(cat $LIST/partitions) 2> $tempfile case $? in 0) INSTALLDEST=`cat $tempfile`;; 1) INSTALLDEST="None";; 255) exit_installer;; esac } amiga_dest() { # Select destination for Amiga-specific files tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$ trap "rm -f $tempfile" 0 1 2 5 15 [ $INSTALLDEST = "None" -o -z $INSTALLDEST ] && PART=`sed q $LIST/partitions` || PART=$INSTALLDEST Xdialog --title "$TITLE" --backtitle "3 - Amiga destination" --cancel-label "Skip" --buttons-style text \ --combobox "Select a partition for Amiga files (Kickstart ROM, operating system)\n(eg. $INSTALLDEST).\n" 0 0 $(cat $LIST/partitions) 2> $tempfile case $? in 0) AMIGADEST=`cat $tempfile`;; 1) AMIGADEST="None";; 255) exit_installer;; esac } select_bootloader() { # Choose bootloader (currently only GRUB) BOOTDEV="None" tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$ trap "rm -f $tempfile" 0 1 2 5 15 Xdialog --title "$TITLE" --backtitle "4 - Bootloader" --cancel-label "Skip" --buttons-style text \ --combobox "A bootloader will be needed to boot your computer into the X-Amiga system.\n\nIf you already have a bootloader just select 'None'.\n" 0 0 "GRUB (GRand Unified Bootloader)" "None (Do not install a bootloader)" 2> $tempfile case $? in 0) BOOTLDR=`cat $tempfile | sed 's/ .*//'` if [ $BOOTLDR = "GRUB" ] then select_bootdev else rm -f $BUILD/boot/grub/grub.conf 2>/dev/null fi;; 1) BOOTLDR="None";; 255) exit_installer;; esac } select_bootdev() { # Select device on which to install bootloader # Remove trailing digit from partition name DRIVE=`echo $INSTALLDEST | sed "s/[0-9].*//"` tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$ trap "rm -f $tempfile" 0 1 2 5 15 Xdialog --title "$TITLE" --backtitle "Confirm boot device" --cancel-label "Skip" --buttons-style text \ --combobox "Please confirm your boot device (eg. $DRIVE).\nGRUB will be installed into the MBR (Master Boot Record).\n" 0 0 $(cat $LIST/drives) 2> $tempfile case $? in 0) BOOTDEV=`cat $tempfile`;; 1) BOOTDEV="None";; 255) exit_installer;; esac } select_video() { # Select videomode from list generated using vbetest # Create list of video modes using vbetest echo 'q' | vbetest > $LIST/videomodes # sed deletes '[' and ']', replaces color info, appends 'off' to end of line VIDEOMODES=`cat $LIST/videomodes | grep -F [ | sed "s/\[//;s/\]//;s/ (16 color palette)/x4/;s/ (256 color palette)/x8/;s/ (5:5:5)/x15/;s/ (5:6:5)/x16/;s/ (8:8:8)/x24/;s/$/ off/"` # Set first item in radiolist as default VIDEOMODES=`echo $VIDEOMODES | sed "s/off/on/"` tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$ trap "rm -f $tempfile" 0 1 2 5 15 Xdialog --title "$TITLE" --backtitle "5 - Video mode" --cancel-label "Skip" --buttons-style text \ --radiolist "Select the resolution at which you would like to run UAE:\n" 0 0 5 $VIDEOMODES 2> $tempfile case $? in 0) VIDEOMODE=`cat $tempfile` # sed searches for line beginning with [$VIDEOMODE, deletes everything before '] ' and after ' (' # (could have used grep and cut instead...) VIDEORES=`cat $LIST/videomodes | sed '/\['"$VIDEOMODE"'/!d;s/.*] //;s/ (.*//'` 2>/dev/null # $VIDEORES is in form 'xres x yres' # sed deletes everything after x and before x to get individual values XRES=`echo $VIDEORES | sed 's/x.*//'` YRES=`echo $VIDEORES | sed 's/.*x//'` # sed replaces color info, searches for line beginning with [$VIDEOMODE, deletes everything before second space VIDEODEP=`cat $LIST/videomodes | sed 's/(16 color palette)/4/;s/(256 color palette)/8/;s/(5:5:5)/15/;s/(5:6:5)/16/;s/(8:8:8)/24/' | sed '/\['"$VIDEOMODE"'/!d;s/.* //'` 2>/dev/null # Add 512 for VGA mode VIDEOMODE=`expr $VIDEOMODE + 512` ;; 1) VIDEOMODE="None" VIDEORES="Nothing" VIDEODEP="zero";; 255) exit_installer;; esac } select_sound() { # Select computer's sound card from list # alsalist is a tab-separated text file ALSALIST=`sed '1d;s/$/ off/' $INSTALLER/alsalist` tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$ trap "rm -f $tempfile" 0 1 2 5 15 Xdialog --title "$TITLE" --backtitle "6 - Sound card" --cancel-label "Skip" --buttons-style text \ --radiolist "Select your audio device:\n" 500x300 5 $ALSALIST 2> $tempfile case $? in 0) AUDIO=`cat $tempfile`;; 1) AUDIO="None";; 255) exit;; esac } net_tools() { # Install suite of networking tools Xdialog --title "$TITLE" --backtitle "7 - Networking" --buttons-style text \ --yesno "Would you like to install networking tools?\nSome configuration may be needed later.\n" 0 0 case $? in 0) NET="Yes";; 1) NET="No";; 255) exit_installer;; esac } root_pass() { # Set root password error=1 while [ $error -ne 0 ] do tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$ trap "rm -f $tempfile" 0 1 2 5 15 Xdialog --title "$TITLE" --backtitle "8 - Password" --cancel-label "Skip" --buttons-style text \ --password --password --2inputsbox "Please enter a system password.\n" 0 0 "Password:" "" "Re-enter password:" "" 2> $tempfile case $? in 0) PASSWORDS="$(<$tempfile)" ROOTPASS="${PASSWORDS%%/*}" ROOTPASS2="${PASSWORDS##*/}" if [ "$ROOTPASS2" = "$ROOTPASS" ] then error=0 else Xdialog --title "$TITLE" --backtitle "Error" --ok-label "Try again" --buttons-style text \ --msgbox "Passwords don't match!\n" 0 0 error=1 test $? = 255 && exit_installer fi;; 1) return;; 255) exit_installer;; esac done } view_summary() { # Print summary of choices so far # Check if deleting partition, or entire drive... if [ -n "$INSTALLDEST" -a $INSTALLDEST != "None" -a -n "$AMIGADEST" -a $AMIGADEST != "None" -a "$INSTALLDEST" != "$AMIGADEST" ] then warning_msg="All data on partitions $INSTALLDEST and $AMIGADEST will be erased" elif [ -n $INSTALLDEST -a $INSTALLDEST != "None" ] then warning_msg="All data on partition $INSTALLDEST will be erased" elif [ -n $AMIGADEST -a $AMIGADEST != "None" ] then warning_msg="All data on partition $AMIGADEST will be erased" else warning_msg="No install destination selected" fi [ $BOOTLDR = "GRUB" ] && BOOTDEV_S=$BOOTDEV || BOOTDEV_S="--" echo -e \ "These are your chosen installation settings:\n \tInstall destination:\t\t$INSTALLDEST \tAmiga destination:\t\t$AMIGADEST \tBoot loader:\t\t\t$BOOTLDR \tBoot device:\t\t\t$BOOTDEV_S \tVideo:\t\t\t\t$VIDEORES in $VIDEODEP bit color \tVGA mode:\t\t\t$VIDEOMODE \tSound:\t\t\t\t$AUDIO \tNetworking tools:\t\t$NET\n Important: $warning_msg" > $LIST/summary Xdialog --title "$TITLE" --backtitle "View summary" --ok-label "Continue" --no-cancel --buttons-style text \ --logbox $LIST/summary 460x260 test $? = 255 && exit_installer } settings_menu() { # Options to change settings or continue while true do tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$ trap "rm -f $tempfile" 0 1 2 5 15 Xdialog --title "$TITLE" --backtitle "Settings menu" --cancel-label "Continue" --buttons-style text \ --menu "Select an option if you need to change a setting.\nWhen you are ready, press 'Continue'.\n" 0 0 9 \ "1" "Partitioning" \ "2" "Install destination" \ "3" "Amiga destination" \ "4" "Bootloader" \ "5" "Video mode" \ "6" "Sound card" \ "7" "Networking" \ "8" "Password" \ "9" "View summary" 2> $tempfile case $? in 0) choice=`cat $tempfile` case $choice in 1) partition;; 2) install_dest;; 3) amiga_dest;; 4) select_bootloader;; 5) select_video;; 6) select_sound;; 7) net_tools;; 8) root_pass;; 9) view_summary;; esac;; 1) return;; 255) exit_installer;; esac done } error_check() { # Simple error checking - all these are critical for installation [ -z $ROOTPASS ] && error_msg="* No password entered! *" && error=1 [ $VIDEOMODE = "None" ] && error_msg="* No video mode selected! *" && error=1 [ $BOOTLDR = "GRUB" -a $BOOTDEV = "None" ] && error_msg="* No GRUB boot device selected! *" && error=1 [ -z $INSTALLDEST -o $INSTALLDEST = "None" ] && error_msg="* No install destination selected! *" && error=1 error_message } error_message() { # Display error message, using message generated in 'error_check' while [ $error -ne 0 ] do Xdialog --title "$TITLE" --backtitle "Installer error" --ok-label "Go back" --buttons-style text \ --msgbox "The installer has encountered an error:\n\n$error_msg\n\nPlease go back and check your settings carefully.\n" 0 0 test $? = 255 && exit_installer error_msg="" error=0 settings_menu error_check done } install_start() { # Ready to start installing Xdialog --title "$TITLE" --backtitle "Ready to install" --ok-label "Install" --cancel-label "Exit" --beep \ --yesno "The installer is now ready to set up X-Amiga on your computer.\n\nPress 'Install' to begin installation.\n\nPress 'Exit' to exit the installer.\n" 0 0 case $? in 0) return;; 1) exit_installer;; 255) exit_installer;; esac } create_log() { # Create log of hardware details, installer details, partition table, kernel config, and Gentoo's emerge output touch $BUILD/log echo "*** X-AMIGA XINSTALLER LOG (Xdialog)***" >> $BUILD/log echo -e "---------------------------------------\n\n" >> $BUILD/log echo -e "DRIVES (fdisk):\n" >> $BUILD/log cat $LIST/drives >> $BUILD/log log_separator echo -e "VIDEO MODES (vbetest):\n" >> $BUILD/log cat $LIST/videomodes >> $BUILD/log log_separator echo -e "INSTALLER OPTIONS \n" >> $BUILD/log cat $LIST/summary >> $BUILD/log log_separator } log_separator() { # Makes log file easier to read echo -e "\n--------------------------------------------------------------------------------" >> $BUILD/log } log_error() { # Note progress in log file [ "${1}" != "0" ] && echo "$log_msg Error" >> $BUILD/log || echo "$log_msg OK" >> $BUILD/log } prep_drive() { # Prepare destination drive - partition, format, create directory tree # (Big indented section due to Xdialog's --infobox) ( mke2fs $INSTALLDEST >> $BUILD/log 2>&1 log_separator log_msg="Mounting X-Amiga destination $INSTALLDEST..." mount $INSTALLDEST $XTARGET log_error $? # Check if amigadest exists, and if different from installdest if [ $AMIGADEST != "None" -a $AMIGADEST != $INSTALLDEST ] then mke2fs $AMIGADEST >> $BUILD/log 2>&1 && log_separator mkdir $ATARGET log_msg="Mounting Amiga-file destination $AMIGADEST..." mount $AMIGADEST $ATARGET log_error $? else mkdir $XTARGET/amiga $ATARGET log_msg="Bind-mounting Amiga-file destination $XTARGET/amiga..." mount -o bind $XTARGET/amiga $ATARGET log_error $? fi # Create directories log_msg="Creating Linux directories..." mkdir -p $XTARGET/amiga $XTARGET/bin $XTARGET/dev $XTARGET/etc $XTARGET/home $XTARGET/lib $XTARGET/mnt $XTARGET/proc $XTARGET/sbin $XTARGET/sys $XTARGET/tmp $XTARGET/usr $XTARGET/var $XTARGET/etc/init.d $XTARGET/lib/firmware $XTARGET/var/lib $XTARGET/var/log $XTARGET/var/run $XTARGET/usr/sbin log_error $? log_msg="Creating Amiga directories..." mkdir -p $ATARGET/OS $ATARGET/ROM $ATARGET/ADF log_error $? chmod 1777 $XTARGET/tmp # Create essential device nodes (udev takes care of rest later) cd $XTARGET/dev log_msg="Creating device nodes..." ( mknod -m 0600 console c 5 1 mknod -m 0600 null c 1 3 mknod -m 0600 tty c 5 0 mknod -m 0600 tty0 c 4 0 mknod -m 0600 tty1 c 4 1 ) log_error $? log_msg="Assigning ownership to nodes..." ( chown root:tty tty chown root:tty tty0 chown root:tty tty1 ) log_error $? log_separator echo "XXXX" ) | Xdialog --title "$TITLE" --backtitle "Installing X-Amiga..." --no-buttons \ --infobox "Preparing destination drive..." 10 56 0 } install_packages() { # This is main installation loop # Remove unnecessary items from packagelist log_msg="Finalizing package list..." ( [ $NET = "No" ] && NONET="network" [ $BOOTLDR = "None" ] && NOBOOT="boot" sed '/,'"$NONET"',/d;/,'"$NOBOOT"',/d' < $INSTALLER/packagelist > $LIST/packagelist ) log_error $? # packagelist is comma-separated list of packages PACKAGELIST=`cut -d "," -f1 $LIST/packagelist` # Count packages so number of steps can be calculated (for progress bar) PACKAGETOTAL=`sed -n '$=' $LIST/packagelist` STEPS=`expr $PACKAGETOTAL - 1` POS=1 echo -e "Installing packages..." >> $BUILD/log log_separator cd $XTARGET ( for PACKAGE in $PACKAGELIST do CATEGORY=`grep $PACKAGE $LIST/packagelist | cut -d "," -f2` ITEM=`grep $PACKAGE $LIST/packagelist | cut -d "," -f3` TOTAL=`grep $PACKAGE $LIST/packagelist | cut -d "," -f4` STAGE="Installing $CATEGORY system: $ITEM of $TOTAL" echo "XXX" echo -e "\n" echo "$STAGE" echo "XXX" echo $PROGRESS PROGRESS=`expr $POS '*' 100 / $STEPS` POS=`expr $POS + 1` echo $PACKAGE >> $BUILD/log tar xjf $PACKAGES/$PACKAGE >> $BUILD/log 2>&1 log_separator done ) | Xdialog --title "$TITLE" --backtitle "Installing X-Amiga..." --gauge "" 10 56 } system_files() { # Create system files # (HUGE indented section due to Xdialog's --infobox) ( # Create busybox symlinks cd $BUILD log_msg="Creating busybox symlinks..." tar xf $XTARGET/usr/share/busybox/busybox-links.tar log_error $? # Some directories can be deleted... echo "Removing unnecessary directories..." >> $BUILD/log rm -rf $XTARGET/etc/conf.d $XTARGET/etc/env.d $XTARGET/etc/init.d/alsasound $XTARGET/etc/init.d/splash $XTARGET/usr/include $XTARGET/usr/lib/pkgconfig $XTARGET/usr/share/X11 $XTARGET/usr/share/aclocal $XTARGET/usr/share/busybox $XTARGET/usr/share/doc $XTARGET/usr/share/info $XTARGET/usr/share/man $XTARGET/lost+found $XTARGET/root $ATARGET/lost+found $XTARGET/usr/share/locale $XTARGET/usr/share/splashutils $XTARGET/usr/share/tabset $XTARGET/usr/share/terminfo 2>/dev/null # Remove static libraries echo "Removing static libraries..." >> $BUILD/log rm -rf $XTARGET/usr/lib/*.a $XTARGET/usr/lib/*.la $XTARGET/usr/lib/alsa-lib/smixer/*.a $XTARGET/usr/lib/alsa-lib/smixer/*.la 2>/dev/null # Create kernel modules list log_msg="Creating modules list..." touch $BUILD/etc/init.d/modules log_error $? [ -n $AUDIO -a $AUDIO != "None" -a $AUDIO != "dummy" ] && echo "snd_$AUDIO" >> $BUILD/etc/init.d/modules # Generate fstab, based on choices for install destination, amiga destination and swap partition # Need to check if install destination is same as Amiga destination log_msg="Generating fstab..." ( if [ $AMIGADEST != $INSTALLDEST ] then sed "s|INSTALLDEST|$INSTALLDEST|;s|AMIGADEST|$AMIGADEST|" < $INSTALLER/proto/fstab.0 > $LIST/fstab else sed "s|INSTALLDEST|$INSTALLDEST|;/^AMIGADEST*/ d" < $INSTALLER/proto/fstab.0 > $LIST/fstab fi # Does partition table contain swap partition? if [ -f $LIST/ptable ] then SWAP=`grep "^/dev/.*Id=82" $LIST/ptable | cut -b 1-9` # sed deletes everything after first space; deletes numbers; outputs only first line else SWAP=`fdisk -l $(echo $INSTALLDEST | sed 's/ .*//;s/[0-9].*//') | grep "^/dev.* 82 " | cut -b 1-9` fi if [ $SWAP ] then sed "s|SWAP|$SWAP|" < $LIST/fstab > $BUILD/etc/fstab else sed "/^SWAP*/ d" < $LIST/fstab > $BUILD/etc/fstab fi ) log_error $? # Generate mtab log_msg="Generating mtab..." ( sed "s|INSTALLDEST|$INSTALLDEST|" < $INSTALLER/proto/mtab.0 > $BUILD/etc/mtab ) log_error $? # Generate grub.conf, based on choices for install destination and video mode # Loop through list of available drives, looking for destination # Then set grub's root using correct format (hdx,y) log_msg="Generating grub.conf..." ( n=0 dev0=`echo $INSTALLDEST | sed "s/[0-9].*//"` grep "/dev" $LIST/drives | sed "s/:.*//" | while read dev do if [ $dev = $dev0 ] then p=`echo $INSTALLDEST | sed "s/.\{8\}//"` pg=$(( $p - 1 )) GRUBROOT=`echo "(hd"$n","$pg")"` sed "s|GRUBROOT|$GRUBROOT|;s|INSTALLDEST|$INSTALLDEST|;s|VIDEOMODE|$VIDEOMODE|;s|VIDEORES|$VIDEORES|" < $INSTALLER/proto/grub.conf.0 > $BUILD/boot/grub/grub.conf break; else n=`expr $n + 1` fi done ) log_error $? # Generate startxa command (startx + E-UAE) log_msg="Generating startxa..." ( sed "s/VIDEORES/$VIDEORES/;s/VIDEODEP/$VIDEODEP/" < $INSTALLER/proto/startxa.0 > $BUILD/usr/bin/startxa chmod +x $BUILD/usr/bin/startxa ) log_error $? # Generate splash images using ImageMagick log_msg="Generating splash images..." ( convert $INSTALLER/proto/splash.png.0 -resize $VIDEORES -gravity center -extent $VIDEORES $BUILD/etc/splash/xamiga/images/silent-$VIDEORES.png convert $INSTALLER/proto/splash.png.1 -resize $VIDEORES -gravity center -extent $VIDEORES $BUILD/etc/splash/xamiga/images/verbose-$VIDEORES.png ) log_error $? # Generate appropriate splash cfg file log_msg="Generating splash config..." sed "s/VIDEORES/$VIDEORES/;s/VIDEODEP/$VIDEODEP/;s/XRES/$XRES/;s/YRES/$YRES/" < $INSTALLER/proto/splashcfg.0 > $BUILD/etc/splash/xamiga/$VIDEORES.cfg log_error $? # Generate initrd echo "Generating splash initrd" >> $BUILD/log # splash_geninitramfs works in /etc - must use bind mounting since /etc is read-only... cp -a $INSTALLER/proto/splash $BUILD/etc mount -o bind $BUILD/etc /etc splash_geninitramfs xamiga -r $VIDEORES -g $BUILD/boot/fbsplash-xamiga-$VIDEORES --no8bpp -v >> $BUILD/log 2>&1 umount /etc # Copy system files to target log_msg="Copying system files..." ( cd $XTARGET tar xjf $INSTALLER/system/system.tar.bz2 cp -a $BUILD/* $XTARGET/ ) log_error $? # Create xamiga user log_msg="Creating xamiga user..." ( mkdir $XAHOME chmod 755 $XAHOME find $XAHOME -print | xargs chown xamiga:xamiga ) log_error $? # If $AMIGADEST is defined, mount it on startup [ $AMIGADEST != "None" -a $AMIGADEST != $INSTALLDEST ] && echo -e "\n# Mount Amiga directory\nmount -o rw $AMIGADEST /amiga" >> $XTARGET/etc/init.d/rcS # Chroot into target and configure system log_msg="Configuring target system..." ( mount -o bind /dev $XTARGET/dev mount -t proc none $XTARGET/proc mount -o bind /sys $XTARGET/sys chroot $XTARGET /bin/sh -c "echo 'xamiga:$ROOTPASS' | /usr/sbin/chpasswd && exit" >> $BUILD/log 2>&1 # Set ALSA if sound card exists if [ $AUDIO != "None" -a $AUDIO != "dummy" ] then echo -e "\nConfiguring ALSA...\n" >> $BUILD/log modprobe "snd_$AUDIO" sleep 2 chroot $XTARGET /bin/sh -c " amixer set Master 31 unmute amixer set PCM 15 unmute alsactl store exit" >> $BUILD/log 2>&1 fi umount $XTARGET/sys umount $XTARGET/proc umount $XTARGET/dev ) log_error $? # Install GRUB if necessary if [ $BOOTLDR = "GRUB" ] then echo -e "\nInstalling GRUB...\n" >> $BUILD/log grub-install --root-directory=$XTARGET $BOOTDEV >> $BUILD/log 2>&1 cd $XTARGET/boot/grub ln -s grub.conf menu.lst fi # Copy log to target echo "Installation finished! Copying log file to target..." >> $BUILD/log cp -a $BUILD/log /$XTARGET echo "XXXX" ) | Xdialog --title "$TITLE" --backtitle "Installing X-Amiga..." --no-buttons \ --infobox "Creating system files & tidying up..." 10 56 0 } install_end() { Xdialog --title "$TITLE" --backtitle "Finished installing" --ok-label "Continue" --cancel-label "Finish" \ --yesno "Main installation has finished!\n\nPress 'Continue' if you want to set up Amiga files.\n\nPress 'Finish' for post-installation notes and exit.\n" 0 0 case $? in 0) AMIGA=1;; 1) AMIGA=0 return;; 255) exit_installer;; esac } rom_setup() { Xdialog --title "$TITLE" --backtitle "Kickstart ROM setup" --buttons-style text \ --yesno "Would you like to transfer an Amiga Kickstart ROM from CDROM or USB drive?\n" 0 0 case $? in 0) DIRTYPE="Amiga ROM" insert_medium choose_src ROMDIR=$DEST ROMFILE=$(basename $(find $DEST -name *.rom)) 2>/dev/null KEYFILE=$(basename $(find $DEST -name *.key)) 2>/dev/null;; 1) ROMDIR="" ROMFILE="" KEYFILE="" return;; 255) exit_installer;; esac } os_setup() { Xdialog --title "$TITLE" --backtitle "Amiga OS setup" --buttons-style text \ --yesno "Would you like to transfer a previously installed Amiga Operating System\nfrom CDROM or USB drive?\n" 0 0 case $? in 0) DIRTYPE="Amiga OS" insert_medium choose_src OSDIR=$DEST # Essential: change ownership and permissions for OS directories chown -R xamiga:xamiga $OSDIR chmod -R 755 $OSDIR ;; 1) OSDIR="" return;; 255) exit_installer;; esac } floppy_setup() { Xdialog --backtitle "$TITLE" --title "Amiga floppy setup" --buttons-style text \ --yesno "Would you like to transfer a directory containing ADF images?\n" 0 0 case $? in 0) DIRTYPE="Amiga ADF" insert_medium choose_src ADFDIR=$DEST;; 1) AFDIR="" return;; 255) exit_installer;; esac } insert_medium() { Xdialog --title "$TITLE" --backtitle "Insert medium" --ok-label "OK" --buttons-style text \ --msgbox "Please insert a CDROM or USB drive.\n\nWait a few seconds for the device to settle before pressing 'OK'.\n" 0 0 test $? = 255 && exit_installer # Mounts variety of CDROM devices # (Same code as used in initrd) # CDROM DEVICES DEVICES="/dev/cdrom* /dev/cdroms/* /dev/ide/cd/* /dev/sr*" # USB Keychain/Storage DEVICES="$DEVICES /dev/sd*" # IDE devices DEVICES="$DEVICES /dev/hd*" # USB using the USB Block Driver DEVICES="$DEVICES /dev/ubd* /dev/ubd/*" # Mount CDROM for i in $DEVICES do # Mount only block devices if [ -b "$i" ] then mount -r -t iso9660 $i $MEDIA/cdrom >/dev/null 2>&1 if [ $? = 0 ] then break fi fi done } choose_src() { tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$ trap "rm -f $tempfile" 0 1 2 5 15 Xdialog --title "$TITLE" --backtitle "Select $DIRTYPE source directory" \ --fselect $MEDIA/ 0 0 2> $tempfile case $? in 0) SRC=`cat $tempfile` choose_dest;; 1) umount $MEDIA/cdrom 2>/dev/null;; 255) exit_installer;; esac } choose_dest() { tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$ trap "rm -f $tempfile" 0 1 2 5 15 Xdialog --title "$TITLE" --backtitle "Select $DIRTYPE destination directory" \ --dselect $ATARGET/ 0 0 2> $tempfile case $? in 0) DEST=`cat $tempfile` confirm_copy;; 1) umount $MEDIA/cdrom 2>/dev/null;; 255) exit_installer;; esac } confirm_copy() { Xdialog --title "$TITLE" --backtitle "Confirm copy" --ok-label "Copy" --cancel-label "Go Back" --buttons-style text \ --yesno "Please confirm the $DIRTYPE source directory:\n\n$SRC\n\nand destination directory:\n\n$DEST\n\nIf these are correct, press 'Copy' to copy files.\n\nPress 'Go Back' to choose again.\n" 0 0 case $? in 0) copy_files copy_another;; 1) choose_src;; 255) exit_installer;; esac } copy_files() { ( [ -d $DEST ] || mkdir -p $DEST cp -a $SRC/* $DEST umount $MEDIA/cdrom 2>/dev/null echo "XXXX" ) | Xdialog --title "$TITLE" --backtitle "Copying..." --no-buttons \ --infobox "Copying $DIRTYPE files...\n" 10 56 0 } copy_another() { Xdialog --title "$TITLE" --backtitle "Copy another?" --buttons-style text \ --yesno "Would you like to copy another $DIRTYPE directory?\n" 0 0 case $? in 0) insert_medium choose_src;; 1) return;; 255) exit_installer;; esac } euae_setup() { Xdialog --title "$TITLE" --backtitle "UAE setup" --buttons-style text \ --yesno "Would you like to generate an UAE configuration file?\nYou should edit this file later using a text editor.\n" 0 0 case $? in 0) generate_uaerc;; 1) return;; 255) exit_installer;; esac } generate_uaerc() { # Generate uaerc in stages (preserving original configuration order) # If directories defined, strip '$ATARGET' and prepend '/amiga' [ $ROMDIR ] && ROMDIR="/amiga`echo $ROMDIR | sed "s|$ATARGET||"`" [ $ADFDIR ] && ADFDIR="/amiga`echo $ADFDIR | sed "s|$ATARGET||"`" # First section... sed "s|ROMDIR|$ROMDIR|;s|ADFDIR|$ADFDIR|;s|ROMFILE|$ROMFILE|;s|KEYFILE|$KEYFILE|" < $INSTALLER/proto/uaerc.0 > $LIST/uaerc # Only process OS directory if it's defined if [ $OSDIR ] then # Get list of Amiga directories ('partitions') ls $OSDIR > $LIST/osdirs OSDIR="/amiga`echo $OSDIR | sed "s|$ATARGET||"`" # Middle section: add Amiga drives... # It assumes first directory found has boot priority 1 - not very intelligent DRIVENUM=0 for i in $(cat $LIST/osdirs) do [ $DRIVENUM -eq 0 ] && BOOTPRI=1 || BOOTPRI=0 echo "filesystem2=rw,DH$DRIVENUM:$i:$OSDIR/$i,$BOOTPRI" >> $LIST/uaerc DRIVENUM=`expr $DRIVENUM + 1` done fi # Append second section of uaerc... sed "s|XRES|$XRES|;s|YRES|$YRES|" < $INSTALLER/proto/uaerc.1 >> $LIST/uaerc # Finally, copy uaerc to home directory... cp -a $LIST/uaerc $XAHOME/.uaerc } amiga_end() { Xdialog --title "$TITLE" --backtitle "Finished copying" --ok-label "Finish" --buttons-style text \ --msgbox "Amiga files have been copied!\n\nPress 'Finish' for post-installation notes and exit.\n" 0 0 test $? = 255 && exit_installer } post_install() { # Create post-installation notes touch $LIST/postnotes echo -e "X-Amiga (Linux) is currently mounted at $XTARGET\nAmiga file directories are at $ATARGET\n" >> $LIST/postnotes # Check log for errors grep -v "No error reported." $XTARGET/log | grep -i "error" && post_log="errors! Please check the log file..." || post_log="no errors :-)" echo -e "The installer log is located at $XTARGET/log\nThe log reports $post_log\n" >> $LIST/postnotes # Point to locations of grub.conf and initrd [ $BOOTLDR = "None" ] && post_grub="Grub has not been installed.\nYou will need to set up your bootloader in order to boot X-Amiga.\n\nA grub configuration file is at $XTARGET/boot/grub/grub.conf\nAn initrd (contains bootsplash) is at $XTARGET/boot/initrd\n\n" || post_grub="Grub has been installed. If the log reports no errors, your system\nshould boot successfully into X-Amiga." echo -e $post_grub >> $LIST/postnotes } post_notes() { # Display post notes Xdialog --clear --title "Post-installation notes" --no-cancel --buttons-style text \ --logbox $LIST/postnotes 460x280 test $? = 255 && exit_installer } the_end() { # Final 'finish' screen Xdialog --title "$TITLE" --backtitle "Finished installing X-Amiga" --ok-label "Notes" --cancel-label "Exit" --buttons-style text \ --yesno "The X-Amiga installation process is complete.\n\nPress 'Notes' to read post-installation notes.\n\nPress 'Exit' to exit the installer.\n" 0 0 case $? in 0) post_notes the_end;; 1) exit_installer;; 255) exit_installer;; esac } finish_signal() { # Wake up user with jingle... for i in 277.2 415.3 277.2 311.1 349.2 370.0 349.2 311.1 311.1 do beep -f $i -l 80 done } exit_installer() { # Exit cleanly from installer rm -rf $LIST $BUILD umount $MEDIA/cdrom 2>/dev/null exit } # # X-Amiga Installer MAIN section # # Gather information for installation welcome partition install_dest amiga_dest select_bootloader select_video select_sound net_tools root_pass view_summary settings_menu error_check # Install Linux OS install_start create_log prep_drive install_packages system_files finish_signal # (Optional) Copy Amiga files, UAE config if [ $AMIGADEST != "None" ] then install_end if [ $AMIGA -eq 1 ] then rom_setup os_setup floppy_setup euae_setup finish_signal amiga_end fi fi # Post install stuff post_install the_end