Updated UFD sections
This commit is contained in:
parent
617bb1484a
commit
798876eb10
2 changed files with 25 additions and 16 deletions
|
|
@ -54,16 +54,8 @@ if __name__ == '__main__':
|
|||
confirm_selections(args)
|
||||
|
||||
# Prep UFD
|
||||
print_info('Prep UFD')
|
||||
if args['--update']:
|
||||
# Remove arch folder
|
||||
try_and_print(
|
||||
indent=2,
|
||||
message='Removing Linux...',
|
||||
function=remove_arch,
|
||||
)
|
||||
else:
|
||||
# Format and partition
|
||||
if not args['--update']:
|
||||
print_info('Prep UFD')
|
||||
prep_device(ufd_dev, UFD_LABEL, use_mbr=args['--use-mbr'])
|
||||
|
||||
# Mount UFD
|
||||
|
|
@ -73,8 +65,17 @@ if __name__ == '__main__':
|
|||
function=mount,
|
||||
mount_source=find_first_partition(ufd_dev),
|
||||
mount_point='/mnt/UFD',
|
||||
read_write=True,
|
||||
)
|
||||
|
||||
# Remove Arch folder
|
||||
if args['--update']:
|
||||
try_and_print(
|
||||
indent=2,
|
||||
message='Removing Linux...',
|
||||
function=remove_arch,
|
||||
)
|
||||
|
||||
# Copy sources
|
||||
print_standard(' ')
|
||||
print_info('Copy Sources')
|
||||
|
|
|
|||
|
|
@ -60,16 +60,16 @@ def confirm_selections(args):
|
|||
|
||||
def copy_source(source, items, overwrite=False):
|
||||
"""Copy source items to /mnt/UFD."""
|
||||
is_iso = source.name.lower().endswith('.iso')
|
||||
is_image = source.is_file()
|
||||
|
||||
# Mount source if necessary
|
||||
if is_iso:
|
||||
if is_image:
|
||||
mount(source, '/mnt/Source')
|
||||
|
||||
# Copy items
|
||||
for i_source, i_dest in items:
|
||||
i_source = '{}{}'.format(
|
||||
'/mnt/Source' if is_iso else source,
|
||||
'/mnt/Source' if is_image else source,
|
||||
i_source,
|
||||
)
|
||||
i_dest = '/mnt/UFD{}'.format(i_dest)
|
||||
|
|
@ -80,7 +80,7 @@ def copy_source(source, items, overwrite=False):
|
|||
pass
|
||||
|
||||
# Unmount source if necessary
|
||||
if is_iso:
|
||||
if is_image:
|
||||
unmount('/mnt/Source')
|
||||
|
||||
|
||||
|
|
@ -199,6 +199,8 @@ def is_valid_path(path_obj, path_type):
|
|||
valid_path = path_obj.is_dir()
|
||||
elif path_type == 'KIT':
|
||||
valid_path = path_obj.is_dir() and path_obj.joinpath('.bin').exists()
|
||||
elif path_type == 'IMG':
|
||||
valid_path = path_obj.is_file() and path_obj.suffix.lower() == '.img'
|
||||
elif path_type == 'ISO':
|
||||
valid_path = path_obj.is_file() and path_obj.suffix.lower() == '.iso'
|
||||
elif path_type == 'UFD':
|
||||
|
|
@ -207,10 +209,16 @@ def is_valid_path(path_obj, path_type):
|
|||
return valid_path
|
||||
|
||||
|
||||
def mount(mount_source, mount_point):
|
||||
def mount(mount_source, mount_point, read_write=False):
|
||||
"""Mount mount_source on mount_point."""
|
||||
os.makedirs(mount_point, exist_ok=True)
|
||||
cmd = ['mount', mount_source, mount_point]
|
||||
cmd = [
|
||||
'mount',
|
||||
mount_source,
|
||||
mount_point,
|
||||
'-o',
|
||||
'rw' if read_write else 'ro',
|
||||
]
|
||||
run_program(cmd)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue