#!/bin/bash
#(c) Copyright Barry Kauler July 2017, barryk.org
#Licence GPL3 (refer: /usr/share/doc/legal).
#170722 based on second half of previous install-quirky-to-drive
#170727 path fix.
#171109 non-english fdisk breaks script.

#note, exported from installquirky: RXVTEXE ATADRIVES Qarch Qfw. ex: Qarch=amd64 Qfw=UEFI
export TEXTDOMAIN=installquirky
export OUTPUT_CHARSET=UTF-8
[ ! "$RXVTEXE" ] && RXVTEXE='urxvt'
[ ! "$Qfw" ] && Qfw="UEFI"
[ ! "$Qarch" ] && Qarch="amd64"

INSTMODE="drive"
INSTMODEtr="$(gettext 'drive')"
REQDSPACE=1200
#151202 passed param...
MODE='full'
[ $1 ] && MODE="$1" #frugal
RUNNING="user"

###source files###
if [ -e ./get-quirky-src ];then #170727
. ./get-quirky-src
else
 if [ -e /usr/local/install_quirky/get-quirky-src ];then
. /usr/local/install_quirky/get-quirky-src
 fi
fi
#...exit with MNTPTsrc path to quirky source files vmlinuz, initrd.q, q.sfs
#...also current dir set to $TMPWKG_MNTPT

###choose target drive###
if [ "$Qfw" == "UEFI" ];then
 M_m1="$(gettext "That is, any modern computer (post-2011) with <span fgcolor='#A000A0'><b>UEFI firmware</b></span> (note that legacy-mode (CSM) does <i>not</i> have to be enabled in the UEFI-Setup). The drive will <i><b>also</b></i> boot on older PCs with <span fgcolor='#A000A0'><b>BIOS firmware</b></span>.")"
else
 M_m1="$(gettext "That is, any computer with at least a i686 CPU, with any version of Windows from XP to 7 installed on it, with BIOS firmware. Or, to a modern computer (post-2011) with UEFI firmware <span fgcolor='#A000A0'>with <b>BIOS legacy-boot (CSM)</b> enabled</span> in the UEFI-Setup.")"
fi
while [ true ];do
 export IQ_DLGc="<window title=\"$(gettext "Quirky Installer: drive")\" icon-name=\"gtk-convert\">
 <vbox>
  <text><label>$(gettext 'The Quirky Installer will download and install Quirky to an entire drive, and make it bootable with the Syslinux boot manager, for any desktop PC or laptop.')</label></text>
  <text use-markup=\"true\"><label>\"${M_m1}\"</label></text>
  <text><label>$(gettext 'The intention is to install to pluggable memory drives such as USB Flash sticks and SD-cards. The entire drive is erased, so take off any files that you want to keep.')</label></text>
  <frame $(gettext 'Plug in drive now')>
   <text use-markup=\"true\"><label>\"<b>$(gettext 'Plug in the drive that you intend to install to, right now')</b>\"</label></text>
   <text use-markup=\"true\"><label>\"$(gettext 'A USB Flash stick is recommended, <b>4GB</b> size, or greater.')\"</label></text>
   <text use-markup=\"true\"><label>\"$(gettext 'Note, 4GB is sufficient, however for a satisfactory ongoing experience using Quirky, it is recommended to use a <b>8GB</b> or greater drive. If you intend to keep using this installation on a daily basis, to allow for plenty of package installations, upgrades, downloads, etc., or installation of the <i>devx</i> PET, it is essential to have at least 8GB.')\"</label></text>
   <text use-markup=\"true\"><label>\"$(gettext 'Have you plugged in the drive? Then click <b>CONTINUE</b> button:')\"</label></text>
  </frame>
  <hbox>
   <button><label>$(gettext 'CONTINUE')</label><action type=\"exit\">continue</action></button>
   <button cancel></button>
  </hbox>
 </vbox>
 </window>"
 RETSTRINGc="$(${PRE}gtkdialog --program=IQ_DLGc --center)"
 [ $? -ne 0 ] && exit
 eval "$RETSTRINGc"
 [ "$EXIT" != "continue" ] && exit
 DRIVEitems="$(${PRE}probedisk | ${PRE}busybox grep -v '|optical|' | ${PRE}busybox sed -e 's%^/dev/%%' -e 's%|% TYPE:%' -e 's%|% DESCRIPTION:%' -e 's%^%<item>%' -e 's%$%</item>%' -e 's%^<item></item>%<item>nothing found</item>%')"
 export IQ_DLGd="<window title=\"$(gettext "Quirky Installer: drive")\" icon-name=\"gtk-convert\">
 <vbox>
  <text><label>$(gettext 'As your drive has been plugged-in, it should be offered in the drop-down list below. If not, something is wrong, so click the Back button.')</label></text>
  <frame $(gettext 'Choose drive')>
   <text use-markup=\"true\"><label>\"<b>$(gettext 'Choose drive to install to:')</b>\"</label></text>
   <text><label>$(gettext 'Please be careful to choose the correct drive.')</label></text>
   <combobox><variable>COMBOd</variable>${DRIVEitems}</combobox>
  </frame>
  <hbox>
   <button><label>$(gettext 'Back')</label><action type=\"exit\">back</action></button>
   <button><label>$(gettext 'CONTINUE')</label><action type=\"exit\">continue</action></button>
   <button cancel></button>
  </hbox>
 </vbox>
 </window>"
 RETSTRINGd="$(${PRE}gtkdialog --program=IQ_DLGd --center)"
 [ $? -ne 0 ] && exit
 eval "$RETSTRINGd"
 [ "$EXIT" == "back" ] && continue
 [ "$EXIT" != "continue" ] && exit
 TARGETDRIVE="$(${PRE}busybox echo -n "$COMBOd" | ${PRE}busybox cut -f 1 -d ' ')"
 #make sure it is unmounted:
 MNTD="$(${PRE}busybox mount | ${PRE}busybox grep "^/dev/${TARGETDRIVE}" | ${PRE}busybox cut -f 1 -d ' ')"
 if [ "$MNTD" ];then
  for aMNTD in $MNTD
  do
   [ "$aMNTD" == "" ] && continue
   ${PRE}busybox umount $aMNTD
   if [ $? -ne 0 ];then
    errTITLE="$(gettext 'ERROR, partition mounted:') ${aMNTD}"
    errMSG="$(gettext 'The partition is mounted, and cannot unmount it. You need to unmount it and try again.')"
    ${PRE}popup "level=top background=#FF8080 terminate=ok|<b>${errTITLE}</b>${CR}${errMSG}"
    continue 2
   fi
  done
 fi
 #150330 Check that fdisk/gdisk utility is working...
 FDISK='fdisk'
 [ "$Qfw" == "UEFI" ] && FDISK='gdisk'
 GDCHK="$(LANG=C ${PRE}${FDISK} -l /dev/${TARGETDRIVE} 2>/dev/null | ${PRE}busybox grep '^Disk identifier')" #171109
 if [ "$GDCHK" = "" ];then
  errTITLE="$(gettext 'Drive:') ${TARGETDRIVE}"
  errMSG="$(gettext 'Unable to read this drive. Perhaps you should try a different drive.')"
  ${PRE}popup "level=top background=#FF8080 terminate=ok|<b>${errTITLE}</b>${CR}${errMSG}"
  continue
 fi
 break
done

###copy files to working-area###
${PRE}busybox cp -a -f ${MNTPTsrc}/q.sfs ./
${PRE}busybox cp -a -f ${MNTPTsrc}/initrd.q ./
${PRE}busybox cp -a -f ${MNTPTsrc}/vmlinuz ./
${PRE}busybox cp -a -f ${MNTPTsrc}/logo.16 ./
${PRE}busybox sync
${PRE}busybox umount ${MNTPTsrc}
#${PRE}busybox rmdir ${MNTPTsrc}
IMGFILE='q.sfs'

echo "Some preliminaries on the ${TARGETDRIVE}..."
FDISKINFO="$(LANG=C ${PRE}fdisk -l /dev/${TARGETDRIVE} 2>/dev/null)" #150330 leave as fdisk, for UEFI also. 171109
SIZEBYTES=`${PRE}busybox echo "$FDISKINFO" | ${PRE}busybox grep '^Disk /dev' | ${PRE}busybox cut -f 5 -d ' '` #141104
SIZEKB=`${PRE}busybox expr $SIZEBYTES \/ 1024`
SIZEM=`${PRE}busybox expr $SIZEKB \/ 1024`
SHORT20M=`${PRE}busybox expr $SIZEM - 20`
SHORT5BLOCKS=`${PRE}busybox expr $SHORT20M \/ 4`
echo "Size of drive=${SIZEM}MB"
${PRE}busybox killall popup

#150402 test have mkfs.ext4:
MKEXT4=0
[ `${PRE}busybox which mkfs.ext4` ] && MKEXT4=1
#150401 test kernel supports f2fs:
F2FS=0
[ "$(${PRE}busybox grep 'f2fs' /proc/filesystems)" != "" ] && F2FS=1
[ $F2FS -eq 0 ] && modinfo f2fs 2>/dev/null && F2FS=1 #cannot use busybox modinfo, it is broken.
if [ $F2FS -eq 0 ];then
 if [ $MKEXT4 -eq 1 ];then
  COMBO_FS_XML="<text use-markup=\"true\"><label>\"$(gettext 'Please choose whether to create a ext2 or ext4 filesystem in the second partition. For Flash media, <span fgcolor='#FF0000'><b>f2fs</b> is very highly recommended, however the Linux kernel currently running does not support f2fs</span>. This is most unfortunate, you must be running an older Linux distribution.')\"</label></text>
  <combobox><variable>COMBOf</variable><item>ext4-without-journal (2nd best choice for Flash)</item><item>ext2</item><item>ext4 with journal (recommended for hard drives)</item></combobox>"
 else
  COMBO_FS_XML="<text use-markup=\"true\"><label>\"$(gettext 'Please choose whether to create a ext2 or ext4 filesystem in the second partition. For Flash media, <span fgcolor='#FF0000'><b>f2fs</b> is very highly recommended, however the Linux kernel currently running does not support f2fs</span>. This is most unfortunate, you must be running an older Linux distribution.')\"</label></text>
  <text use-markup=\"true\"><label>\"$(gettext '<span fgcolor='#FF0000'><b>You do not even have the mkfs.ext4 utility, so cannot offer ext4 filesystem</b></span>')\"</label></text>
  <combobox><variable>COMBOf</variable><item>ext2</item></combobox>"
 fi
else
 if [ $MKEXT4 -eq 1 ];then
  COMBO_FS_XML="  <text><label>$(gettext 'Please choose whether to create a ext2, ext4, or f2fs filesystem in the second partition. For Flash media, f2fs is very highly recommended.')</label></text>
  <combobox><variable>COMBOf</variable><item>f2fs (best choice for Flash)</item><item>ext4-without-journal (2nd best choice for Flash)</item><item>ext2</item><item>ext4 with journal (recommended for hard drives)</item></combobox>"
 else
  COMBO_FS_XML="  <text><label>$(gettext 'Please choose whether to create a ext2, ext4, or f2fs filesystem in the second partition. For Flash media, f2fs is very highly recommended.')</label></text>
  <text use-markup=\"true\"><label>\"$(gettext '<span fgcolor='#FF0000'><b>You do not have the mkfs.ext4 utility, so cannot offer ext4 filesystem</b></span>')\"</label></text>
  <combobox><variable>COMBOf</variable><item>f2fs (best choice for Flash)</item><item>ext2</combobox>"
 fi
fi

export IQ_DLGe="<window title=\"$(gettext "Quirky Installer: drive")\" icon-name=\"gtk-convert\">
<vbox>
 <text use-markup=\"true\"><label>\"<b>$(gettext 'Final sanity check, is this correct?:') <big>${TARGETDRIVE}</big></b>\"</label></text>
 <text><label>$(gettext 'Drive details:') ${COMBOd} $(gettext 'Size:') ${SIZEM}MB</label></text>
 <frame $(gettext 'Zeroize')>
  <text><label>$(gettext 'Would you like to zeroize the entire drive before installation?')</label></text>
  <text><label>$(gettext 'You should tick the checkbox if you choose to make a image-file of the drive immediately after installation (this script will later offer to do that) -- an image-file is useful for writing to other drives, or to give to others. Zeroizing beforehand will make the image-file smaller.')</label></text>
  <text><label>\"$(gettext 'NOTES:')${CR}$(gettext 'Zeroizing may take over 30 minutes, depending on size of drive.')
$(gettext 'Do not do this with a USB1 interface or via a USB-hub (too slow).')
$(gettext 'Unless you really need to do this, recommend do not tick checkbox.')\"</label></text>
  <checkbox><variable>CHK_ZERO</variable><label>$(gettext 'Zeroize entire drive')</label></checkbox>
 </frame>
 
 <frame $(gettext 'Filesystem')>
  <text><label>$(gettext 'The drive will be formatted with two partitions, the first with a FAT filesystem, with bootup files, the second will contain the Quirky installation.')</label></text>
  ${COMBO_FS_XML}
 </frame>
 
 <hbox>
  <button><label>$(gettext 'CONTINUE')</label><action type=\"exit\">continue</action></button>
  <button cancel></button>
 </hbox>
</vbox>
</window>"
RETSTRINGe="$(${PRE}gtkdialog --program=IQ_DLGe --center)"
[ $? -ne 0 ] && exit
eval "$RETSTRINGe"
[ "$EXIT" != "continue" ] && exit

###preliminary###
${PRE}popup "name=format writemode=append-newline level=top background='#FF8000'|<b>$(gettext 'Formatting drive:') ${TARGETDRIVE}</b>${CR}$(gettext 'Please wait...')"
if [ "$CHK_ZERO" == "true" ];then
 ${PRE}popadd "name=format|$(gettext 'Please wait, zeroizing entire drive...')"
 QTRM=`expr $SIZEM \/ 4`
 ${PRE}busybox dd if=/dev/zero of=/dev/${TARGETDRIVE} bs=4M conv=fsync #no, make sure writes right to end. count=${QTRM}
 ${PRE}busybox sync
else
 ${PRE}popadd "name=format|$(gettext 'Please wait, zeroizing part of drive...')"
 ${PRE}popadd "name=format|$(gettext 'It is necessary to zeroize a small part of the drive, the beginning and the end. The end, because if the drive previously had a GPT secondary partition table on it, this has to be wiped.')"
 ${PRE}popadd "name=format|$(gettext 'Zeroizing only first 20MB and last 20MB of drive...')"
 ${PRE}busybox dd if=/dev/zero of=/dev/${TARGETDRIVE} bs=4M count=5 conv=fsync
 ${PRE}busybox sync
 ${PRE}busybox dd if=/dev/zero of=/dev/${TARGETDRIVE} bs=4M seek=${SHORT5BLOCKS} conv=fsync 2> /dev/null
 #...reason is if drive has previously had a GPT on it, the secondary-GPT at end of drive confuses fdisk.
 ${PRE}busybox sync
fi

#create first partition:
if [ "$PRE" == "" ];then
 SLPATH='/usr/share/syslinux/'
else
 SLPATH="${PRE}syslinux6/" #150408
fi
if [ "$Qfw" == "UEFI" ];then
 M_345="$(gettext 'Creating 512MB FAT32 first partition...')"
 M_367="$(gettext 'Creating GUID partition table...')"
 MBRBIN=${SLPATH}gptmbr.bin
else
 M_345="$(gettext 'Creating 16MB FAT16 first partition...')"
 M_367="$(gettext 'Creating DOS partition table...')"
 MBRBIN=${SLPATH}mbr.bin
fi
${PRE}popadd "name=format background='#FFA000'|${M_345}"
PARTNUM1="1"
PARTNUM2="2"
if [ "`${PRE}busybox echo -n "$TARGETDRIVE" | ${PRE}busybox grep 'mm'`" != "" ];then
 PARTNUM1="p1"
 PARTNUM2="p2"
fi

###create 16MB FAT-16 first partition###
${PRE}popadd "name=format background='#FFC000'|${M_367}"

if [ "$Qfw" == "UEFI" ];then #150330
 ${PRE}busybox echo "New gpt (GUID partition table) for /dev/${TARGETDRIVE}:" > /tmp/installquirkygdisk.log
 ${PRE}busybox echo -e 'o\nY\nw\nY\n' | ${PRE}gdisk /dev/${TARGETDRIVE} >> /tmp/installquirkygdisk.log 2>&1
 ${PRE}busybox sync
 echo "Writing ${MBRBIN}" >> /tmp/installquirkygdisk.log
 ${PRE}busybox dd bs=440 conv=notrunc count=1 if=${MBRBIN} of=/dev/${TARGETDRIVE}
else
 #o=create new dos partition table... 141103...
 ${PRE}busybox echo -e 'o\nw\n' | ${PRE}fdisk /dev/${TARGETDRIVE} > /tmp/installquirkyfdisk.log 2>&1
 #write mbr...
 ${PRE}busybox sync #150104
 ${PRE}busybox dd bs=440 conv=notrunc count=1 if=${MBRBIN} of=/dev/${TARGETDRIVE}
fi
${PRE}busybox sync

#create first partition...
if [ "$Qfw" == "UEFI" ];then #150330
 #create a partition... 2048=first sector, size 512MB... also ef00 is efi filesystem...
 ${PRE}busybox echo "Create 512MB esp partition:" >> /tmp/installquirkygdisk.log
 ${PRE}busybox echo -e 'n\n1\n2048\n+512M\nef00\nw\nY\n' | ${PRE}gdisk /dev/${TARGETDRIVE} >> /tmp/installquirkygdisk.log 2>&1
 ${PRE}busybox sync
 #set the boot flag... 141104 0=system partition, 2=legacy bios bootable. 150324 choose 2
 #150324 select x (expert), a (attributes), partition number 1, toggle attribute field 2 (legacy_boot), enter again to exit, write, confirm exit:
 ${PRE}busybox echo "Set legacy_boot flag of esp (log to /tmp/installquirkygdisk.log)"
 ${PRE}busybox echo "Set legacy_boot flag of esp:" >> /tmp/installquirkygdisk.log
 #150324 doesn't make any sense, but somehow this is setting both 1=hide-from-efi and 2=legacy_boot flags:
 # haha, i know, it doesn't ask for partition# coz at this stage there is only one:
 #busybox echo -e 'x\na\n1\n2\n\nw\nY' | gdisk /dev/${TARGETDRIVE} >> /tmp/installquirkygdisk.log 2>&1
 ${PRE}busybox echo -e 'x\na\n2\n\nw\nY' | ${PRE}gdisk /dev/${TARGETDRIVE} >> /tmp/installquirkygdisk.log 2>&1
 ${PRE}busybox sync
 #create a fat32 f.s....
 #${PRE}busybox mkdosfs -F 32 -n quirky1 /dev/${TARGETDRIVE}${PARTNUM1} #FAT32.
 ${PRE}mkfs.fat -F 32 -n quirky1 /dev/${TARGETDRIVE}${PARTNUM1} #FAT32. 150417
else
 #create a partition... 2048=first sector, size 16MB...
 ${PRE}busybox echo -e 'n\np\n1\n2048\n+16M\nw\n' | ${PRE}fdisk /dev/${TARGETDRIVE} >> /tmp/installquirkyfdisk.log 2>&1
 ${PRE}busybox sync
 #set partition-id to fat16 (06=fat16, 0e=fat16-lba)...
 ${PRE}busybox echo -e 't\n06\nw' | ${PRE}fdisk /dev/${TARGETDRIVE} >> /tmp/installquirkyfdisk.log 2>&1 #will default to 1st partition, as that all exists.
 ${PRE}busybox sync
 #set the boot flag...
 ${PRE}busybox echo -e 'a\n1\nw' | ${PRE}fdisk /dev/${TARGETDRIVE} >> /tmp/installquirkyfdisk.log 2>&1
 ${PRE}busybox sync
 #create a fat16 f.s....
 #${PRE}busybox mkdosfs -F 16 -n quirky1 /dev/${TARGETDRIVE}${PARTNUM1} #FAT16.
 ${PRE}mkfs.fat -F 16 -n quirky1 /dev/${TARGETDRIVE}${PARTNUM1} #FAT16. 150417
fi
${PRE}busybox sync

#install syslinux...
if [ "$Qfw" == "UEFI" ];then #150330
 #syslinux efi files, for uefi booting, have to be copied in:
 ${PRE}busybox mkdir -p /mnt/${TARGETDRIVE}${PARTNUM1}
 ${PRE}busybox mount -t vfat /dev/${TARGETDRIVE}${PARTNUM1} /mnt/${TARGETDRIVE}${PARTNUM1}
 ${PRE}busybox mkdir -p /mnt/${TARGETDRIVE}${PARTNUM1}/EFI/BOOT
 #cp ${SLPATH}/efi32/ldlinux.e32 /mnt/${TARGETDRIVE}${PARTNUM1}/EFI/BOOT/
 #cp ${SLPATH}/efi32/syslinux.efi /mnt/${TARGETDRIVE}${PARTNUM1}/EFI/BOOT/BOOTIA32.EFI
 ${PRE}busybox cp ${SLPATH}/efi64/ldlinux.e64 /mnt/${TARGETDRIVE}${PARTNUM1}/EFI/BOOT/
 ${PRE}busybox cp ${SLPATH}/efi64/syslinux.efi /mnt/${TARGETDRIVE}${PARTNUM1}/EFI/BOOT/BOOTX64.EFI
 ${PRE}busybox sync
 ${PRE}busybox umount /mnt/${TARGETDRIVE}${PARTNUM1}
 #despite where we are installing, this is for bios booting: 150325 no, put into / ...
 #syslinux --directory EFI/BOOT --install /dev/${TARGETDRIVE}${PARTNUM1} #need --install for 4.05+.
 ${PRE}syslinux --install /dev/${TARGETDRIVE}${PARTNUM1}
else
 ${PRE}popadd "name=format background='#EFD000'|$(gettext 'Installing syslinux in 1st partition,') ${TARGETDRIVE}${PARTNUM1}..."
 ${PRE}syslinux --install /dev/${TARGETDRIVE}${PARTNUM1} #need --install for 4.05.
fi
${PRE}busybox sync

###create 2nd partition###
#calculate a suitable size for 2nd partition...
#this free space at end is to allow us to create a flash-drive-image from the drive, for others to use. other drives may have slightly different actual sizes.
SPACEM=10240; NOMINALG='256'
if [ $SIZEM -lt 131072 ];then
 SPACEM=5120
 NOMINALG='128'
fi
if [ $SIZEM -lt 65536 ];then
 SPACEM=2560 #under 64GB
 NOMINALG='64'
fi
if [ $SIZEM -lt 32768 ];then
 SPACEM=1280 #under 32GB
 NOMINALG='32'
fi
if [ $SIZEM -lt 16384 ];then
 SPACEM=640 #under 16GB
 NOMINALG='16'
fi
if [ $SIZEM -lt 8192 ];then
 SPACEM=320 #under 8GB ex: an "8GB" drive will be here
 NOMINALG='8'
fi
if [ $SIZEM -lt 4096 ];then
 SPACEM=160 #under 4GB
 NOMINALG='4'
fi
if [ $SIZEM -lt 2048 ];then
 SPACEM=80 #under 2GB
 NOMINALG='2'
fi
if [ $SIZEM -lt 1500 ];then
 killall popup
 ${PRE}popup "level=top background='#FF8080' terminate=ok|<b>$(gettext 'Drive size:') ${SIZEM}MB</b>${CR}$(gettext 'Drive is too small, aborting.')"
 #popadd 'name=format terminate=now|'
 exit
fi

#create second partition...
if [ "$Qfw" == "UEFI" ];then #150330
 SMALLER0M=`${PRE}busybox expr $SIZEM - $SPACEM` #some empty space at end of drive.
 SMALLERM=`${PRE}busybox expr $SMALLER0M - 520` #take off size of 1st partition plus gaps 512+8
 ONE8TH=`${PRE}busybox expr $SMALLERM \/ 8`
 FINALM=`${PRE}busybox expr $ONE8TH \* 8`
 #create a partition, 49152=start sector, +${FINALM}M size
 #141104 1st partition now 512MB (was 16) (starts sector 2048 (1MB), next free is sector 1050624),
 #       leave 7MB gap, second partition starts sector 1064960...
 #       8300 is Linux filesystem...
 ${PRE}popadd "name=format|$(gettext 'Creating 2nd partition, size:') ${FINALM}MB..."
 ${PRE}busybox echo -e "n\n2\n1064960\n+${FINALM}M\n8300\nw\nY" | ${PRE}gdisk /dev/${TARGETDRIVE} >> /tmp/installquirkygdisk.log 2>&1
else
 SMALLERM=`${PRE}busybox expr $SIZEM - $SPACEM` #some empty space at end of drive.
 ONE8TH=`${PRE}busybox expr $SMALLERM \/ 8`
 FINALM=`${PRE}busybox expr $ONE8TH \* 8`
 #create a partition, 49152=start sector, +${FINALM}M size
 ${PRE}popadd "name=format|$(gettext 'Creating 2nd partition, size:') ${FINALM}MB..."
 ${PRE}busybox echo -e "n\np\n2\n49152\n+${FINALM}M\nw\n" | ${PRE}fdisk /dev/${TARGETDRIVE} >> /tmp/installquirkyfdisk.log 2>&1
 ${PRE}busybox sync
 #set partition-id to Linux...
 ${PRE}busybox echo -e 't\n2\n83\nw' | ${PRE}fdisk /dev/${TARGETDRIVE} >> /tmp/installquirkyfdisk.log 2>&1
fi
${PRE}busybox sync

#second partition filesystem
TARGETFS="$(${PRE}busybox echo "$COMBOf" | cut -f 1 -d ' ')"
${PRE}popadd "name=format background='#DFE000'|$(gettext 'Creating filesystem in second partition. Type:') ${TARGETFS}..."
case $TARGETFS in
 ext2) ${PRE}busybox mkfs.ext2 -m 0 -L quirky2 /dev/${TARGETDRIVE}${PARTNUM2} ;;
 ext4) mkfs.ext4 -m 0 -L quirky2 /dev/${TARGETDRIVE}${PARTNUM2} ;;
 ext4-without-journal)
  mke2fs -t ext4 -O ^has_journal -L quirky2 -m 0 -b 4096 /dev/${TARGETDRIVE}${PARTNUM2}
  TARGETFS="ext4"
 ;;
 *)
  if [ "$PRE" ];then
   #LD_PRELOAD=${PRE}libf2fs.so.0 ${PRE}mkfs.f2fs -l quirky2 /dev/${TARGETDRIVE}${PARTNUM2}
   #LD_PRELOAD=${LIBF2FS} ${PRE}mkfs.f2fs -l quirky2 /dev/${TARGETDRIVE}${PARTNUM2} #150417
   ${PRE}mkfs.f2fs -l quirky2 /dev/${TARGETDRIVE}${PARTNUM2} #151004
  else
   mkfs.f2fs -l quirky2 /dev/${TARGETDRIVE}${PARTNUM2}
  fi
 ;;
esac
sync

###populate target drive###
${PRE}popadd "name=format background='#CFF000'|$(gettext 'Populating the partitions...')" #150929 fix.
${PRE}busybox mkdir -p mntpt
${PRE}busybox mount -t squashfs -o loop,ro ${IMGFILE} mntpt #140111 ro
if [ $? -ne 0 ];then
 ${PRE}busybox killall popup
 ${PRE}popup "level=top background='#FF8080' terminate=ok|<b>$(gettext 'Mounting file:') ${IMGFILE}</b>${CR}$(gettext 'Error mounting file, aborting.')"
 #popadd 'name=format terminate=now|'
 ${PRE}busybox rm -f ${IMGFILE}
 exit_func 1
fi
TARGETVERSION="$(${PRE}busybox grep '^DISTRO_VERSION=' mntpt/etc/DISTRO_SPECS | ${PRE}busybox cut -f 2 -d '=' | ${PRE}busybox cut -f 2 -d "'" | ${PRE}busybox cut -f 1 -d ' ')" #'ex: 6.0.1

${PRE}popadd "name=format|$(gettext 'Populating 1st partition,') ${TARGETDRIVE}${PARTNUM1}..."
if [ "$Qfw" == "UEFI" ];then #150330
 #have to run this again, as DISKUUID (NT disk signature) has changed after mbr installed...
 #141104 use gdisk, now Disk indentifier is GUID, but we need GUID of 2nd partition...
 #141104 ref: http://www.linux.com/learn/tutorials/730440-using-the-new-guid-partition-table-in-linux-good-bye-ancient-mbr-
 #141104 ref: http://unix.stackexchange.com/questions/93767/why-cant-i-specify-my-root-fs-with-a-uuid
 #141104 ref: http://archives.gentoo.org/gentoo-user/msg_35eb3187ef8be8a23cdec253b66b5a59.xml
 #141104 i=show detailed information on a partition, 2=2nd partition, q=quit:
 GDISKINFO2="$(${PRE}busybox echo -e 'i\n2\nq' | ${PRE}gdisk /dev/${TARGETDRIVE} 2>/dev/null)"
 DISKUUID2="$(${PRE}busybox echo "$GDISKINFO2" | ${PRE}busybox grep '^Partition unique GUID:' | ${PRE}busybox tr -s ' ' | ${PRE}busybox cut -f 4 -d ' ')" #ex: 054B918C-CC12-4D29-85F6-039A91B391AA
 ${PRE}busybox mkdir -p /mnt/${TARGETDRIVE}${PARTNUM1}
 ${PRE}busybox mount -t vfat /dev/${TARGETDRIVE}${PARTNUM1} /mnt/${TARGETDRIVE}${PARTNUM1}
 if [ $? -ne 0 ];then
  ${PRE}busybox killall popup
  ${PRE}popup "level=top background='#FF8080' terminate=ok|<b>$(gettext 'Mounting first partition:') ${TARGETDRIVE}${PARTNUM1}</b>${CR}$(gettext 'Error mounting first partition, aborting.')"
  exit_func 1
 fi
 #150324 now copy to EFI/BOOT... 150325 revert...
 #cp -a mntpt/boot/syslinux/* /mnt/${TARGETDRIVE}${PARTNUM1}/EFI/BOOT/
 ${PRE}busybox cp -a mntpt/boot/syslinux/* /mnt/${TARGETDRIVE}${PARTNUM1}/
 ${PRE}busybox echo "PARTUUID of 2nd partition written to syslinux.cfg in 1st partition."
 PTN1="s%INSERTPARTID%${DISKUUID2}%" #141104
 #sed -i -e "${PTN1}"  /mnt/${TARGETDRIVE}${PARTNUM1}/EFI/BOOT/syslinux.cfg
 ${PRE}busybox sed -i -e "${PTN1}"  /mnt/${TARGETDRIVE}${PARTNUM1}/syslinux.cfg
 #150326 have removed "video=640x480" from built-in kernel, do it here (but not for efi):
 #150918 using my 64-bit kernel with 32-bit software booting on bios laptop, this causes problem, remove...
 #${PRE}busybox sed -i -e 's%^append %append video=640x480 %' /mnt/${TARGETDRIVE}${PARTNUM1}/syslinux.cfg
 ${PRE}busybox sync
 
 #160419 not there in iso...
 #${PRE}busybox cp -a mntpt/boot/vmlinuz /mnt/${TARGETDRIVE}${PARTNUM1}/
 ${PRE}busybox cp -a ${TMPWKG_MNTPT}/vmlinuz /mnt/${TARGETDRIVE}${PARTNUM1}/ #current dir should be $TMPWKG_MNTPT anyway.
 
 #150325 copy syslinux.cfg for efi boot:
 ${PRE}busybox cp -a mntpt/boot/syslinux/* /mnt/${TARGETDRIVE}${PARTNUM1}/EFI/BOOT/
 ${PRE}busybox sed -i -e "${PTN1}"  /mnt/${TARGETDRIVE}${PARTNUM1}/EFI/BOOT/syslinux.cfg
 ${PRE}busybox sed -i -e 's% vmlinuz% ../../vmlinuz%' /mnt/${TARGETDRIVE}${PARTNUM1}/EFI/BOOT/syslinux.cfg
 ${PRE}busybox sync
 ${PRE}busybox umount /mnt/${TARGETDRIVE}${PARTNUM1}
else
 #have to run this again, as DISKUUID (NT disk signature) has changed after mbr installed...
 FDISKINFO="$(LANG=C ${PRE}fdisk -l /dev/${TARGETDRIVE} 2>/dev/null)" #171109
 DISKUUID="$(${PRE}busybox echo "$FDISKINFO" | ${PRE}busybox grep '^Disk identifier:' | ${PRE}busybox tr -s ' ' | ${PRE}busybox cut -f 3 -d ' ' | ${PRE}busybox sed -e 's%^0x%%')" #ex: 2669a57d
 ${PRE}busybox mkdir -p /mnt/${TARGETDRIVE}${PARTNUM1}
 ${PRE}busybox mount -t vfat /dev/${TARGETDRIVE}${PARTNUM1} /mnt/${TARGETDRIVE}${PARTNUM1}
 if [ $? -ne 0 ];then
  ${PRE}busybox killall popup
  ${PRE}popup "level=top background='#FF8080' terminate=ok|<b>$(gettext 'Mounting first partition:') ${TARGETDRIVE}${PARTNUM1}</b>${CR}$(gettext 'Error mounting first partition, aborting.')"
  exit_func 1
 fi
 ${PRE}busybox cp -a mntpt/boot/syslinux/* /mnt/${TARGETDRIVE}${PARTNUM1}/
 ${PRE}popadd "name=format|$(gettext 'PARTUUID of 2nd partition written to syslinux.cfg in 1st partition.')"
 PTN1="s%INSERTPARTID%${DISKUUID}-02%"
 ${PRE}busybox sed -i -e "${PTN1}"  /mnt/${TARGETDRIVE}${PARTNUM1}/syslinux.cfg
 #150326 have removed "video=640x480" from built-in kernel, do it here: 150929 removed:
 #${PRE}busybox sed -i -e 's%^append %append video=640x480 %' /mnt/${TARGETDRIVE}${PARTNUM1}/syslinux.cfg
 ${PRE}busybox sync

 #160419 not there in iso...
 ${PRE}busybox cp -a mntpt/boot/vmlinuz /mnt/${TARGETDRIVE}${PARTNUM1}/
 ${PRE}busybox cp -a ${TMPWKG_MNTPT}/vmlinuz /mnt/${TARGETDRIVE}${PARTNUM1}/ #current dir should be $TMPWKG_MNTPT anyway.

 ${PRE}busybox sync
 ${PRE}busybox umount /mnt/${TARGETDRIVE}${PARTNUM1}
fi

#151202 hack 1st partition for frugal install (has q.sfs in 2nd partition, want initrd.q in 1st)...
if [ "$MODE" == "frugal" ];then
 ${PRE}busybox mount -t vfat /dev/${TARGETDRIVE}${PARTNUM1} /mnt/${TARGETDRIVE}${PARTNUM1}
 #no, do not open up initrd.q, instead pass "install_specs" on isolinix.cfg commandline...
 #${PRE}busybox mkdir ${TMPWKG_MNTPT}/initrd-tree
 #cd ${TMPWKG_MNTPT}/initrd-tree #no busybox 'cd' applet.
 #${PRE}busybox cat ${TMPWKG_MNTPT}/initrd.q | ${PRE}busybox cpio -i -d -m
 #${PRE}busybox sync
 #${PRE}busybox rm -f ${TMPWKG_MNTPT}/initrd.q
 #${PRE}busybox echo -e "INSTALL_DEV=${DESTDEV}\nINSTALL_FS=${DESTFS}\nINSTALL_FOLDER=${DESTFOLDER}" > INSTALL_SPECS
 #${PRE}busybox sync
 #${PRE}busybox find . | ${PRE}busybox cpio -o -H newc > ../initrd.q  #.cpio
 #${PRE}busybox sync
 mv -f ${TMPWKG_MNTPT}/initrd.q /mnt/${TARGETDRIVE}${PARTNUM1}/ #current dir should be $TMPWKG_MNTPT
 ${PRE}busybox sync
 
 DESTDEV="${TARGETDRIVE}${PARTNUM2}" #151209 2nd partition.
 zDESTDEV="$(${PRE}busybox blkid | ${PRE}busybox grep "^/dev/${DESTDEV}:" | ${PRE}busybox grep -o ' UUID=[^ ]*' | ${PRE}busybox cut -f 2 -d '"')"
 INSTALL_SPECS="UUID=${zDESTDEV}:${TARGETFS}:" #151209
 echo "default quirky
display boot.msg
prompt 1
timeout 50

F1 boot.msg
F2 help.msg

label quirky
kernel vmlinuz
initrd initrd.q
append rw install_specs=${INSTALL_SPECS}" > /mnt/${TARGETDRIVE}${PARTNUM1}/syslinux.cfg
 #151210 help.msg has qfix=fsck,bak, not relevent to frugal or livecd...
 sed -i '/qfix=fsck/d' /mnt/${TARGETDRIVE}${PARTNUM1}/help.msg
 sed -i '/qfix=bak/d' /mnt/${TARGETDRIVE}${PARTNUM1}/help.msg
 if [ -d /mnt/${TARGETDRIVE}${PARTNUM1}/EFI/BOOT ];then
 echo "default quirky
display boot.msg
prompt 1
timeout 50

F1 boot.msg
F2 help.msg

label quirky
kernel ../../vmlinuz
initrd ../../initrd.q
append rw install_specs=${INSTALL_SPECS}" > /mnt/${TARGETDRIVE}${PARTNUM1}/EFI/BOOT/syslinux.cfg
  #151210 help.msg has qfix=fsck,bak, not relevent to frugal or livecd...
  sed -i '/qfix=fsck/d' /mnt/${TARGETDRIVE}${PARTNUM1}/EFI/BOOT/help.msg
  sed -i '/qfix=bak/d' /mnt/${TARGETDRIVE}${PARTNUM1}/EFI/BOOT/help.msg
 fi

 ${PRE}busybox sync
 ${PRE}busybox umount /mnt/${TARGETDRIVE}${PARTNUM1}
 cd ${TMPWKG_MNTPT}
fi
[ -f ${TMPWKG_MNTPT}/initrd.q ] && ${PRE}busybox rm -f ${TMPWKG_MNTPT}/initrd.q

#populating 2nd partition
${PRE}popadd "name=format background='#BFFF00'|$(gettext 'Populating 2nd partition,') ${TARGETDRIVE}${PARTNUM2}..."
${PRE}busybox mkdir -p /mnt/${TARGETDRIVE}${PARTNUM2}
${PRE}busybox mount -t ${TARGETFS} /dev/${TARGETDRIVE}${PARTNUM2} /mnt/${TARGETDRIVE}${PARTNUM2}
if [ $? -ne 0 ];then
 ${PRE}busybox killall popup
 ${PRE}popup "level=top background='#FF8080' terminate=ok|<b>$(gettext 'Mounting second partition:') ${TARGETDRIVE}${PARTNUM2}</b>${CR}$(gettext 'Error mounting second partition, aborting.')"
 exit_func 1
fi

if [ "$MODE" == "frugal" ];then
 ${PRE}busybox sync
 ${PRE}busybox umount mntpt
 ${PRE}busybox mv -f ${IMGFILE} /mnt/${TARGETDRIVE}${PARTNUM2}/ #q.sfs
 ${PRE}busybox sync
 #based on code from install-quirky-to-frugal...
 
  [ -d ${TMPWKG_MNTPT}/q ] && ${PRE}busybox rm -rf ${TMPWKG_MNTPT}/q #precaution.
  ${RXVTEXE} -borderLess -geometry 80x3+0+0 -bg orange -fg black -title "$(gettext 'Expanding:') q.sfs $(gettext 'Folder:') ${TMPWKG_MNTPT}/q" -e ${PRE}unsquashfs -p 1 -d ${TMPWKG_MNTPT}/q /mnt/${TARGETDRIVE}${PARTNUM2}/q.sfs
  #${PRE}busybox sync #170722 slow, using fsync below.
   #see also 7build-live-cd:
   ${PRE}busybox sed -i '/installquirky/d' ${TMPWKG_MNTPT}/q/root/Choices/ROX-Filer/PuppyPin #remove "install" icon
   
   #160419 i think, bung vmlinuz into it...
   [ ! -f ${TMPWKG_MNTPT}/q/boot/vmlinuz ] && ${PRE}busybox cp -a ${TMPWKG_MNTPT}/vmlinuz ${TMPWKG_MNTPT}/q/boot/
   #160420 still using INSTALLED_MODE...
   echo 'INSTALLED_MODE=frugal' >> ${TMPWKG_MNTPT}/q/etc/rc.d/install.log
   
   #get some target variables:
   ${PRE}busybox sed -e 's%^DISTRO_%INSTALL_%' ${TMPWKG_MNTPT}/q/etc/DISTRO_SPECS > /tmp/iq_distro_specs
   . /tmp/iq_distro_specs
   #${PRE}busybox sync #170722 removed
   #now put it together again...
   ${PRE}busybox rm -f /mnt/${TARGETDRIVE}${PARTNUM2}/q.sfs
   #mksquashfs ${TMPWKG_MNTPT}/q q.sfs -comp xz -processors 1
   #150219 removed  "-processors 1"
   #150317 do not compress (removed "-comp xz", instead "-noI -noD -noF -noX -no-exports")...
   ${RXVTEXE} -borderLess -geometry 80x3+0+0 -bg orange -fg black -title "$(gettext 'Rebuilding:') q.sfs $(gettext 'Folder:') ${DESTFOLDER}" -e ${PRE}mksquashfs ${TMPWKG_MNTPT}/q /mnt/${TARGETDRIVE}${PARTNUM2}/q.sfs #151109 -noI -noD -noF -noX -no-exports
   #170722 sync is slow, try fsync...
   #${PRE}busybox sync
   ${PRE}busybox fsync /mnt/${TARGETDRIVE}${PARTNUM2}/q.sfs
   ${PRE}busybox rm -rf ${TMPWKG_MNTPT}/q
 
else
 ${PRE}busybox cp -a mntpt/* /mnt/${TARGETDRIVE}${PARTNUM2}/
 ${PRE}busybox sync
 ${PRE}busybox umount mntpt
 #fix f.s....
 tPTN1="s%.*MARK_DEV1FS_LINE.*% DEV1FS='${TARGETFS}' #MARK_DEV1FS_LINE%"
 tPTN2="s%DEV1FS='f2fs'.*%DEV1FS='${TARGETFS}' #MARK_DEV1FS_LINE%"
 ${PRE}busybox sed -i -e "$tPTN1" /mnt/${TARGETDRIVE}${PARTNUM2}/sbin/init
 ${PRE}busybox sed -i -e "$tPTN2" /mnt/${TARGETDRIVE}${PARTNUM2}/etc/rc.d/rc.sysinit
 #save img file for our audit trail... 131227 no longer doing this...
 #echo "Copying ${IMGFILE} to /mnt/${TARGETDRIVE}${PARTNUM2}/audit/, for audit-trail..."
 ${PRE}busybox mkdir -p /mnt/${TARGETDRIVE}${PARTNUM2}/audit
 #cp -a ${IMGFILE} /mnt/${TARGETDRIVE}${PARTNUM2}/audit/
 #151209 do not want "install" and "save" icons on desktop with full install...
 ${PRE}busybox sed -i '/installquirky/d' /mnt/${TARGETDRIVE}${PARTNUM2}/root/Choices/ROX-Filer/PuppyPin #remove "install" icon
 ${PRE}busybox sed -i '/savesession/d' /mnt/${TARGETDRIVE}${PARTNUM2}/root/Choices/ROX-Filer/PuppyPin #remove "install" icon

 #160419 i think, bung vmlinuz into it...
 [ ! -f /mnt/${TARGETDRIVE}${PARTNUM2}/boot/vmlinuz ] && ${PRE}busybox cp -a ${TMPWKG_MNTPT}/vmlinuz /mnt/${TARGETDRIVE}${PARTNUM2}/boot/
   #160420 still using INSTALLED_MODE...
   echo 'INSTALLED_MODE=full' >> /mnt/${TARGETDRIVE}${PARTNUM2}/etc/rc.d/install.log
 
 ${PRE}busybox sync
 ${PRE}busybox rm -f ${IMGFILE}
fi
${PRE}busybox umount /mnt/${TARGETDRIVE}${PARTNUM2} #151209

#150104 somehow won't boot, for amd64 install. reinstalling mbr.bin here fixes it...
${PRE}busybox sync
${PRE}busybox dd bs=440 conv=notrunc count=1 if=${MBRBIN} of=/dev/${TARGETDRIVE}
${PRE}busybox sync

${PRE}popadd "name=format background='#80FF80'|$(gettext 'Target drive:') ${TARGETDRIVE}"
${PRE}popadd "name=format|<b>$(gettext "That's it, the target drive is now ready to boot from! But, please leave it plugged in for now.")</b>"
#have a daemon, send this uevent to it, then /usr/local/pup_event/frontend_change will be called...
${PRE}busybox echo change > /sys/block/${TARGETDRIVE}/uevent
${PRE}busybox sleep 5
${PRE}busybox killall popup

if [ "$CHK_ZERO" == "true" ];then #zeroized entire drive.
 if [ "$Qfw" == "UEFI" ];then #150330
  FIRSTSUMS="1M + 512M + 7M"
  TOTALM=`${PRE}busybox expr 520 + $FINALM`
 else
  FIRSTSUMS="1M + 16M + 7M"
  TOTALM=`${PRE}busybox expr 24 + $FINALM`
 fi
 TOTAL4THM=`${PRE}busybox expr $TOTALM \/ 4`
 export IQ_DLGw="<window title=\"$(gettext "Quirky Installer: drive")\" icon-name=\"gtk-convert\">
 <vbox>
  <text use-markup=\"true\"><label>\"<b>$(gettext 'Do you want to create an image file of the drive?')</b>\"</label></text>
  <text><label>$(gettext 'If you want to create a copy of the drive, as an image file, for deployment to other users, the size is:')  ${FIRSTSUMS} + ${FINALM}  $(gettext 'Total:') ${TOTALM}MB</label></text>
  <text><label>$(gettext 'An image can be created like this:')</label></text>
  <text use-markup=\"true\"><label>\"# dd if=/dev/${TARGETDRIVE} bs=4M count=${TOTAL4THM} | xz --compress --stdout -7 - > ${FILEPREFIX}-${TARGETVERSION}-${NOMINALG}gb.img.xz\"</label></text>
  <text use-markup=\"true\"><label>\"$(gettext 'If you would like to do this now, click the <b>Image</b> button, otherwise click <b>FINISHED</b> to exit from the Installer')\"</label></text>
  <hbox>
   <button><label>$(gettext 'Image')</label><action type=\"exit\">image</action></button>
   <button><label>$(gettext 'FINISHED')</label><action type=\"exit\">finished</action></button>
  </hbox>
 </vbox>
 </window>"
 RETSTRINGw="$(${PRE}gtkdialog --program=IQ_DLGw --center)"
 [ $? -ne 0 ] && exit
 eval "$RETSTRINGw"
 if [ "$EXIT" == "image" ];then
  ${PRE}popup "level=top background='#FF8000'|<b>$(gettext 'Reading drive:') ${TARGETDRIVE}</b>${CR}$(gettext 'Please wait, creating compressed image file of drive...')"
  if [ "$PRE" ];then
   #LD_PRELOAD=${PRE}liblzma.so.5 ${PRE}busybox dd if=/dev/${TARGETDRIVE} bs=4M count=${TOTAL4THM} | ${PRE}xz --compress --stdout -7 - > ${FILEPREFIX}-${TARGETVERSION}-${NOMINALG}gb.img.xz
   #LD_PRELOAD=${LIBLZMA} ${PRE}busybox dd if=/dev/${TARGETDRIVE} bs=4M count=${TOTAL4THM} | ${PRE}xz --compress --stdout -7 - > ${FILEPREFIX}-${TARGETVERSION}-${NOMINALG}gb.img.xz #150417
   ${PRE}busybox dd if=/dev/${TARGETDRIVE} bs=4M count=${TOTAL4THM} | ${PRE}xz --compress --stdout -7 - > ${FILEPREFIX}-${TARGETVERSION}-${NOMINALG}gb.img.xz #151004
  else
   ${PRE}busybox dd if=/dev/${TARGETDRIVE} bs=4M count=${TOTAL4THM} | ${PRE}xz --compress --stdout -7 - > ${FILEPREFIX}-${TARGETVERSION}-${NOMINALG}gb.img.xz
  fi
  ${PRE}busybox sync
  ${PRE}busybox sleep 5
  ${PRE}busybox killall popup
  PWD3="`${PRE}busybox pwd`"
  export IQ_DLGx="<window title=\"$(gettext "Quirky Installer: drive")\" icon-name=\"gtk-convert\">
  <vbox>
   <text use-markup=\"true\"><label>\"<b>$(gettext 'Created:') ${FILEPREFIX}-${TARGETVERSION}-${NOMINALG}GB.img.xz</b>\"</label></text>
   <text use-markup=\"true\"><label>\"<b>$(gettext 'Location:') ${PWD3}</b>\"</label></text>
   <text><label>$(gettext "That's it. You can instruct users to write the image to a drive, of nominal size:") ${NOMINALG}GB $(gettext '(or bigger). Like this:')</label></text>
   <text use-markup=\"true\"><label>\"# xz --decompress --stdout ${FILEPREFIX}-${TARGETVERSION}-${NOMINALG}gb.img.xz | dd of=/dev/<drive> bs=4M conv=fsync\"</label></text>
   <hbox>
    <button><label>$(gettext 'FINISHED')</label><action type=\"exit\">finished</action></button>
   </hbox>
  </vbox>
  </window>"
  RETSTRINGx="$(${PRE}gtkdialog --program=IQ_DLGx --center)"
 fi

fi

export IQ_DLGy="<window title=\"$(gettext "Quirky Installer: drive")\" icon-name=\"gtk-convert\">
<vbox>
 <text use-markup=\"true\"><label>\"<b>$(gettext 'Installed to drive:') ${TARGETDRIVE}</b>\"</label></text>
 <text use-markup=\"true\"><label>\"<b>$(gettext 'Done, all finished! You may unplug the drive.')</b>\"</label></text>
 <hbox>
  <button><label>$(gettext 'FINISHED')</label><action type=\"exit\">finished</action></button>
 </hbox>
</vbox>
</window>"
RETSTRINGx="$(${PRE}gtkdialog --program=IQ_DLGy --center)"

exit_func 0
###END###

