Bug 1848161

Summary: Custom DNF variables which worked in CentOS 8.1.1911 are broken in 8.2.2004
Product: Red Hat Enterprise Linux 8 Reporter: Jason Tucker <jasonwtucker>
Component: dnfAssignee: Marek Blaha <mblaha>
Status: CLOSED ERRATA QA Contact: Radek Bíba <rbiba>
Severity: unspecified Docs Contact:
Priority: medium    
Version: 8.2CC: james.antill, jasonwtucker, mblaha, nsella, pkratoch
Target Milestone: rcKeywords: Triaged
Target Release: 8.0   
Hardware: Unspecified   
OS: Linux   
Fixed In Version: dnf-4.2.23-3.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-11-04 01:53:17 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Jason Tucker 2020-06-17 20:18:04 UTC
Description of problem:

When using 'DNF_VAR_*' environment variables in dnf repo configs, substitution worked fine in 8.1.1911, but in 8.2.2004 does not.

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1. Define dnf repo configs using 'DNF_VAR_*' variables
2. Export variables
3. Try to use dnf on affected repo

Actual results:

Example repo config:

baseurl = http://mirror.sesp.northwestern.edu/centos/$DNF_VAR_REL/BaseOS/$DNF_VAR_ARCH/os/
gpgcheck = 1
#gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Official
enabled = 1

Example repolist output illustrating lack of substitution:

$ DNF_VAR_REL=8 DNF_VAR_ARCH=x86_64 dnf -c /etc/dnf.mirrors.conf repolist
repo id                 repo name
BaseOS-upstream         CentOS $DNF_VAR_REL $DNF_VAR_ARCH (BaseOS)

Expected results:

Note, same host as above example, with dnf downgraded to dnf-4.2.7-7.el8_1 from the 8.1 repo.

$ DNF_VAR_REL=8 DNF_VAR_ARCH=x86_64 dnf -c /etc/dnf.mirrors.conf repolist
Last metadata expiration check: 0:23:04 ago on Wed 17 Jun 2020 07:53:48 PM UTC.
repo id                       repo name                              status
BaseOS-upstream               CentOS 8 x86_64 (BaseOS)               1,675

Additional info:

Easy to replicate by simply upgrading/downgrading the version of dnf.

Comment 1 Jason Tucker 2020-06-17 20:33:18 UTC
Linked CentOS bug report.

Comment 2 Daniel Mach 2020-06-18 04:57:24 UTC
I can confirm that it's reproducible.

IIRC the intent was to use DNF_VAR_ prefix in the variable name in the shell
to avoid any collisions with other variable names.
The prefix is stripped in DNF now.

Following config should work:
name = CentOS $REL $ARCH (BaseOS)
baseurl = http://mirror.sesp.northwestern.edu/centos/$DNF_VAR_REL/BaseOS/$ARCH/os/
gpgcheck = 1
#gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Official
enabled = 1

We should definitely document this behavior properly in dnf(8).
We should also review how existing variables are set.
I'd expect setting DNF_VAR_releasever=foo DNF_VAR_basearch=bar to work,
but it doesn't.

Comment 5 Jason Tucker 2020-06-18 15:17:13 UTC
Confirmed that stripping the DNF_VAR_ prefix from my repo configs did fix the problem - thank you! I do agree that this is just a documentation problem at this point. When I noticed the issue, the first thing I did was check the docs to see if anything changed, and it showed nothing.

Comment 7 Marek Blaha 2020-07-14 07:11:25 UTC
PR https://github.com/rpm-software-management/dnf/pull/1637 enhances repo variables documentation

Comment 14 errata-xmlrpc 2020-11-04 01:53:17 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (yum bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.