PMEDIA="`Xdialog --left --title "Puppy Universal Installer" --no-tags --stdout --menubox "Welcome to the Puppy Universal Installer!\nIf you wish to install Puppy to a removable media, such\nas a USB Flash or hard drive, CD/DVD disc, floppy disk,\nZip disk, LS-120 disk, please insert it right now,\nbefore proceeding.\n\nINSERT MEDIA NOW\nThen, choose the media that you want to install Puppy to:" 0 0 8 usbflash "USB Flash drive" usbhd "USB hard drive" usb2ideflash "USB CF Flash drive, later move CF to IDE adaptor" ideflash "IDE Flash drive (CF card in IDE adaptor)" idehd "IDE (ATA) internal hard drive" idezip "Internal (IDE) ZIP or LS120 drive" satahd "SATA internal hard drive" scsihd "SCSI internal hard drive"`"
[ ! $? -eq 0 ] && exit
[ "$PMEDIA" = "" ] && exit
FINALPMEDIA="$PMEDIA"
if [ "$PMEDIA" = "usb2ideflash" ];then
PMEDIA="usbflash"
FINALPMEDIA="ideflash"
fi
case $PMEDIA in
usbflash)
if [ "`lsmod | grep --extended-regexp '^usb\-storage|^usb_storage'`" = "" ];then
echo "Loading usb-storage module (needs several seconds)..."
Xdialog --left --title "Puppy Universal Installer" --ok-label "QUIT" --msgbox "Your computer has these IDE (ATAPI) CD/DVD drives:\n$SELECTIONS \n\nHowever, you cannot install Puppy to a CD/DVD in the same way as a\nhard drive, USB Flash drive or Zip drive, as the CD/DVD is not\ndirectly writable. For the CD/DVD, you need to do what is called\n'remastering' and Puppy has a program for this, called 'Remaster\nPuppy live-CD', found in the Setup menu. This program enables\nyou to create your own custom live-CD/DVD.\nNote, you will need a new blank CD-R or DVD-R (not +R).\n\nClick button to quit..." 0 0
<text><label>WARNING: NOT NORMALLY RECOMMENDED. Do you want to install Puppy in Superfloppy mode, that is, no MBR and no partitions? ...in that case, the drive will be accessed as /dev/$DRVSEL, without a partition number. This may be a good choice for booting USB Flash drive from PC with a quirky BIOS. Click button if yes:</label></text>
<text><label>The drive is currently in Superfloppy mode and has no MBR and no partitions. It is accessed as /dev/$DRVSEL, without a partition number (this may be a good choice for booting USB Flash drive from PC with a quirky BIOS). Do you want to partition the drive so that it has a /dev/${DRVSEL}1 partition, in which Puppy can be installed? If so, click button:</label></text>
[ "$SANITYRORW" = "(ro)" ] && SANITYMSG2="$SANITYPART is mounted read-only!"
[ -f $SANITYMNTPT/pup_save.3fs ] && SANITYMSG3="$SANITYPART has personal file pup_save.3fs in it!"
Xdialog --left --title "Puppy universal installer: SANITY CHECK" --ok-label "CONTINUE" --cancel-label "QUIT" --yesno "A partition sanity check before continuing:\n$SANITYMSG1 \n$SANITYMSG2 \n$SANITYMSG3 \n\nIf the above report is that the partition is mounted, you need to unmount it\nright now, but if report is it cannot be unmounted, then there may be install\ndifficulties -- certainly, in the case of install to hard drive you will only\nbe able to do an \"option1\" install (explained further on).\nIf the partition has pup_save.3fs in it, that is the reason it cannot be\nunmounted -- it is currently in use by Puppy. If booting Puppy from live-CD,\nif pup_save.3fs does not exist then Puppy will run totally in RAM, which will\nsolve the problem -- but you should not delete or rename pup_save.3fs right\nnow as it is in use. Instead, boot some other OS then rename the file, then\nboot Puppy live-CD.\n\nBottom-line, unmount the partition now, if you can, otherwise CONTINUE script\nwith the restricted install choice, or QUIT script now and try to fix the\nproblem of the partition getting mounted..." 0 0
if [ "`echo "$DESTPART" | grep "[0-9]$"`" = "" ];then
#want superfloppy...
DLG3="
<wtitle>Puppy Universal Installer</wtitle>
<vbox>
<text><label>You have chosen to format /dev/${DESTPART} as a Superfloppy. You now need to choose whether to create a vfat or a ext3 filesystem on the drive. Ext3 is the most flexible (and recommended) choice, however if you need to be able to read the drive from Windows then choose vfat. Note, however, there are tools for accessing ext2/3 drives in Windows.</label></text>
<text><label>A further clarification: if you choose ext3, then the entire drive will be immediately available for personal data storage, whereas if you choose vfat this installer will have to create a file with a ext3 filesystem inside it (pup_save.3fs) -- that file will contain all your personal files. Press FORMAT_ext3 or FORMAT_vfat button to commence formatting...</label></text>
<text><label>You have chosen to format /dev/${DRVSEL} with a MBR and a partition. You now need to choose whether to create a vfat or a ext3 filesystem on the partition. Ext3 is the most flexible (and recommended) choice, however if you need to be able to read the drive from Windows then choose vfat. Note, however, there are tools for accessing ext2/3 drives in Windows.</label></text>
<text><label>A further clarification: if you choose ext3, then the entire partition will be immediately available for personal data storage, whereas if you choose vfat this installer will have to create a file with a ext3 filesystem inside it (pup_save.3fs) -- that file will contain all your personal files. Press FORMAT_ext3 or FORMAT_vfat button to commence formatting...</label></text>
if [ "`echo "$DESTPART" | grep "[0-9]$"`" = "" ];then
#superfloppy
DLG4="
<wtitle>Puppy Universal Installer</wtitle>
<vbox>
<text><label>You have chosen to install Puppy to the entire drive, which is what we call Superfloppy mode, in which there is no MBR (Master Boot Record) and no partitions. This may be a good choice for Flash memory, especially USB Flash, that the PC BIOS has trouble booting from.</label></text>
<text><label>The target drive is ${DESTPART}, which has a ${DESTFS}, of size ${DESTSIZM}M. Press OK button to install Puppy to the drive...</label></text>
<text><label>You have chosen to install Puppy to partition /dev/${DESTPART}, which has a ${DESTFS} filesystem and the size is ${DESTSIZM}M.</label></text>
<text><label>Press OK button to install Puppy (note, there will be one or two more dialog windows before you have to commit to the actual install)...</label></text>
Xdialog --left --buttons-style text --title "Puppy universal installer" --ok-label "CD" --cancel-label "DIRECTORY" --yesno "Puppy consists of three files:\nvmlinuz The Linux kernel\ninitrd.gz The initial ramdisk.\npup_$NEWVER.sfs This has all the Puppy files.\nIf you booted Puppy from a live-CD, those three files will be on it.\nOtherwise, they are in the .iso file and can be extracted -- in that\ncase, you will need to select the directory where you have extracted\nthem to.\nPlease do NOT use a path with any spaces!!!\n\n\nWhere are the Puppy files?..." 0 0
Xdialog --left --title "Puppy universal installer" --msgbox "Please insert the Puppy live-CD (if not already) into the drive.\nNote, in case your PC has two CD/DVD drives, Puppy is expecting\nthe live-CD to be inserted into $CDDRIVE, which is described as:\n $CDDRVINFO \n\nAfter inserting live-CD, click OK button..." 0 0
mkdir /mnt/$CDDRIVE 2> /dev/null
mount -t iso9660 /dev/$CDDRIVE /mnt/$CDDRIVE
if [ -f /mnt/$CDDRIVE/initrd.gz ];then
SRCPATH="/mnt/$CDDRIVE"
else
Xdialog --left --title "Puppy universal installer: ERROR" --msgbox "Sorry, Puppy is not on the CD.\nPlease mount the CD using one of the mount programs\n(see File Managers menu) then click OK button..." 0 0
RETVAL=1
fi
fi
if [ ! $RETVAL -eq 0 ];then #DIRECTORY
SRCFPATH="`Xdialog --left --backtitle "Please find the latest Puppy files\nvmlinuz, initrd.gz and pup_$NEWVER.sfs,\nTHEN HIGHLIGHT ANY ONE OF THEM\nand click the OK button" --title "Puppy universal installer" --stdout --no-buttons --no-cancel --fselect "*" 0 0`"
[ ! $? -eq 0 ] && exit
SRCPATH="`dirname $SRCFPATH`"
fi
fi
#sanity check...
if [ ! -f $SRCPATH/pup_$NEWVER.sfs ];then
Xdialog --left --title "Puppy universal installer: ERROR" --msgbox "Oh dear, a \"sanity check\" has failed.\nThis file: $SRCPATH/pup_$NEWVER.sfs\ndoes not exist.\nThe above is supposed to be path-to-where-puppy-files-are/pup_xxx.sfs\nwhere \"xxx\" is the latest version number.\nClick OK button to quit..." 0 0
exit
fi
#find out if puppy already on dest...
ispupfunc $DESTFS $DESTPART
#...sets PUPVEROLD.
#now to do the actual install...
case $FINALPMEDIA in
usbflash|usbhd|ideflash|idezip) #removable media, install with syslinux/extlinux
#26mar06 JustGreg fix mbr...
if [ ! "`echo "$DESTPART" | grep '[0-9]$'`" = "" ];then #superfloppy mode has no mbr.
MBRCHOICE="`Xdialog --left --title "Puppy Universal Installer" --no-cancel --stdout --menubox "The bootstrap loader code is missing from the MBR (Master Boot Record),\nmeaning that the USB drive will not boot. Please choose one of the\nfollowing to fix this. Personally, I have had success with mbr.bin." 0 0 4 sys-nopart.mbr "Bootstrap loader code, created by JustGreg" mbr.bin "From the Syslinux package" mbrfat.bin "From the makebootfat package" spb2_mbr.bin "From spblinux, created by Christian Ostheimer" `"
else
MBRCHOICE="`Xdialog --left --title "Puppy Universal Installer" --no-cancel --stdout --menubox "The MBR (Master Boot Record) in the USB drive is probably okay as-is, so choose\nthe first option. However, if you cannot get the drive to boot, and you are\nsure that the BIOS settings are not to blame and the PC is capable of booting\nfrom USB, then try one of these alternative MBRs.\nNote, if you choose to change the MBR, the old first 446 bytes (the\nbootstrap loader part) of the MBR will be backed up to /tmp/oldmbr.bin\nNote, you can install these MBRs directly, without running this\nInstaller program again: they are located in /usr/lib/syslinux,\nand you can use the dd program to copy them.\nExample: dd if=spb2_mbr.bin of=/dev/${DESTDRV}\nNote, personally I have had success with mbr.bin." 0 0 5 default "DO NOTHING, leave current MBR alone" sys-nopart.mbr "Bootstrap loader code, created by JustGreg" mbr.bin "From the Syslinux package" mbrfat.bin "From the makebootfat package" spb2_mbr.bin "From spblinux, created by Christian Ostheimer" `"
PARTCHOICE="`Xdialog --left --title "Puppy Universal Installer" --no-cancel --stdout --menubox "Please just accept the default here, 'JUST KEEP GOING'.\nPLEASE MAKE SURE TOP ENTRY HIGHLIGHTED THEN CLICK OK BUTTON\n\nHowever, if you have tried this Puppy Universal Installer\nbut Puppy will not boot, you can try one of the other choices here.\n\nPersonally, I have had success with using GParted to wipe and\nrecreate the partition..." 0 0 4 default "JUST KEEP GOING" GParted "Wipe and recreate USB/IDE-CF partition using GParted" syslinux "Make USB or IDE-CF msdos/vfat partition bootable"`"
#option1: files vmlinuz, initrd.gz, pup_xxx.sfs, to dest partition.
#option2: file vmlinuz to partition, contents of pup_xxx.sfs to partition.
if [ $PUPVEROLD -eq 0 ];then
PREVPUPMSG="It appears that this is a new installation."
else
PREVPUPMSG="There appears to be an existing installation of Puppy, version $PUPVEROLD,
and you may choose to upgrade or totally replace."
fi
INSTOPTION="1"
if [ ! "$DESTFS" = "vfat" ];then
Xdialog --left --buttons-style text --title "Puppy Universal Installer" --ok-label "NORMAL" --cancel-label "COEXIST" --yesno "You have chosen to install to /dev/$DESTPART, which appears to be an internal\nhard drive ($FINALPMEDIA).\n$PREVPUPMSG \n\nYou have two ways to install Puppy to the partition, either by what we call\n\"option1\", which means copy the files vmlinuz, initrd.gz, and pup_$NEWVER.sfs to the\npartition, leaving the previous contents of the partition untouched (good\nchoice if there is already another distro installed in the partition -- Puppy\ncan coexist with it, not interfere with it at all.\n\nOr, choose \"option2\" which is a \"normal\" Linux installation, requiring usage\nof the entire partition by Puppy. This choice is recommended by developers\n(anyone who wants to compile or develop/test applications for Puppy).\nIn fact, option2 is the recommended option for everyone, if the $DESTPART\npartition is available for Puppy to take over.\n\nNote, for option2 you can create either or both floppy/usb boot disk and/or\nh.d. Grub bootloader, but option1 only offers a floppy boot disk boot method.\nTHE OPTION1 BOOT DISK WILL ONLY BOOT PUPPY IN A FAT PARTITION!!!\n\nDo you want to install Puppy like a normal Linux distro (option2)?\n\nClick NORMAL button for normal Linux install (option2)...\nClick COEXIST button for coexist type of install (option1)...\nClick window close box to quit..." 0 0
#A floppy disk can be used to boot Puppy.\nPLEASE INSERT THE FLOPPY DISK RIGHT NOW.\n(anything on the floppy disk will be wiped)\nBE SURE THAT THE FLOPPY DISK IS NOT CURRENTLY MOUNTED." 0 0
Xdialog --left --title "Puppy Universal Installer" --ok-label "CREATE_BOOT_DISK" --cancel-label "NO_BOOT_DISK" --yesno "A floppy disk can be used to boot Puppy.\nCurrently we are offering WakePup2, a generic boot floppy\nthat scans the PC and finds where Puppy is installed." 0 0
if [ $? -eq 0 ];then
/usr/sbin/wakepup2
fi
else
Xdialog --left --title "Puppy Universal Installer" --msgbox "NOTICE: As you have installed to a partition with a $DESTFS filesystem,\nwhich is non-FAT, you cannot create a boot floppy disk. The only option\nleft is to manually setup your Grub or Lilo or other boot system. Note,\nthere are other boot floppy systems that can boot a non-FAT partition.\nNote, partition $DESTPART has the files vmlinuz, initrd.gz and\npup_$NEWVER.sfs on it, where vmlinuz is the kernel and initrd.gz is the\ninitial ramdisk. You should provide the boot parameter 'PMEDIA=idehd' if\n$DESTPART is an ide drive." 0 0
fi
#finished. could put up a final dlg here, then quit script.
Xdialog --left --buttons-style text --title "Puppy Universal Installer" --ok-label "UPGRADE" --cancel-label "WIPE" --yesno "There is already a version of Puppy installed in $DESTPART.\nDo you want to upgrade, or totally wipe the partition?\n\nFINAL SANITY CHECK: ARE YOU SURE $DESTPART IS THE RIGHT PARTITION?\n(note, $DESTPART is currently mounted on $DESTMNTPT -- okay?)\n\nSelect UPGRADE button to upgrade...\nSelect WIPE button to wipe partition...\nClick window Close box to quit..." 0 0
RET_VAL=$?
if [ $RET_VAL -eq 255 ];then
rox -D "$DESTMNTPT"
sync
umount $DESTMNTPT 2>/dev/null
exit
fi
if [ $RET_VAL -eq 1 ];then #no
Xdialog --title "Puppy Universal Installer" --no-buttons --infobox "Please wait, wiping all files in $DESTPART..." 0 0 50000 &
#TODO needs work, as could have usb hd, that cannot unplug and do not want it to be turned
# into a boot disk!...
Xdialog --left --buttons-style text --title "Puppy Universal Installer" --ok-label "Boot from USB" --cancel-label "Install GRUB" --yesno "If all went well, Puppy has been installed to $DESTPART.\n\
But, now we have the sometimes-difficult part, how to make Puppy bootable.\n\
You can do one, or both, of these:\n\
\n\
Boot disk: Use a floppy disk or USB pen drive to boot Puppy.\n\
GRUB: Install GRUB in the hard drive.\n\
\n\
If you already have GRUB installed in the hard drive, you can choose the\n\
GRUB option here and reinstall it with Puppy added to the boot menu.\n\
\n\
Click 'Boot from USB' if you want to sacrifice a usb Flash pen drive as a\n\
'boot disk'. This Universal Installer script will return to this dialog\n\
window after creating the USB 'boot disk'.\n\
Note, you would probably only choose this if your PC does not have a floppy\n\
drive and you do not want to install GRUB to the hard drive.\n\
\n\
Click 'Install GRUB' to install the GRUB boot manager. You will be given the\n\
opportunity to create a floppy 'boot disk' as well as install GRUB to the\n\
hard drive.\n\
\n\
FOR USB BOOT DISK CHOICE, PLEASE INSERT IT RIGHT NOW BEFORE PROCEEDING!\n\
(any files in it will be deleted)\n\
IT MUST ALSO BE UNMOUNTED -- BE SURE BEFORE PROCEEDING" 0 0
Xdialog --left --title "Puppy Universal Installer" --yesno "Please confirm that you want to make '$BOOTPART' into a boot disk for Puppy.\nNote, be extremely careful here if you have a USB hard drive or SATA hard\ndrive, as these have the same 'sd' device notation as a removable Flash pen\ndrive. If Puppy has mis-identified the device, then answer 'No' here...\n\nClick 'Yes' button if correct device..." 0 0
Xdialog --left --title "Puppy Universal Installer" --msgbox "The \"grubconfig\" script is about to be executed.\nJust accept the defaults. The very first question will ask if you\nwant to do a simple installation, and you accept that option, which\nis the default. The only place where I suggest you deviate from the\ndefault, is when it asks where to install Grub, choose \"MBR\"." 0 0
unmountcdfunc
while [ 1 ];do
grubconfig /dev/$DESTPART
#...if choose to create a boot floppy, writes 'no' to /tmp/loopbrk.txt.
Xdialog --title "Universal Installer" --yesno "If you have already run grubconfig to create a boot floppy or installed\n\
to h.d., click 'Yes' button to rerun grubconfig script to either create\n\
another boot floppy or install or reinstall GRUB to the hard drive.\n\
If choose 'Yes', just accept all the defaults as before.\n\
\n\
Click 'Yes' to rerun grubconfig...\n\
Click 'No' if installation finished..." 0 0
[ ! $? -eq 0 ] && break
done
rm -f /tmp/loopbrk.txt
exit
fi
Xdialog --title "Puppy Universal Installer" --yesno "Do you want to go back and create another boot disk or Grub boot?..." 0 0