Browse Source

merge latest changes

merge latest changes from convbsd
enable gfxboot grub
tags/debian/0.11.3
Alf Gaida 6 years ago
parent
commit
f6d921ab18

+ 19
- 0
debian/changelog View File

@@ -1,3 +1,22 @@
fll-installer (2015.03.23) experimental; urgency=medium

* upstream merges and latest changes by convbsd

-- Alf Gaida <agaida@siduction.org> Mon, 23 Mar 2015 00:20:59 +0100

fll-installer (2014.12.10) unstable; urgency=medium

* enable grubthemes, if installed
* merge upstream

-- Alf Gaida <agaida@siduction.org> Wed, 10 Dec 2014 23:12:15 +0100

fll-installer (2014.10.04) unstable; urgency=medium

* update-initramfs changed

-- Alf Gaida <agaida@siduction.org> Sun, 05 Oct 2014 16:29:17 +0200

fll-installer (2014.09.29) unstable; urgency=medium

* initramfs update instead of creation

+ 1
- 1
debian/control View File

@@ -6,7 +6,7 @@ Uploaders: J. Hamatoma <hama@siduction.net>,
Ferdinand Thommes <devil@siduction.org>,
Ovidiu Angelescu <convbsd@siduction.net>,
Build-Depends: debhelper (>= 9)
Standards-Version: 3.9.5
Standards-Version: 3.9.6
Vcs-Git: git://git.siduction.org/code/fll-installer
Vcs-Browser: http://git.siduction.org/?p=code/fll-installer.git


+ 11
- 8
debian/copyright View File

@@ -8,25 +8,28 @@ Copyright: 2012-2013 Alf Gaida <agaida@siduction.org>
2007-2011 Joaquim Boura <x-un-i@berlios.de>
2006-2008 Red Hat, Inc.
2008-2010 Niall Walsh <niallwalsh@users.berlios.de>
2004-2014 Stefan Lippers-Hollmann <s.l-h@gmx.de>.
License: GPL-2.0+

2004-2015 Stefan Lippers-Hollmann <s.l-h@gmx.de>
License: GPL-2.0
Comment:
Based on the knoppix installer from Fabian Franz
<knoppix-installer@fabian-franz.de> with fixes and help by: Joerg Schirottke
<master@kanotix.de> and Stefan Lippers-Hollmann <s.l-h@gmx.de>
Files: modules/backend/fix_boot_on_HD.bm
Copyright: 2012 J. Hamatoma <hama@siduction.net>
License: GPL-2.0+
License: GPL-2.0

Files: debian/*
Copyright: 2011-2014 Alf Gaida <agaida@siduction.org>
2007-2011 Joaquim Boura <x-un-i@berlios.de>
2008-2010 Niall Walsh <niallwalsh@users.berlios.de>
2004-2011 Stefan Lippers-Hollmann <s.l-h@gmx.de>.
License: GPL-2.0+
License: GPL-2.0

License: GPL-2.0+
License: GPL-2.0
This package is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
the Free Software Foundation; version 2 of the License.
.
This package is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of

debian/fll-installer.install → debian/install View File


+ 1
- 0
debian/manpages View File

@@ -0,0 +1 @@
fll-installer.1

+ 27
- 0
debian/preinst View File

@@ -0,0 +1,27 @@
#!/bin/sh

set -e

case "$1" in
install|upgrade)
if ! ischroot; then
if [ ! -d /fll ] ; then
echo '############################################################'
echo 'Installing this package is only allowed in live systems!'
echo 'Aborting installation.'
echo '############################################################'
exit 1
fi
fi
;;
abort-upgrade)
;;
*)
echo "preinst called with unknown argument \`$1'" >&2
exit 1
;;
esac

#DEBHELPER#

exit 0

+ 1
- 2
debian/rules View File

@@ -1,6 +1,5 @@
#!/usr/bin/make -f

export DH_VERBOSE=1
# export DH_VERBOSE=1

%:
dh $@

+ 0
- 3
debian/source/options View File

@@ -1,3 +0,0 @@
#Use bzip2 instead of gzip
compression = "bzip2"
compression-level = 9

+ 25
- 0
fll-installer.1 View File

@@ -0,0 +1,25 @@
.TH fll-installer "3" "January 2015" "fll-installer [OPTIONS]" "User Commands (1)"
.SH NAME
fll-installer - installer backend to install a fullstory/ aptosid based system
.SH SYNOPSIS
.B fll-installer
[\fIOPTIONS\fR]
installer
.SH DESCRIPTION
`fll-installer', is the backend to install a fullstory/ aptosid based live
system to the harddisk.
.TP
\fB\-h\fR|\-\-help
Print this help
.TP
\fB\-d\fR|\-\-debug
Print verbose debugging info
Repeat for more verbose debugging
.TP
\fB\-i\fR|\-\-inotify FIFO
specify inotify FIFO pipe
.SH "SEE ALSO"
.BR install-gui
.SH AUTHOR
This manual has been written by Stefan Lippers-Hollmann <s.l-h@gmx.de> for
the Debian project (but may be used by others).

+ 0
- 372
fll-iso2disk View File

@@ -1,372 +0,0 @@
#!/bin/bash
# Convert a live CD iso so that it's bootable from a partition
# Copyright 2007 Red Hat, Inc.
# Jeremy Katz <katzj@redhat.com>
#
# overlay/persistence enhancements by Douglas McClendon <dmc@viros.org>
# forked siduction version by Alf Gaida <agaida@siduction.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses>

# NOTE
# extra args are appended to kernel cmdlines
# There's no md5sum checking anywhere (noverify hardcoded on)
# It is hardcoded to use "siduction" as the path
# It cuts filenames down to fit 8.3
# ext* is untested
# block device as iso support newly added (untested)
# mtools and syslinux MUST BOTH be installed for fat
# syslinux alone is sufficient for ext*

# TODO if we want it, we need a checkisomd5 function :-/
noverify=1
# TODO Should be from default/distro or similar?
LiveOS="siduction"

export PATH=/sbin:/usr/sbin:$PATH

usage() {
echo "$0 [--overlay-size-mb [<size>]] [--noboot] [--reset-mbr] [--test] <iso path> <target device> -- [kernel_args]"
echo "creates a bootable fromiso install, with optional persist, on an existing ext2/3 or fat partition"
exit 1
}

cleanup() {
[ -d "$CDMNT" ] && umount $CDMNT && rmdir $CDMNT
[ -d "$USBMNT" ] && umount $USBMNT && rmdir $USBMNT
}

exitclean() {
echo "Cleaning up to exit..."
cleanup
exit 1
}

getdisk() {
DEV=$1

p=$(udevinfo -q path -n $DEV)
if [ -e /sys/$p/device ]; then
device=$(basename /sys/$p)
else
device=$(basename $(readlink -f /sys/$p/../))
fi
if [ ! -e /sys/block/$device -o ! -e /dev/$device ]; then
echo "Error finding block device of $DEV. Aborting!"
exitclean
fi

device="/dev/$device"
}

resetMBR() {
getdisk $1
if [ -f /usr/lib/syslinux/mbr.bin ]; then
cat /usr/lib/syslinux/mbr.bin > $device
elif [ -f /usr/share/syslinux/mbr.bin ]; then
cat /usr/share/syslinux/mbr.bin > $device
else
exitclean
fi
}

checkMBR() {
getdisk $1

bs=$(mktemp /tmp/bs.XXXXXX)
dd if=$device of=$bs bs=512 count=1 2>/dev/null || exit 2

mbrword=$(hexdump -n 2 $bs |head -n 1|awk {'print $2;'})
rm -f $bs
if [ "$mbrword" = "0000" ]; then
echo "MBR appears to be blank."
echo "Do you want to replace the MBR on this device?"
echo "Press Enter to continue or ctrl-c to abort"
read
resetMBR $1
fi

return 0
}

checkPartActive() {
dev=$1
getdisk $dev

# if we're installing to whole-disk and not a partition, then we
# don't need to worry about being active
if [ "$dev" = "$device" ]; then
return
fi

if [ "$(/sbin/fdisk -l $device 2>/dev/null |grep $dev |awk {'print $2;'})" != "*" ]; then
echo "Partition isn't marked bootable!"
echo "You can mark the partition as bootable with "
if [ "$(which parted)" ]; then
echo " # /sbin/parted $device"
echo " (parted) toggle N boot"
echo " (parted) quit"
else
echo "Assuming it is the first partition"
echo " # /sbin/fdisk $device"
echo " Command (m for help): a"
echo " Partition number (1-4): 1"
echo " Command (m for help): w"
fi
exitclean
fi
}

checkFilesystem() {
dev=$1

USBFS=$(/sbin/blkid -p $dev | sed s/.*TYPE\=\"// | cut -d\" -f1)
if [ "$USBFS" != "vfat" -a "$USBFS" != "msdos" -a "$USBFS" != "ext2" -a "$USBFS" != "ext3" ]; then
echo "USB filesystem must be vfat or ext[23]"
exitclean
fi

}

checkSyslinuxVersion() {
if [ ! -x /usr/bin/syslinux ]; then
echo "You need to have syslinux installed to run this script"
exit 1
fi
if [ ! -x /usr/bin/mtools ]; then
echo "You need to have mtools installed to run this script"
exit 1
fi
}

# TODO check why and if anything is possible?
if [ $(id -u) != 0 ]; then
echo "You need to be root to run this script"
exit 1
fi

while [ $# -gt 2 -a -z "$endargsfound" ]; do
case $1 in
--overlay-size-mb)
if [ $2 -gt 0 ]; then
overlaysizemb=$2
shift
else
overlaysizemb="256"
fi
;;
--noverify)
noverify=1
;;
--reset-mbr|--resetmbr)
resetmbr=1
;;
--noboot)
noboot=1
;;
--test)
test=1
;;
*)
if [ "$3" = "--" ]; then
endargsfound=1
else
usage
fi
;;
esac
if [ -z "$endargsfound" ]; then
shift
fi
done

ISO=$(readlink -f "$1")
USBDEV=$(readlink -f "$2")
shift
shift

if [ "$3" = "--" ]; then
shift
fi

if [ -z "$ISO" ] || [ ! -b "$ISO" -a ! -f "$ISO" ]; then
echo 'No suitable iso provided'
usage
fi

if [ -z "$USBDEV" -o ! -b "$USBDEV" ]; then
echo 'No suitable target device provided'
usage
fi

if [ -z "$noverify" ]; then
# verify the image
echo "Verifying image..."
checkisomd5 --verbose $ISO
if [ $? -ne 0 ]; then
echo "Are you SURE you want to continue?"
echo "Press Enter to continue or ctrl-c to abort"
read
fi
fi

# do some basic sanity checks.
checkFilesystem $USBDEV
if [ -z "$noboot" ]; then
checkSyslinuxVersion
checkPartActive $USBDEV
checkMBR $USBDEV
[ -n $resetmbr ] && resetMBR $USBDEV
fi

if [ "$USBFS" = "vfat" -a "$overlaysizemb" -gt 2047 ]; then
echo "Can't have an overlay greater than 2048MB on VFAT"
exitclean
fi

# FIXME: would be better if we had better mountpoints
CDMNT=$(mktemp -d /media/cdtmp.XXXXXX)
if [ -f $ISO ]; then
mount -o loop,ro $ISO $CDMNT || exitclean
else
mount -o ro $ISO $CDMNT || exitclean
fi
USBMNT=$(mktemp -d /media/usbdev.XXXXXX)
mount $USBDEV $USBMNT || exitclean

trap exitclean SIGINT SIGTERM

# let's try to make sure there's enough room on the partition
check=$ISO
if [ -d $USBMNT/$LiveOS ]; then
tbd=$(du -s -B 1M $USBMNT/$LiveOS | awk {'print $1;'})
else
tbd=0
fi
livesize=$(du -s -B 1M $check | awk {'print $1;'})
free=$(df -B1M $USBDEV |tail -n 1 |awk {'print $4;'})

if [ -z "$test" -a $(($overlaysizemb + $livesize)) -gt $(($free + $tbd)) ]; then
echo "Unable to fit live image + overlay on available space on partition"
echo "Size of live image: $livesize"
echo "Overlay size: $overlaysizemb"
echo "Available space: $(($free + $tbd))"
exitclean
fi

if [ -d $USBMNT/$LiveOS ]; then
echo "Already set up as live image. Deleting old in fifteen seconds..."
sleep 15

rm -rf $USBMNT/$LiveOS
fi

echo "Copying live image to partition"

if [ ! -d $USBMNT/$LiveOS ]; then mkdir $USBMNT/$LiveOS ; fi

cp $CDMNT/boot/vmlinuz\-*\-686 $USBMNT/$LiveOS/vmlinuz.686 || exitclean
cp $CDMNT/boot/initrd.img\-*\-686 $USBMNT/$LiveOS/initrd.686 || exitclean
ISOARCH=( 686 )

if ls $CDMNT/boot/vmlinuz\-*\-amd64 > /dev/null; then
ISOARCH+=( x64 )
cp $CDMNT/boot/vmlinuz\-*\-amd64 $USBMNT/$LiveOS/vmlinuz.x64 || exitclean
cp $CDMNT/boot/initrd.img\-*\-amd64 $USBMNT/$LiveOS/initrd.x64 || exitclean
fi

if [ -z "$test" ]; then
if [ -f $ISO ]; then
cp $ISO $USBMNT/$LiveOS/${LiveOS}.iso || exitclean
else
dd if=$ISO of=$USBMNT/$LiveOS/${LiveOS}.iso || exitclean
fi
fi

if [ ! -z "$overlaysizemb" ]; then
PERSIST='persist'
if [ "$USBFS" = "vfat" ]; then
echo "Initializing persistent overlay file"
if [ -z "$test" ]; then
dd if=/dev/zero of=$USBMNT/$LiveOS/${LiveOS}-rw count=$overlaysizemb bs=1M || exitclean
echo 'y' | /sbin/mkfs.ext3 $USBMNT/$LiveOS/${LiveOS}-rw || exitclean
fi
PERSIST='persist='$LiveOS'/'$LiveOS'-rw'
fi
fi

echo "Creating boot config file"

cp /usr/lib/syslinux/menu.c32 $USBMNT/syslinux/
echo 'default menu.c32
prompt 0
timeout 50
menu title '$LiveOS' Live Disk Boot
' > $USBMNT/syslinux/extlinux.cfg || exitclean
for MYARCH in ${ISOARCH[@]}; do
echo 'label '$LiveOS'
menu label '$LiveOS' '$MYARCH' with persist
' >> $USBMNT/syslinux/extlinux.cfg || exitclean
if [ "$MYARCH" = "686" ]; then
echo 'menu default' >> $USBMNT/syslinux/extlinux.cfg || exitclean
fi
echo 'text help
Boots the live '$LiveOS' system from the disk.
Sets the appropriate persist option for your disk.
Stores most changes.
endtext
kernel /'$LiveOS'/vmlinuz.'$MYARCH'
append initrd=/'$LiveOS'/initrd.'$MYARCH' boot=fll quiet vga=791 fromiso='$LiveOS'/'$LiveOS'.iso '$PERSIST' '$@'
' >> $USBMNT/syslinux/extlinux.cfg || exitclean
if [ "$PERSIST" ]; then
echo '
label temp
menu label '$LiveOS' '$MYARCH' without persist
text help
Boots the live '$LiveOS' system from the disk.
Does not set persist so you get a clean system.
Does not store any changes.
endtext
kernel /'$LiveOS'/vmlinuz.'$MYARCH'
append initrd=/'$LiveOS'/initrd.'$MYARCH' boot=fll quiet vga=791 fromiso='$LiveOS'/'$LiveOS'.iso '$@'
' >> $USBMNT/syslinux/extlinux.cfg || exitclean
fi
echo 'label standard
menu label '$LiveOS' '$MYARCH' defaults
text help
Boots the live '$LiveOS' system from the disk.
Does not use any extra options.
Does not store any changes.
endtext
kernel /'$LiveOS'/vmlinuz.'$MYARCH'
append initrd=/'$LiveOS'/initrd.'$MYARCH' boot=fll quiet vga=791 fromiso='$LiveOS'/'$LiveOS'.iso
' >> $USBMNT/syslinux/extlinux.cfg || exitclean
done

if [ -z "$noboot" ]; then
echo "Installing boot loader"
if [ "$USBFS" = "vfat" -o "$USBFS" = "msdos" ]; then
# syslinux expects the config to be named syslinux.cfg
mv $USBMNT/syslinux/extlinux.cfg $USBMNT/syslinux/syslinux.cfg
# and has to run with the file system unmounted
cleanup
syslinux -d syslinux $USBDEV || exitclean
elif [ "$USBFS" = "ext2" -o "$USBFS" = "ext3" ]; then
# TODO does extlinux.cfg need to be in $USBMNT/$LiveOS ?
# has to be run with the file system mounted
extlinux -d syslinux -i $USBMNT/$LiveOS || exitclean
cleanup
fi
fi

echo "Partition set up as live image!"

+ 0
- 48
fll-iso2disk.8 View File

@@ -1,48 +0,0 @@
.TH FLL-ISO2DISK "8" "1th March 2013" "" ""
.SH NAME
\fBfll-iso2disk\fR \- installs a live-CD iso build with the
fll\-tools as a fromiso into a preformatted partition
.SH SYNOPSIS
\fBfll-iso2disk\fR \fI<options>\fR \fBIsoPath\fR \fBTargetDevice\fR \fI-- <extra_options_to_boot>\fR
.SH DESCRIPTION
installs a \fBsiduction\fR iso-image to a partition, makes
the partition bootable and writes the needed syslinux files.
.PP
\fBfll-iso2disk\fR takes an iso file (or device) and
creates a bootable live system using syslinux on the target device.
Any arguments following the IsoPath and TargetDevice are appended
to the live systems boot command line. Target device should be an
existing fat or ext2/3/4 partition.
.PP
.SH OPTIONS
.TP
\fB\-\-overlay-size-mb\fR \fI<size>\fR
Setup the live system to use persist, and if the target device
is a fat partition optionally set the size of the loopback file
used for the persistance data (default 256).
.TP
\fB\-\-noboot\fR
Creates all the files on the target without any checking of boot
settings or installation of any bootloader.
.TP
\fB\-\-reset-mbr\fR
Force putting the plain syslinux mbr on the device.
.TP
\fB\-\-noverify\fR
Do not verify the integrity of the iso.
Currently always on as no verification code written for siduction.
.TP
\fB\-\-test\fR
Do not copy the iso or create a persist file.
.PP
.SH EXAMPLES
.TP
\fBfll-iso2disk --overlay-size-mb 1024 /home/siduction/siduction.iso /dev/sdb1 \\\fR
\fB \-\- lang=de nointro nonetwork\fR
.PP
installs the iso image into the device sdb1 and creates a 1GB loopback file
for persistance. Uses the cheatcodes on the boot command line.
.PP
.SH AUTHOR
This manual page was originally written by Niall Walsh <niallwalsh@users.berlios.de>
and is modified by Alf Gaida <agaida@siduction.org>

+ 119
- 26
modules/backend/add_bootmanager.bm View File

@@ -6,6 +6,7 @@
# BOOT_LOADER
# HD_CHOICE
# HD_MAP
# FLL_GFXBOOT_THEME
#
# Calls:
# logit
@@ -36,8 +37,55 @@ add_bootmanager()
mount --bind /dev "${TARGET_MNT_POINT}/dev"
mount --bind /sys "${TARGET_MNT_POINT}/sys"
mount --bind /run "${TARGET_MNT_POINT}/run"

##
## workaround...start
##
# This can be probably changed later, but for now
# must be done as at least update-grub uses an old-style /etc/fstab
# so we create one for that

# 0. prepare
root_partition=$(echo ${HD_CHOICE} |cut -d"'" -f2)
map_devices="$(fll_disk_device $root_partition)"

if [ -n "${HD_MAP}" ]; then
for i in "${HD_MAP}"
do
part=$(echo $i | cut -d":" -f1)
map_devices="${map_devices} $(fll_disk_device $part)"
done
fi
map_devices="$(echo ${map_devices} | uniq -u)"
wanted=""
for map_device in ${map_devices}; do
wanted="${wanted} --wanted ${map_device}"
done

chroot_it fll_fstab_generator --file /etc/fstab ${wanted}

local cryptsource
local crypttarget

set -- $(fll_crypt_device ${root_partition})
while [ -n "$1" ]; do
cryptsource="$1"
crypttarget="$2"
shift 2
if [ "${cryptsource}" = "${cryptsource#/dev/mapper/}" ]; then
local cryptuuid
# use uuid if possible for non /dev/mapper devices
cryptuuid=$(udevadm info -q env --name ${cryptsource} | \
awk 'BEGIN{FS="="}/ID_FS_UUID=/{print $2}')
if [ -n "${cryptuuid}" ]; then
cryptsource="UUID=${cryptuuid}"
fi
fi
echo "${crypttarget#/dev/mapper/} $cryptsource none luks" >> ${TARGET_MNT_POINT}/etc/crypttab
done
BOOT_KERNELS=""

for i in $TARGET_MNT_POINT/lib/modules/?.*
do
BOOT_KERNEL=$(basename $i)
@@ -57,29 +105,6 @@ add_bootmanager()

progress "$MSG2"

##
## workaround...start
##
# This can be probably changed later, but for now
# must be done as at least update-grub uses an old-style /etc/fstab
# so we create one for that

# 0. prepare
root_partition=$(echo ${HD_CHOICE} |cut -d"'" -f2)
root_device=$(get_root_device $root_partition)
wanted="--wanted ${root_device}"

if [ -n "${HD_MAP}" ]; then
for i in "${HD_MAP}"
do
part=$(echo $i | cut -d":" -f1)
root_device=$(get_root_device $part)
wanted="${wanted} --wanted ${root_device}"
done
fi

chroot_it fll_fstab_generator --file /etc/fstab ${wanted}

##
## workaround...end
##
@@ -90,9 +115,17 @@ add_bootmanager()
get_efisys
fi

# determine if root_device is usb
device=$(echo $root_device|cut -d / -f3)
usb_dev=$(readlink -f /sys/block/${device}/device | grep "usb")
# determine if map devices are just usb
usb_dev=""
for map_device in ${map_devices}; do
if [ -n "$(fll_disk_isusb ${map_device})" ] ; then
usb_dev="${usb_dev} ${map_device}"
else
# any non usb device means efi could be installed
usb_dev=""
break
fi
done

# do efi if grub and have efi system partition and not usb install
if [ "$BOOT_LOADER" = "grub" ] && [ -n "$efisys" ] && [ -z "$usb_dev" ]
@@ -106,6 +139,66 @@ add_bootmanager()
#
fi

if [ "$BOOT_LOADER" = "grub" ]; then
#
# Create initital grub configuration (grub2 ignores -y)
#
say "create initial grub configuration"

if [ -e "${TARGET_MNT_POINT}/etc/default/grub" ]; then
#TODO a proper configuration
# propagate the default video mode
# extract vga mode from CMDLINE
GRUB_DEFOPTIONS=""
GRUB_VGA=$(getbootparam vga)
[ -n "$GRUB_VGA" ] && GRUB_DEFOPTIONS="vga=$GRUB_VGA"

# find out what cryptopts we need for /
local cryptsource
local crypttarget
set -- $(fll_crypt_device ${root_partition})
while [ -n "$1" ]; do
cryptsource="$1"
crypttarget="${2#/dev/mapper/}"
shift 2
if [ "${cryptsource}" = "${cryptsource#/dev/mapper/}" ]; then
local cryptuuid
# use uuid if possible for non /dev/mapper devices
cryptuuid=$(udevadm info -q env --name ${cryptsource} | \
awk 'BEGIN{FS="="}/ID_FS_UUID=/{print $2}')
if [ -n "${cryptuuid}" ]; then
cryptsource="UUID=${cryptuuid}"
fi
fi
# $dev is a crypted device on $crypt
if [ -z "$GRUB_DEFOPTIONS" ]; then
GRUB_DEFOPTIONS="cryptopts=source=$cryptsource,target=$crypttarget"
else
GRUB_DEFOPTIONS="${GRUB_DEFOPTIONS} cryptopts=source=$crypt,target=$crypttarget"
fi
# root is in a volume group so scan it
fll_disk_abstract ${root_partition}
[ "${f_d_abstract}" = "lvm" ] && GRUB_DEFOPTIONS="${GRUB_DEFOPTIONS},lvm=${root_partition##/dev/mapper/}"
done
sed -i "s|\(GRUB_CMDLINE_LINUX=\).*|\1\"${GRUB_DEFOPTIONS}\"|" \
"${TARGET_MNT_POINT}/etc/default/grub"

# enable a grub theme, if it exists
if [ -n "${FLL_GFXBOOT_THEME}" ] && [ -r "/usr/share/grub/themes/${FLL_GFXBOOT_THEME}/theme.txt" ]; then
if grep -q ^GRUB_THEME\= "${TARGET_MNT_POINT}/etc/default/grub" >/dev/null 2>&1; then
sed -i "s|\(GRUB_THEME=\).*|\1/usr/share/grub/themes/${FLL_GFXBOOT_THEME}/theme.txt|"
"${TARGET_MNT_POINT}/etc/default/grub"
else
printf "\nGRUB_THEME=\"/usr/share/grub/themes/${FLL_GFXBOOT_THEME}/theme.txt\"\n" \
>>"${TARGET_MNT_POINT}/etc/default/grub"
fi
fi
fi

# update the grub config with our changes
chroot_it update-grub >&2
fi

##
## workaround...start
##

+ 13
- 9
modules/backend/copy2HD.bm View File

@@ -45,31 +45,35 @@ copy2HD()
#
ln -sf "$(readlink -f ${dir})" "${TARGET_MNT_POINT}/${dir##*/}"
else
case "${dir##*/}" in
dev)
dir="/${dir##*/}"
case "${dir}" in
/dev)
# copy the static dev from ${DEFAULT_DIR}
dir="${DEFAULT_DIR}${dir}"
;;
home)
/home)
# don't clobber an existing /home/${DEFAULT_USER}
[ -d "${TARGET_MNT_POINT}/home/${DEFAULT_USER}" ] && continue
# don't copy if /home/${USER_NAME} exists
# we could not move /home/${DEFAULT_USER}
[ -d "${TARGET_MNT_POINT}/home/${USER_NAME}" ] && continue

# substitute variable to point to dir on live fs
dir="/${dir##*/}"
;;
*)
# substitute variable to point to dir on live fs
dir="/${dir##*/}"
# don't copy trees containing either source or target
[ "${TARGET_MNT_POINT#${dir}}" != "${TARGET_MNT_POINT}" ] && continue
[ "${DEFAULT_DIR#${dir}}" != "${DEFAULT_DIR}" ] && continue
;;
esac
#
# do the copy
#
rsync --archive --quiet \
rsync --archive \
--acls \
--hard-links \
--xattrs \
--quiet \
--exclude-from="${SEARCHPATH}/data/exclusion_list" \
"${dir}" "${TARGET_MNT_POINT}"
if [ $? -ne 0 ] ; then

+ 4
- 4
modules/backend/fix_home_on_HD.bm View File

@@ -27,7 +27,7 @@ fix_home_on_HD()
if [ -d "${TARGET_MNT_POINT}${LIVEHOME}" ] && \
[ ! -d "${TARGET_MNT_POINT}${INSTHOME}" ]; then
mv "${TARGET_MNT_POINT}${LIVEHOME}" "${TARGET_MNT_POINT}${INSTHOME}"
# fix /home/user paths in various config files
find "${TARGET_MNT_POINT}${INSTHOME}" \
-type f \
@@ -47,15 +47,15 @@ fix_home_on_HD()
"${TARGET_MNT_POINT}${INSTHOME}/.config/chromium/Local State" \
"${TARGET_MNT_POINT}${INSTHOME}/.config/chromium/First Run" \
"${TARGET_MNT_POINT}/root/.hushlogin"; do
[ -f "${file}" -o -L "$file" ] && rm -f "${file}"
[ -f "${file}" ] && rm -f "${file}"
done

#
# purge content of some dirs
#
for dir in ${TARGET_MNT_POINT}${INSTHOME}/.cache \
${TARGET_MNT_POINT}${INSTHOME}/.config/midori \
${TARGET_MNT_POINT}${INSTHOME}/.config/qupzilla/profiles ; do
${TARGET_MNT_POINT}${INSTHOME}/.config/midori \
${TARGET_MNT_POINT}${INSTHOME}/.config/qupzilla/profiles ; do
[ -d "$dir" ] && rm -Rf ${dir}/*
done


+ 66
- 121
modules/backend/install_grub.bm View File

@@ -28,66 +28,61 @@
##
install_grub()
{
local GRUB_KOPT
local GRUB_DEFOPTIONS
local GRUB_VGA
local root_partition
local root_device
local device
local usb_dev
local point
local bootfrom
local grubdev

#
# log my call
#
logit "installing grub"
#

root_partition=$(echo ${HD_CHOICE} |cut -d"'" -f2)

root_device=$(get_root_device $root_partition)

device=$(echo $root_device|cut -d / -f3)

usb_dev=$(readlink -f /sys/block/${device}/device | grep "usb")
local GRUB_KOPT
local GRUB_DEFOPTIONS
local GRUB_VGA
local root_partition
local root_device
local device
local usb_dev
local point
local bootfrom
local grubdev
#
# log my call
#
logit "installing grub"
#

grubdev=""
root_partition=$(echo ${HD_CHOICE} |cut -d"'" -f2)
bootfrom=""
grubdev=""

case $BOOT_WHERE in
mbr)
case "$BOOT_WHERE" in
mbr)
bootfrom=$(grub-mkdevicemap -n -m - | awk '/^\(hd0\)/{print $2}')
grubdev="${bootfrom}"
;;
partition)
bootfrom="${root_partition}"
;;
/dev/[hsv]d[a-z])
bootfrom="${BOOT_WHERE}"
;;
*)
bootfrom="${root_partition}"
esac

[ -z "$grubdev" ] && grubdev="$(ls -l /dev/disk/by-id | grep ${bootfrom##*/}$)"

# in case of jfs/xfs force installation to mbr
# but only if it's not already MBR
if [ "${BOOT_WHERE}" = "partition" ]; then
case "$HD_FSTYPE" in
jfs|xfs) bootfrom=${root_device};;
;;
partition)
bootfrom="${root_partition}"
;;
esac
fi

#
# install grub
#
# is twice because sometimes the first one fails in that cases the second
# don't fail !!!
grub-install --recheck --no-floppy --force --root-directory=$TARGET_MNT_POINT "${bootfrom}" >&2 || \
grub-install --recheck --no-floppy --force --root-directory=$TARGET_MNT_POINT "${bootfrom}" >&2
chroot_it sh -c "echo \"grub-pc grub-pc/install_devices multiselect ${grubdev}\" | debconf-set-selections "
[ -z "${bootfrom}" ] && bootfrom="${BOOT_WHERE}"
# grub will install on $bf and tell debconf to install it to $gds
gds=""
for bf in ${bootfrom}; do
# get the gd for this bf
# mbr might have set it but we want it reset each loop otherwise
if [ -z "$grubdev" ] ; then
gd="$(ls -l /dev/disk/by-id | awk '/\/'${bf##*/}'$/{print "/dev/disk/by-id/"$9;exit}' )"
else
gd="${grubdev}"
fi
#
# install grub
#
# is twice because sometimes the first one fails in that cases the second
# don't fail !!!
grub-install --recheck --no-floppy --force --root-directory=$TARGET_MNT_POINT "${bf}" >&2 || \
grub-install --recheck --no-floppy --force --root-directory=$TARGET_MNT_POINT "${bf}" >&2
if [ -z "${gds}" ]; then
gds="$gd"
else
gds="$gds, $gd"
fi
done
chroot_it sh -c "echo \"grub-pc grub-pc/install_devices multiselect ${gds}\" | debconf-set-selections "

