mirror of https://github.com/Chizi123/Arch-autobuild-repo.git

Joel Grunbaum
21 hours ago 2db2123c703a189738e517b210b92d4fdce42410
Refresh repos with pacman for deps
2 files modified
24 ■■■■ changed files
src/archrepobuild/builder.py 2 ●●● patch | view | raw | blame | history
src/archrepobuild/resolver.py 22 ●●●● patch | view | raw | blame | history
src/archrepobuild/builder.py
@@ -533,7 +533,7 @@
                    logger.info(f"Adding {pkg_name} to repository")
                    self.repo.add_packages(result)
                    # Refresh resolver cache to recognize the newly added package
                    self.resolver._refresh_pacman_cache()
                    self.resolver._refresh_pacman_cache(sync=True)
            elif result.status == BuildStatus.FAILED:
                logger.error(f"Failed to process {pkg_name}, aborting")
                if pkg_name == package:
src/archrepobuild/resolver.py
@@ -78,9 +78,22 @@
        self._pacman_cache: dict[str, set[str]] = {}  # repo -> packages
        self._pacman_checked = False
    def _refresh_pacman_cache(self) -> None:
        """Refresh cache of packages available from official repos."""
    def _refresh_pacman_cache(self, sync: bool = False) -> None:
        """Refresh cache of packages available from official repos.
        Args:
            sync: Whether to synchronize pacman databases first using sudo pacman -Sy
        """
        try:
            if sync:
                logger.info("Synchronizing pacman databases...")
                subprocess.run(
                    ["sudo", "pacman", "-Sy", "--noconfirm"],
                    capture_output=True,
                    text=True,
                    check=True,
                )
            result = subprocess.run(
                ["pacman", "-Sl"],
                capture_output=True,
@@ -102,8 +115,9 @@
            total_pkgs = sum(len(pkgs) for pkgs in self._pacman_cache.values())
            logger.debug(f"Cached {total_pkgs} packages from {len(self._pacman_cache)} repos")
        except subprocess.CalledProcessError as e:
            logger.warning(f"Failed to get pacman package list: {e}")
            self._pacman_cache = {}
            logger.warning(f"Failed to refresh pacman cache: {e}")
            if not self._pacman_cache:
                self._pacman_cache = {}
    def is_in_repos(self, name: str, include_all: bool = True) -> str | None:
        """Check if package is available in repositories.