Wednesday, June 07, 2017

Building RPMs for Mageia - x2x

Occasionally, you may need to install something that is not included with Mageia. For instance, the x2x applications used to be included with Mageia, but has been dropped in Mageia 5. There are other packages, perhaps Ubuntu packages that I might want to use on my system. Or it's possible no package exists,  just a tarball.

Why would you want to build a package from source if the binary is already available? 

Let's begin with the Mageia Packagers RPM Tutorial as a reference.

Create Your Build Environment

It's always a good practice to build packages as a normal user, not as root. Still, it's handy to have sudo enabled for certain operations.

Create you build environment.

$ mkdir -p ~/rpmbuild/{SRPMS,SOURCES,SPECS,tmp}

Using your favorite editor, create the .rpmmacros file to build Mageia packages.
   # Only set %_topdir and %_tmppath if you want to ovveride the the default ~/rpmbuild 
   # and ~/rpmbuild/tmp
   #%_topdir                %(echo $HOME)/rpm
   #%_tmppath               %(echo $HOME)/rpm/tmp
   # If you want your packages to be GPG signed automatically, add these three lines
   # replacing 'your_name' with your GPG name. You may also use rpm --resign
   # to sign the packages later.
   %_signature             gpg
   %_gpg_name              your_name
   %_gpg_path              ~/.gnupg
   # Add your name and e-mail into the %packager field below. You may also want to
   # also replace vendor with yourself.
   %packager               John Doe 
   # you only need to set distribution and vendor if you are not building on
   # a mga host
   #%distribution           Mageia
   #%vendor                 Mageia.Org
   # If you want your packages to have your own distsuffix instead of mga (mga5 and older),
   # add it here like this
   #%distsuffix             foo
   # With mga6 and newer, if you want your packages to have your own dist instead of mga, 
   # add it here like this
   #%dist                   foo

We also need to install some packages like a compiler. I've found that installing the application checkinstall will bring in most everything we need. Checkinstall is a handy app used to create rpm files from tarballs and some scripts.

$ sudo urpmi checkinstall

Building From a Source RPM

To build from a source RPM file, we need to first install the source repositories.

$ sudo urpmi.addmedia core_src

 And then install it with

$ urpmi --install-src packagename

 You can also use ftp with urpmi. Since x2x was dropped (it has not been maintained in a while, circa 2003), we can search in RPMfind for the x2x packages (or go to the homepage for a tarball), and locate a suitable package. Also, we check that 1.30beta is the most current version available.

From this page we can follow the link to a 64-bit package and use the ftp feature of urpmi  to install the package as a regular user.

$ urpmi --install-src

That should have worked, except that the files are so old, they have been deleted from the servers.  I eventually found a source rpm file at , but it would not install due to missing dependencies (unsatisfied libXext-devel), therefore I used wget to download the file and I'll use urpmi to install the missing dependency and then install the source rpm.

Get  List of Dependencies Before Installing

There are several ways to get this information.

If you are installing a source rpm from the Mageia repository that you installeld above, then use

$ urpmq -d -m --sources

I find it easier if a source package is available, to use mc to peek inside the rpm file and look at the contents of comtents.cpio and examine the .spec file, which will list the dependencies. In this case, they are

 libX11-devel, libXext-devel, libXtst-devel, imake

But these are for a Fedora system, so the equivalent Mageia must be discovered.

 libx11-devel, libxext-devel, libxtst-devel, imake

Note how just the (annoying) difference in capitalization make things different. so

$sudo  urpmi libx11-devel libxext-devel libxtst-devel imake

Install these and the 17 packages that it takes to sort out all their dependencies. Ugh.


Mageia URPMI

Quick URPMI Reference

Mageia Packaging Tutorial

Checkinstall Homepage & README

No comments: