| | |
| | | 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, |
| | |
| | | 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. |
| | |
| | | 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) |
| | |
| | | |
| | | 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 |
| | |
| | | # 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: |