Skip to content

Commit

Permalink
fix(build, install_cli): when passing --rebuild flag - rebuild only e…
Browse files Browse the repository at this point in the history
…xplicitly requested package itself, but not its deps
  • Loading branch information
actionless committed Dec 25, 2024
1 parent e9fcafc commit 84cb764
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
20 changes: 16 additions & 4 deletions pikaur/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
print_stderr,
print_stdout,
)
from .pikatypes import ComparableType
from .pikatypes import AURInstallInfo, ComparableType
from .privilege import (
isolate_root_cmd,
sudo,
Expand Down Expand Up @@ -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]
Expand All @@ -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)
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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 {
Expand Down
22 changes: 15 additions & 7 deletions pikaur/install_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -833,14 +840,15 @@ 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:
provided_name = VersionMatcher(provided_str).pkg_name
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)
Expand Down

0 comments on commit 84cb764

Please sign in to comment.