Red-Hat-Packagemanager

Intended audience: distribution maintainers.


The following pages describe how to create RPM packages of GNAT.

Why RPM?

RPM packages have the distinct advantage of being installable and de-installable. This is quite interesting for maintainers and users alike: Every make install might leave you with no working compiler. And without a compiler you can't compile a new one. Catch 22.

I noticed that very painfully when upgrading to SuSE 10.0 – the GCC 4.0.2 of SuSE 10.0 can't compile GNAT/GPL so one needs a working GNAT/GPL to create a new one.

Quick guide

For those who don't like to read much and want to get right to it.

  1. Download and Install the RPM-Spec-Files
  2. Copy and amend the .rpmmacros file.
  3. Download and Install the GNAT-Configuration-Files
  4. Download and install the source-rpm-Files
  5. Run rpmbuild -ba gnat-gpl-2005.spec and rpmbuild -ba gnat-gcc-4.0.2.spec, and install the resulting packages.
  6. Run Package_Step_2.bash and install the resulting packages.
  7. Run Package_Step_3.bash and install the resulting packages.
  8. Run Upload_R2.bash to upload the files to SourceForge.
  9. Add or edit the appropiate Packages and Releases

Detailed guide

For those who don't like to figure everything out by themselves.

1. Download and Install the RPM-Spec-Files

You have two options open:

  1. You can download them from the download server and then install them with rpm --install. This installs into /work/rpm. You can also use rpm --install --prefix=Directory to install then at any location you like.
  2. You can check them out from the Subversion Archive. The module you need is trunk/rpm. In Subversion you can also find the configuration for older compiler releases.

The documentation is based on the assumption that you use /work/rpm as the build directory.

2. Copy and amend the .rpmmacros file.

You will find a file called /work/rpm/SPECS/.rpmmacros after the download/install. Copy that file to your home directory. Then open it with your favorite editor - there are only 3 lines - change them to reflect your system:

 %_topdir /work/rpm
 %System_Id   SuSE_10_0
 %System_Name SuSE 10.0

Important: System_Id must be one word - no space, not dot, no dash, no fancy anything!

Once you changed %_topdir all installations of source-rpm will go there.

3. Download and Install the GNAT-Configuration-Files

The configuration files install into /opt/gnat but you can change that with rpm --install --prefix=Directory.

These files are used to switch from one GNAT to another.

4. Download the source-rpm-Files

You need to download the RPM-source-file of the system you want to compile – or of a system similar to the one you use. Again you have two options open:

  1. You can download them from the download server and then install them with rpm --install. This installs them into /work/rpm/SOURCES.
  2. You get them from somewhere else and copy them into /work/rpm/SOURCES.

5. Run make gpl and make gcc, and install the resulting packages.

You should know that this step will take several hours – even on modern systems. For the first run you want to start in the morning and from time to time have a look at how things are going.

When finished you will have 2 compiler systems ready – one from the GNAT/GPL sources and one from GNAT/GCC 4.1.1 (at time of writing). You need to install them to continue.

If you have both of these packages installed and want to rebuild them, you can run Package_Step_1.bash instead of the rpmbuild commands. Each compiler will then compile itself. The Package* scripts will only work if the gnat-gcc and gnat-gpl packages are allready installed.

Currently (Sep.2006) there is one extra hurdle: The GNAT/GPL can only be compiled using another (older) GNAT/GPL. This can be solved by

  1. Temporarly installing GNAT from Libre.
  2. Installing a GNAT/GPL from a similar System.

6. Run Package_Step_2.bash and install the resulting packages.

This will compile the libraries and tools which we currently distribute.

7. Run Package_Step_3.bash and install the resulting packages.

Some of the libraries and tools will only compile if others are already installed, so to run step 3 you will need to install the packages from step 2.

8. Run Upload_R2.bash to upload the files to SourceForge.

You will need NcFTP to run this script. You can use any other FTP client you like but then you have to write your own script.

As always you should have a look into the script before executing it.

9. Add or edit the appropiate Packages and Releases

What about Package_Step_0.bash?

Step 0 creates the RPM packages with the rpm-spec-files and the GNAT configuration files. Since this should be independent of the (POSIX) OS used you should have no need to create them.

It did not work

If you read this you are a programmer and therefore should be able to fix it. Here are some hints:

  1. Make a copy of the spec file in question. That way we can add the spec to Subversion repository.
  2. The file you have to look at – apart from the spec – is gnat-common.bash. There you find all common settings for all packages. Since you are planning a special spec file you might want to do away with the gnat-common.bash and expand the functions into your spec file.
  3. try rpmbuild -bp (prepare only) and rpmbuild -bc (prepare and compile).
  4. Remove the calls to Do_Clean – then rpmbuild will keep the temporary files and leave you with more to debug with. The spec files have been designed to be restartable in most cases. Beware: restart won't work on fatal errors in the prepare phase - then you need to clean it all up yourself.

BASH scripts

The package creation with RPM relyies on the use of the bash shell. Here a few hints.

if

The if is probably the most difficult to unterstand bash command. if executed the command between if and ; then and converts the return value to Boolean (in Ada : retval /= 0). There are 4 common commands which to be used between if and ; then:

CommandDescription
test ...Perfomes various tests. Since help test gives a very helpfull introduction I consider test "prefered" to the other commands.
[[ ... ]]Works allmost test. help [[ will tell you only about the differences to test.
let "..."Performes and arithmetic evaluation on the expression and returnes the result. c§help let§§ will tell you about the operations possible.
(( ... ))Same as let but looks nicer. However you need the very un-intuitive help \(\( to get the online help which in turn only tells that the command is equevalent to let. For a team effort I suggest to use let.

M4

We use a set of Prototype RPM specs which we pass thrue the M4 macro preprocessor to create the real RPM specs.

As we are Ada programmers the priority is placed on easy reading over easy writing. We therefore use only a very small subset of the m4 features. Also we use the "m4_" prefix feature so all m4 commands are prefixed the - well - "m4_"

Vim / Exim

Sometimes sources must be patched. We usualy do this with litte exim scripts (the script language from the vim editor). Again priority is placed on easy reading over easy writing. All exim commands are written in there full form and prefixed with ":".

Also exim often is easier to read and understand then diff patch files. For details of Exim see Learning the vi editor/Vim - Ex/Exim Script language.

Packages

The following packages should be installed on your computer:

CommandDescription
atkAn Accessibility ToolKit
autoconf 
aclocal 
automakeA Program for Automatically Generating GNU-Style Makefile.in files
bashThe GNU Bourne-Again Shell
bisonThe GNU Parser Generator
bonoboCORBA Interfaces for Reusable Components
cairoVector graphics library with cross-device output support
coreutilsGNU Core Utilities
cups-libslibraries for CUPS
dbBerkeley DB Database Library
expatXML Parser Toolkit
flexFast Lexical Analyser Generator
fontconfigLibrary for Font Configuration
freetypeTrueType Font Engine
freetype2A TrueType font library
gawkGNU awk
gconf2The GNOME 2.x Desktop Configuration Database System
gdbmGNU database routines
glib2A Library with Convenient Functions Written in C
glibcStandard Shared Libraries (from the GNU C Library)
glitzGlitz--OpenGL Image Compositing Library
gmpThe GNU MP Library
gnome-vfs2The GNOME 2.x Desktop Virtual File-System Libraries
gpmConsole Mouse Support
gtk2Library for Creation of Graphical User Interfaces
libaclA dynamic library for accessing POSIX Access Control Lists
libapr0Apache Portable Runtime (APR) Library
libart_lgplLibart components licensed under the LGPL
libbonoboThe Bonobo Component System for the GNOME 2.x Desktop Platform
libbonobouiThe Bonobo Part of the GNOME User Interface Libraries
libgccC compiler runtime library
libgnomeThe GNOME 2.x Desktop Base Libraries
libgnomecanvasAn Add-On for the GNOME User Interface Libraries
libgnomeuiThe GNOME User Interface Library
libpngLibrary for the Portable Network Graphics Format
libxml2A library to manipulate XML files
iconv 
ncursesNew curses libraries
opensslSecure Sockets and Transport Layer Security
orbit2High-Performance CORBA Object Request Broker
pangoSystem for Layout and Rendering of Internationalised Text
perlThe Perl interpreter
poptA C library for parsing command line parameters
pythonPython Interpreter
rpmThe RPM Package Manager
rubyAn Interpreted Object-Oriented Scripting Language
tclThe Tcl scripting language
tcshThe C SHell
texinfoTools Needed to Create Documentation from Texinfo Sources
xorg-x11-libsX Window System shared libraries
xorg-x11-MesaMesa Libraries
zlibData Compression Library
tetexThe Base System of teTeX

Hint: you can get the package summaries with:

 rpm --query --queryformat='||%{name} ||%{summary} ||\n' ruby

Ada programming, © 2005,2006 the Authors, Content is available under GNU Free Documentation License.