| | |
| | | from enum import Enum |
| | | from pathlib import Path |
| | | from concurrent.futures import ProcessPoolExecutor |
| | | from typing import Any |
| | | from typing import Any, TYPE_CHECKING |
| | | if TYPE_CHECKING: |
| | | from archrepobuild.repo import RepoManager |
| | | |
| | | from archrepobuild.aur import AURClient |
| | | from archrepobuild.config import Config, PackageOverride |
| | |
| | | self, |
| | | config: Config, |
| | | aur_client: AURClient, |
| | | repo: RepoManager | None = None, |
| | | ): |
| | | """Initialize builder. |
| | | |
| | | Args: |
| | | config: Application configuration |
| | | aur_client: AUR client for package info |
| | | repo: Optional repository manager for incremental registration |
| | | """ |
| | | self.config = config |
| | | self.aur_client = aur_client |
| | | self.repo = repo |
| | | self.resolver = DependencyResolver(aur_client) |
| | | self._lock_dir = config.repository.build_dir / ".locks" |
| | | self._executor: ProcessPoolExecutor | None = None |
| | |
| | | raise ValueError(f"Package not found in AUR: {package}") |
| | | |
| | | pkg_dir.parent.mkdir(parents=True, exist_ok=True) |
| | | subprocess.run( |
| | | ["git", "clone", pkg_info.git_url, str(pkg_dir)], |
| | | check=True, |
| | | capture_output=True, |
| | | ) |
| | | try: |
| | | subprocess.run( |
| | | ["git", "clone", pkg_info.git_url, str(pkg_dir)], |
| | | check=True, |
| | | capture_output=True, |
| | | text=True, |
| | | ) |
| | | except subprocess.CalledProcessError as e: |
| | | logger.error(f"Failed to clone {package} from {pkg_info.git_url}: {e.stderr}") |
| | | raise ValueError(f"Failed to clone package from AUR: {e.stderr}") |
| | | return True |
| | | |
| | | def _is_vcs_package(self, package_dir: Path) -> bool: |
| | |
| | | |
| | | final_results.append(result) |
| | | |
| | | if result.status == BuildStatus.FAILED: |
| | | if result.status == BuildStatus.SUCCESS: |
| | | if self.repo: |
| | | 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(sync=True) |
| | | elif result.status == BuildStatus.FAILED: |
| | | logger.error(f"Failed to process {pkg_name}, aborting") |
| | | if pkg_name == package: |
| | | return result |