Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am new to Centos and yum in general.

  1. How do I retreive the SRPM using yumdownloader --source? When I run the command it says the SRPMs are not found. How do I add the repository? I am talking about official CentOS packages here.
  2. Once downloaded, what is the command to unpack the SRPM so I can edit the files?
  3. Last, once I am done modifying, what is the command to rebuild the modified source RPM?
  4. From a SRPM, how does one create a RPM?
share|improve this question
add comment

2 Answers

up vote 0 down vote accepted
  • How do I retreive the SRPM using yumdownloader --source? When I run the command it says the SRPMs are not found. How do I add the repository? I am talking about official CentOS packages here.

This is an issue with CentOS: http://bugs.centos.org/view.php?id=1646

Assuming you're CentOS 5, create this file in /etc/yum.repos.d/CentOS-SRPMS.repo

[base-SRPMS]
name=CentOS-$releasever - Base SRPMS
baseurl=http://mirror.centos.org/centos/$releasever/os/SRPMS/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
priority=1
enabled=1

#released updates
[update-SRPMS]
name=CentOS-$releasever - Updates SRPMS
baseurl=http://mirror.centos.org/centos/$releasever/updates/SRPMS/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
priority=1
enabled=1

#packages used/produced in the build but not released
[addons-SRPMS]
name=CentOS-$releasever - Addons SRPMS
baseurl=http://mirror.centos.org/centos/$releasever/addons/SRPMS/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
priority=1
enabled=1

#additional packages that may be useful
[extras-SRPMS]
name=CentOS-$releasever - Extras SRPMS
baseurl=http://mirror.centos.org/centos/$releasever/extras/SRPMS/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
priority=1
enabled=1

#additional packages that extend functionality of existing packages
[centosplus-SRPMS]
name=CentOS-$releasever - Plus SRPMS
baseurl=http://mirror.centos.org/centos/$releasever/centosplus/SRPMS/
gpgcheck=1
enabled=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
priority=1

#contrib - packages by Centos Users
[contrib-SRPMS]
name=CentOS-$releasever - Contrib SRPMS
baseurl=http://mirror.centos.org/centos/$releasever/contrib/SRPMS/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
priority=1
  • Once downloaded, what is the command to unpack the SRPM so I can edit the files?

rpm -ivh your.src.rpm

This assumes you have necessary directories, if you don't run mkdir -p /usr/src/redhat/{BUILD,RPMS,SOURCES,SPECS,SRPMS} to create them.

The file you'll usually want to edit is the spec file in /usr/src/redhat/SPECS/packagename.spec.

  • Last, once I am done modifying, what is the command to rebuild the modified source RPM?

rpmbuild -bb /usr/src/redhat/SPECS/your.spec to just build the RPM

rpmbuild -ba /usr/src/redhat/SPECS/your.spec to just build the RPM and an SRPM

  • From a SRPM, how does one create a RPM?

rpmbuild --rebuild your.src.rpm

If you need to build RPMs you should look in to using mock.

share|improve this answer
add comment

[centos-src]
name=CentOS $releasever - $basearch - Source
baseurl=http://mirror.centos.org/centos/$releasever/os/SRPMS/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

yumdownloader --source kernel

rpm -i kernel-arch.src.rpm

UPDATE: This is also relevant:

http://wiki.centos.org/HowTos/I_need_the_Kernel_Source

cd /usr/src/redhat/SPECS
rpmbuild -bp --target=`uname -m` kernel-2.6.spec

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.