Add fix for sync DBs not loaded
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
schema: spec-driven
|
||||||
|
created: 2026-04-14
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
## Context
|
||||||
|
|
||||||
|
The dyalpm library's `SyncDBs()` returns an empty slice because it doesn't automatically load sync databases from pacman.conf. This causes `resolvePackages()` to skip the sync DB search entirely and fall through to checking the AUR, which fails for official repo packages.
|
||||||
|
|
||||||
|
## Goals / Non-Goals
|
||||||
|
|
||||||
|
**Goals:**
|
||||||
|
- Register sync databases so `resolvePackages()` can find official repo packages
|
||||||
|
|
||||||
|
**Non-Goals:**
|
||||||
|
- Modify package installation logic
|
||||||
|
- Add support for custom repositories
|
||||||
|
|
||||||
|
## Decisions
|
||||||
|
|
||||||
|
1. **Register each repo manually** - After `handle.SyncDBs()` returns empty, loop through known repos (core, extra, multilib) and call `handle.RegisterSyncDB()` for each.
|
||||||
|
|
||||||
|
2. **Use hardcoded repo list** - Arch Linux standard repos are core, extra, multilib. This matches pacman.conf.
|
||||||
|
|
||||||
|
3. **Silent failure for missing repos** - If a repo isn't configured in pacman.conf, `RegisterSyncDB` will return a valid but empty DB. Filter by checking if `PkgCache()` has any packages.
|
||||||
|
|
||||||
|
## Risks / Trade-offs
|
||||||
|
|
||||||
|
- Hardcoded repo names may need updating if Arch adds/removes standard repos → Low risk, rare change
|
||||||
|
- Repo registration could fail silently → Mitigated by checking PkgCache count
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
## Why
|
||||||
|
|
||||||
|
The program fails to find packages that exist in official repositories (like `cmake` in `extra`). The dyalpm library's `SyncDBs()` returns an empty list, so the code never searches the sync databases and falls through to checking the AUR, which also doesn't have the package.
|
||||||
|
|
||||||
|
## What Changes
|
||||||
|
|
||||||
|
- Register sync databases manually after initializing the dyalpm handle
|
||||||
|
- Loop through known repos (core, extra, multilib) and call `RegisterSyncDB` for each
|
||||||
|
- Handle the case where a repo might not be configured in pacman.conf
|
||||||
|
|
||||||
|
## Capabilities
|
||||||
|
|
||||||
|
### New Capabilities
|
||||||
|
- None - this is a bug fix to existing functionality
|
||||||
|
|
||||||
|
### Modified Capabilities
|
||||||
|
- None
|
||||||
|
|
||||||
|
## Impact
|
||||||
|
|
||||||
|
- `pkg/pacman/pacman.go`: Modify `New()` function to register sync DBs after getting them from the handle
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
## ADDED Requirements
|
||||||
|
|
||||||
|
No new requirements - this is a bug fix to existing package resolution functionality.
|
||||||
|
|
||||||
|
## MODIFIED Requirements
|
||||||
|
|
||||||
|
No modified requirements.
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
## 1. Implement sync DB registration
|
||||||
|
|
||||||
|
- [ ] 1.1 Modify Pac struct to include a method for registering sync DBs
|
||||||
|
- [ ] 1.2 In New(), after getting empty syncDBs from handle, loop through ["core", "extra", "multilib"] and call RegisterSyncDB for each
|
||||||
|
- [ ] 1.3 Filter out repos that have no packages (not configured in pacman.conf)
|
||||||
|
|
||||||
|
## 2. Test the fix
|
||||||
|
|
||||||
|
- [ ] 2.1 Run `./declpac --dry-run --state <(echo "cmake")` and verify it resolves cmake from extra repo
|
||||||
|
- [ ] 2.2 Test with other official repo packages (e.g., "git" from extra, "base" from core)
|
||||||
Reference in New Issue
Block a user