Uploaded image for project: 'Insights Experiences'
  1. Insights Experiences
  2. HMS-10318

Solver: Implement per-transaction package excludes in the DNF5 solver

    • Icon: Task Task
    • Resolution: Done
    • Icon: Undefined Undefined
    • None
    • None
    • Image Builder
    • None

      After https://github.com/osbuild/osbuild/pull/2379, I realized that I could use the same sack-level filtering to implement the last missing critical feature in DNF5 solver, which is the handling of `exclude_specs`, so here it is...

      The DNF5 solver was silently ignoring `exclude_specs` on depsolve transactions, while the DNF4 solver handled them natively via `install_specs()`. This meant features like excluding firmware packages from a `@core` group install, or excluding a package in one transaction while installing it in another, were broken on DNF5. This PR adds the missing functionality using the same `sack.add_user_excludes()` pattern already proven for `repo_ids` filtering, bringing DNF5 to parity with DNF4 for package excludes.

        1. Architectural Changes

      DNF4's `install_specs()` accepts both package specs and exclude specs in a single call, handling exclusion internally via `sack.add_excludes()`. DNF5's `Goal.add_install()` API has no equivalent – it only takes package specs. After reviewing the libdnf5 API (Goal, GoalJobSettings, PackageSack), `sack.add_user_excludes()` is the only runtime mechanism for per-transaction package exclusion. The exclude block is placed after `add_rpm_install()` (which re-adds packages from previous transactions) to match DNF4's ordering where `package_install()` precedes `install_specs()`. Excludes are automatically scoped per-transaction because `sack.clear_user_excludes()` is already called at the start of each loop iteration.

        1. Key Changes
      • Add `exclude_specs` handling in the DNF5 depsolve loop using `sack.add_user_excludes()` with GLOB-based name filtering, supporting both exact names and glob patterns
      • Add unit tests for exclude behavior: one verifying excludes affect dependency resolution (not just top-level requests), another verifying excludes don't leak across transactions
      • Remove `basic_pkg_group_with_excludes` and `install_pkg_excluded_in_another_transaction` from the DNF5 broken test cases skip list
        1. Breaking Changes

      This PR is fully backward compatible.

      /jira-epic HMS-10032

              thozza@redhat.com Tomas Hozza
              imagebuilder-bot Image-Builder Bot
              None
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: