Merge pull request #162252 from sternenseemann/systemd-boot-builder-fix-errors
sdboot-builder: fix crash in exception handling
This commit is contained in:
commit
5f81753d1b
|
@ -15,9 +15,12 @@ import re
|
||||||
import datetime
|
import datetime
|
||||||
import glob
|
import glob
|
||||||
import os.path
|
import os.path
|
||||||
from typing import Tuple, List, Optional
|
from typing import NamedTuple, List, Optional
|
||||||
|
|
||||||
SystemIdentifier = Tuple[Optional[str], int, Optional[str]]
|
class SystemIdentifier(NamedTuple):
|
||||||
|
profile: Optional[str]
|
||||||
|
generation: int
|
||||||
|
specialisation: Optional[str]
|
||||||
|
|
||||||
|
|
||||||
def copy_if_not_exists(source: str, dest: str) -> None:
|
def copy_if_not_exists(source: str, dest: str) -> None:
|
||||||
|
@ -151,7 +154,14 @@ def get_generations(profile: Optional[str] = None) -> List[SystemIdentifier]:
|
||||||
gen_lines.pop()
|
gen_lines.pop()
|
||||||
|
|
||||||
configurationLimit = @configurationLimit@
|
configurationLimit = @configurationLimit@
|
||||||
configurations: List[SystemIdentifier] = [ (profile, int(line.split()[0]), None) for line in gen_lines ]
|
configurations = [
|
||||||
|
SystemIdentifier(
|
||||||
|
profile=profile,
|
||||||
|
generation=int(line.split()[0]),
|
||||||
|
specialisation=None
|
||||||
|
)
|
||||||
|
for line in gen_lines
|
||||||
|
]
|
||||||
return configurations[-configurationLimit:]
|
return configurations[-configurationLimit:]
|
||||||
|
|
||||||
|
|
||||||
|
@ -160,7 +170,7 @@ def get_specialisations(profile: Optional[str], generation: int, _: Optional[str
|
||||||
system_dir(profile, generation, None), "specialisation")
|
system_dir(profile, generation, None), "specialisation")
|
||||||
if not os.path.exists(specialisations_dir):
|
if not os.path.exists(specialisations_dir):
|
||||||
return []
|
return []
|
||||||
return [(profile, generation, spec) for spec in os.listdir(specialisations_dir)]
|
return [SystemIdentifier(profile, generation, spec) for spec in os.listdir(specialisations_dir)]
|
||||||
|
|
||||||
|
|
||||||
def remove_old_entries(gens: List[SystemIdentifier]) -> None:
|
def remove_old_entries(gens: List[SystemIdentifier]) -> None:
|
||||||
|
@ -271,7 +281,8 @@ def main() -> None:
|
||||||
if os.readlink(system_dir(*gen)) == args.default_config:
|
if os.readlink(system_dir(*gen)) == args.default_config:
|
||||||
write_loader_conf(*gen)
|
write_loader_conf(*gen)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
print("ignoring generation '{}' in the list of boot entries because of the following error:\n{}".format(*gen, e), file=sys.stderr)
|
profile = f"profile '{gen.profile}'" if gen.profile else "default profile"
|
||||||
|
print("ignoring {} in the list of boot entries because of the following error:\n{}".format(profile, e), file=sys.stderr)
|
||||||
|
|
||||||
for root, _, files in os.walk('@efiSysMountPoint@/efi/nixos/.extra-files', topdown=False):
|
for root, _, files in os.walk('@efiSysMountPoint@/efi/nixos/.extra-files', topdown=False):
|
||||||
relative_root = root.removeprefix("@efiSysMountPoint@/efi/nixos/.extra-files").removeprefix("/")
|
relative_root = root.removeprefix("@efiSysMountPoint@/efi/nixos/.extra-files").removeprefix("/")
|
||||||
|
|
Loading…
Reference in a new issue