Admin Spotting for Fun and Profit

Getting the Source

February 17th, 2008 Posted in Linux

There seem to be more and more people wanting to get their hands on the CentOS source rpms for various reasons. Some are looking to see the secret options used in the CentOS brew. Others are looking to make modifications, and some are looking simply to learn.

A while back, the CentOS folks added source repository support to the mirrors, but there was never an addition to the mirrorlist tool to add SRPM as a valid repository option. There was also no addition to /etc/yum.repos.d with the source repository descriptions. This has led to various chatter on irc for people asking how to get to the source repositories.

To get access to the CentOS source repositories, you will need 2 things. The yum-utils plugin, which is available in the extras repository, and the CentOS-Source.repo file. This file contains the source repository definitions for the CentOS 5 Base, Updates, Extras, and CentOSPlus reposositories.

Simply drop this file into /etc/yum.repos.d/ and use yumdownloader to fetch your source rpm. A sample command is listed below:

yumdownloader --source -e c5-updates-src mysql

  1. 2 Responses to “Getting the Source”

  2. By mahajivana on Dec 11, 2009

    This doesn’t work anymore.

    First: In current Versions of yumdownloader “-e” sets the error level. The correct switch now is “–enablerepo=[repo]“:

    yumdownloader –source –enablerepo=c5-updates-src mysql

    Second: Although the above command is correct, CentOS still won’t find the sources. For me this never worked with CentOS 5.

    This is still a bug in CentOS 5: http://bugs.centos.org/view.php?id=2035

  3. By robertsong on Apr 28, 2010

    hi, mahajivana,
    I checked it on my machine, and it works.
    In fact, you can check the http://mirror.centos.org/centos/5.4/updates/SRPMS/ link.
    And you can find the file there.

Post a Comment