core: chroot: Deduplicate supported arch list (MR 2476)

self.arch is a property and calls Arch.from_str, which errors upon
encountering an unknown architecture. Therefore, the error message is
changed and needs to be adjusted in the tests. Since Arch.supported is a
set, error messages were not deterministic before, so we need to sort
the list of architectures now.

Signed-off-by: Jens Reidel <adrian@travitia.xyz>
This commit is contained in:
Jens Reidel 2024-10-07 00:32:04 +02:00
parent 6d72043ac2
commit 9ca0ada582
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
3 changed files with 6 additions and 12 deletions

View file

@ -41,21 +41,12 @@ class Chroot:
"""
Ensures that this suffix follows the correct format.
"""
valid_arches = [
"x86",
"x86_64",
"aarch64",
"armhf", # XXX: remove this?
"armv7",
"riscv64",
]
if self.__type not in ChrootType._member_map_.values():
raise ValueError(f"Invalid chroot type: '{self.__type}'")
# A buildroot suffix must have a name matching one of alpines
# architectures.
if self.__type == ChrootType.BUILDROOT and self.__name not in valid_arches:
if self.__type == ChrootType.BUILDROOT and self.arch not in Arch.supported():
raise ValueError(f"Invalid buildroot suffix: '{self.__name}'")
# A rootfs or installer suffix must have a name matching a device.