From Fedora Project Wiki

Revision as of 14:21, 1 February 2013 by Jzeleny (talk | contribs) (Simple RPM builds - command sequence)

Simple RPM builds from source files - command sequence

This tutorial assumes you have a tarball, (optionally) set of patches you want to be applied on top of content of that tarball and a spec file describing how to build that tarball.


You can use following simple command sequence run by root to build your RPM package from spec file on your system:

# yum install rpmdevtools yum-utils
# su - <user>
$ rpmdev-setuptree
$ cp <sources> ~/rpmbuild/SOURCES
$ cd ~/rpmbuild/SPECS
$ sudo yum-builddep <package>.spec
$ rpmbuild -ba <package>.spec                          # now your rpms are in ../RPMS and src.rpm in ../SRPMS

Simple RPM builds - commands' description

Now let's take a look at the thing above, one command at a time.

# yum install rpmdevtools yum-utils

This will install two packages which are necessary for the following work. rpmdevtools contains rpmdev-setuptree script and yum-utils contains yum-builddep.


$ rpmdev-setuptree

This will create a directory tree necessary to build packages in your home directory. For more details on the tree structure, please see How_to_create_an_RPM_package.

$ mc                                                 # now copy package's files where necessary

The important thing to know is that you should copy your spec file into SPECS and all other source files into SOURCES directory.

$ cd ~/rpmbuild/SPECS
$ rpmbuild -bs package.spec

This will create srpm package. That is necessary for the next step. If you are sure all build dependencies of the package are installed, you can skip these two steps.

$ cd ~/rpmbuild/SRPMS
$ yum-builddep package.srpm

This will try to download and install all built-time dependencies of desired package. Unfortunatelly rpmbuild can't do that on its own.

$ cd -
$ rpmbuild -bb package.spec

This will build your rpm package. If any errors occur, you will see them on terminal. Otherwise look for your packages in ../RPMS