Initial Python layout
* Going to use docopt for argument handling * Script will be run as user using sudo where needed * Tentatively dropping tmux usage
This commit is contained in:
parent
a22e6f552f
commit
639a338cca
3 changed files with 114 additions and 27 deletions
89
.bin/Scripts/build-ufd
Executable file
89
.bin/Scripts/build-ufd
Executable file
|
|
@ -0,0 +1,89 @@
|
||||||
|
#!/bin/env python3
|
||||||
|
#
|
||||||
|
## Wizard Kit: UFD build tool
|
||||||
|
|
||||||
|
# Init
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
|
||||||
|
|
||||||
|
from docopt import docopt
|
||||||
|
from functions.common import *
|
||||||
|
|
||||||
|
set_log_file('Build UFD ({Date-Time}).log'.format(**global_vars['Env']))
|
||||||
|
|
||||||
|
|
||||||
|
# STATIC VARIABLES
|
||||||
|
DOCSTRING = '''Build UFD.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
build-ufd [options] --ufd-device PATH --linux-iso PATH
|
||||||
|
[--linux-minimal-iso PATH]
|
||||||
|
[--main-kit PATH]
|
||||||
|
[--winpe-iso PATH]
|
||||||
|
[--extra-dir PATH]
|
||||||
|
build-ufd (-h | --help)
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-e PATH, --extra-dir PATH
|
||||||
|
-k PATH, --main-kit PATH
|
||||||
|
-l PATH, --linux-iso PATH
|
||||||
|
-m PATH, --linux-minimal-iso PATH
|
||||||
|
-u PATH, --ufd-device PATH
|
||||||
|
-w PATH, --winpe-iso PATH
|
||||||
|
|
||||||
|
-d --debug Enable debug mode
|
||||||
|
-h --help Show this page
|
||||||
|
-v --verbose Enable verbose mode
|
||||||
|
-M --use-mbr Use real MBR instead of GPT w/ Protective MBR
|
||||||
|
-F --force Bypass all confirmation messages. USE WITH EXTREME CAUTION!
|
||||||
|
-U --update Don't format device, just update
|
||||||
|
'''
|
||||||
|
ISO_LABEL = '{}_LINUX'.format(KIT_NAME_SHORT)
|
||||||
|
UFD_LABEL = '{}_UFD'.format(KIT_NAME_SHORT)
|
||||||
|
|
||||||
|
|
||||||
|
# Functions
|
||||||
|
def get_full_path(item):
|
||||||
|
"""Get full path to item, returns str."""
|
||||||
|
#TODO
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def is_block_device(item):
|
||||||
|
"""Verify item is a block device, returns bool."""
|
||||||
|
#TODO
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def is_valid_main_kit(path):
|
||||||
|
"""Verify path contains the main kit, returns bool."""
|
||||||
|
|
||||||
|
|
||||||
|
# Main section
|
||||||
|
if __name__ == '__main__':
|
||||||
|
args = docopt(DOCSTRING)
|
||||||
|
|
||||||
|
# Verify selections
|
||||||
|
|
||||||
|
# Show selections
|
||||||
|
|
||||||
|
# Double-check if formating device
|
||||||
|
|
||||||
|
# Format and partition device
|
||||||
|
|
||||||
|
# Mount sources
|
||||||
|
|
||||||
|
# Copy sources
|
||||||
|
|
||||||
|
# Update boot entries
|
||||||
|
|
||||||
|
# Install syslinux
|
||||||
|
|
||||||
|
# Hide items
|
||||||
|
|
||||||
|
# Unmount sources
|
||||||
|
|
||||||
|
|
||||||
|
# vim: sts=2 sw=2 ts=2
|
||||||
|
|
@ -879,25 +879,19 @@ def make_tmp_dirs():
|
||||||
|
|
||||||
def set_common_vars():
|
def set_common_vars():
|
||||||
"""Set common variables."""
|
"""Set common variables."""
|
||||||
global_vars['Date'] = time.strftime("%Y-%m-%d")
|
global_vars['Date'] = time.strftime("%Y-%m-%d")
|
||||||
global_vars['Date-Time'] = time.strftime("%Y-%m-%d_%H%M_%z")
|
global_vars['Date-Time'] = time.strftime("%Y-%m-%d_%H%M_%z")
|
||||||
global_vars['Env'] = os.environ.copy()
|
global_vars['Env'] = os.environ.copy()
|
||||||
|
|
||||||
global_vars['ArchivePassword'] = ARCHIVE_PASSWORD
|
global_vars['ArchivePassword'] = ARCHIVE_PASSWORD
|
||||||
global_vars['BinDir'] = r'{BaseDir}\.bin'.format(
|
global_vars['BinDir'] = r'{BaseDir}\.bin'.format(**global_vars)
|
||||||
**global_vars)
|
global_vars['CBinDir'] = r'{BaseDir}\.cbin'.format(**global_vars)
|
||||||
global_vars['CBinDir'] = r'{BaseDir}\.cbin'.format(
|
global_vars['ClientDir'] = r'{SYSTEMDRIVE}\{prefix}'.format(
|
||||||
**global_vars)
|
prefix=KIT_NAME_SHORT, **global_vars['Env'])
|
||||||
global_vars['ClientDir'] = r'{SYSTEMDRIVE}\{prefix}'.format(
|
global_vars['BackupDir'] = r'{ClientDir}\Backups'.format(**global_vars)
|
||||||
prefix=KIT_NAME_SHORT, **global_vars['Env'])
|
global_vars['LogDir'] = r'{ClientDir}\Logs\{Date}'.format(**global_vars)
|
||||||
global_vars['BackupDir'] = r'{ClientDir}\Backups'.format(
|
global_vars['QuarantineDir'] = r'{ClientDir}\Quarantine'.format(**global_vars)
|
||||||
**global_vars)
|
global_vars['TmpDir'] = r'{BinDir}\tmp'.format(**global_vars)
|
||||||
global_vars['LogDir'] = r'{ClientDir}\Logs\{Date}'.format(
|
|
||||||
**global_vars)
|
|
||||||
global_vars['QuarantineDir'] = r'{ClientDir}\Quarantine'.format(
|
|
||||||
**global_vars)
|
|
||||||
global_vars['TmpDir'] = r'{BinDir}\tmp'.format(
|
|
||||||
**global_vars)
|
|
||||||
|
|
||||||
|
|
||||||
def set_linux_vars():
|
def set_linux_vars():
|
||||||
|
|
@ -905,12 +899,12 @@ def set_linux_vars():
|
||||||
|
|
||||||
These assume we're running under a WK-Linux build."""
|
These assume we're running under a WK-Linux build."""
|
||||||
result = run_program(['mktemp', '-d'])
|
result = run_program(['mktemp', '-d'])
|
||||||
global_vars['TmpDir'] = result.stdout.decode().strip()
|
global_vars['TmpDir'] = result.stdout.decode().strip()
|
||||||
global_vars['Date'] = time.strftime("%Y-%m-%d")
|
global_vars['Date'] = time.strftime("%Y-%m-%d")
|
||||||
global_vars['Date-Time'] = time.strftime("%Y-%m-%d_%H%M_%z")
|
global_vars['Date-Time'] = time.strftime("%Y-%m-%d_%H%M_%z")
|
||||||
global_vars['Env'] = os.environ.copy()
|
global_vars['Env'] = os.environ.copy()
|
||||||
global_vars['BinDir'] = '/usr/local/bin'
|
global_vars['BinDir'] = '/usr/local/bin'
|
||||||
global_vars['LogDir'] = global_vars['TmpDir']
|
global_vars['LogDir'] = '{}/Logs',format(global_vars['Env']['HOME'])
|
||||||
global_vars['Tools'] = {
|
global_vars['Tools'] = {
|
||||||
'wimlib-imagex': 'wimlib-imagex',
|
'wimlib-imagex': 'wimlib-imagex',
|
||||||
'SevenZip': '7z',
|
'SevenZip': '7z',
|
||||||
|
|
@ -919,10 +913,13 @@ def set_linux_vars():
|
||||||
|
|
||||||
def set_log_file(log_name):
|
def set_log_file(log_name):
|
||||||
"""Sets global var LogFile and creates path as needed."""
|
"""Sets global var LogFile and creates path as needed."""
|
||||||
folder_path = '{}{}{}'.format(
|
if psutil.LINUX:
|
||||||
global_vars['LogDir'],
|
folder_path = global_vars['LogDir']
|
||||||
os.sep,
|
else:
|
||||||
KIT_NAME_FULL)
|
folder_path = '{}{}{}'.format(
|
||||||
|
global_vars['LogDir'],
|
||||||
|
os.sep,
|
||||||
|
KIT_NAME_FULL)
|
||||||
log_file = '{}{}{}'.format(
|
log_file = '{}{}{}'.format(
|
||||||
folder_path,
|
folder_path,
|
||||||
os.sep,
|
os.sep,
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ networkmanager
|
||||||
p7zip
|
p7zip
|
||||||
progsreiserfs
|
progsreiserfs
|
||||||
python
|
python
|
||||||
|
python-docopt
|
||||||
python-psutil
|
python-psutil
|
||||||
python-requests
|
python-requests
|
||||||
reiserfsprogs
|
reiserfsprogs
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue