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

Joel Grunbaum
yesterday f250049cca24d7178cb52569c1da4273884e5aa8
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.
@@ -207,11 +221,9 @@
            dep_parsed = Dependency.parse(dep)
            base_name = dep_parsed.name
            # Skip if in repos or already installed
            # Skip if in repos
            if self.is_in_repos(base_name):
                continue
            if self.is_installed(base_name):
                continue
            aur_deps.append(base_name)
            graph[package.name].add(base_name)
@@ -311,11 +323,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,12 +339,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
            if self.is_installed(name):
                logger.info(f"Package {name} is already installed, 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
            aur_package_names.append(name)
        if not aur_package_names: