summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIru Cai <mytbk920423@gmail.com>2018-10-23 01:07:23 +0800
committerIru Cai <mytbk920423@gmail.com>2018-10-23 01:07:23 +0800
commit909115cc43f06c2305e6fb1b75832d73014da60e (patch)
treebb735f9c89d928a65f1aaae22ab5c6960bd081ba
parentbd1064a61103cb81faf1ea85387f438add67e6c1 (diff)
downloadliveusb-builder-909115cc43f06c2305e6fb1b75832d73014da60e.tar.xz
supporting specifying the block device name as root/boot partition
Now we can build a live USB like this: ./buildlive --boot /dev/sdb1 --root /dev/sdb2 \ manjaro/64/kde xubuntu/18.04
-rwxr-xr-xbuildlive35
1 files changed, 35 insertions, 0 deletions
diff --git a/buildlive b/buildlive
index 3440592..ef9b285 100755
--- a/buildlive
+++ b/buildlive
@@ -14,6 +14,8 @@ DATADIR=
INSTALL_GRUB=1
GRUBCFG_ONLY=0
DOWNLOAD_ONLY=0
+UMOUNT_BOOT=0
+UMOUNT_ROOT=0
. functions.sh
@@ -42,6 +44,18 @@ options:
EOF
}
+try_mount() {
+ local mnt
+ if [[ "$1" =~ ^/dev ]]
+ then
+ mnt=$(mktemp -u /media/buildlive.XXXXXX)
+ udevil mount "$1" "$mnt" > /dev/null
+ else
+ mnt="$1"
+ fi
+ echo "$mnt"
+}
+
unset ISOPATH
CFGFILE="$HOME/.liveusb-builder"
test -f "$CFGFILE" && source "$CFGFILE" || true
@@ -100,8 +114,20 @@ if [[ -z "$ROOTPATH" && "$DOWNLOAD_ONLY" == 0 ]]; then
exit 1
fi
+_mnt="$(try_mount "$ROOTPATH")"
+if [ "${_mnt}" != "$ROOTPATH" ]; then
+ ROOTPATH="${_mnt}"
+ UMOUNT_ROOT=1
+fi
+
if [[ -z "$BOOTPATH" ]]; then
BOOTPATH="$ROOTPATH"
+else
+ _mnt="$(try_mount "$BOOTPATH")"
+ if [ "${_mnt}" != "$BOOTPATH" ]; then
+ BOOTPATH="${_mnt}"
+ UMOUNT_BOOT=1
+ fi
fi
if [[ "$DOWNLOAD_ONLY" == 0 ]]; then
@@ -181,3 +207,12 @@ elif [ "$INSTALL_GRUB" == 1 ]; then
as-root grub-install --boot-directory="$BOOTPATH" --efi-directory="$BOOTPATH" --bootloader-id=grub --target=x86_64-efi --removable --no-nvram "$DEVNAME"
fi
fi
+
+if [ "$UMOUNT_BOOT" == 1 ]; then
+ msg 'Trying to umount the boot mountpoint, you may need to wait for sync() to complete.'
+ udevil umount "$BOOTPATH"
+fi
+if [ "$UMOUNT_ROOT" == 1 ]; then
+ msg 'Trying to umount the root mountpoint, you may need to wait for sync() to complete.'
+ udevil umount "$ROOTPATH"
+fi