yum $releasever expands to %24releasever

Had this error when we were messing around with Centos 6.

ftp://ftp.server.com/pub/centos/mirror/%24releasever/os/x86_64/repodata/repomd.xml:
[Errno 14] FTP Error 550 : ftp://ftp.server.com/pub/centos/mirror/%24releasever/os/x86_64/repodata/repomd.xml

Couple of the trouble shooting steps I did was that I first straced it:

yum clean all
strace -f -o /tmp/yumoutput yum info gcc

I looked inside the /tmp/yumoutput and found that when yum would ftp to the mirror, it didn’t expand out the $releasever to be 6, but actually releasever:

20209 sendto(7, "CWD $releasever\r\n", 17, MSG_NOSIGNAL, NULL, 0) = 17

I got a ftp 505 error as a result and the fact is that /mirror/$releasever was not a valid path to the mirror. This path is defined in a /etc/yum.repos.d/local-mirror file and we are using the builtin variable $releasever so that we don’t have to update it every time the release changes.

My coworker found a page that includes a simple python script to run to get the releasever also:

python -c 'import yum, pprint; yb = yum.YumBase(); pprint.pprint(yb.conf.yumvar, width=1)'

Which resulted in:

Loaded plugins: fastestmirror
{'arch': 'amd64',
 'basearch': 'x86_64',
 'releasever': '$releasever',
 'uuid': 'a9aaaaa-6aa4-4aa0-a9aa-e2aaaaaaaa59'}

but really should result to:

Loaded plugins: fastestmirror
{'arch': 'amd64',
 'basearch': 'x86_64',
 'releasever': '6',
 'uuid': 'a9aaaaa-6aa4-4aa0-a9aa-e2aaaaaaaa59'}

There’s also the /var/cache/yum/arch folder and there was a $releasever folder in there.  Another indication that the $releasever was not expanding out.

We have set our Centos 5 servers to have the yum.conf setting for distroverpkg=centos-release-notes so that we don’t upgrade to the next minor point release on accident when yum updating. When we are good and ready to update, we change it to distroverpkg=centos-release and then do an update to the next point release. When we changed the distropkgver=centos-release in /etc/yum.conf, the yum just started to magically work. The python code translated the $releasever to be 6 instead of the text “$releasever” and I felt a sigh of relief at finding the problem.

The quest to find out why was next. Looking at the man yum.conf, I discovered this handy quote:

distroverpkg The package used by yum to determine the “version” of the distribution. This can be any installed package. Default
is redhat-release. You can see what provides this manually by using: “yum whatprovides redhat-release”.

Unfortunately, yum doesn’t work so I can’t use the command above. The following is the equivalent but using rpm query and using centos-release instead of redhat-release (which also works):

rpm -q --whatprovides centos-release

So here’s the result for my CentOS 5 box:

rpm -q --whatprovides centos-release
centos-release-5-7.el5.centos
rpm -q --whatprovides centos-release-notes
centos-release-notes-5.7-0

When doing it on the CentOS 6 server, I see the error:

rpm -q --whatprovides centos-release
centos-release-6-0.el6.centos.5.x86_64
rpm -q --whatprovides centos-release-notes
no package provides centos-release-notes

I checked the mirror, but wasn’t able to find any centos-release-notes for CentOS 6 so I may be out of luck until 6.1 comes out and the CR is removed or something else.

== Update 2012.04.22 ==

I forgot to up this post, but I found out awhile ago reading the centos release notes, that they removed the redhat-release-notes package and didn’t replace it with a centos-release-notes one.

This entry was posted in software and tagged , , , , . Bookmark the permalink.

4 Responses to yum $releasever expands to %24releasever

  1. Alexander says:

    Thank you! Very useful. Going to hardcode version number to configfile, but found this page at the last moment 🙂

  2. Joe says:

    I have been back to this page like 4 times now 🙂 Thanks for the informative post!

  3. Tiago Cruz says:

    Nice man, same thing with RHEL 6, kkkk

    Thanks!!

  4. ajozwik says:

    I just upgraded to centos 7 and during restart I receive `kernel panic`.
    Many thanks your article is still up to date!!!

Leave a Reply

Your email address will not be published. Required fields are marked *