AlmaLinux 9: audit package sources instead of trusting priorities
Test scope
Section titled “Test scope”A local repo containing tree, wget and their dependencies was built inside an almalinux:9 container (AlmaLinux 9.8), then --disablerepo="*" --enablerepo=multi list available was run, repeated with includepkgs=tree, and again with excludepkgs=wget. Log: plans/content-expansion/evidence/logs/alma-repo-priority.log.
The cost option was compared on Rocky (it did not change the selection) but was not repeated on Alma; this page only documents the two tested mechanisms.
Audit the sources first
Section titled “Audit the sources first”AlmaLinux enables only baseos, appstream and extras by default. Once you add EPEL, CRB, Remi or a local repo, the same package name may exist in several sources. Which build you get depends on which sources are enabled, not on which one is newer.
Start by looking:
dnf repolist --all | head -20The enabled column tells you which sources are currently on.
Option one: pin the source per command
Section titled “Option one: pin the source per command”sudo dnf --disablerepo="*" --enablerepo=multi list availableAvailable Packageslibpsl.aarch64 0.21.1-5.el9 multipublicsuffix-list-dafsa.noarch 20210518-3.el9 multitree.aarch64 1.8.0-10.el9 multiwget.aarch64 1.21.1-11.el9_8 multi--disablerepo="*" turns everything off and then enables the one you name: only multi resolves, and the permanent configuration in /etc/yum.repos.d/ is untouched.
Option two: tighten what a repo exposes
Section titled “Option two: tighten what a repo exposes”[multi]name=Multibaseurl=file:///srv/multienabled=0gpgcheck=0includepkgs=treeAvailable Packagestree.aarch64 1.8.0-10.el9 multiOnly tree remains. The inverse uses excludepkgs=wget:
Available Packageslibpsl.aarch64 0.21.1-5.el9 multipublicsuffix-list-dafsa.noarch 20210518-3.el9 multitree.aarch64 1.8.0-10.el9 multiwget is excluded while the rest stays visible. Both directives take package names, not file names.
Conclusion: tighten first, talk about “priority” later
Section titled “Conclusion: tighten first, talk about “priority” later”The usual trap is assuming a configuration knob decides automatically. What tested reliably:
- disable everything for that command and enable one source (
--disablerepo="*" --enablerepo=<id>); - keep unwanted packages out of a repo with
includepkgs/excludepkgs; - when a source must be fixed long-term, set
enabled=1there andenabled=0elsewhere so “which sources take part” becomes explicit configuration.
Common traps
Section titled “Common traps”- Enabling permanently when you only needed it once: an
enabled=1third-party repo joins laterdnf updateruns; - Forgetting
dnf clean all: editing a repo file while metadata is cached makeslist availablelook unchanged; - Excluding a dependency: a too-broad
excludepkgshides required packages and the install fails on dependencies.
Practice: install only from the local source
Section titled “Practice: install only from the local source”sudo dnf --disablerepo="*" --enablerepo=multi install -y treerpm -q treeChecks:
rpm -q treeprints a version- After adding
includepkgs=treetomulti.repoand runningdnf clean all,dnf --disablerepo="*" --enablerepo=multi list available | grep -c wget→0 - With
excludepkgs=wgetinstead, still0, while other packages remain visible
常见问题
Why is the version I get different from what I expected?
dnf only resolves from currently enabled sources. A third-party or local repo may offer the same name built differently; check `dnf repolist --all`, then pin the source with --enablerepo.
Can includepkgs and excludepkgs be used together?
Yes, but the semantics get confusing: includepkgs narrows to a set and excludepkgs removes part of it. Pick one in production so you can reason about the visible set.
Is there something like yum-plugin-priorities?
EL9 default repositories do not ship a usable priority plugin (dnf-plugins-core does not include it). The reliable approach is controlling which sources are enabled and using includepkgs/excludepkgs rather than trusting a priority number.
Next steps
Section titled “Next steps”- Repositories and SIGs: AlmaLinux repositories
- Third-party sources: Third-party repos
- Offline installs: Offline package installs