#
# portable efi
@@ -95,8 +90,18 @@ install_grub()
# when the install is on usb and that usb has a fat partition
# we put portable efi bootloaders in the ESP on the device
# or the first fat partition
if [ -n "${usb_dev}" ]; then
get_usbefi "${root_device}"
isusb=""
for disk in $(fll_disk_device ${root_partition}); do
if [ -n "$(fll_disk_isusb ${disk})" ]; then
isusb="${isusb} ${disk}"
else
# any non-usb root device means we are not going portable
isusb=""
break
fi
done
if [ -n "${isusb}" ]; then
get_usbefi ${root_partition}
if [ -n "${usbefi}" ]; then
HD_MAP="$usbefi:/boot/efi ${HD_MAP}"

@@ -108,7 +113,9 @@ install_grub()
EFIAPTSOURCES=$(mktemp -d --tmpdir=${TARGET_MNT_POINT}/tmp/ liveapt.XXXXXX)
APTGETBASE="apt-get -o Dir::Etc=${EFIAPTSOURCES##${TARGET_MNT_POINT}}"
. /lib/init/fll
mount -o bind $(fll_get_mnt) ${TARGET_MNT_POINT}/mnt
extramnt="/fll"
[ -e "${extramnt}/extras" ] || extramnt="$(fll_get_mnt)"
mount -o bind ${extramnt} ${TARGET_MNT_POINT}/mnt
echo 'deb file:///mnt/extras sid main' > ${EFIAPTSOURCES}/sources.list
mkdir ${EFIAPTSOURCES}/preferences.d
chroot_it ${APTGETBASE} update > /dev/null
@@ -122,67 +129,5 @@ install_grub()
fi
fi

#
# Create initital grub configuration (grub2 ignores -y)
#
say "create initial grub configuration"

if [ -e "${TARGET_MNT_POINT}/etc/default/grub" ]; then
#TODO a proper configuration
# propagate the default video mode
# extract vga mode from CMDLINE
GRUB_DEFOPTIONS=""
GRUB_VGA=$(getbootparam vga)
[ -n "$GRUB_VGA" ] && GRUB_DEFOPTIONS="vga=$GRUB_VGA"

# find out what cryptopts we need for /
cryptopts=""
rooton=""
vg=$(lvs --noheadings -o vg_name $root_device 2>/dev/null | xargs echo)
if [ -n "$vg" ]; then
# / is in a lvm volume group
pv=$(vgs --noheadings -o pv_name $vg 2>/dev/null | xargs echo)
for p in $pv ; do
# p is a physical volume in vg needed for /
# get it's /dev/mapper name
dmname=$(dmsetup --columns --noheadings -o name info $p 2>/dev/null | xargs echo)
if [ -n "$dmname" ]; then
rooton="$rooton $dmname"
fi
done
else
# check any /dev/mapper device
[ "${root_device}" = "${root_device##/dev/mapper/}" ] || rooton="${root_device##/dev/mapper/}"
fi
# if we found any mapper devices to check for crypt
for dev in $rooton ; do
cryptsource=$(cryptsetup status $dev 2>/dev/null | awk -F: '/device:/{print $2}' | xargs echo)
if [ -n "$cryptsource" ] ; then
if [ "${cryptsource}" = "${cryptsource#/dev/mapper/}" ]; then
# use uuid if possible for non /dev/mapper devices
cryptuuid=$(udevadm info -q env --name ${cryptsource} | \
awk 'BEGIN{FS="="}/ID_FS_UUID=/{print $2}')
if [ -n "${cryptuuid}" ]; then
cryptsource="UUID=${cryptuuid}"
fi
fi
# $dev is a crypted device on $cryptsource
if [ -z "$GRUB_DEFOPTIONS" ]; then
GRUB_DEFOPTIONS="cryptopts=source=$cryptsource,target=$dev"
else
GRUB_DEFOPTIONS="${GRUB_DEFOPTIONS} cryptopts=source=$cryptsource,target=$dev"
fi
# root is in a volume group so scan it
[ -n "$vg" ] && GRUB_DEFOPTIONS="${GRUB_DEFOPTIONS},lvm=${root_device##/dev/mapper/}"
echo "$dev $cryptsource none luks" >> /etc/crypttab
fi
done
sed -i -e "s#\(GRUB_CMDLINE_LINUX=\).*#\1\"${GRUB_DEFOPTIONS}\"#" \
${TARGET_MNT_POINT}/etc/default/grub
fi

# update the grub config with our changes
chroot_it update-grub >&2

return 0
return 0
}

+ 13
- 97
modules/backend/install_grub_efi.bm View File

@@ -1,42 +1,25 @@
##
##-------------------------------------
# Needs:
# HD_CHOICE
# TARGET_MNT_POINT
# FLL_DISTRO_NAME
# HD_MAP (updates it)
#
# Calls:
# logit
# get_root_device
# chroot_it
# getbootparam
# get_efisys
# fll_get_mnt (from /lib/init/fll)
#
##-------------------------------------
##
install_grub_efi()
{
local GRUB_KOPT
local GRUB_DEFOPTIONS
local GRUB_VGA
local root_partition
local root_device
local device
local usb_dev
local point
local bootfrom
local EFIAPTSOURCES
local APTGETBASE
local cryptopts
local cryptsource
local cryptuuid
local rooton
local vg
local pv
local dmname
local dev

local efisize
local instarch
local grubdeb

#
# log my call
@@ -44,12 +27,6 @@ install_grub_efi()
logit "installing grub-efi"
#

root_partition=$(echo ${HD_CHOICE} |cut -d"'" -f2)

root_device=$(get_root_device $root_partition)

device=$(echo $root_device|cut -d / -f3)
get_efisys
HD_MAP="$efisys:/boot/efi ${HD_MAP}"

@@ -59,21 +36,22 @@ install_grub_efi()
mkdir -p "${TARGET_MNT_POINT}/boot/efi/EFI/debian"

# Install grub-efi in the chroot
( grep -q ia32-efi /proc/cmdline && bootarch="i386" ) || bootarch="amd64"
grubdeb="grub-efi"
instarch=$(dpkg-architecture --print-architecture)
if [ "${bootarch}" = "${instarch}" ]; then
grubdeb="grub-efi"
else
if [ "${bootarch}" = "i386" ]; then
if [ -r /sys/firmware/efi/fw_platform_size ]; then
efisize="$(head -n1 /sys/firmware/efi/fw_platform_size)"
if [ "${instarch}" = "i386" ] && [ "${efisize}" = "64" ]; then
grubdeb="grub-efi-amd64"
elif [ "${instarch}" = "amd64" ] && [ "${efisize}" = "32" ]; then
grubdeb="grub-efi-ia32"
else
grubdeb="grub-efi-${bootarch}"
fi
fi
EFIAPTSOURCES=$(mktemp -d --tmpdir=${TARGET_MNT_POINT}/tmp/ liveapt.XXXXXX)
APTGETBASE="apt-get -o Dir::Etc=${EFIAPTSOURCES##${TARGET_MNT_POINT}}"
. /lib/init/fll
mount -o bind $(fll_get_mnt) ${TARGET_MNT_POINT}/mnt
extramnt="/fll"
[ -e "${extramnt}/extras" ] || extramnt="$(fll_get_mnt)"
mount -o bind ${extramnt} ${TARGET_MNT_POINT}/mnt
echo 'deb file:///mnt/extras sid main' > ${EFIAPTSOURCES}/sources.list
mkdir ${EFIAPTSOURCES}/preferences.d
chroot_it ${APTGETBASE} update > /dev/null
@@ -84,68 +62,6 @@ install_grub_efi()
chroot_it ${APTGETBASE} clean > /dev/null
rm -rf ${EFIAPTSOURCES}

#
# Create initital grub configuration (grub2 ignores -y)
#
say "create initial grub efi configuration"

if [ -e "${TARGET_MNT_POINT}/etc/default/grub" ]; then
#TODO a proper configuration
# propagate the default video mode
# extract vga mode from CMDLINE
GRUB_DEFOPTIONS=""
GRUB_VGA=$(getbootparam vga)
[ -n "$GRUB_VGA" ] && GRUB_DEFOPTIONS="vga=$GRUB_VGA"

# find out what cryptopts we need for /
cryptopts=""
rooton=""
vg=$(lvs --noheadings -o vg_name $root_device 2>/dev/null | xargs echo)
if [ -n "$vg" ]; then
# / is in a lvm volume group
pv=$(vgs --noheadings -o pv_name $vg 2>/dev/null | xargs echo)
for p in $pv ; do
# p is a physical volume in vg needed for /
# get it's /dev/mapper name
dmname=$(dmsetup --columns --noheadings -o name info $p 2>/dev/null | xargs echo)
if [ -n "$dmname" ]; then
rooton="$rooton $dmname"
fi
done
else
# check any /dev/mapper device
[ "${root_device}" = "${root_device##/dev/mapper/}" ] || rooton="${root_device##/dev/mapper/}"
fi
# if we found any mapper devices to check for crypt
for dev in $rooton ; do
cryptsource=$(cryptsetup status $dev 2>/dev/null | awk -F: '/device:/{print $2}' | xargs echo)
if [ -n "$cryptsource" ] ; then
if [ "${cryptsource}" = "${cryptsource#/dev/mapper/}" ]; then
# use uuid if possible for non /dev/mapper devices
cryptuuid=$(udevadm info -q env --name ${cryptsource} | \
awk 'BEGIN{FS="="}/ID_FS_UUID=/{print $2}')
if [ -n "${cryptuuid}" ]; then
cryptsource="UUID=${cryptuuid}"
fi
fi
# $dev is a crypted device on $cryptsource
if [ -z "$GRUB_DEFOPTIONS" ]; then
GRUB_DEFOPTIONS="cryptopts=source=$cryptsource,target=$dev"
else
GRUB_DEFOPTIONS="${GRUB_DEFOPTIONS} cryptopts=source=$cryptsource,target=$dev"
fi
# root is in a volume group so scan it
[ -n "$vg" ] && GRUB_DEFOPTIONS="${GRUB_DEFOPTIONS},lvm=${root_device##/dev/mapper/}"
echo "$dev $cryptsource none luks" >> /etc/crypttab
fi
done
sed -i -e "s#\(GRUB_CMDLINE_LINUX=\).*#\1\"${GRUB_DEFOPTIONS}\"#" \
${TARGET_MNT_POINT}/etc/default/grub
fi

# update the grub config with our changes
chroot_it update-grub >&2

return 0
}


+ 3
- 1
modules/backend/purge_live_only_stuff.bm View File

