Arch Linux (ALPM) Adapter
Relevant source files
The following files were used as context for generating this wiki page:
The Arch Linux (ALPM) Adapter is a specialized registry implementation within the regxa library designed to interface with both the official Arch Linux package repositories and the Arch User Repository (AUR). It normalizes metadata from these distinct sources into the unified data models used across the project, such as Package, Version, and Dependency.
The adapter acts as a routing layer that interprets a package's namespace to determine whether to query the Arch Linux official JSON API or the AUR RPC v5. This allows users to treat Arch Linux as a single ecosystem while benefiting from the vast collection of community-maintained packages.
Sources: src/registries/alpm.ts:1-76, README.md:104-108
Architecture and Routing
The AlpmRegistry class implements the Registry interface. It manages requests by parsing the input package name to identify a namespace. If no namespace is provided, it defaults to the official repositories.
Namespace Handling
The adapter uses a specific string parsing logic to route requests:
- arch: Routes to
https://archlinux.org/packages/search/json/. - aur: Routes to
https://aur.archlinux.org/rpc/v5/info/.
The following flowchart illustrates the internal routing logic:
The parseName method normalizes the input by trimming and converting it to lowercase before splitting.
Sources: src/registries/alpm.ts:241-262, test/unit/alpm.test.ts:251-270
Data Normalization
The adapter translates complex upstream responses into standardized types.
Version Formatting
For official packages, the adapter formats versions using the ALPM standard: [epoch:]pkgver-pkgrel. The epoch is only included if it is greater than zero. AUR packages return a pre-formatted version string directly from the RPC.
Sources: src/registries/alpm.ts:269-272, test/unit/alpm.test.ts:98-107
Status Mapping
Package "freshness" and status are mapped to the core VersionStatus type:
| Source Condition | Normalized Status |
|---|---|
Official: flag_date is not null | deprecated |
AUR: OutOfDate is not null | deprecated |
| Otherwise | "" (Empty string) |
Sources: src/registries/alpm.ts:145, src/registries/alpm.ts:208, test/unit/alpm.test.ts:143-152
Dependency Parsing
ALPM dependencies often include version constraints (e.g., bash>=5.0) or optional descriptions (e.g., perl: for translation). The adapter uses regex and string splitting to separate these components.
API Implementation
The AlpmRegistry class provides the following core methods:
| Method | Description |
|---|---|
fetchPackage | Fetches high-level metadata, description, and latest version. Prefers x86_64 architecture for official packages. |
fetchVersions | Returns an array containing the current version and its status. |
fetchDependencies | Parses depends, makedepends, optdepends, and checkdepends. |
fetchMaintainers | Extracts maintainer lists from the maintainers array (official) or the Maintainer field (AUR). |
urls | Generates a URLBuilder for documentation, download, and registry links. |
Official Repository Specifics
When querying official repositories, the adapter specifically filters results to prefer x86_64. If multiple architectures are present and x86_64 is found, it is prioritized; otherwise, it falls back to the first available result.
Sources: src/registries/alpm.ts:167-183, test/unit/alpm.test.ts:109-122
AUR Specifics
AUR timestamps are provided as Unix seconds. The adapter converts these to JavaScript Date objects by multiplying by 1000.
Sources: src/registries/alpm.ts:205, test/unit/alpm.test.ts:210-220
URL Generation
The urls() method provides a standard way to retrieve relevant links for a package.
// Example from src/registries/alpm.ts
urls(): URLBuilder {
return {
registry: (name: string) => {
const { namespace, pkgName } = this.parseName(name);
return namespace === "aur"
? `https://aur.archlinux.org/packages/${pkgName}`
: `https://archlinux.org/packages/?name=${pkgName}`;
},
download: (name: string) => {
const { namespace, pkgName } = this.parseName(name);
if (namespace === "aur") {
return `https://aur.archlinux.org/cgit/aur.git/snapshot/${pkgName}.tar.gz`;
}
const letter = pkgName.charAt(0);
return `https://archive.archlinux.org/packages/${letter}/${pkgName}/`;
},
// ...
};
}
Sources: src/registries/alpm.ts:101-127
Summary
The Arch Linux (ALPM) Adapter provides a bridge between the Arch Linux ecosystem and the regxa library. By abstracting the differences between the official Arch Linux JSON API and the AUR RPC, it enables a PURL-native query interface (pkg:alpm/arch/name or pkg:alpm/aur/name). It ensures that Arch Linux package data—including version epochs, flagged status, and complex dependency constraints—is normalized for use in CLI and AI-driven workflows.