summaryrefslogtreecommitdiff
path: root/buildlive
diff options
context:
space:
mode:
authorIru Cai <mytbk920423@gmail.com>2017-03-24 11:31:32 +0800
committerIru Cai <mytbk920423@gmail.com>2018-04-23 12:47:29 +0800
commitc479aa36313c4c08014c83c83a24d03e8334dc18 (patch)
tree03b7b54a751f70303957ed360c12ebd92ac48e53 /buildlive
parent7713876d9b855b64e3889d136a76a7e77ce18dbc (diff)
downloadliveusb-builder-c479aa36313c4c08014c83c83a24d03e8334dc18.tar.xz
separate BOOTPATH and ROOTPATH
and add "--boot <...>" and "--root <...>"
Diffstat (limited to 'buildlive')
-rwxr-xr-xbuildlive52
1 files changed, 39 insertions, 13 deletions
diff --git a/buildlive b/buildlive
index 30fea28..45ddc82 100755
--- a/buildlive
+++ b/buildlive
@@ -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