81 lines
1.9 KiB
Python
Executable file
81 lines
1.9 KiB
Python
Executable file
#!/bin/env python3
|
|
#
|
|
## Wizard Kit: UFD build tool
|
|
|
|
import os
|
|
import sys
|
|
|
|
# Init
|
|
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
|
|
from collections import OrderedDict
|
|
from docopt import docopt
|
|
from functions.ufd import *
|
|
from settings.ufd import *
|
|
init_global_vars()
|
|
set_log_file('Build UFD ({Date-Time}).log'.format(**global_vars))
|
|
|
|
|
|
# Main section
|
|
if __name__ == '__main__':
|
|
try:
|
|
args = docopt(DOCSTRING)
|
|
sources = OrderedDict()
|
|
|
|
# Verify selections
|
|
## UFD
|
|
try:
|
|
ufd_dev = find_path(args['--ufd-device'])
|
|
except FileNotFoundError:
|
|
print_error('ERROR: UFD device not found: {}'.format(
|
|
args['--ufd-device']))
|
|
abort()
|
|
if not is_valid_path(ufd_dev, 'UFD'):
|
|
print_error('ERROR: Invalid UFD device: {}'.format(ufd_dev))
|
|
abort()
|
|
## Sources
|
|
for label, data in UFD_SOURCES.items():
|
|
s_path = args[data['Arg']]
|
|
if s_path:
|
|
try:
|
|
s_path_obj = find_path(s_path)
|
|
except FileNotFoundError:
|
|
print_error('ERROR: {} not found: {}'.format(label, s_path))
|
|
abort()
|
|
if not is_valid_path(s_path_obj, data['Type']):
|
|
print_error('ERROR: Invalid {} source: {}'.format(label, s_path))
|
|
abort()
|
|
sources[label] = s_path_obj
|
|
|
|
# Show selections
|
|
# TODO FIXME
|
|
print_standard('UFD: {}'.format(ufd_dev))
|
|
print_standard('Sources:')
|
|
for label, s_path in sources.items():
|
|
print_standard(' {:<16} {}'.format(label+':', s_path))
|
|
|
|
# Double-check if formating device
|
|
|
|
# Format and partition device
|
|
|
|
# Copy sources
|
|
|
|
# Update boot entries
|
|
|
|
# Install syslinux
|
|
|
|
# Hide items
|
|
|
|
# Unmount sources
|
|
|
|
# Done
|
|
if not args['--force']:
|
|
print_standard('\nDone.')
|
|
pause('Press Enter to exit...')
|
|
exit_script()
|
|
except SystemExit:
|
|
pass
|
|
except:
|
|
major_exception()
|
|
|
|
|
|
# vim: sts=2 sw=2 ts=2
|