Skip to content

fix(resolver): use pkgbase for consistent indexing & optimize build force flag - #1

Merged
Manpreet113 merged 2 commits into
masterfrom
dev
Mar 21, 2026
Merged

Manpreet113 merged 2 commits into
masterfrom
dev

Conversation

@Manpreet113

Copy link
Copy Markdown
Owner

This PR refactors the AUR dependency resolver to use pkgbase consistently and optimizes the build process by making the force-build flag optional. It also includes a fix for the infinite building loop (already merged to dev but included in this batch for the master release).

- fix(main): add missing `break` in outer build retry loop
  The Ok(package_paths) arm of the build loop never exited on success —
  only the inner install-retry loop had a break. This caused ax to
  rebuild and reinstall the same package infinitely.

- ci: trigger CI on pushes/PRs to the dev branch

- docs: update CHANGELOG with unreleased entries for both changes
Copilot AI review requested due to automatic review settings March 21, 2026 08:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the AUR resolution/build pipeline to (1) index AUR metadata by pkgbase for more consistent dependency/build ordering and (2) avoid always forcing rebuilds by making makepkg -f conditional. It also includes a fix to stop rebuilding the same package indefinitely after a successful build/install.

Changes:

  • Store AUR package metadata keyed by pkgbase in the dependency resolver to better handle split packages/aliases.
  • Fix the build retry loop in install_packages() to exit after a successful build/install (prevents infinite rebuilds).
  • Make makepkg force-build (-f) conditional based on the clean-build configuration, and expand CI triggers to include dev.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/resolver.rs Switches AUR metadata indexing to pkgbase for more consistent graph lookup/build ordering.
src/main.rs Ensures the outer build retry loop exits after a successful build/install.
src/builder.rs Makes makepkg flags dynamic so force-build is not always enabled.
CHANGELOG.md Documents the infinite loop fix, resolver refactor, builder change, and CI trigger update.
.github/workflows/ci.yml Extends CI triggers to run on dev branch push/PR events.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/resolver.rs
Comment on lines 60 to +62
if let Ok(metadata) = crate::parser::parse_srcinfo(&cache_path) {
aur_packages.insert(pkg.clone(), metadata.clone());
// Store by pkgbase to ensure consistent lookup in Phase 3
aur_packages.insert(metadata.pkgbase.clone(), metadata.clone());

Copilot AI Mar 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that aur_packages is keyed by pkgbase, Phase 1 should also resolve pkg to a pkgbase before cloning/pulling and choosing cache_path. As written, the clone URL and cache directory still use the dependency string (pkg), which will fail for split-package pkgnames and can also cause repeated clones/pulls for multiple pkgnames that share one pkgbase. Consider maintaining a pkgname -> pkgbase map during collection and using the resolved base for both the git URL and cache dir.

Copilot uses AI. Check for mistakes.
Comment thread src/resolver.rs
Comment on lines +61 to +62
// Store by pkgbase to ensure consistent lookup in Phase 3
aur_packages.insert(metadata.pkgbase.clone(), metadata.clone());

Copilot AI Mar 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After keying aur_packages by pkgbase, the cycle fallback logic later in this function becomes inconsistent: it iterates aur_packages.keys() (now pkgbase) and then does pkgbase_map.get(pkg) where pkgbase_map is keyed by pkgname. This can yield an empty fallback build list for split packages where no pkgname equals pkgbase. The fallback should use the pkgbase keys directly (or build the fallback from aur_packages.values().map(|m| m.pkgbase.clone())).

Suggested change
// Store by pkgbase to ensure consistent lookup in Phase 3
aur_packages.insert(metadata.pkgbase.clone(), metadata.clone());
// Store by pkgname to remain consistent with downstream resolution logic
aur_packages.insert(pkg.clone(), metadata.clone());

Copilot uses AI. Check for mistakes.
Comment thread src/builder.rs
Comment on lines +145 to +149
// Base flags: Sync deps, Remove deps
let mut flags = "-sr".to_string();
if config.clean_build {
flags.push('f'); // Force build if cleaning
}

Copilot AI Mar 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-f is added only when config.clean_build is true, but Step 4 already does git clean -fdx, so -f is least useful in the clean-build case. The non-clean-build path is where existing package archives are most likely to remain and require either -f or explicit deletion/reuse logic to avoid makepkg refusing to overwrite. Consider inverting the condition or making force/reuse behavior explicit.

Suggested change
// Base flags: Sync deps, Remove deps
let mut flags = "-sr".to_string();
if config.clean_build {
flags.push('f'); // Force build if cleaning
}
// Base flags: Sync deps, Remove deps, Force overwrite existing artifacts
let mut flags = "-srf".to_string();

Copilot uses AI. Check for mistakes.
Comment thread src/resolver.rs
aur_packages.insert(pkg.clone(), metadata.clone());
// Store by pkgbase to ensure consistent lookup in Phase 3
aur_packages.insert(metadata.pkgbase.clone(), metadata.clone());

Copilot AI Mar 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There’s trailing whitespace on the blank line after inserting into aur_packages (and it looks like an extra blank line was introduced). This will cause cargo fmt --check to fail if rustfmt hasn’t been run. Please run rustfmt or remove the trailing spaces.

Suggested change

Copilot uses AI. Check for mistakes.
@Manpreet113
Manpreet113 merged commit 70b1ea3 into master Mar 21, 2026
6 checks passed
@Manpreet113
Manpreet113 deleted the dev branch May 2, 2026 04:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants