GPortage - Next-generation Package Manager for Gentoo

GPortage is a modern reimplementation of Gentoo's Portage package manager in Go, designed to solve fundamental problems in dependency resolution while maintaining full compatibility with existing Gentoo ecosystems.
Why GPortage?
Gentoo's traditional package management faces challenges with long-term system upgrades. GPortage solves these problems with:
β
SAT-based dependency solver - Guarantees conflict-free upgrades
π Transactional updates - Snapshot-based rollbacks using Btrfs/ZFS
π Incremental sync - Git-like repository updates
π Full Portage compatibility - Seamless transition from existing systems
β‘ Parallel processing - Optimized for modern multi-core systems
# Solve upgrade conflicts that traditional Portage can't handle
gportage resolve --deep-upgrade
Architecture Overview
v0.9.0: Single Binary with Daemon + DDD Architecture
graph TD
subgraph "GPortage Binary"
CLI[CLI Mode] -->|Auto-detect| DAEMON{Daemon Running?}
DAEMON -->|Yes| GRPC[gRPC Client]
DAEMON -->|No| STANDALONE[Standalone Mode]
subgraph "Daemon Mode (DDD Layered Architecture)"
subgraph "Interface Layer"
GRPCS[gRPC Server<br/>Unix Socket]
REST[REST API<br/>HTTP :8080]
end
subgraph "Application Layer"
APP[PackageService<br/>Orchestration]
DTO[DTOs<br/>Data Transfer]
end
subgraph "Domain Layer"
PKG[Package<br/>Aggregate Root]
DEPSVC[DependencyService<br/>Domain Logic]
end
subgraph "Infrastructure Layer"
SOLVER[SAT Solver<br/>Resolution]
REPO[Repository<br/>Package Data]
end
CACHE[Warm Cache<br/>Ebuilds/SAT]
QUEUE[Job Queue<br/>Parallel Tasks]
MONITOR[Background<br/>Monitoring]
end
GRPC -.->|RPC| GRPCS
REST --> GRPCS
GRPCS --> APP
APP --> DTO
APP --> DEPSVC
APP --> SOLVER
APP --> REPO
DEPSVC --> PKG
SOLVER --> REPO
SOLVER --> PKG
DAEMON_SERVICE[gportage daemon]
DAEMON_SERVICE --> GRPCS
DAEMON_SERVICE --> REST
DAEMON_SERVICE --> MONITOR
DAEMON_SERVICE --> CACHE
end
subgraph "Backend Data Sources"
PORTAGE[Portage Tree<br/>/var/db/repos/gentoo]
STATE[System State<br/>/var/db/pkg]
BINPKG[Binary Packages<br/>.gpkg.tar]
end
STANDALONE --> APP
REPO --> PORTAGE
REPO --> STATE
REPO --> BINPKG
Key Benefits:
- β‘ Instant CLI responses - Warm cache eliminates cold-start delays
- π Job queue - Prevents package conflicts from concurrent operations
- π‘ REST API - Web dashboards and monitoring tools
- π― Auto-detection - CLI automatically uses daemon when available
- π Fallback mode - Works standalone if daemon unavailable
DDD Architecture (Phase 3+):
- Interface Layer - gRPC/REST adapters (thin, protocol conversion)
- Application Layer - Use case orchestration (PackageService)
- Domain Layer - Business logic (Package, DependencyService)
- Infrastructure Layer - Technical concerns (SAT solver, Repository)
Benefits: Clean separation of concerns, testability, maintainability, future-proof for microservices migration.
Getting Started
Prerequisites
- Go 1.25+
- Git
- Btrfs or ZFS (for snapshots)
Installation
git clone https://github.com/kolkov/gportage.git
cd gportage
make build
sudo make install
Migrating from Portage
# Convert existing Portage installation
gportage init --convert-portage
# Perform initial system scan
gportage scan-system
# Test upgrade solution
gportage update --dry-run
Basic Usage
Daemon Mode (Recommended):
# Start daemon (OpenRC)
sudo rc-service gportaged start
sudo rc-update add gportaged default
# OR systemd
sudo systemctl start gportaged
sudo systemctl enable gportaged
# Check daemon status
gportage status
# CLI now uses daemon automatically
gportage install www-servers/nginx # β‘ Instant via daemon
gportage update --create-snapshot
gportage search firefox
Standalone Mode (No Daemon):
# Stop daemon
sudo rc-service gportaged stop
# CLI falls back to standalone mode
gportage status # Shows: "Daemon: not running, Mode: standalone"
gportage install www-servers/nginx # Still works, slower cold-start
Common Operations:
# Install packages
gportage install www-servers/nginx
# Update system with snapshot protection
gportage update --create-snapshot
# Query package information
gportage info dev-lang/go
# Remove package with dependency cleanup
gportage remove net-misc/curl
# Search packages
gportage search firefox
# Show system status
gportage status
Key Features
Advanced Dependency Resolution
// Example constraint solving
solution, err := solver.Resolve(pkg.Constraint{
Name: "dev-lang/go",
Version: ">=1.22",
Slot: "0/1.22",
UseFlags: []string{"ssl", "-pie"},
})
if err != nil {
log.Fatal("Resolution failed:", err)
}
Transactional Safety
# Create pre-upgrade snapshot
gportage snapshot create --tag pre-upgrade-2025
# Rollback if update fails
gportage snapshot restore pre-upgrade-2025
# List available snapshots
gportage snapshot list
Portage Compatibility Layer
// Convert traditional ebuild to native format
pkg, err := compat.ConvertEbuild(
"/var/db/repos/gentoo/sys-kernel/gentoo-sources/gentoo-sources-6.9.1.ebuild"
)
if err != nil {
return fmt.Errorf("ebuild conversion failed: %w", err)
}
Development Setup (GoLand)
-
Clone repository:
git clone https://github.com/kolkov/gportage.git
-
Open in GoLand: File > Open > Select project directory
-
Setup build configuration:
- Go Build configuration
- Build command:
make dev-build
- Run command:
./bin/gportage --dev-mode
-
Enable tests:
make test # Run all tests
make coverage # Generate coverage report
make benchmark # Run performance benchmarks
-
Debugging:
- Use the built-in debugger with
debug build tag
- Example launch configuration:
{
"name": "Test Resolver",
"type": "go",
"request": "launch",
"mode": "test",
"program": "${workspaceFolder}/solver",
"args": ["-test.run", "TestComplexResolution"]
}
Contributing
We welcome contributions! Please follow our workflow:
- Fork the repository
- Create feature branch (
feat/your-feature)
- Commit using Conventional Commits
- Submit a PR with detailed description
See our Contribution Guidelines for details.
Roadmap
| Version |
Status |
Features |
Target |
| v0.1.0 |
β
Done |
Architecture foundation, SAT solver |
Q1 2025 |
| v0.2.0 |
β
Done |
Portage compatibility layer |
Q2 2025 |
| v0.3.0 |
β
Done |
USE flag resolution |
Q3 2025 |
| v0.4.0 |
β
Done |
Dependency graph solver |
Q4 2025 |
| v0.5.0 |
β
Done |
System integration (5 phases) |
Oct 2025 |
| v0.6.0 |
β
Done |
Binary packages (core) |
Oct 2025 |
| v0.7.0 |
β
Done |
Binary packages (building) |
Oct 2025 |
| v0.9.0 |
π Next |
Daemon + API/CLI |
Q1 2026 |
| v0.8.0 |
π Planned |
GoReleaser (optional) |
TBD |
| v1.0.0 |
π― Target |
Production-ready release |
Q2 2026 |
Current Status: v0.9.0 Phase 3 π IN PROGRESS
v0.9.0 - Daemon + API/CLI + DDD Architecture
Phase 1 - Foundation (Week 1-2) β
COMPLETE
- β
Single binary with mode detection (
gportage / gportage daemon)
- β
Daemon core with gRPC + REST servers
- β
CLI client with auto-daemon detection
- β
Version injection via ldflags (Git commit, build date)
- β
Unix socket communication (
/var/run/gportage.sock)
- β
REST API health check (
/health, /api/v1/status)
- β
Graceful shutdown handling (SIGTERM, SIGINT)
- β
Professional Makefile with build targets
Phase 2 - gRPC Service (Week 3-4) β
COMPLETE
- β
Protocol Buffers service definition
- β
Package operations (Ping, GetStatus, InstallPackage, etc.)
- β
Streaming progress for long operations
- β
Full gRPC client-server implementation
- β
PID file management (cross-platform)
- β
Daemon detection and health checks
Phase 3 - Application Services (Week 5-6) β
COMPLETE
- β
DDD Layered Architecture implementation
- β
Application Service layer (PackageService)
- ResolvePackage (SAT solver integration)
- SearchPackages (repository queries)
- GetPackageInfo (detailed package data)
- InstallPackage (streaming progress)
- β
DTOs for clean layer boundaries
- β
Domain integration (Package, DependencyService)
- β
Infrastructure integration (Solver, Repository)
- β
All tests passing + linter clean
Phase 4 - Job Queue (Week 7) π IN PROGRESS
- β
Job Queue implementation (Worker pool pattern)
- Concurrent job execution with configurable workers
- Priority support (High/Normal/Low)
- Job types: Install, Remove, Update, Sync
- Status tracking: Pending β Running β Completed/Failed/Canceled
- Progress callbacks for real-time updates
- Graceful shutdown with timeout
- Thread-safe operations
- β
Daemon integration
- Auto-start with daemon
- Graceful stop with daemon
- Statistics API (active workers, queue length, jobs by status)
- β
gRPC Job management API
- GetJobStatus(job_id) - query job status
- ListJobs(filter) - list all jobs with optional filtering
- CancelJob(job_id) - cancel running/pending jobs
- InstallPackage now uses Job Queue (streaming + job_id)
- β
Comprehensive tests (11 tests for Job Queue)
- Job lifecycle tests
- Concurrent execution tests
- Cancellation tests
- Graceful shutdown tests
- β
Context-aware cancellation
- Proper handling of canceled vs failed jobs
- Context propagation through job execution
- Graceful degradation on timeout
- β
Package Conflict Detection (CRITICAL FOR SAFETY!)
- SAT solver-based dependency analysis
- Prevents parallel operations on same package
- Detects shared dependency conflicts
- Version-aware package name matching
- Automatic job rejection with clear error messages
- Examples:
- β dev-lang/go + dev-lang/go-1.22 β CONFLICT (same package)
- β pkg1 (requires glibc-2.38) + pkg2 (updates glibc) β CONFLICT (shared dep)
- β
dev-lang/go + dev-lang/python β OK (different packages)
Implementation Stats (Phases 1-4):
- Code: ~3,500 lines (daemon + gRPC + Application + Job Queue + Conflict Detection)
- Files: 21+ new files
- Tests: 50+ tests (including 11 Job Queue + 10 Conflict Detection tests)
- Architecture: Clean DDD + Worker Pool + Conflict Detection pattern
- Build: Single binary with version injection
- Linter: 0 issues (golangci-lint)
- Safety: Production-ready conflict prevention β
Next: Phase 4 (continued)
- CLI commands integration (status, job management)
- Persistent cache system
- Background monitoring service
Previous Achievement: v0.7.0 β
Complete
- β
Binary package builder (source β .gpkg.tar / .tbz2)
- β
Package signing (GPG/SSH/RSA)
- β
Local binhost manager + remote uploader
- β
1,533 lines of tests (29 tests + 6 benchmarks)
Test Coverage (Overall):
- Domain layer: 92.3% β
- Application layer: Tested via integration β
- Solver layer: 75%+ β
- Config layer: 100% β
- Binpkg layer: 32.3% β
- Daemon layer: Full integration tests β
- gRPC layer: Streaming + RPC tests β
See ROADMAP.md for detailed plans and CHANGELOG.md for full history.
CI/CD & Release Process
Current Setup:
- β
GitHub Actions for automated testing (Go 1.25, Linux only)
- β
GolangCI-Lint v2 for code quality
- β
Coverage tracking with Codecov
- β
Benchmark monitoring
Release Workflow (git-flow):
# Development happens in develop branch
git checkout develop
# Create release branch when ready
git flow release start v0.5.0
# Tag and merge to main
git flow release finish v0.5.0
# Tags trigger automated releases (v0.5.0+)
Automated Releases:
- GoReleaser configuration will be activated at v0.5.0+
- Binary releases for Linux, macOS, Windows, FreeBSD
- Multi-architecture support (amd64, arm64)
- Automated changelog generation
- GitHub Releases with checksums
Note: Currently in rapid development phase (v0.3.0). Production releases (v0.5.0+) will include full automation with GoReleaser.
License
GPortage is licensed under the GNU General Public License v2.0 - the same as original Portage.