diff options
author | Iru Cai <mytbk920423@gmail.com> | 2018-10-23 01:07:23 +0800 |
---|---|---|
committer | Iru Cai <mytbk920423@gmail.com> | 2018-10-23 01:07:23 +0800 |
commit | 909115cc43f06c2305e6fb1b75832d73014da60e (patch) | |
tree | bb735f9c89d928a65f1aaae22ab5c6960bd081ba /buildlive | |
parent | bd1064a61103cb81faf1ea85387f438add67e6c1 (diff) | |
download | liveusb-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
Diffstat (limited to 'buildlive')
-rwxr-xr-x | buildlive | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -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 |