From 836d8600c66ae24c7238d5fdd3fa954b8aafbcef Mon Sep 17 00:00:00 2001 From: AI Bot Date: Tue, 14 Apr 2026 21:59:08 +0200 Subject: [PATCH] Add fix for sync DBs not loaded --- .../fix-sync-dbs-not-loaded/.openspec.yaml | 2 ++ .../changes/fix-sync-dbs-not-loaded/design.md | 25 +++++++++++++++++++ .../fix-sync-dbs-not-loaded/proposal.md | 21 ++++++++++++++++ .../specs/package-resolution/spec.md | 7 ++++++ .../changes/fix-sync-dbs-not-loaded/tasks.md | 10 ++++++++ 5 files changed, 65 insertions(+) create mode 100644 openspec/changes/fix-sync-dbs-not-loaded/.openspec.yaml create mode 100644 openspec/changes/fix-sync-dbs-not-loaded/design.md create mode 100644 openspec/changes/fix-sync-dbs-not-loaded/proposal.md create mode 100644 openspec/changes/fix-sync-dbs-not-loaded/specs/package-resolution/spec.md create mode 100644 openspec/changes/fix-sync-dbs-not-loaded/tasks.md diff --git a/openspec/changes/fix-sync-dbs-not-loaded/.openspec.yaml b/openspec/changes/fix-sync-dbs-not-loaded/.openspec.yaml new file mode 100644 index 0000000..76a85e8 --- /dev/null +++ b/openspec/changes/fix-sync-dbs-not-loaded/.openspec.yaml @@ -0,0 +1,2 @@ +schema: spec-driven +created: 2026-04-14 diff --git a/openspec/changes/fix-sync-dbs-not-loaded/design.md b/openspec/changes/fix-sync-dbs-not-loaded/design.md new file mode 100644 index 0000000..f13f13e --- /dev/null +++ b/openspec/changes/fix-sync-dbs-not-loaded/design.md @@ -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 \ No newline at end of file diff --git a/openspec/changes/fix-sync-dbs-not-loaded/proposal.md b/openspec/changes/fix-sync-dbs-not-loaded/proposal.md new file mode 100644 index 0000000..ef29df5 --- /dev/null +++ b/openspec/changes/fix-sync-dbs-not-loaded/proposal.md @@ -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 \ No newline at end of file diff --git a/openspec/changes/fix-sync-dbs-not-loaded/specs/package-resolution/spec.md b/openspec/changes/fix-sync-dbs-not-loaded/specs/package-resolution/spec.md new file mode 100644 index 0000000..4556d8a --- /dev/null +++ b/openspec/changes/fix-sync-dbs-not-loaded/specs/package-resolution/spec.md @@ -0,0 +1,7 @@ +## ADDED Requirements + +No new requirements - this is a bug fix to existing package resolution functionality. + +## MODIFIED Requirements + +No modified requirements. \ No newline at end of file diff --git a/openspec/changes/fix-sync-dbs-not-loaded/tasks.md b/openspec/changes/fix-sync-dbs-not-loaded/tasks.md new file mode 100644 index 0000000..414c1a1 --- /dev/null +++ b/openspec/changes/fix-sync-dbs-not-loaded/tasks.md @@ -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) \ No newline at end of file