feat: add auto secure boot to new kernel update
This commit is contained in:
@ -4,6 +4,8 @@ from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
from secure_boot import prepare_secure_boot, refresh_secure_boot
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
PACMAN_LOCK = Path("/var/lib/pacman/db.lck")
|
||||
@ -75,12 +77,30 @@ def install_packages(names: list[str]) -> InstallResult:
|
||||
if not names:
|
||||
return InstallResult(success=True)
|
||||
|
||||
secure_boot = prepare_secure_boot(names)
|
||||
if not secure_boot.success:
|
||||
return InstallResult(
|
||||
success=False,
|
||||
failed=names,
|
||||
error=f"Préparation Secure Boot impossible : {secure_boot.error}",
|
||||
)
|
||||
|
||||
result = subprocess.run(
|
||||
["pacman", "-S", "--noconfirm", "--needed", "--noprogressbar"] + names,
|
||||
capture_output=True, text=True, timeout=600
|
||||
)
|
||||
|
||||
if result.returncode == 0:
|
||||
secure_boot = refresh_secure_boot(names)
|
||||
if not secure_boot.success:
|
||||
return InstallResult(
|
||||
success=False,
|
||||
failed=names,
|
||||
error=(
|
||||
"Les paquets ont été installés, mais la chaîne de démarrage "
|
||||
f"n'a pas pu être sécurisée : {secure_boot.error}"
|
||||
),
|
||||
)
|
||||
return InstallResult(success=True, installed=names)
|
||||
else:
|
||||
return InstallResult(
|
||||
@ -100,12 +120,30 @@ def upgrade_cached_packages(expected_names: list[str]) -> InstallResult:
|
||||
if not expected_names:
|
||||
return InstallResult(success=True)
|
||||
|
||||
secure_boot = prepare_secure_boot(expected_names)
|
||||
if not secure_boot.success:
|
||||
return InstallResult(
|
||||
success=False,
|
||||
failed=expected_names,
|
||||
error=f"Préparation Secure Boot impossible : {secure_boot.error}",
|
||||
)
|
||||
|
||||
result = subprocess.run(
|
||||
["pacman", "-Su", "--noconfirm", "--noprogressbar"],
|
||||
capture_output=True, text=True, timeout=600
|
||||
)
|
||||
|
||||
if result.returncode == 0:
|
||||
secure_boot = refresh_secure_boot(expected_names)
|
||||
if not secure_boot.success:
|
||||
return InstallResult(
|
||||
success=False,
|
||||
failed=expected_names,
|
||||
error=(
|
||||
"Les paquets ont été installés, mais la chaîne de démarrage "
|
||||
f"n'a pas pu être sécurisée : {secure_boot.error}"
|
||||
),
|
||||
)
|
||||
return InstallResult(success=True, installed=expected_names)
|
||||
else:
|
||||
return InstallResult(
|
||||
|
||||
Reference in New Issue
Block a user