WizardKit/.bin/Scripts/build-ufd

74 lines
1.5 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 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['Env']))
# Main section
if __name__ == '__main__':
try:
args = docopt(DOCSTRING)
sources = ()
# Verify selections
## UFD
try:
ufd_dev = get_full_path(args['--ufd-device'])
if not is_block_device(ufd_dev):
print_error('Invalid UFD device: {}'.format(ufd_dev))
abort()
except Exception:
# TODO Catch FileNotFound exception and abort accordingly
raise
## Sources
for label, source in UFD_SOURCES:
if args[source]:
try:
sources.append((label, get_full_path(source)))
except Exception:
# TODO Catch FileNotFound exception and abort accordingly
raise
# Show selections
# TODO FIXME
print_standard('UFD: {}'.format(ufd_dev))
print_standard('Sources:')
for s in sources:
print_standard(' {}: {}'.format(*s))
# 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