| 20 hours ago | Joel Grunbaum | ![]() |
| 20 hours ago | Joel Grunbaum | ![]() |
| 20 hours ago | Joel Grunbaum | ![]() |
| 20 hours ago | Joel Grunbaum | ![]() |
| src/archrepobuild/cli.py | ●●●●● patch | view | raw | blame | history | |
| src/archrepobuild/notifications.py | ●●●●● patch | view | raw | blame | history | |
| src/archrepobuild/resolver.py | ●●●●● patch | view | raw | blame | history | |
| tests/test_resolver.py | ●●●●● patch | view | raw | blame | history |
src/archrepobuild/cli.py
@@ -179,8 +179,9 @@ @cli.command() @click.option("--all-repos", "-a", is_flag=True, help="Include all enabled repositories, not just official ones") @pass_context def check(ctx: Context) -> None: def check(ctx: Context, all_repos: bool) -> None: """Check for packages moved to official repos or removed from AUR.""" config = ctx.config @@ -196,13 +197,20 @@ with console.status("Checking packages..."): for pkg in packages: if resolver.is_in_official_repos(pkg.name): # Ignore debug packages if the regular version is in official repos if pkg.name.endswith("-debug"): base_name = pkg.name[:-6] if resolver.is_in_official_repos(base_name, include_all=all_repos) or await aur.is_available(base_name): continue if resolver.is_in_official_repos(pkg.name, include_all=all_repos): in_official.append(pkg.name) elif not await aur.is_available(pkg.name): not_in_aur.append(pkg.name) if in_official: console.print("\n[yellow]Packages now in official repos:[/]") repo_type = "official" if not all_repos else "enabled" console.print(f"\n[yellow]Packages now in {repo_type} repos:[/]") for pkg in in_official: console.print(f" • {pkg}") src/archrepobuild/notifications.py
@@ -106,7 +106,7 @@ async def send(self, summary: BuildSummary, config: Config) -> bool: """Send email notification.""" if not self.config.enabled and ((not self.config.email_everytime) and summary.failed == 0): if not self.config.enabled: return True if not self.config.to: @@ -114,7 +114,7 @@ return False # Only send on failures if summary.failed == 0: if (not self.config.email_everytime) and summary.failed == 0: logger.debug("No failures, skipping email notification") return True src/archrepobuild/resolver.py
@@ -10,6 +10,10 @@ logger = get_logger("resolver") # Official Arch Linux repositories OFFICIAL_REPOS = {"core", "extra", "multilib", "testing", "extra-testing", "multilib-testing", "gnome-unstable", "kde-unstable"} class DependencyType(Enum): """Type of dependency.""" @@ -71,40 +75,58 @@ aur_client: AURClient instance for fetching package info """ self.aur_client = aur_client self._pacman_cache: set[str] = set() 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.""" try: result = subprocess.run( ["pacman", "-Slq"], ["pacman", "-Sl"], capture_output=True, text=True, check=True, ) self._pacman_cache = set(result.stdout.strip().split("\n")) self._pacman_cache = {} for line in result.stdout.strip().split("\n"): if not line: continue parts = line.split() if len(parts) >= 2: repo, name = parts[0], parts[1] if repo not in self._pacman_cache: self._pacman_cache[repo] = set() self._pacman_cache[repo].add(name) self._pacman_checked = True logger.debug(f"Cached {len(self._pacman_cache)} packages from official repos") 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 = set() self._pacman_cache = {} def is_in_official_repos(self, name: str) -> bool: def is_in_official_repos(self, name: str, include_all: bool = True) -> bool: """Check if package is available in official repositories. Args: name: Package name (without version constraint) include_all: If True, check all enabled repos. If False, only official ones. Returns: True if available in official repos True if available in repos """ if not self._pacman_checked: self._refresh_pacman_cache() # Strip version constraint base_name = name.split(">=")[0].split("<=")[0].split("=")[0].split(">")[0].split("<")[0] return base_name in self._pacman_cache for repo, pkgs in self._pacman_cache.items(): if not include_all and repo not in OFFICIAL_REPOS: continue if base_name in pkgs: return True return False def is_installed(self, name: str) -> bool: """Check if package is already installed. tests/test_resolver.py
@@ -122,10 +122,17 @@ def test_is_in_official_repos(self, mock_run, mock_aur_client): """Test checking official repos.""" mock_run.return_value.returncode = 0 mock_run.return_value.stdout = "base\ngit\nvim\n" mock_run.return_value.stdout = "core base\nextra git\ncustom mypkg\n" resolver = DependencyResolver(mock_aur_client) resolver._refresh_pacman_cache() # Test default (include_all=True) assert resolver.is_in_official_repos("git") assert resolver.is_in_official_repos("mypkg") assert resolver.is_in_official_repos("base") assert not resolver.is_in_official_repos("yay") # Test official_only (include_all=False) assert resolver.is_in_official_repos("git", include_all=False) assert resolver.is_in_official_repos("base", include_all=False) assert not resolver.is_in_official_repos("mypkg", include_all=False)