From c8944e5a14b6beb87aa722b1a30a05867ff2f2af Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Mon, 15 Apr 2019 21:27:27 -0700 Subject: [PATCH] Fixed prep_device() --- .bin/Scripts/build-ufd | 8 ++++---- .bin/Scripts/functions/ufd.py | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.bin/Scripts/build-ufd b/.bin/Scripts/build-ufd index 1b29b91b..3c0abbe6 100755 --- a/.bin/Scripts/build-ufd +++ b/.bin/Scripts/build-ufd @@ -52,14 +52,14 @@ if __name__ == '__main__': show_selections(args, sources, ufd_dev, UFD_SOURCES) confirm_selections(args) - # TODO: DELETEME - print_success("It's go-time!") - exit_script() - # Format and partition device if not args['--update']: prep_device(ufd_dev, UFD_LABEL, use_mbr=args['--use-mbr']) + # TODO: DELETEME + print_success("It's go-time!") + exit_script() + # Copy sources # Update boot entries diff --git a/.bin/Scripts/functions/ufd.py b/.bin/Scripts/functions/ufd.py index 902d3b14..34940e1f 100644 --- a/.bin/Scripts/functions/ufd.py +++ b/.bin/Scripts/functions/ufd.py @@ -143,7 +143,7 @@ def prep_device(dev_path, label, use_mbr=False): ) # Create partition table - cmd = 'parted {} --script -- mklabel {} primary fat32 4MiB {}'.format( + cmd = 'parted {} --script -- mklabel {} mkpart primary fat32 4MiB {}'.format( dev_path, 'msdos' if use_mbr else 'gpt', '-1s' if use_mbr else '-4MiB', @@ -165,11 +165,23 @@ def prep_device(dev_path, label, use_mbr=False): cmd=cmd, ) + # Find partition + cmd = [ + 'lsblk', + '--list', + '--noheadings', + '--output', 'name', + '--paths', + dev_path, + ] + result = run_program(cmd, encoding='utf-8', errors='ignore') + part_path = result.stdout.splitlines()[-1].strip() + # Format partition cmd = [ 'mkfs.vfat', '-F', '32', '-n', label, - '{}1'.format(dev_path), + part_path, ] try_and_print( message='Formatting partition...',