diff --git a/pikaur/build.py b/pikaur/build.py index 154ada6c..01274e7a 100644 --- a/pikaur/build.py +++ b/pikaur/build.py @@ -50,7 +50,7 @@ print_stderr, print_stdout, ) -from .pikatypes import ComparableType +from .pikatypes import AURInstallInfo, ComparableType from .privilege import ( isolate_root_cmd, sudo, @@ -150,6 +150,7 @@ class PackageBuild(ComparableType): _build_files_copied = False failed: bool | None = None + is_dep: bool | None = None new_deps_to_install: list[str] new_make_deps_to_install: list[str] @@ -172,8 +173,11 @@ def __init__( self, package_names: list[str] | None = None, pkgbuild_path: str | None = None, + *, + is_dep: bool | None = None, ) -> None: self.args = parse_args() + self.is_dep = is_dep if pkgbuild_path: self.repo_path = dirname(pkgbuild_path) @@ -608,7 +612,7 @@ def check_if_already_built(self) -> bool: self.get_latest_dev_sources() self.set_built_package_path() if ( - not self.args.rebuild and + not (self.args.rebuild and not self.is_dep) and len(self.built_packages_paths) == len(self.package_names) ): message = translate_many( @@ -1013,7 +1017,8 @@ def get(cls, repo: str) -> bool: return repo in cls.repos -def clone_aur_repos(package_names: list[str]) -> dict[str, PackageBuild]: +def clone_aur_repos(package_infos: list[AURInstallInfo]) -> dict[str, PackageBuild]: + package_names = [info.name for info in package_infos] aur_pkgs, _ = find_aur_packages(package_names) packages_bases: dict[str, list[str]] = {} for aur_pkg in aur_pkgs: @@ -1023,6 +1028,10 @@ def clone_aur_repos(package_names: list[str]) -> dict[str, PackageBuild]: for pkgbase, pkg_names in packages_bases.items() if not AlreadyClonedRepos.get(pkgbase) } + install_infos_by_base = { + info.package.packagebase: info + for info in package_infos + } pool_size: int | None = None if clone_c := parse_args().aur_clone_concurrency: @@ -1053,7 +1062,10 @@ def clone_aur_repos(package_names: list[str]) -> dict[str, PackageBuild]: raise exc all_package_builds_by_base = { - pkgbase: PackageBuild(package_names=pkg_names) + pkgbase: PackageBuild( + package_names=pkg_names, + is_dep=bool(install_infos_by_base[pkgbase].required_by), + ) for pkgbase, pkg_names in packages_bases.items() } return { diff --git a/pikaur/install_cli.py b/pikaur/install_cli.py index 36ae0b79..91efce2d 100644 --- a/pikaur/install_cli.py +++ b/pikaur/install_cli.py @@ -55,7 +55,7 @@ print_stdout, print_warning, ) -from .pikatypes import AURPackageInfo, PackageSource +from .pikatypes import AURInstallInfo, AURPackageInfo, PackageSource from .print_department import ( pretty_format_sysupgrade, print_not_found_packages, @@ -316,7 +316,13 @@ def _get_pkgbuild_for_name_or_provided(self, pkg_name: str) -> PackageBuild: ) def edit_pkgbuild_during_the_build(self, pkg_name: str) -> None: - updated_pkgbuilds = self._clone_aur_repos([pkg_name]) + updated_pkgbuilds = self._clone_aur_repos([ + install_info + for install_info in ( + self.install_info._all_aur_updates_raw # pylint: disable=protected-access # noqa: SLF001,E501,RUF100 + ) + if install_info.name == pkg_name + ]) if not updated_pkgbuilds: return self.package_builds_by_name.update(updated_pkgbuilds) @@ -741,12 +747,12 @@ def _find_extra_aur_build_deps(self, all_package_builds: dict[str, PackageBuild] raise self.ExitMainSequence def _clone_aur_repos( # pylint: disable=too-many-branches - self, package_names: list[str], + self, package_infos: list[AURInstallInfo], ) -> dict[str, PackageBuild] | None: stash_pop_list: list[str] = [] while True: try: - pkgbuild_by_name = clone_aur_repos(package_names=package_names) + pkgbuild_by_name = clone_aur_repos(package_infos=package_infos) except CloneError as err: package_build = err.build print_stderr(color_line( @@ -801,8 +807,9 @@ def _clone_aur_repos( # pylint: disable=too-many-branches elif answer == translate("s"): # pragma: no cover for skip_pkg_name in package_build.package_names: self.discard_install_info(skip_pkg_name) - if skip_pkg_name in package_names: - package_names.remove(skip_pkg_name) + for info in package_infos.copy(): + if skip_pkg_name == info.name: + package_infos.remove(info) elif answer == translate("a"): # pragma: no cover raise SysExit(125) from err else: @@ -833,6 +840,7 @@ def get_package_builds(self) -> None: pkgbuilds_by_base[pkg_base] = PackageBuild( pkgbuild_path=info.pkgbuild_path, package_names=package_names, + is_dep=bool(info.required_by), ) pkgbuilds_by_name[info.name] = pkgbuilds_by_base[pkg_base] for provided_str in info.package.provides: @@ -840,7 +848,7 @@ def get_package_builds(self) -> None: pkgbuilds_by_provides[provided_name] = pkgbuilds_by_base[pkg_base] else: clone_infos.append(info) - cloned_pkgbuilds = self._clone_aur_repos([info.name for info in clone_infos]) + cloned_pkgbuilds = self._clone_aur_repos(clone_infos) if cloned_pkgbuilds: logger.debug("cloned_pkgbuilds={}", cloned_pkgbuilds) pkgbuilds_by_name.update(cloned_pkgbuilds)