@@ -26,10 +26,12 @@ purge_live_only_stuff() {
chmod +x "${TARGET_MNT_POINT}/usr/sbin/policy-rc.d"

# purge live-specific packages
for i in cli-installer \
for i in \
cli-installer \
desktop-defaults-*\
gfxboot \
fll-* \
kexec-tools \
nbd-client \
setpassword \
sidu-installer \

+ 24
- 31
modules/backend/update_fstab.bm View File

@@ -10,14 +10,15 @@
# logit
# progress
# chroot_it
# get_root_device
# fll_disk_device
# fll_disk_usb
#
##-------------------------------------
##
update_fstab()
{
local autohd
local root_partition root_device part wanted ignore_device
local root_partition root_device usb_dev part wanted want wants ignore_device d fdd igds i
#
# log my call
#
@@ -28,38 +29,26 @@ update_fstab()

# 0. prepare
root_partition=$(echo ${HD_CHOICE} |cut -d"'" -f2)
root_device=$(get_root_device $root_partition)
wanted="--wanted ${root_device}"
root_device="$(fll_disk_device $root_partition)"
usb_dev="$(fll_disk_usb $root_partition)"
for want in ${root_device} ; do
wants="${wants} ${want}"
done
if [ -b /dev/mapper/${FLL_DISTRO_NAME}-live ]; then
ignore_device="--ignore ${FLL_DISTRO_NAME}-live"
fi
# if root_device is usb ignore devices not solely on it (like install-gui scripts/disk)
usb_dev=$(readlink -f /sys/block/${root_device#/dev/}/device | grep "usb")
if [ -n "${usb_dev}" ]; then
# if root_device is solely usb, ignore devices not on the same device(s)
if [ "${root_device}" = "${usb_dev}" ]; then
for d in /sys/block/* ; do
mydisk="/dev/${d#/sys/block/}"
dmd=""
if [ "x$(grub-probe -d "${mydisk}" -t abstraction)" = "xlvm" ]; then
# lvm device so discover pv device(s)
dmd="/dev/mapper/$(cat ${d}/dm/name)"
lvd="$(lvs --noheadings -o devices ${dmd})"
[ -n "${lvd}" ] || continue
# check it is on only one device
set -- $lvd
[ $# -gt 1 ] && continue
# strip the trailing (12345) sector of disk
mydisk="${1%\(*}"
fi
gp="$(grub-probe -d "${mydisk}" -t disk)"
# using set to strip whitespace
if [ -n "${gp}" ] && set -- ${gp} && \
[ "x${1}" != "x${root_device}" ]; then
if [ -n "${dmd}" ]; then
ignore_device="${ignore_device} --ignore ${dmd}"
else
ignore_device="${ignore_device} --ignore ${1}"
for fdd in $(fll_disk_device /dev/${d##*/}) ; do
# add to list to ignore unless part of root
if echo ${root_device} | grep -m 1 -q -v ${fdd} ; then
igds="${igds} ${fdd}"
fi
fi
done
done
for igd in $(echo ${igds} | sort -u); do
ignore_device="${ignore_device} --ignore ${igd}"
done
fi

@@ -67,10 +56,14 @@ update_fstab()
for i in "${HD_MAP}"
do
part=$(echo $i | cut -d":" -f1)
root_device=$(get_root_device $part)
wanted="${wanted} --wanted ${root_device}"
for want in $(fll_disk_device $part); do
wants="${wants} ${want}"
done
done
fi
for want in $(echo ${wants} | sort -u) ; do
wanted="${wanted} --wanted ${want}"
done

# 1. mount /proc, /dev and /sys on chroot
mount --bind /proc "${TARGET_MNT_POINT}/proc"

+ 93
- 0
modules/common/disk.bm View File

@@ -0,0 +1,93 @@
# TODO md-raid

fll_disk_abstract() {
# sets f_d_abstract to the end level of abstraction
local f_d_disk
f_d_disk="$1"
f_d_abstract=""
[ -b "${f_d_disk}" ] || return
f_d_abstract="$(grub-probe -d "${f_d_disk}" -t abstraction | tac | grep -m 1 -e lvm -e cryptodisk)"
}

fll_disk_device() {
# de-dupe the result of fll_d_d
fll_d_d $@ | sort -u
}

fll_d_d() {
# walks up and out from block device and reports any unabstracted top level devices
local f_d_disk
local f_d_temp
f_d_disk="$1"
[ -b "${f_d_disk}" ] || return
fll_disk_abstract ${f_d_disk}
if [ -z "${f_d_abstract}" ]; then
echo $(grub-probe -d "${f_d_disk}" -t disk)
elif [ "${f_d_abstract}" = "lvm" ]; then
for f_d_temp in $(lvs --noheadings -o devices ${f_d_disk}); do
fll_d_d ${f_d_temp%\(*}
done
elif [ "${f_d_abstract}" = "cryptodisk" ]; then
for f_d_temp in $(cryptsetup status "${f_d_disk}" | awk '/^\s+device\:/{$1="";print $0}'); do
fll_d_d ${f_d_temp}
done
fi
}

fll_crypt_device() {
# de-dupe the result of fll_c_d
sources=""
targets=""
pairs=""
set -- $(fll_c_d $1)
while [ -n "$1" ]; do
# just bail if we don't have a target, wrong args
[ -n "$2" ] || break
# do not repeat a source or target
echo $sources | grep -q "$1" && continue
echo $targets | grep -q "$2" && continue
sources="$sources $1"
targets="$targets $2"
pairs="$pairs $1 $2"
shift 2
done
echo $pairs
}

fll_c_d() {
# walks up and out from block device and reports the crypt devices it hits in "source target" pairs
local f_d_disk
local f_d_temp
f_d_disk="$1"
[ -b "${f_d_disk}" ] || return
fll_disk_abstract ${f_d_disk}
if [ -z "${f_d_abstract}" ]; then
return
elif [ "${f_d_abstract}" = "lvm" ]; then
for f_d_temp in $(lvs --noheadings -o devices ${f_d_disk}); do
fll_c_d ${f_d_temp%\(*}
done
elif [ "${f_d_abstract}" = "cryptodisk" ]; then
for f_d_temp in $(cryptsetup status "${f_d_disk}" | awk '/^\s+device\:/{$1="";print $0}'); do
echo "${f_d_temp} ${f_d_disk}"
fll_c_d ${f_d_temp}
done
fi
}

fll_disk_usb() {
# de-dupe fll_d_u
fll_d_u $1 | sort -u
}

fll_d_u() {
# walks up and out from block device and reports the usb disks required for it
local f_d_disk
for f_d_disk in $(fll_disk_device $1); do
fll_disk_isusb ${f_d_disk}
done
}

fll_disk_isusb() {
readlink -f /sys/block/${1#/dev/}/device | grep -q usb && echo ${1}
}

+ 11
- 15
modules/initialization.bm View File

@@ -35,11 +35,7 @@ get_efisys () {
#
get_esp () {
disk="${1}"
# GPT disks appear in fdisk as a single partition of System GPT
parts=$(fdisk -l $disk | grep -v "Extended" | \
grep '^/dev/' | cut -d " " -f1 | cut -d "/" -f 3)
if [ "/dev/${parts}" = "${disk}1" ] && \
[ -n "$(fdisk -l $disk | awk '/^\/dev\//{if($6 == "GPT"){print "GPT"}}')" ]
if LANG=C fdisk -l ${disk} | grep -q 'Disklabel type: gpt'
then
# use gdisk to check for efi system partition
efis="$(gdisk -l ${disk} | \
@@ -57,11 +53,7 @@ get_esp () {
#
get_fat () {
disk="${1}"
# GPT disks appear in fdisk as a single partition of System GPT
parts=$(fdisk -l $disk | grep -v "Extended" | \
grep '^/dev/' | cut -d " " -f1 | cut -d "/" -f 3)
if [ "/dev/${parts}" = "${disk}1" ] && \
[ -n "$(fdisk -l $disk | awk '/^\/dev\//{if($6 == "GPT"){print "GPT"}}')" ]
if LANG=C fdisk -l ${disk} | grep -q 'Disklabel type: gpt'
then
# use gdisk to check for partitions
parts="$(gdisk -l ${disk} | \
@@ -87,13 +79,17 @@ get_fat () {
###-------------------------------------
#
get_usbefi () {
# given a partition, finds an efi on a usb disk it is on
# failing that the first fat partition a disk it requires has
usbdisk="${1}"
usbefi=""
get_esp "${usbdisk}"
if [ -z "${esp}" ]; then
get_fat "${usbdisk}"
esp="${fat}"
fi
fat=""
for disk in $(fll_disk_usb ${usbdisk}) ; do
get_esp "${disk}"
[ -n "$esp" ] && break
[ -z "$fat" ] && get_fat "${disk}"
done
[ -z "$esp" ] && [ -n "$fat" ] && esp="$fat"
[ -n "${esp}" ] && usbefi="${esp}"
}


Loading…
Cancel
Save