diff --git a/.bin/Scripts/functions/ufd.py b/.bin/Scripts/functions/ufd.py index f771c1da..51b1ad7c 100644 --- a/.bin/Scripts/functions/ufd.py +++ b/.bin/Scripts/functions/ufd.py @@ -68,45 +68,6 @@ def copy_source(source, items, overwrite=False): unmount('/mnt/Source') -def update_boot_entries(boot_entries, boot_files, iso_label, ufd_label): - """Update boot files for UFD usage""" - configs = [] - - # Find config files - for c_path, c_ext in boot_files.items(): - c_path = find_path(c_path) - for item in os.scandir(c_path): - if item.name.lower().endswith(c_ext.lower()): - configs.append(item.path) - - # Update Linux labels - cmd = [ - 'sed', - '--in-place', - '--regexp-extended', - 's/{}/{}/'.format(iso_label, ufd_label), - *configs, - ] - run_program(cmd) - - # Uncomment extra entries if present - for b_path, b_comment in boot_entries: - try: - find_path('/mnt/UFD{}'.format(b_path)) - except (FileNotFoundError, NotADirectoryError): - # Entry not found, continue to next entry - continue - - # Entry found, update config files - cmd = [ - 'sed', - '--in-place', - '"s/#{}#//"'.format(b_comment), - *configs, - ] - run_program(cmd) - - def find_first_partition(dev_path): """Find path to first partition of dev, returns str.""" cmd = [ @@ -390,6 +351,45 @@ def unmount(mount_point): run_program(cmd) +def update_boot_entries(boot_entries, boot_files, iso_label, ufd_label): + """Update boot files for UFD usage""" + configs = [] + + # Find config files + for c_path, c_ext in boot_files.items(): + c_path = find_path(c_path) + for item in os.scandir(c_path): + if item.name.lower().endswith(c_ext.lower()): + configs.append(item.path) + + # Update Linux labels + cmd = [ + 'sed', + '--in-place', + '--regexp-extended', + 's/{}/{}/'.format(iso_label, ufd_label), + *configs, + ] + run_program(cmd) + + # Uncomment extra entries if present + for b_path, b_comment in boot_entries: + try: + find_path('/mnt/UFD{}'.format(b_path)) + except (FileNotFoundError, NotADirectoryError): + # Entry not found, continue to next entry + continue + + # Entry found, update config files + cmd = [ + 'sed', + '--in-place', + '"s/#{}#//"'.format(b_comment), + *configs, + ] + run_program(cmd) + + def verify_sources(args, ufd_sources): """Check all sources and abort if necessary, returns dict.""" sources = OrderedDict()