diff options
-rwxr-xr-x | buildlive | 52 |
1 files changed, 39 insertions, 13 deletions
@@ -4,6 +4,7 @@ set -e DISTROLIST=() ISOLIST=() +BOOTPATH= ROOTPATH= DEVNAME= KERNELDIR= @@ -25,9 +26,13 @@ fatalerror() { usage() { >&2 cat << EOF -$0 [--root=<rootpath>] [options] [distro 1] [distro 2] ... +$0 [--root <path>] [options] [distro 1] [distro 2] ... use $0 -L to list available distros options: + --root <path> + --root=<path>: set the path to put the live USB data files + --boot <path> + --boot=<path>: set the path to put the kernel and loader files --no-grub: do not install GRUB loader (still generate grub.cfg) --grubcfg: do not do real install, only generate grub.cfg file --downloadonly: only download the ISO files @@ -46,16 +51,19 @@ do -L) exec ./listisos.sh ;; + --boot=*) + BOOTPATH="${1/--boot=}" + ;; + --boot) + shift + BOOTPATH="$1" + ;; --root=*) - ROOTPATH=${1/--root=} - UUID="$(findmnt -o UUID --raw --noheadings $ROOTPATH \ - || fatalerror "UUID of $ROOTPATH not found, not a mountpoint?")" - DEVNAME="/dev/$(getdiskbypart "/dev/disk/by-uuid/$UUID")" - KERNELDIR="$ROOTPATH/liveusb-kernel" - DATADIR="$ROOTPATH/liveusb-data" - GRUBCFG="$ROOTPATH/grub/grub.cfg" - install -d "$KERNELDIR" "$DATADIR" - msg "Files will be copy to $ROOTPATH" + ROOTPATH="${1/--root=}" + ;; + --root) + shift + ROOTPATH="$1" ;; --dev=*) DEVNAME=${1/--dev=} @@ -90,6 +98,25 @@ if [[ -z "$ROOTPATH" && "$DOWNLOAD_ONLY" == 0 ]]; then exit 1 fi +if [[ -z "$BOOTPATH" ]]; then + BOOTPATH="$ROOTPATH" +fi + +if [[ "$DOWNLOAD_ONLY" == 0 ]]; then + UUID="$(findmnt -o UUID --raw --noheadings $ROOTPATH \ + || fatalerror "UUID of $ROOTPATH not found, not a mountpoint?")" + # liveusb kernel and data should be placed on one disk + # so get DEVNAME by the mountpoint of ROOTPATH is ok + DEVNAME="/dev/$(getdiskbypart "/dev/disk/by-uuid/$UUID")" + + KERNELDIR="$BOOTPATH/liveusb-kernel" + DATADIR="$ROOTPATH/liveusb-data" + GRUBCFG="$BOOTPATH/grub/grub.cfg" + install -d "$BOOTPATH/grub" + install -d "$KERNELDIR" "$DATADIR" + msg "Files will be copy to $ROOTPATH" +fi + if [[ "${#DISTROLIST[@]}" == 0 ]]; then usage exit 1 @@ -116,7 +143,6 @@ if [[ "$DOWNLOAD_ONLY" == 1 ]]; then exit 0 fi -install -d "$ROOTPATH/grub" echo '# The live USB grub.cfg file' > "$GRUBCFG" if [ -z "$TXTMODE" ]; then @@ -153,7 +179,7 @@ if [ "$GRUBCFG_ONLY" == 1 ]; then elif [ "$INSTALL_GRUB" == 1 ]; then read -p 'Answer Y to install GRUB.[Y/n] ' if [[ "$REPLY" =~ ^[Yy]|^$ ]]; then - as-root grub-install --boot-directory="$ROOTPATH" --target=i386-pc "$DEVNAME" - as-root grub-install --boot-directory="$ROOTPATH" --efi-directory="$ROOTPATH" --bootloader-id=grub --target=x86_64-efi --removable --no-nvram "$DEVNAME" + as-root grub-install --force --boot-directory="$BOOTPATH" --target=i386-pc "$DEVNAME" + as-root grub-install --boot-directory="$BOOTPATH" --efi-directory="$BOOTPATH" --bootloader-id=grub --target=x86_64-efi --removable --no-nvram "$DEVNAME" fi fi |