chroot: replace arch.from_chroot_suffix() with chroot.arch (MR 2252)

Another usage of args dropped!

Although the device_arch variable thing is not very ideal...

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
Caleb Connolly 2024-05-24 19:22:35 +02:00 committed by Oliver Smith
parent 8526631589
commit fa804c9453
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
9 changed files with 29 additions and 19 deletions

View file

@ -72,6 +72,23 @@ class Chroot:
return Path(pmb.config.work, self.dirname)
@property
# FIXME: make an Arch type
def arch(self) -> str:
if self.type == ChrootType.NATIVE:
return pmb.config.arch_native
if self.type == ChrootType.BUILDROOT:
return self.name()
# FIXME: this is quite delicate as it will only be valid
# for certain pmbootstrap commands... It was like this
# before but it should be fixed.
arch = pmb.core.get_context().device_arch
if arch is not None:
return arch
raise ValueError(f"Invalid chroot suffix: {self}"
" (wrong device chosen in 'init' step?)")
def __eq__(self, other: object) -> bool:
if isinstance(other, str):
return str(self) == other or self.path == Path(other) or self.name() == other