packages/pkgbuild: track whether pkg is built on a per-architecture basis

This commit is contained in:
InsanePrawn 2022-12-11 02:31:46 +01:00
parent 45eba305cb
commit cec828553d
2 changed files with 15 additions and 10 deletions

View file

@ -698,7 +698,7 @@ def build_packages(
for package in need_build: for package in need_build:
base = package.pkgbase if isinstance(package, SubPkgbuild) else package base = package.pkgbase if isinstance(package, SubPkgbuild) else package
assert isinstance(base, Pkgbase) assert isinstance(base, Pkgbase)
if package.is_built(): if package.is_built(arch):
logging.info(f"Skipping building {package.name} since it was already built this run as part of pkgbase {base.name}") logging.info(f"Skipping building {package.name} since it was already built this run as part of pkgbase {base.name}")
continue continue
build_package( build_package(
@ -711,7 +711,9 @@ def build_packages(
) )
files += add_package_to_repo(package, arch) files += add_package_to_repo(package, arch)
updated_repos.add(package.repo) updated_repos.add(package.repo)
base._is_built = True for _arch in ['any', arch]:
if _arch in base.arches:
base._built_for.add(_arch)
# rescan affected repos # rescan affected repos
local_repos = get_kupfer_local(arch, in_chroot=False, scan=False) local_repos = get_kupfer_local(arch, in_chroot=False, scan=False)
for repo_name in updated_repos: for repo_name in updated_repos:

View file

@ -239,16 +239,16 @@ class Pkgbuild(PackageInfo):
arch = 'any' arch = 'any'
return f'{self.name}-{self.version}-{arch}.pkg.tar.zst' return f'{self.name}-{self.version}-{arch}.pkg.tar.zst'
def is_built(self) -> bool: def is_built(self, arch: Arch, tolerate_archless: bool = True) -> bool:
raise NotImplementedError() raise NotImplementedError()
class Pkgbase(Pkgbuild): class Pkgbase(Pkgbuild):
subpackages: list[SubPkgbuild] subpackages: list[SubPkgbuild]
_is_built: bool _built_for: set[Arch]
def __init__(self, relative_path: str, subpackages: list[SubPkgbuild] = [], **args): def __init__(self, relative_path: str, subpackages: list[SubPkgbuild] = [], **args):
self._is_built = False self._built_for = set()
self.subpackages = list(subpackages) self.subpackages = list(subpackages)
super().__init__(relative_path, **args) super().__init__(relative_path, **args)
@ -256,7 +256,7 @@ class Pkgbase(Pkgbuild):
if not isinstance(pkg, Pkgbase): if not isinstance(pkg, Pkgbase):
raise Exception(f"Tried to update pkgbase {self.name} with non-base pkg {pkg}") raise Exception(f"Tried to update pkgbase {self.name} with non-base pkg {pkg}")
Pkgbuild.update(self, pkg) Pkgbuild.update(self, pkg)
self._is_built = pkg._is_built or self._is_built self._built_for.update(pkg._built_for)
sub_dict = {p.name: p for p in self.subpackages} sub_dict = {p.name: p for p in self.subpackages}
self.subpackages.clear() self.subpackages.clear()
for new_pkg in pkg.subpackages: for new_pkg in pkg.subpackages:
@ -290,8 +290,11 @@ class Pkgbase(Pkgbuild):
names.update(pkg.names()) names.update(pkg.names())
return list(names) return list(names)
def is_built(self) -> bool: def is_built(self, arch: Arch, tolerate_archless: bool = True) -> bool:
return self._is_built arches = {arch}
if tolerate_archless:
arches.add('any')
return bool(self._built_for.intersection(arches))
class SubPkgbuild(Pkgbuild): class SubPkgbuild(Pkgbuild):
@ -313,8 +316,8 @@ class SubPkgbuild(Pkgbuild):
assert self.pkgbase assert self.pkgbase
self.pkgbase.refresh_sources(lazy=lazy) self.pkgbase.refresh_sources(lazy=lazy)
def is_built(self) -> bool: def is_built(self, arch: Arch, tolerate_archless: bool = True) -> bool:
return self.pkgbase.is_built() return self.pkgbase.is_built(arch)
def parse_pkgbuild( def parse_pkgbuild(