From Fedora Project Wiki

< User:Tibbs

Revision as of 17:31, 29 January 2015 by Tibbs (talk | contribs) (Created page with "== BuildRequires == In package development and testing, please verify that your package is not missing any necessary build dependencies. Having proper build requirements save...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

BuildRequires

In package development and testing, please verify that your package is not missing any necessary build dependencies. Having proper build requirements saves the time of all developers and testers as well as autobuild systems because they will not need to search for missing build requirements manually. It is also a safety feature that prevents builds with that would not otherwise fail, but would be missing crucial features. For example, a graphical application may exclude PNG support after its configure script detects that libpng is not installed.

Before adding BuildRequires to any package, please be comfortable with Requires .

There are two suggested ways of detecting missing BuildRequires. rpmdev-rmdevelrpms and mock. The first one is designed to remove all developer-related packages from your system. If the build fails or is missing certain features due to missing build dependencies, then the missing dependency needs to be found and added. Check the rpmdev-rmdevelrpms section to find out more.
mock is another good way to check build dependencies. Rather than remove all developer packages, it tries to build your package in a chroot. It makes no changes to your normal, daily environment and ensures that your package will build fine. However, mock may need a good internet connection to download all required packages. MockTricks page contains more information. Another mock-like tool, mach is also available in the Fedora repository.

rpmdev-rmdevelrpms

rpmdev-rmdevelrpms script within the rpmdevtools toolkit is a script written by Ville Skyttä that helps RPM packagers in finding missing BuildRequires. Simply run it and allow it to remove all *-devel packages and build tools like this example.

[root@build-fc1 /] # rpmdev-rmdevelrpms
Found 52 devel packages:
guile-devel-1.6.4-8.2
bison-1.875-5
m4-1.4.1-14
flex-2.5.4a-30
openssl-devel-0.9.7a-23
automake-1.7.8-1
fontconfig-devel-2.2.1-6.1
XFree86-devel-4.3.0-42
tcl-devel-8.3.5-93
SDL_image-devel-1.2.3-3
SDL_ttf-devel-2.0.6-0.fdr.3.1
pth-devel-2.0.0-0.fdr.1.1
libIDL-devel-0.8.2-1
atk-devel-1.4.0-1
gtk2-devel-2.2.4-5.1
libmng-devel-1.0.4-4
glib-devel-1.2.10-11
gtk+-devel-1.2.10-28.1
audiofile-devel-0.2.3-7
compface-1.4-0.fdr.3.1
esound-devel-0.2.31-1
libungif-devel-4.1.0-16
gnome-libs-devel-1.4.1.2.90-35
openldap-devel-2.1.22-8
aspell-devel-0.50.3-16
gpgme03-devel-0.3.16-0.fdr.2.1
freeglut-devel-1.3-1.20020125.3
e2fsprogs-devel-1.34-1
db4-devel-4.1.25-14
krb5-devel-1.3.1-6
autoconf-2.57-3
libtool-1.5-8
gdbm-devel-1.8.0-21
freetype-devel-2.1.4-5
pkgconfig-0.14.0-6
ncurses-devel-5.3-9
tk-devel-8.3.5-93
SDL-devel-1.2.5-9
SDL_mixer-devel-1.2.4-9
zlib-devel-1.2.0.7-2
libgpg-error-devel-0.6-0.fr.3.1
glib2-devel-2.2.3-1.1
pango-devel-1.2.5-1.1
libjpeg-devel-6b-29
libpng-devel-1.2.2-17
ORBit-devel-0.5.17-10.3
clamav-devel-0.65-0.fdr.4.1
cyrus-sasl-devel-2.1.15-6
libtiff-devel-3.5.7-14
imlib-devel-1.9.13-14
gdk-pixbuf-devel-0.22.0-3.0
pilot-link-devel-0.11.8-1
Remove them? [y/N]  y[
]Removing.................................................................................................
................................................................Done.

Then attempt to build your RPM package. Use yum to reinstall any packages that are already in BuildRequires. If your build fails after this point, then you need to read through the build process and ascertain the missing BuildRequires from the error messages within.

Be very careful to watch especially the configure part of the build process for missing optional libraries or tools that are desirable for the package.

By default, the script may attempt to remove some packages that your system needs to operate correctly. Usually, this will fail due to an unsatisfied dependency (and this, BTW is why the script is using rpm -e instead of yum remove...)

An example of this are the gettext and libgcj packages. gettext is usually a development-only package, but for example redhat-lsb depends on it. Also, it seems that RH9 Konqueror needs openssl-devel for SSL. If you wish to mark some packages so that they will be ignored by rpmdev-rmdevelrpms, do it in /etc/rpmdevtools/rmdevelrpms.conf or your personal /.rmdevelrpmsrc and pay special attention to the packages you treated this way when building.

Exceptions

There is no need to include the following packages or their dependencies as BuildRequires because they would occur too often. These packages are considered the minimum build environment.

bash
bzip2
coreutils
cpio
diffutils
fedora-release
findutils
gawk
gcc
gcc-c++
grep
gzip
info
make
patch
redhat-rpm-config
rpm-build
sed
shadow-utils
tar
unzip
util-linux
which
xz

BuildRequires and %{_isa}

You MUST NOT use arched BuildRequires. The arch ends up in the built SRPM but SRPMs need to be architecture independent. For instance, if you did this:

# Example of what *not* to do
BuildRequires:	python%{?_isa} >= 2.7

Then the SRPM that is built in Fedora would have one of these Requirements depending on what builder the SRPM was created on:

python(x86-32) >= 2.7
# or
python(x86-64) >= 2.7

This would prevent yum-builddep or similar tools that use the SRPM's requirements from operating correctly.

BuildRequires based on pkg-config

Fedora packages which use pkg-config to build against a library (e.g. 'foo') on which they depend, SHOULD express their build dependency correctly as pkgconfig(foo). For more information, see Packaging:PkgConfigBuildRequires.