From Fedora Project Wiki

 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:


== 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:
You can use following simple command sequence run by root to build your RPM package from spec file on your system:
Line 7: Line 10:
# su - <user>
# su - <user>
$ rpmdev-setuptree
$ rpmdev-setuptree
$ mc                                                # now copy package's files where necessary
$ cp <sources> ~/rpmbuild/SOURCES
$ cd ~/rpmbuild/SPECS
$ cd ~/rpmbuild/SPECS
$ rpmbuild -bs package.spec
$ sudo yum-builddep <package>.spec
$ cd ~/rpmbuild/SRPMS
$ rpmbuild -ba <package>.spec                         # now your rpms are in ../RPMS and src.rpm in ../SRPMS
$ yum-builddep package.srpm
$ cd - && rpmbuild -ba package.spec                 # now your rpms are in ../RPMS
</pre>
</pre>


== Simple RPM builds - commands' description ==
== Simple RPM builds - commands' description ==
Line 21: Line 21:
# yum install rpmdevtools yum-utils
# yum install rpmdevtools yum-utils
</pre>
</pre>
This will install two packages which are necessary for the following work. rpmdevtools contains rpmdev-setuptree script and yum-utils contains yum-builddep.
This is a one-time action, which will prepare your system - it will install two packages which are necessary for the following work. rpmdevtools contains rpmdev-setuptree script and yum-utils contains yum-builddep. You don't have to install rpmdevtools if you already have your rpm build tree (if you, for example, built some packages before).




Line 27: Line 27:
$ rpmdev-setuptree
$ rpmdev-setuptree
</pre>
</pre>
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]].
This will create a directory tree necessary to build packages in your home directory. If you already have the tree, you can skip this step. For more details on the tree structure, please see [[How_to_create_an_RPM_package]].


<pre>
<pre>
$ mc                                                # now copy package's files where necessary
$ cp <sources> ~/rpmbuild/SOURCES
</pre>
</pre>
The important thing to know is that you should copy your spec file into <code>SPECS</code> and all other source files into <code>SOURCES</code> directory.
The important thing to know is that you should copy your spec file into <code>SPECS</code> and all other source files into <code>SOURCES</code> directory.
Line 36: Line 36:
<pre>
<pre>
$ cd ~/rpmbuild/SPECS
$ cd ~/rpmbuild/SPECS
$ rpmbuild -bs package.spec
$ yum-builddep package.spec
</pre>
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.
 
<pre>
$ cd ~/rpmbuild/SRPMS
$ yum-builddep package.srpm
</pre>
</pre>
This will try to download and install all built-time dependencies of desired package. Unfortunatelly rpmbuild can't do that on its own.
This will try to download and install all built-time dependencies of desired package. Unfortunatelly rpmbuild can't do that on its own.
Line 48: Line 42:
<pre>
<pre>
$ cd -
$ cd -
$ rpmbuild -bb package.spec
$ rpmbuild -ba package.spec
</pre>
</pre>
This will build your rpm package. If any errors occur, you will see them on terminal. Otherwise look for your packages in <code>../RPMS</code>
This will build your rpm and srpm packages. If any errors occur, you will see them on terminal. Otherwise look for your packages in <code>../RPMS</code> and <code>../SRPMS</code> respectively.

Latest revision as of 14:29, 1 February 2013

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 is a one-time action, which will prepare your system - it will install two packages which are necessary for the following work. rpmdevtools contains rpmdev-setuptree script and yum-utils contains yum-builddep. You don't have to install rpmdevtools if you already have your rpm build tree (if you, for example, built some packages before).


$ rpmdev-setuptree

This will create a directory tree necessary to build packages in your home directory. If you already have the tree, you can skip this step. For more details on the tree structure, please see How_to_create_an_RPM_package.

$ cp <sources> ~/rpmbuild/SOURCES

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
$ yum-builddep package.spec

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 -ba package.spec

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