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

Joel Grunbaum
yesterday ce77be2fb546f5bd67cc438c7dece3b10b8da056
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.
@@ -311,11 +325,12 @@
        return cycles
    async def resolve(self, package_names: list[str]) -> BuildOrder:
    async def resolve(self, package_names: list[str], exclude_repo: str | None = None) -> BuildOrder:
        """Resolve dependencies and determine build order.
        Args:
            package_names: List of packages to resolve
            exclude_repo: Optional repository name to exclude from existence checks
        Returns:
            BuildOrder with packages in correct build order
@@ -326,9 +341,13 @@
        # Filter out packages already in repos or installed
        aur_package_names = []
        for name in package_names:
            if self.is_in_repos(name):
                logger.info(f"Package {name} found in repositories, skipping AUR lookup")
                continue
            repo = self.is_in_repos(name)
            if repo:
                if exclude_repo and repo == exclude_repo:
                    logger.debug(f"Package {name} found in excluded repo {repo}, treating as not in repos")
                else:
                    logger.info(f"Package {name} found in {repo}, skipping AUR lookup")
                    continue
            if self.is_installed(name):
                logger.info(f"Package {name} is already installed, skipping AUR lookup")
                continue