Merge remote-tracking branch 'upstream/dev' into dev
This commit is contained in:
commit
aff124dd8c
9 changed files with 73 additions and 72 deletions
|
|
@ -13,6 +13,8 @@ SOURCES = {
|
||||||
'AdwCleaner': 'https://downloads.malwarebytes.com/file/adwcleaner',
|
'AdwCleaner': 'https://downloads.malwarebytes.com/file/adwcleaner',
|
||||||
'AIDA64': 'https://download.aida64.com/aida64engineer633.zip',
|
'AIDA64': 'https://download.aida64.com/aida64engineer633.zip',
|
||||||
'aria2': 'https://github.com/aria2/aria2/releases/download/release-1.35.0/aria2-1.35.0-win-32bit-build1.zip',
|
'aria2': 'https://github.com/aria2/aria2/releases/download/release-1.35.0/aria2-1.35.0-win-32bit-build1.zip',
|
||||||
|
'Autologon32': 'http://live.sysinternals.com/Autologon.exe',
|
||||||
|
'Autologon64': 'http://live.sysinternals.com/Autologon64.exe',
|
||||||
'Autoruns': 'https://download.sysinternals.com/files/Autoruns.zip',
|
'Autoruns': 'https://download.sysinternals.com/files/Autoruns.zip',
|
||||||
'AVRemover32': 'https://download.eset.com/com/eset/tools/installers/av_remover/latest/avremover_nt32_enu.exe',
|
'AVRemover32': 'https://download.eset.com/com/eset/tools/installers/av_remover/latest/avremover_nt32_enu.exe',
|
||||||
'AVRemover64': 'https://download.eset.com/com/eset/tools/installers/av_remover/latest/avremover_nt64_enu.exe',
|
'AVRemover64': 'https://download.eset.com/com/eset/tools/installers/av_remover/latest/avremover_nt64_enu.exe',
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,10 @@ BOOT_ENTRIES = {
|
||||||
'/sources/boot.wim': 'UFD-WINPE',
|
'/sources/boot.wim': 'UFD-WINPE',
|
||||||
}
|
}
|
||||||
BOOT_FILES = {
|
BOOT_FILES = {
|
||||||
# Directory: extension
|
# Directory: extension
|
||||||
'/arch/boot/syslinux': 'cfg',
|
'/syslinux': 'cfg',
|
||||||
'/boot/grub': 'cfg',
|
'/boot/grub': 'cfg',
|
||||||
'/EFI/boot': 'conf',
|
'/EFI/boot': 'conf',
|
||||||
}
|
}
|
||||||
|
|
||||||
# Definitions: Sources and Destinations
|
# Definitions: Sources and Destinations
|
||||||
|
|
@ -37,45 +37,44 @@ BOOT_FILES = {
|
||||||
## Sources use rsync's trailing slash syntax
|
## Sources use rsync's trailing slash syntax
|
||||||
ITEMS = {
|
ITEMS = {
|
||||||
'ESET SysRescue': (
|
'ESET SysRescue': (
|
||||||
('/boot/grub/', '/boot/grub/'),
|
('/boot/grub/', '/boot/grub/'),
|
||||||
('/casper/', '/casper/'),
|
('/casper/', '/casper/'),
|
||||||
('/EFI/boot/', '/EFI/ESET/'),
|
('/EFI/boot/', '/EFI/ESET/'),
|
||||||
),
|
),
|
||||||
'Extra Dir': (
|
'Extra Dir': (
|
||||||
('/', '/'),
|
('/', '/'),
|
||||||
),
|
),
|
||||||
'HDClone': (
|
'HDClone': (
|
||||||
('/bootenv', '/'),
|
('/bootenv', '/'),
|
||||||
('/kernel.map', '/'),
|
('/kernel.map', '/'),
|
||||||
('/EFI/boot/', '/EFI/HDClone/'),
|
('/EFI/boot/', '/EFI/HDClone/'),
|
||||||
('/hdclone.iso', '/sources/'),
|
('/hdclone.iso', '/sources/'),
|
||||||
),
|
),
|
||||||
'Linux': (
|
'Linux': (
|
||||||
('/arch', '/'),
|
('/arch', '/'),
|
||||||
('/isolinux', '/'),
|
('/EFI/boot', '/EFI/'),
|
||||||
('/EFI/boot', '/EFI/'),
|
('/syslinux', '/'),
|
||||||
('/EFI/memtest86', '/EFI/'),
|
|
||||||
),
|
),
|
||||||
'Linux (Minimal)': (
|
'Linux (Minimal)': (
|
||||||
('/arch/boot/x86_64/archiso.img', '/arch_minimal/'),
|
('/arch/boot/x86_64/initramfs-linux.img', '/arch_minimal/'),
|
||||||
('/arch/boot/x86_64/vmlinuz', '/arch_minimal/'),
|
('/arch/boot/x86_64/vmlinuz-linux', '/arch_minimal/'),
|
||||||
('/arch/pkglist.x86_64.txt', '/arch_minimal/'),
|
('/arch/pkglist.x86_64.txt', '/arch_minimal/'),
|
||||||
('/arch/x86_64', '/arch_minimal/'),
|
('/arch/x86_64', '/arch_minimal/'),
|
||||||
),
|
),
|
||||||
'Main Kit': (
|
'Main Kit': (
|
||||||
('/', f'/{KIT_NAME_FULL}/'),
|
('/', f'/{KIT_NAME_FULL}/'),
|
||||||
),
|
),
|
||||||
'WinPE': (
|
'WinPE': (
|
||||||
('/bootmgr', '/'),
|
('/bootmgr', '/'),
|
||||||
('/bootmgr.efi', '/'),
|
('/bootmgr.efi', '/'),
|
||||||
('/en_us', '/'),
|
('/en_us', '/'),
|
||||||
('/Boot/', '/boot/'),
|
('/Boot/', '/boot/'),
|
||||||
('/EFI/Boot/', '/EFI/Microsoft/'),
|
('/EFI/Boot/', '/EFI/Microsoft/'),
|
||||||
('/EFI/Microsoft/', '/EFI/Microsoft/'),
|
('/EFI/Microsoft/', '/EFI/Microsoft/'),
|
||||||
('/Boot/BCD', '/sources/'),
|
('/Boot/BCD', '/sources/'),
|
||||||
('/Boot/boot.sdi', '/sources/'),
|
('/Boot/boot.sdi', '/sources/'),
|
||||||
('/bootmgr', '/sources/'),
|
('/bootmgr', '/sources/'),
|
||||||
('/sources/boot.wim', '/sources/'),
|
('/sources/boot.wim', '/sources/'),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
ITEMS_HIDDEN = (
|
ITEMS_HIDDEN = (
|
||||||
|
|
@ -88,7 +87,7 @@ ITEMS_HIDDEN = (
|
||||||
'arch',
|
'arch',
|
||||||
'arch_minimal',
|
'arch_minimal',
|
||||||
'EFI',
|
'EFI',
|
||||||
'isolinux',
|
'syslinux',
|
||||||
# Main Kit
|
# Main Kit
|
||||||
f'{KIT_NAME_FULL}/.bin',
|
f'{KIT_NAME_FULL}/.bin',
|
||||||
f'{KIT_NAME_FULL}/.cbin',
|
f'{KIT_NAME_FULL}/.cbin',
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ def download_tool(folder, name):
|
||||||
# Get ARCH specific URL if available
|
# Get ARCH specific URL if available
|
||||||
if name_arch in SOURCES:
|
if name_arch in SOURCES:
|
||||||
source_url = SOURCES[name_arch]
|
source_url = SOURCES[name_arch]
|
||||||
out_path = out_path.with_stem(name_arch)
|
out_path = out_path.with_name(f'{name_arch}{out_path.suffix}')
|
||||||
else:
|
else:
|
||||||
source_url = SOURCES[name]
|
source_url = SOURCES[name]
|
||||||
|
|
||||||
|
|
@ -153,7 +153,7 @@ def get_tool_path(folder, name, check=True):
|
||||||
tool_path = bin_dir.joinpath(f'{folder}/{name_arch}.exe')
|
tool_path = bin_dir.joinpath(f'{folder}/{name_arch}.exe')
|
||||||
if not (tool_path.exists() or name_arch in SOURCES):
|
if not (tool_path.exists() or name_arch in SOURCES):
|
||||||
# Use "default" path instead
|
# Use "default" path instead
|
||||||
tool_path = tool_path.with_stem(name)
|
tool_path = tool_path.with_name(f'{name}.exe')
|
||||||
|
|
||||||
# Missing?
|
# Missing?
|
||||||
if check and not tool_path.exists():
|
if check and not tool_path.exists():
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,8 @@ from wk.os import linux
|
||||||
DOCSTRING = '''WizardKit: Build UFD
|
DOCSTRING = '''WizardKit: Build UFD
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
build-ufd [options] --ufd-device PATH --linux PATH
|
build-ufd [options] --ufd-device PATH
|
||||||
|
[--linux PATH]
|
||||||
[--linux-minimal PATH]
|
[--linux-minimal PATH]
|
||||||
[--main-kit PATH]
|
[--main-kit PATH]
|
||||||
[--winpe PATH]
|
[--winpe PATH]
|
||||||
|
|
@ -38,6 +39,7 @@ Options:
|
||||||
-u PATH, --ufd-device PATH
|
-u PATH, --ufd-device PATH
|
||||||
-w PATH, --winpe PATH
|
-w PATH, --winpe PATH
|
||||||
|
|
||||||
|
-d --debug Enable debug mode
|
||||||
-h --help Show this page
|
-h --help Show this page
|
||||||
-M --use-mbr Use real MBR instead of GPT w/ Protective MBR
|
-M --use-mbr Use real MBR instead of GPT w/ Protective MBR
|
||||||
-F --force Bypass all confirmation messages. USE WITH EXTREME CAUTION!
|
-F --force Bypass all confirmation messages. USE WITH EXTREME CAUTION!
|
||||||
|
|
@ -52,9 +54,11 @@ UFD_LABEL = f'{KIT_NAME_SHORT}_UFD'
|
||||||
def build_ufd():
|
def build_ufd():
|
||||||
"""Build UFD using selected sources."""
|
"""Build UFD using selected sources."""
|
||||||
args = docopt(DOCSTRING)
|
args = docopt(DOCSTRING)
|
||||||
|
if args['--debug']:
|
||||||
|
log.enable_debug_mode()
|
||||||
log.update_log_path(dest_name='build-ufd', timestamp=True)
|
log.update_log_path(dest_name='build-ufd', timestamp=True)
|
||||||
try_print = std.TryAndPrint()
|
try_print = std.TryAndPrint()
|
||||||
try_print.add_error(FileNotFoundError)
|
try_print.add_error('FileNotFoundError')
|
||||||
try_print.catch_all = False
|
try_print.catch_all = False
|
||||||
try_print.verbose = True
|
try_print.verbose = True
|
||||||
try_print.indent = 2
|
try_print.indent = 2
|
||||||
|
|
@ -97,12 +101,13 @@ def build_ufd():
|
||||||
dev_path=ufd_dev,
|
dev_path=ufd_dev,
|
||||||
label=UFD_LABEL,
|
label=UFD_LABEL,
|
||||||
)
|
)
|
||||||
|
ufd_dev_first_partition = find_first_partition(ufd_dev)
|
||||||
|
|
||||||
# Mount UFD
|
# Mount UFD
|
||||||
try_print.run(
|
try_print.run(
|
||||||
message='Mounting UFD...',
|
message='Mounting UFD...',
|
||||||
function=linux.mount,
|
function=linux.mount,
|
||||||
source=find_first_partition(ufd_dev),
|
source=ufd_dev_first_partition,
|
||||||
mount_point='/mnt/UFD',
|
mount_point='/mnt/UFD',
|
||||||
read_write=True,
|
read_write=True,
|
||||||
)
|
)
|
||||||
|
|
@ -117,6 +122,10 @@ def build_ufd():
|
||||||
# Copy sources
|
# Copy sources
|
||||||
std.print_standard(' ')
|
std.print_standard(' ')
|
||||||
std.print_info('Copy Sources')
|
std.print_info('Copy Sources')
|
||||||
|
try_print.run(
|
||||||
|
'Copying Memtest86...', io.recursive_copy,
|
||||||
|
'/usr/share/memtest86-efi/', '/mnt/UFD/EFI/Memtest86/', overwrite=True,
|
||||||
|
)
|
||||||
for s_label, s_path in sources.items():
|
for s_label, s_path in sources.items():
|
||||||
try_print.run(
|
try_print.run(
|
||||||
message='Copying {}...'.format(s_label),
|
message='Copying {}...'.format(s_label),
|
||||||
|
|
@ -138,7 +147,7 @@ def build_ufd():
|
||||||
try_print.run(
|
try_print.run(
|
||||||
message='Syslinux (partition)...',
|
message='Syslinux (partition)...',
|
||||||
function=install_syslinux_to_partition,
|
function=install_syslinux_to_partition,
|
||||||
partition=find_first_partition(ufd_dev),
|
partition=ufd_dev_first_partition,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Unmount UFD
|
# Unmount UFD
|
||||||
|
|
@ -162,7 +171,7 @@ def build_ufd():
|
||||||
try_print.run(
|
try_print.run(
|
||||||
message='Hiding items...',
|
message='Hiding items...',
|
||||||
function=hide_items,
|
function=hide_items,
|
||||||
ufd_dev=ufd_dev,
|
ufd_dev_first_partition=ufd_dev_first_partition,
|
||||||
items=ITEMS_HIDDEN,
|
items=ITEMS_HIDDEN,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -235,11 +244,7 @@ def create_table(dev_path, use_mbr=False):
|
||||||
|
|
||||||
|
|
||||||
def find_first_partition(dev_path):
|
def find_first_partition(dev_path):
|
||||||
"""Find path to first partition of dev, returns str.
|
"""Find path to first partition of dev, returns str."""
|
||||||
|
|
||||||
NOTE: This assumes the dev was just partitioned with
|
|
||||||
a single partition.
|
|
||||||
"""
|
|
||||||
cmd = [
|
cmd = [
|
||||||
'lsblk',
|
'lsblk',
|
||||||
'--list',
|
'--list',
|
||||||
|
|
@ -251,7 +256,7 @@ def find_first_partition(dev_path):
|
||||||
|
|
||||||
# Run cmd
|
# Run cmd
|
||||||
proc = run_program(cmd)
|
proc = run_program(cmd)
|
||||||
part_path = proc.stdout.splitlines()[-1].strip()
|
part_path = proc.stdout.splitlines()[1].strip()
|
||||||
|
|
||||||
# Done
|
# Done
|
||||||
return part_path
|
return part_path
|
||||||
|
|
@ -285,17 +290,16 @@ def get_uuid(path):
|
||||||
return proc.stdout.strip()
|
return proc.stdout.strip()
|
||||||
|
|
||||||
|
|
||||||
def hide_items(ufd_dev, items):
|
def hide_items(ufd_dev_first_partition, items):
|
||||||
"""Set FAT32 hidden flag for items."""
|
"""Set FAT32 hidden flag for items."""
|
||||||
first_partition = find_first_partition(ufd_dev)
|
|
||||||
with open('/root/.mtoolsrc', 'w') as _f:
|
with open('/root/.mtoolsrc', 'w') as _f:
|
||||||
_f.write(f'drive U: file="{first_partition}"\n')
|
_f.write(f'drive U: file="{ufd_dev_first_partition}"\n')
|
||||||
_f.write('mtools_skip_check=1\n')
|
_f.write('mtools_skip_check=1\n')
|
||||||
|
|
||||||
# Hide items
|
# Hide items
|
||||||
for item in items:
|
for item in items:
|
||||||
cmd = [f'yes | sudo mattrib +h "U:/{item}"']
|
cmd = [f'yes | sudo mattrib +h "U:/{item}"']
|
||||||
run_program(cmd, shell=True)
|
run_program(cmd, shell=True, check=False)
|
||||||
|
|
||||||
|
|
||||||
def install_syslinux_to_dev(ufd_dev, use_mbr):
|
def install_syslinux_to_dev(ufd_dev, use_mbr):
|
||||||
|
|
@ -318,7 +322,7 @@ def install_syslinux_to_partition(partition):
|
||||||
'syslinux',
|
'syslinux',
|
||||||
'--install',
|
'--install',
|
||||||
'--directory',
|
'--directory',
|
||||||
'/arch/boot/syslinux/',
|
'/syslinux/',
|
||||||
partition,
|
partition,
|
||||||
]
|
]
|
||||||
run_program(cmd)
|
run_program(cmd)
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ def mount_volumes(device_path=None, read_write=False, scan_corestorage=False):
|
||||||
result += 'Failed to mount'
|
result += 'Failed to mount'
|
||||||
report.append(std.color_string(result, 'RED'))
|
report.append(std.color_string(result, 'RED'))
|
||||||
continue
|
continue
|
||||||
result += f'{"Mounted on "+vol.details.get("mountpoint", "?"):<40}'
|
result += f'{"Mounted on "+str(vol.details.get("mountpoint", "?")):<40}'
|
||||||
|
|
||||||
# Add size to result
|
# Add size to result
|
||||||
vol.get_details()
|
vol.get_details()
|
||||||
|
|
|
||||||
|
|
@ -228,7 +228,7 @@ def end_session():
|
||||||
|
|
||||||
# Disable Autologon
|
# Disable Autologon
|
||||||
if is_autologon_enabled():
|
if is_autologon_enabled():
|
||||||
run_tool('Sysinternals', 'Autologon')
|
run_tool('Sysinternals', 'Autologon', download=True)
|
||||||
reg_set_value(
|
reg_set_value(
|
||||||
'HKLM', r'Software\Microsoft\Windows NT\CurrentVersion\Winlogon',
|
'HKLM', r'Software\Microsoft\Windows NT\CurrentVersion\Winlogon',
|
||||||
'AutoAdminLogon', '0', 'SZ',
|
'AutoAdminLogon', '0', 'SZ',
|
||||||
|
|
@ -294,8 +294,8 @@ def init_run(options):
|
||||||
if options['Use Autologon']['Selected'] and not is_autologon_enabled():
|
if options['Use Autologon']['Selected'] and not is_autologon_enabled():
|
||||||
TRY_PRINT.run(
|
TRY_PRINT.run(
|
||||||
'Running Autologon...', run_tool,
|
'Running Autologon...', run_tool,
|
||||||
'Autologon', 'Autologon',
|
'Sysinternals', 'Autologon',
|
||||||
cbin=True, msg_good='DONE',
|
download=True, msg_good='DONE',
|
||||||
)
|
)
|
||||||
if options['Sync Clock']['Selected']:
|
if options['Sync Clock']['Selected']:
|
||||||
TRY_PRINT.run(
|
TRY_PRINT.run(
|
||||||
|
|
|
||||||
|
|
@ -419,37 +419,33 @@ class TryAndPrint():
|
||||||
def _format_exception_message(self, _exception):
|
def _format_exception_message(self, _exception):
|
||||||
"""Format using the exception's args or name, returns str."""
|
"""Format using the exception's args or name, returns str."""
|
||||||
LOG.debug(
|
LOG.debug(
|
||||||
'Formatting exception: %s',
|
'Formatting exception: %s, %s',
|
||||||
_exception.__class__.__name__,
|
_exception.__class__.__name__,
|
||||||
|
_exception,
|
||||||
)
|
)
|
||||||
message = None
|
message = ''
|
||||||
|
|
||||||
# Use known argument index or first string found
|
# Format message string from _exception
|
||||||
try:
|
try:
|
||||||
if isinstance(_exception, subprocess.CalledProcessError):
|
if isinstance(_exception, subprocess.CalledProcessError):
|
||||||
message = _exception.stderr
|
message = _exception.stderr
|
||||||
if not isinstance(message, str):
|
if not isinstance(message, str):
|
||||||
message = message.decode('utf-8')
|
message = message.decode('utf-8')
|
||||||
message = message.strip()
|
message = message.strip()
|
||||||
elif isinstance(_exception, FileNotFoundError):
|
|
||||||
message = _exception.args[1]
|
|
||||||
elif isinstance(_exception, ZeroDivisionError):
|
elif isinstance(_exception, ZeroDivisionError):
|
||||||
message = 'ZeroDivisionError'
|
# Skip and just use exception name below
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
for arg in _exception.args:
|
message = str(_exception)
|
||||||
if isinstance(arg, str):
|
|
||||||
message = arg
|
|
||||||
break
|
|
||||||
except Exception: # pylint: disable=broad-except
|
except Exception: # pylint: disable=broad-except
|
||||||
# Just use the exception name instead
|
# Just use the exception name instead
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Safety check
|
# Prepend exception name
|
||||||
if not message:
|
try:
|
||||||
try:
|
message = f'{_exception.__class__.__name__}: {message}'
|
||||||
message = _exception.__class__.__name__
|
except Exception: # pylint: disable=broad-except
|
||||||
except Exception: # pylint: disable=broad-except
|
message = f'UNKNOWN ERROR: {message}'
|
||||||
message = 'UNKNOWN ERROR'
|
|
||||||
|
|
||||||
# Fix multi-line messages
|
# Fix multi-line messages
|
||||||
if '\n' in message:
|
if '\n' in message:
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,7 @@ function update_live_env() {
|
||||||
|
|
||||||
# Boot config (legacy)
|
# Boot config (legacy)
|
||||||
mkdir -p "$PROFILE_DIR/arch"
|
mkdir -p "$PROFILE_DIR/arch"
|
||||||
cp "$ROOT_DIR/images/Syslinux.jpg" "$PROFILE_DIR/arch/syslinux.jpg"
|
cp "$ROOT_DIR/images/Syslinux.jpg" "$PROFILE_DIR/syslinux/syslinux.jpg"
|
||||||
sed -i -r "s/__+/$KIT_NAME_FULL/" "$PROFILE_DIR/syslinux/syslinux.cfg"
|
sed -i -r "s/__+/$KIT_NAME_FULL/" "$PROFILE_DIR/syslinux/syslinux.cfg"
|
||||||
mkdir -p "$TEMP_DIR" 2>/dev/null
|
mkdir -p "$TEMP_DIR" 2>/dev/null
|
||||||
curl -Lo "$TEMP_DIR/wimboot.zip" "http://git.ipxe.org/releases/wimboot/wimboot-latest.zip"
|
curl -Lo "$TEMP_DIR/wimboot.zip" "http://git.ipxe.org/releases/wimboot/wimboot-latest.zip"
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,4 @@ A live Windows environment
|
||||||
ENDTEXT
|
ENDTEXT
|
||||||
MENU LABEL Windows PE
|
MENU LABEL Windows PE
|
||||||
COM32 linux.c32
|
COM32 linux.c32
|
||||||
APPEND /%INSTALL_DIR%/boot/wimboot gui initrdfile=/sources/bootmgr,/sources/BCD,/sources/boot.sdi,/sources/boot.wim
|
APPEND wimboot gui initrdfile=/sources/bootmgr,/sources/BCD,/sources/boot.sdi,/sources/boot.wim
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue