APB is a distributed Arch Linux package building system that provides automated, multi-architecture package compilation across multiple build servers. It consists of three main components that work together to efficiently build and distribute pacman packages.
APB (Arch Package Builder) is designed to solve the challenges of building Arch Linux packages across different architectures and managing build infrastructure at scale. It provides:
- Distributed Building: Automatically distribute package builds across multiple servers based on architecture and load
- Multi-Architecture Support: Build packages for x86_64, aarch64, powerpc64le, riscv64, and other architectures
- Architecture-Independent Packages:
arch=('any')packages can be routed to any available build server - Automated Buildroot Management: Handles chroot creation, maintenance, and cleanup using
mkarchrootandmakechrootpkg - Source Management: Automatic GPG key validation, source dependency handling, and tarball uploads that include source directories
- Build Monitoring: Real-time build status tracking and log streaming
- Artifact Caching: The farm caches completed build artifacts locally so clients download from the farm without re-fetching from build servers
- Resource Management: Intelligent load balancing and concurrent build limiting
- Authentication & Authorization: Secure user management with role-based access control
- Web Dashboard: Farm dashboard for server health, build history, and administration
APB is particularly useful for:
- Package maintainers building pacman packages for multiple architectures
- Organizations maintaining private package repositories
- Developers needing consistent, isolated build environments
- Projects requiring automated CI/CD package building
- Teams needing secure, multi-user build infrastructure
APB follows a three-tier architecture:
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ APB Client │───▶│ APB Farm │───▶│ APB Server │
│ │ │ │ │ │
│ • Submit builds │ │ • Load balancing│ │ • Package builds│
│ • Monitor status│ │ • Architecture │ │ • Buildroot mgmt│
│ • Download files│ │ routing │ │ • Resource mgmt │
│ • Build control │ │ • Multi-server │ │ • File serving │
│ • Authentication│ │ coordination │ └─────────────────┘
└─────────────────┘ │ • User management│
│ • Access control │
│ • Artifact cache │
└─────────────────┘
The command-line interface and Python library (apb.client) for interacting with the build system. It handles:
- Submitting build requests as tarballs of the package directory (PKGBUILD plus sources)
- Monitoring build progress with real-time output streaming
- Waiting for farm artifact caching (
artifacts_ready) before downloading results - Downloading completed packages and build artifacts
- Managing multiple architectures and build configurations
- User authentication and session management
The central coordinator that manages multiple build servers. It provides:
- Automatic server discovery and health monitoring
- Intelligent build routing based on architecture and server load
- Build queue management and prioritization
- Unified API interface for clients
- Build tracking across all servers with cached status when servers are temporarily unavailable
- User authentication and authorization system
- Role-based access control (admin, user, guest)
- Secure token-based session management
- Web dashboard at
/dashboardwith path-based URLs (for example/dashboard/builds/2) - Artifact caching with configurable retention
- SMTP notifications and custom pacman repository configuration (admin)
The build execution engine that runs on each build machine. It handles:
- Isolated package building using clean chroots
- Buildroot lifecycle management with automatic recreation
- Source caching and GPG key validation
- Concurrent build management and resource limiting
- Build artifact storage and serving
APB is installed as a Python package under src/apb/:
| Module | Purpose |
|---|---|
apb.client |
CLI, HTTP client, and authentication |
apb.farm |
Farm application, routing, and core logic |
apb.server |
Server application and build engine |
apb.pkgbuild |
PKGBUILD parsing (including bash-style variable substitution) |
apb.tarball |
Build directory tarball creation |
apb.config |
Shared configuration loading |
apb.web |
Jinja2 HTML templates and static assets |
Console entry points are defined in pyproject.toml: apb, apb-farm, and apb-server.
The system uses a JSON configuration file (apb.json) that defines server topology and optional cache settings:
{
"servers": {
"x86_64": [
"http://server1.example.com:8000",
"http://server2.example.com:8000"
],
"aarch64": [
"http://arm-server1.example.com:8000"
],
"any": [
"http://fallback-server.example.com:8000"
]
},
"farm_url": "http://farm.example.com:8080",
"cache": {
"enabled": true,
"retention_days": 30,
"directory": "~/.apb/cache",
"max_size_mb": 10240
}
}Servers listed under the any group act as fallbacks for arch=('any') packages or when load-based selection cannot reach server status endpoints.
Components look for apb.json in the following locations (in order):
- Current working directory:
./apb.json - System-wide:
/etc/apb/apb.json - User home:
~/.apb/apb.json - Farm-specific:
~/.apb-farm/apb.json
APB Farm includes a authentication and authorization system.
- Admin: Full system access including user management, can cancel any build, see full server details, configure SMTP and custom repositories
- User: Can submit builds, cancel own builds, view own build history via
/my/builds - Guest: Read-only access to dashboard and build status (no authentication required)
- Token-based Authentication: Secure Bearer tokens with 10-day expiration
- Password Security: PBKDF2 password hashing with 100,000 iterations
- Automatic Token Renewal: Tokens automatically renewed on use
- Session Management: Users can revoke tokens and manage active sessions
When the farm starts for the first time, it automatically creates a default admin account:
- Username:
admin - Password:
admin123
IMPORTANT: Change the default admin password immediately after first login.
APB requires Python 3.12+ and installs as a Python package with console scripts apb, apb-farm, and apb-server.
pip install -e .Or install dependencies from requirements.txt first:
pip install -r requirements.txt && pip install -e .On Arch Linux, APB can also be built and installed from the included PKGBUILD (requires devtools and arch-install-scripts on build servers).
For development and unit tests:
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
python -m pytest -vUse python -m pytest so the active virtualenv's interpreter is used. A system-wide pytest command may invoke a different Python and fail to import apb.
Integration tests spawn farm and server processes and require Linux, Arch build tools, multipart>=1.3, and APB_INTEGRATION=1:
./tests/run-integration.shOn Arch Linux, install the distribution package with pacman -S python-multipart (PyPI name multipart, not Kludex python-multipart).
-
Set up a build server:
apb-server --host 0.0.0.0
-
Start the farm:
apb-farm --config apb.json
-
Login to the farm (first time setup):
apb --farm --login --username admin # Password: admin123 (change this immediately!) apb --farm --auth-status -
Submit a build:
apb --farm /path/to/package/
-
Open the dashboard at
http://farm-host:8080/dashboardto monitor servers and builds. -
Create additional users (admin only) via the farm web interface or API endpoints.
The APB Farm acts as the central coordinator for multiple build servers.
# Start the farm with default settings
apb-farm
# Start on specific host and port
apb-farm --host 0.0.0.0 --port 8080
# Use custom configuration file
apb-farm --config /path/to/custom-apb.json
# Enable debug logging
apb-farm --log-level DEBUG| Option | Default | Description |
|---|---|---|
--host |
0.0.0.0 |
Host interface to bind to |
--port |
8080 |
Port to listen on |
--log-level |
INFO |
Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL) |
--config |
auto-detect | Path to configuration file |
The APB Server is the build execution engine that should run on each build machine.
# Start server with default settings
apb-server
# Start on specific host and port
apb-server --host 0.0.0.0 --port 8000
# Custom buildroot location
apb-server --buildroot /srv/apb/buildroot
# Custom build storage directory
apb-server --builds-dir /srv/apb/builds
# Limit concurrent builds
apb-server --max-concurrent 2
# Auto-recreate buildroot every 50 builds
apb-server --buildroot-autorecreate 50
# Override architecture detection
apb-server --architecture powerpc
# Custom file size and timeout limits
apb-server --max-file-size 209715200 --max-request-size 1073741824 --build-timeout 7200
# Enable debug logging
apb-server --debug| Option | Default | Description |
|---|---|---|
--host |
localhost |
Host interface to bind to |
--port |
8000 |
Port to listen on |
--buildroot |
~/.apb/buildroot |
Directory for the build chroot |
--builds-dir |
~/.apb/builds |
Directory to store build results |
--max-concurrent |
3 |
Maximum number of concurrent builds |
--buildroot-autorecreate |
disabled | Recreate buildroot after N builds |
--architecture |
auto-detect | Override detected architecture |
--max-file-size |
100MB |
Maximum individual upload file size |
--max-request-size |
500MB |
Maximum total request size |
--build-timeout |
7200 |
Maximum build time in seconds |
--debug |
false |
Enable debug logging |
The server automatically detects its architecture using this process:
- Command-line override:
--architectureflag takes precedence - Read
/etc/pacman.conf: Uses theArchitecturesetting - Machine architecture mapping: Maps
uname -moutput for compatibility:ppc64le→powerpc64leppc64→powerpc64ppc→powerpc
The server uses Arch Linux's standard build tools:
- Buildroot Creation:
mkarchrootcreates a clean chroot environment - Package Building:
makechrootpkgbuilds packages in isolation - Source Management: Automatic handling of
SRCDESTandCCACHE_DIR - GPG Validation: Downloads GPG keys from
validpgpkeysarrays
- Build Monitoring: View builds at
http://server-host:8000/ - Cleanup: Trigger cleanup at
http://server-host:8000/admin/cleanup - Health Check: Monitor health at
http://server-host:8000/health
The APB Client is used to submit builds, monitor progress, and download results.
Before submitting builds to an APB Farm, you need to authenticate:
# Login to farm
apb --farm --login
# or specify username
apb --farm --login --username myuser
# Check authentication status
apb --farm --auth-status
# Logout
apb --farm --logout# Build package in current directory (requires authentication for farm)
apb --farm
# Build specific package directory
apb --farm /path/to/package/
# Build for specific architecture
apb --farm --arch x86_64 /path/to/package/
# Build for multiple architectures
apb --farm --arch x86_64,aarch64,powerpc64le /path/to/package/
# Use specific server (no authentication required)
apb --server http://build-server:8000 /path/to/package/
# Submit build and exit (don't wait)
apb --farm --detach /path/to/package/
# Monitor existing build
apb --farm --monitor 48ea1df5-f7f3-477e-a7a7-36e526ea7cd3
# Download build results by ID
apb --farm --download 48ea1df5-f7f3-477e-a7a7-36e526ea7cd3
# Download latest successful builds for every arch=() from PKGBUILD
apb --farm --download
apb --farm --download /path/to/package/
apb --farm --arch x86_64,aarch64 --download /path/to/package/
# Check build status
apb --farm --status 48ea1df5-f7f3-477e-a7a7-36e526ea7cd3
# Cancel running build (own builds only, unless admin)
apb --farm --cancel 48ea1df5-f7f3-477e-a7a7-36e526ea7cd3| Option | Description |
|---|---|
pkgbuild_path |
Path to PKGBUILD or package directory (optional if PKGBUILD in current dir) |
--server URL |
Server URL |
--arch ARCH |
Target architecture(s) (comma-separated) |
--config PATH |
Path to configuration file |
--verbose |
Enable verbose output |
--quiet |
Suppress output except errors |
| Option | Description |
|---|---|
--login |
Login to farm |
--logout |
Logout from farm |
--auth-status |
Show authentication status |
--username USER |
Username for login |
| Option | Default | Description |
|---|---|---|
--output-dir PATH |
./output |
Output directory for downloaded files |
--detach |
false |
Submit build and exit (don't wait for completion) |
--no-download |
false |
Don't download build results |
--force |
false |
Force rebuild even if package exists |
--build-timeout SECS |
server default | Build timeout in seconds, 300–14400 (admin only) |
| Option | Description |
|---|---|
--monitor BUILD_ID |
Monitor existing build |
--download [BUILD_ID|PATH] |
Download by build ID, or latest farm builds per PKGBUILD arch=() |
--status BUILD_ID |
Check build status |
--cancel BUILD_ID |
Cancel running build |
| Option | Description |
|---|---|
--farm |
Use APB Farm instead of direct server |
--list-servers |
List available servers |
--cleanup |
Trigger server cleanup |
--test-arch |
Test architecture compatibility |
Create ~/.apb/apb.json or specify with --config:
{
"farm_url": "http://farm.example.com:8080",
"default_server": "http://server.example.com:8000",
"default_arch": "x86_64",
"servers": {
"x86_64": ["http://server1:8000", "http://server2:8000"],
"aarch64": ["http://arm-server:8000"]
}
}Authentication tokens are stored in ~/.apb/auth.json with restrictive permissions (600). The client automatically manages token storage and renewal.
The client automatically organizes downloaded files by architecture:
output/
├── x86_64/
│ ├── package-1.0.0-1-x86_64.pkg.tar.zst
│ └── build.log
├── aarch64/
│ ├── package-1.0.0-1-aarch64.pkg.tar.zst
│ └── build.log
├── any/
│ ├── package-1.0.0-1-any.pkg.tar.zst
│ └── build.log
└── powerpc64le/
├── package-1.0.0-1-powerpc64le.pkg.tar.zst
└── build.log
Packages with arch=('any') in the PKGBUILD are downloaded to the any/ subdirectory.
The client provides real-time monitoring capabilities:
- Progress Tracking: Live build status updates
- Output Streaming: Real-time build log display
- Artifact Readiness: Waits for the farm to finish caching artifacts before downloading
- Server Resilience: Uses cached status when build servers are temporarily unavailable
- Completion Notification: Automatic success/failure reporting
- Change default password: Immediately change the default admin password
- Create user accounts: Set up individual user accounts instead of sharing admin access
- Use HTTPS: Deploy with HTTPS in production environments
- Firewall configuration: Restrict access to farm and server ports; deploy servers behind the farm
- Regular token rotation: Logout and login periodically to refresh tokens
For detailed API reference, see the documentation in the doc/ directory: