Contents
How to package an application for Mageia
Since we want this to be as real an exercise as possible, we're going to set up a package that is probably not installed on your Mageia yet, as it's a bit esoteric, being a graphical demodulator program for amateur radio (ham) use, called fldigi
.
For more information, the home page is here. Come back when you're done reading all about it ;-)
Anyway, let's get on with it. It's not too difficult. Really.
Prerequisites
Firstly, let's get the build environment set up.
You'll need to install rpm-build
first:
urpmi rpm-build
No-doubt this will bring back a bunch of dependencies to install. This is what came back when I tried. Not too bad:
To satisfy dependencies, the following packages are going to be installed: Package Version Release Arch (medium "Core Release") autoconf 2.68 1.mga1 noarch automake 1.11.1 3.mga1 noarch elfutils 0.152 1.mga1 i586 perl-File-Slurp 9999.150.0 1.mga1 noarch perl-JSON 2.510.0 1.mga1 noarch perl-List-MoreUtils 0.300.0 3.mga1 i586 perl-Module-ScanDeps 1.20.0 1.mga1 noarch perl-YAML 0.730.0 1.mga1 noarch python-pkg-resources 0.6.14 7.mga1 noarch rpm-mageia-setup-build 1.133 1.mga1 i586 spec-helper 0.31.5 2.mga1 noarch (medium "Core Updates (distrib3)") rpm-build 4.8.1 10.3.mga1 i586 7.3MB of additional disk space will be used. 2MB of packages will be retrieved. Proceed with the installation of the 12 packages? (Y/n)
Just answer "Y" and let it run.
Directory structure
You'll need to create a directory structure to house your development environment in. This should be in your home directory.
mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS/i586,RPMS/X86_64,RPMS/noarch,SOURCES,SRPMS,SPECS,tmp}
For other architectures, you'll need to use the correct directory names under "RPMS".
Populating the directories with data
OK. The next step is to start filling up all the holes with files.
Firstly, I have retrieved the fldigi source as a TAR file and put it into the SOURCE directory. Next, the Specification (.spec) file for the build is required. Below is the spec file for the package I'm trying to build here.
Whilst I could use almost anything for "Name, Version and Release", I'm trying to follow a convention for packaging Mageia RPMs, so let's be pedantic.
Name: fldigi Version: 3.21.40 Release: %mkrel 1 Summary: Digital modem program License: GPL Group: Communications URL: http://www.w1hkj.com/Fldigi.html Source0: http://www.w1hkj.com/downloads/%{name}/%{name}-%{version}.tar.gz BuildRequires: libfltk-devel libsamplerate-devel %description Digital modem program %prep %setup -q %build %configure2_5x %install rm -rf %{buildroot} %makeinstall_std %find_lang %{name} %files -f %{name}.lang %{_bindir}/flarq %{_bindir}/fldigi %{_datadir}/applications/flarq.desktop %{_datadir}/applications/fldigi.desktop %{_mandir}/man1/flarq.1.* %{_mandir}/man1/fldigi.1.* %{_datadir}/pixmaps/flarq.xpm %{_datadir}/pixmaps/fldigi.xpm %changelog * Wed Mar 15 2012 Simon Parsons <simonnzg@mageia.org> 3.21.39-0.mga1 - Packaged for Mageia
Remember: This file is used to give the packaging tool all the information it needs to create your RPM, including the name of the file; where it's going to be installed to; and all the way down to where in the desktop menu it's going to be put, so we have to be careful and decide beforehand where it will go. It's worth digging around the sourrce to see if you can find out what directories it's expecting to be installed in. You can see that the Mageia defaults are given in the .spec file as variables, i.e. you don't need to know, you only need to know the basics and much of it can be guessed fron other .spec files, like this one :-)
This .spec file should produce a file called fldigi-3.21.40-0.mga1.i586.rpm
and once installed will be available in the "Communications" Menu. I'd have liked a specific Group for Ham Radio, but let's not digress. Communications will do - it's probably full of programs for publicity, spamming people and printing advertising banners, but let's not go there, shall we? ;-)
It's also a good idea to know what else this package will require before it will compile and be buildable. A good place to look is in the TAR file. Look for a file called INSTALL
. This is what the one for fldigi tells us:
Installation Instructions for fldigi ************************************ To compile fldigi you will need: * A recent C++ compiler. The GNU C++ compilers in the 4.x series are known to work. * Version 1.1.x of the Fast Light Tool Kit (FLTK), with its development library and headers. Versions 1.1.7 to 1.1.9 are known to work. FLTK's multi-threading support is required. * The samplerate (a.k.a. secret rabbit code) library. * The PNG library. You should also install the libraries and headers for PortAudio, the Portable audio I/O library. Additional features are enabled if the corresponding libraries are present on your system: * Support for rig control via hamlib is enabled if the hamlib development files are installed. * Audio file generation, capture and playback support is enabled if `configure' can find the sndfile library. * The PulseAudio sound backend is compiled if the development files for libpulse-simple, the PulseAudio simple API library, are present. * The embedded XML-RPC web server is enabled if `configure' can find the C++ bindings for the libxmlrpc-c3 library. An example client can be found in scripts/fldigi-shell. Once you have installed the required packages, the following commands should be sufficient to compile fldigi and install it under /usr/local: ./configure make make install (you may need superuser privileges for installation)
This naturally takes us on to the next stage:
Dependencies
Fldigi needs a few extra libraries and helper applications to compile. These are listed in the INSTALL file and include GCC. Well, rpm-build
should do that for you. In particular, this application needs fltk-devel
, which will need to be installed if you don't already have it. Another requrement is libsamplerate-devel
. Install the whole lot with:
urpmi libfltk-devel libsamplerate-devel
As usual, a bunch of other stuff will be required. Just say "yes" and let it run.
Running rpmbuild
OK. with luck, you can now sit yourself into the SPECS directory and run the following command:
rpmbuild -ba fldigi.spec
Depending on what goes wrong, you should start to see the SRPM and then the RPM get built. If the process fails, you'll see a message at the point that it stops telling you that something is missing from the build environment. Open a root shell and install what's missing and try again. Eventually, you'll reach the end and, with luck, you'll have a shiny new RPM to play with. :-)
Installing your RPM
Well. Of course you'll want to do this.
Go to the directory your RPM is in. In this case, it's RPMS/i586
Run the following command and hold your breath.
rpm -ivv fldigi-3.21.40-1.mga1.i586.rpm
Actually, you only need to type rpm -iv fldigi-3
and then bash the "Tab" key, which should fill in the rest automatically.
You should see lots of debugging information caused by the -vv switch. It's worth taking a quick look though it to make sure nothing seems to be wrong. If you didn't include -vv you'd get almost no feedback on what happens at all.
Now, return to being a normal user and try running fldigi:
fldigi
Fldigi should execute, leaving a few lines of text on your console as it launches. You can look at it later: It's recording what serial ports it's found and several other items such as default macros, log files, that sort of stuff. Hopefully the fldigi window has launched and you're looking at a rather strange window that looks a bit like the picture below.
Problems still needing to be resolved
I still haven't managed to ge the correct settings to add a menu item "Communications", nor enter a shortcut in that menu to fldigi.