Building Tool RPM Packages

From RTEMSWiki

Jump to: navigation, search
Chris: This is the start of documenting building the tool RPM packages.

RTEMS provides binary tool packages in the RPM format. If you wish to build binary tools for RTEMS you can use the method used to produce the binary RPM packages. Building tools from source is a complicated and sometimes fragile operation. To help keep the procedure simple all RPM files are built in Linux including the Windows versions. The RPM tools is used as it provided a excellent tools designed for building large packages from source.

To build the tools you will need the RTEMS source tree, plus the source for GCC, binutils, newlib and GDB. The standard packages may require patches.

Contents

Build Machine

The current tool sets are build on Linux PC based machines. Joel uses a RedHat 7.3 machine to give the resulting executables a wide range of machines to run on. Ralf and Chris use Fedora Core 4 machines. This documentation is written while building on a Fedora Core 4 machine.

The host machine needs to be a software development machine. You need to make sure you have a working GNU compiler suite. If you intend to build all possible packages you will need a large amount of disk space. You need to install perl and help2man. On Fedora Core 4 you can find a help2man RPM package in the Extras RPM repository.

Source Code

To build the latest tool set you will need a current RTEMS snapshot. A CVS checkout may be suitable. You will also need to download these source code packages from the ftp://ftp.rtems.org/pub/rtems/SOURCES/ directory on the RTEMS ftp server:

Place these files in a SOURCES directory under the RPM build location you select.

RPM Base Directory

You need to selection a location on the host build machine where the RPMs are built and the resulting images left. An example is:

 /opt/rtems/src

This means the source code should be placed in:

 /opt/rtems/src/SOURCES

You also need to create few working directories. These are:

$ cd /opt/rtems/src
$ mkdir SRPMS
$ mkdir -p RPMS/noarch

RPM Macros File

Create a private RPM macros file in your home directory:

$ cat ~/.rpmmacros
%_topdir     /opt/rtems/src
%_tmppath    /tmp/rtems
%_rpmdir     %_topdir/%_target_os/RPMS
%_srcrpmdir  %_topdir/%_target_os/SRPMS
%_signature  gpg
# %_gpg_path ~/.gnupg
# %_gpg_name "RTEMS Packager"
%_gpg_name   rtems
%vendor:     OAR Corp
%packager    http://www.rtems.org/

The %_topdir field is set to your RPM Base directory.

Building

The building of the RPM packages requires a number of phases to be completed in order. Each phase requires the previous phase to be completed.

Configuring the CrossRPM Scripts

The latest method of building the RPM files is using the scripts in contrib/crossrpms. These scripts can build tools for the following hosts:

  • Linux
  • FreeBSD
  • Solaris
  • Windows (Cygwin)
  • Windows (MinGW)

The Linux RPM files have to be built so we build them first. They are needed for the building of the tools for other hosts. The Linux tools are cross-compiler tools. The build of the other host platform tools is something called a Canadian cross-compilet. Follow the Cross-compiling link for more details.

Enter the crossrpms directory of the RTEMS source tree and run configure script. This assumes you have successfully completed a bootstrap. To build tools for the Windows MinGW host you configure with:

$ cd /opt/rtems/src/cvs/contrib/crossrpms
$ ./configure --prefix=/opt/rtems/test/4.7 --host=i686-pc-mingw32 --target=m68k-rtems4.7
$ make

The result are a number of specs files in the rtems and mingw32 directory.

The crossrpms directory contains a bootstrap script. You can run this script so you do not need to bootstrap RTEMS.

Running rpmbuild

The first packages you need to build are the autotools packages. RTEMS uses autotool packages that are later releases than those found on most Linux operating sysems. To build enter the autotools directory and run rpmbuild:

$ cd autotools
$ rpmbuild -ba rtems-4.7-autoconf-rtems.spec --target=i686-pc-linux-gnu

This builds autoconf for a Linux PC host.

Note: Different versions of RPM may behave differently. This may appear when building a different target. If this occurs try:

rpmbuild \
 --define '_build i386-redhat-linux' \
 --define '_host i686-pc-cygwin' \
 --target=i686-pc-cygwin \
 -ba <spec-files>

Installing Test RPMs

If you are a developer and wish to build and install tools using the RPM scripts you may wish to not install the RPM files into the system RPM database of your build machine. This is important if you have a machine that is building code with production tools yet you wish to develop new tools.

You can avoid clashing with the production tools by using a different prefix and changing the RPM release value in the setup.def file. For example change the rtems_rpm_release value then run configure then make in the scripts directory followed by the rpmbuild command.

If you do not wish to install test RPM files as root you can perform this task as a user by coping to the current RPM database to your test prefix and changing ownership to your user id. You then provide the --dbpath option the rpm command. For example:

$ cd /local/tool/rtems
$ mkdir -p test/var/lib/rpm
$ cp -r /var/lib/rpm test/var/lib
$ rpm --dbpath /local/tools/rtems/test/var/lib/rpm -qa | grep rtems
$ rpm --dbpath /local/tools/rtems/test/var/lib/rpm \
  -i /local/tools/rtems/tools/packages/linux/RPMS/i686/rtems-4.7-m68k-rtems4.7-libc-1.14.0.i686.rpm
Personal tools