Fixed prep_device()

This commit is contained in:
2Shirt 2019-04-15 21:27:27 -07:00
parent 2230ea1eea
commit c8944e5a14
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
2 changed files with 18 additions and 6 deletions

View file

@ -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

View file

@ -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...',