https://github.com/lu-zero/portage-atom-pubgrub
Bridge between portage-atom and the PubGrub dependency solver
https://github.com/lu-zero/portage-atom-pubgrub
Last synced: 26 days ago
JSON representation
Bridge between portage-atom and the PubGrub dependency solver
- Host: GitHub
- URL: https://github.com/lu-zero/portage-atom-pubgrub
- Owner: lu-zero
- License: mit
- Created: 2026-05-15T17:00:59.000Z (about 1 month ago)
- Default Branch: master
- Last Pushed: 2026-05-16T06:46:42.000Z (about 1 month ago)
- Last Synced: 2026-05-16T08:39:17.789Z (about 1 month ago)
- Language: Rust
- Size: 36.1 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-MIT
- Agents: AGENTS.md
Awesome Lists containing this project
README
# portage-atom-pubgrub
[](LICENSE-MIT)
[](https://github.com/lu-zero/portage-atom-pubgrub/actions?query=workflow:CI)
[](https://crates.io/crates/portage-atom-pubgrub)
[](https://docs.rs/portage-atom-pubgrub)
A Rust library that bridges [portage-atom](https://crates.io/crates/portage-atom) types with the [PubGrub](https://pubgrub-rs.github.io/pubgrub/) dependency solver, implementing the [Package Manager Specification (PMS) 9](https://projects.gentoo.org/pms/9/pms.html).
> **Warning**: This codebase was largely AI-generated and has not been thoroughly
> audited. It may contain bugs, incomplete PMS coverage, or surprising edge-case
> behaviour. Use at your own risk and please report issues.
## Overview
`portage-atom-pubgrub` provides a `DependencyProvider` implementation for the
PubGrub version solver that understands Gentoo Portage dependency semantics:
- **`PortagePackage`** — a PubGrub `Package` backed by a `Cpn` + optional slot
- **`PortageVersionSet`** — a PubGrub `VersionSet` mapping PMS operators (`>=`,
`~`, `=*`, etc.) to `Ranges`
- **`PortageDependencyProvider`** — a PubGrub `DependencyProvider` over a
package repository, with support for:
- All five PMS dependency classes (DEPEND, RDEPEND, BDEPEND, PDEPEND, IDEPEND)
- OR groups, exactly-one-of, at-most-one-of modelled as virtual choice packages
- Slot and subslot operators (`:=`, `:*`)
- USE-conditional dependencies with hybrid evaluation (eager for user-decided,
virtual packages for solver-decided flags)
- USE-dep constraints (`[ssl]`, `[-debug]`, `[ssl?]`, `[ssl=]`)
- Repository constraints (`::gentoo`)
- Installed package tracking (favored / locked)
- Blocker detection and post-solve validation
- Dependency graph with labeled edges and topological install ordering
- Filtering of dependencies referencing packages absent from the repository
## Installation
Add to your `Cargo.toml`:
```toml
[dependencies]
portage-atom-pubgrub = "0.1"
```
## Usage
```rust
use portage_atom_pubgrub::{
PackageRepository, PortageDependencyProvider, PortagePackage, PortageVersionSet, UseConfig,
};
use portage_atom::{Cpn, Version};
use pubgrub::resolve;
// Implement PackageRepository for your data source
let repo = MyRepository::new();
let use_config = UseConfig::new();
let mut provider = PortageDependencyProvider::new(repo, use_config);
// Set up a root package with the target dependencies
let root = PortagePackage::unslotted(Cpn::parse("virtual/root").unwrap());
let root_ver = Version::parse("1").unwrap();
provider.add_root(root.clone(), root_ver.clone(), vec![
(target_package, target_version_set),
]);
let solution = resolve(&provider, root, root_ver);
```
See `examples/resolve.rs` and `examples/resolve_conflicts.rs` for complete examples.
## PMS Operators to Version Sets
| PMS Operator | Version Set |
|---|---|
| `>=V` | `Ranges::higher_than(V)` |
| `>V` | `Ranges::strictly_higher_than(V)` |
| `<=V` | `Ranges::lower_than(V)` |
| `