[CentOS] recommended way to install source rpms?

Mathieu Baudier mbaudier at argeo.org
Mon Oct 11 01:10:07 EDT 2010


> More people should be doing this kind of stuff.  The world needs more
> open source developers.  Looking at existing code is a great tool for
> learning.

+1

As Karanbir put it in his interview in Distrowatch a few months ago,
CentOS is not only great as a stable and predictable server distrib,
but can also serve as a basis for going further in one particular
area, leaving the rest rock solid and untouched.

- create rpmbuild environment as here:
http://wiki.centos.org/HowTos/SetupRpmBuildEnvironment
- install 'mock' (IMPORTANT: install the one from CentOS, exclude the
one from EPEL in your repo file)

- download SRPM(s)
- (optional) if taken from Fedora after around 9 or 10, rpm -i
*.src.rpm won't work, unpack it manually with Archive Manager, put the
spec file in SPECS, the rest in SOURCES
- download the latest source, or hack the spec file, etc.
- create the SRPM: rpmbuild -bs --nodeps rpmbuild/SPECS/myspecfile.spec
- build the SRPM you just created in mock (with debug option enabled
to see all the logs, but they will also be in build.log)
- do it over and over until your build dependencies are right and it
completely builds
- retrieve your RPMs, put them in a directory, use 'createrepo' to
create metadata, use this directory as an additional repo for mock
(update /etc/mock/*.cfg)
- create a virtual machine (using KVM, VirtualBox, ...)
- install your binaries RPM in the virtual machine (you could expose
the above created local repo via httpd or NFS)
- break your dummy virtual machine as much as you want
- if what you have done could be useful to someone else, you are free
to redistribute it (http://www.gnu.org/philosophy/free-sw.html), just
be clear that it is not supported CentOS, especially if you updated
core parts (*-plus repositories)

[1] building in mock is really efficient and clean: it takes care of
the dependencies in a clean chrooted install, otherwise you end up
having plenty of build dependencies on your workstation and if you
have to build the dependency of the dependency of the dependency,
install it in order to build the next one, etc. you're pretty much
sure to break your workstation. You can use 'mock shell' to go and
build manually in the chrooted install in case something went wrong
and you want to study it without redoing the whole process.


More information about the CentOS mailing list