Merge branch 'project-overhaul' into dev

This commit is contained in:
2Shirt 2020-01-13 17:25:03 -07:00
commit 6c374e9ae4
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
12 changed files with 1326 additions and 1241 deletions

View file

@ -619,7 +619,7 @@ def check_self_test_results(test_obj, aborted=False):
# known progress instead of just "was aborted buy host"
test_details = test_obj.dev.get_smart_self_test_details()
test_result = test_details.get('status', {}).get('string', 'Unknown')
test_obj.report.append(f' {test_result}')
test_obj.report.append(f' {test_result.capitalize()}')
if aborted and not (test_obj.passed or test_obj.failed):
test_obj.report.append(std.color_string(' Aborted', 'YELLOW'))
test_obj.set_status('Aborted')
@ -895,6 +895,8 @@ def disk_self_test(state, test_objects):
test_obj.failed = True
result = 'TimedOut'
except hw_obj.SMARTNotSupportedError:
# Pass test since it doesn't apply
test_obj.passed = True
result = 'N/A'
# Set status

View file

@ -163,6 +163,11 @@ class Disk(BaseObj):
self.get_details()
self.enable_smart()
self.update_smart_details()
if self.details['bus'] == 'USB' and not self.attributes:
# Try using SAT
LOG.warning('Using SAT for smartctl for %s', self.path)
self.enable_smart(use_sat=True)
self.update_smart_details(use_sat=True)
if not self.is_4k_aligned():
self.add_note('One or more partitions are not 4K aligned', 'YELLOW')
@ -218,11 +223,12 @@ class Disk(BaseObj):
test.set_status('Denied')
test.disabled = True
def enable_smart(self):
def enable_smart(self, use_sat=False):
"""Try enabling SMART for this disk."""
cmd = [
'sudo',
'smartctl',
f'--device={"sat,auto" if use_sat else "auto"}',
'--tolerance=permissive',
'--smart=on',
self.path,
@ -500,12 +506,23 @@ class Disk(BaseObj):
# Done
return result
def update_smart_details(self):
def update_smart_details(self, use_sat=False):
"""Update SMART details via smartctl."""
self.attributes = {}
# Check if SAT is needed
if not use_sat:
# use_sat not set, check previous run (if possible)
for arg in self.smartctl.get('smartctl', {}).get('argv', []):
if arg == '--device=sat,auto':
use_sat = True
break
# Get SMART data
cmd = [
'sudo',
'smartctl',
f'--device={"sat,auto" if use_sat else "auto"}',
'--tolerance=verypermissive',
'--all',
'--json',

View file

@ -15,6 +15,7 @@ from wk import io, log, std
from wk.cfg.main import KIT_NAME_FULL, KIT_NAME_SHORT
from wk.cfg.ufd import BOOT_ENTRIES, BOOT_FILES, ITEMS, ITEMS_HIDDEN, SOURCES
from wk.exe import run_program
from wk.hw.obj import Disk
from wk.os import linux
@ -391,6 +392,8 @@ def show_selections(args, sources, ufd_dev, ufd_sources):
def update_boot_entries():
"""Update boot files for UFD usage"""
configs = []
ufd = Disk('/mnt/UFD')
uuid = ufd.details.get('uuid')
# Find config files
for c_path, c_ext in BOOT_FILES.items():
@ -399,12 +402,12 @@ def update_boot_entries():
if item.name.lower().endswith(c_ext.lower()):
configs.append(item.path)
# Update Linux labels
# Use UUID instead of label
cmd = [
'sed',
'--in-place',
'--regexp-extended',
f's/{ISO_LABEL}/{UFD_LABEL}/',
f's#archisolabel={ISO_LABEL}#archisodevice=/dev/disk/by-uuid/{uuid}#',
*configs,
]
run_program(cmd)

View file

@ -160,7 +160,7 @@ function update_live_env() {
sed -i -r "s/_+/$KIT_NAME_FULL/" "$LIVE_DIR/syslinux/wk_head.cfg"
mkdir -p "$TEMP_DIR" 2>/dev/null
curl -Lo "$TEMP_DIR/wimboot.zip" "http://git.ipxe.org/releases/wimboot/wimboot-latest.zip"
7z e "$TEMP_DIR/wimboot.zip" -o"$LIVE_DIR/arch/boot" 'wimboot*/LICENSE.txt' 'wimboot*/README.txt' 'wimboot*/wimboot'
7z e -aoa "$TEMP_DIR/wimboot.zip" -o"$LIVE_DIR/arch/boot" 'wimboot*/LICENSE.txt' 'wimboot*/README.txt' 'wimboot*/wimboot'
# Boot config (UEFI)
mkdir -p "$LIVE_DIR/EFI/boot"
@ -177,9 +177,9 @@ function update_live_env() {
mkdir -p "$LIVE_DIR/EFI/memtest86/Benchmark"
mkdir -p "$TEMP_DIR/memtest86"
curl -Lo "$TEMP_DIR/memtest86/memtest86-usb.zip" "https://www.memtest86.com/downloads/memtest86-usb.zip"
7z e "$TEMP_DIR/memtest86/memtest86-usb.zip" -o"$TEMP_DIR/memtest86" "memtest86-usb.img"
7z e "$TEMP_DIR/memtest86/memtest86-usb.img" -o"$TEMP_DIR/memtest86" "MemTest86.img"
7z x "$TEMP_DIR/memtest86/MemTest86.img" -o"$TEMP_DIR/memtest86"
7z e -aoa "$TEMP_DIR/memtest86/memtest86-usb.zip" -o"$TEMP_DIR/memtest86" "memtest86-usb.img"
7z e -aoa "$TEMP_DIR/memtest86/memtest86-usb.img" -o"$TEMP_DIR/memtest86" "MemTest86.img"
7z x -aoa "$TEMP_DIR/memtest86/MemTest86.img" -o"$TEMP_DIR/memtest86"
rm "$TEMP_DIR/memtest86/EFI/BOOT/BOOTIA32.efi"
mv "$TEMP_DIR/memtest86/EFI/BOOT/BOOTX64.efi" "$LIVE_DIR/EFI/memtest86/memtestx64.efi"
mv "$TEMP_DIR/memtest86/EFI/BOOT"/* "$LIVE_DIR/EFI/memtest86"/
@ -333,6 +333,39 @@ function install_deps() {
run_elevated pacman -Syu --needed --noconfirm $packages
}
function build_all() {
if [[ "$EUID" -ne 0 ]]; then
echo "This section is meant to be run as root."
echo "Aborted."
exit 1
fi
# Prep for build
cleanup
fix_kit_permissions
install_deps
load_settings --edit
update_repo
# Build (full)
copy_live_env
update_live_env
# Rerun script as root to start Archiso build process
run_elevated "$(realpath "$0")" --build-iso
# Cleanup
mv -nv "$LIVE_DIR" "${LIVE_DIR}.full"
perl-rename -v "s/(${KIT_NAME_SHORT}-Linux)-(${DATE}.*)/\1-Full-\2/" "$OUT_DIR"/*
# Build (minimal)
copy_live_env --minimal
update_live_env --minimal
# Rerun script as root to start Archiso build process
run_elevated "$(realpath "$0")" --build-iso
# Cleanup
mv -nv "$LIVE_DIR" "${LIVE_DIR}.minimal"
perl-rename -v "s/(${KIT_NAME_SHORT}-Linux)-(${DATE}.*)/\1-Minimal-\2/" "$OUT_DIR"/*
}
function build_iso() {
if [[ "$EUID" -ne 0 ]]; then
echo "This section is meant to be run as root."
@ -386,10 +419,38 @@ function build_full() {
update_live_env
# Rerun script as root to start Archiso build process
run_elevated "$(realpath "$0")" --build-iso
# Cleanup
perl-rename -v "s/(${KIT_NAME_SHORT}-Linux)-(${DATE}.*)/\1-Full-\2/" "$OUT_DIR"/*
}
function build_minimal() {
if [[ "$EUID" -eq 0 ]]; then
echo "This section not meant to be run as root."
echo "Aborted."
exit 1
fi
# Prep for build
cleanup
fix_kit_permissions
install_deps
load_settings --edit
update_repo
copy_live_env --minimal
update_live_env --minimal
# Rerun script as root to start Archiso build process
run_elevated "$(realpath "$0")" --build-iso
# Cleanup
perl-rename -v "s/(${KIT_NAME_SHORT}-Linux)-(${DATE}.*)/\1-Minimal-\2/" "$OUT_DIR"/*
}
# Check input
case ${1:-} in
-a|--build-all)
build_all
echo Done
;;
-b|--build-full)
build_full
echo Done
@ -434,13 +495,15 @@ case ${1:-} in
echo "Usage: $(basename "$0") [OPTIONS]"
echo ""
echo "Options:"
echo " -b --build-full Perform all tasks and build iso"
echo " -a --build-all Perform all tasks to build all isos"
echo " -b --build-full Perform all tasks to build the full iso"
echo " -m --build-minimal Perform all tasks to build the minimal iso"
echo " -h --help Show usage"
echo ""
echo "Advanced options:"
echo " -f --fix-perms Fix folder permissions"
echo " -i --install-deps Install build dependencies"
echo " -m --prep-minimal-env Prep live & airootfs folders (minimal packages)"
echo " -n --prep-minimal-env Prep live & airootfs folders (minimal packages)"
echo " -o --build-iso Build ISO (using current setup)"
echo " -p --prep-live-env Prep live & airootfs folders"
echo " -u --update-repo Update custom pacman repo"