HOWTO: cre­at­ing your own updat­ed lin­ux RPM for the FreeB­SD linuxulator

Back­ground info

The FreeB­SD lin­ux com­pat­i­bil­i­ty envi­ron­ment cur­rent­ly uses RPMs from Fedo­ra 10. Unfor­tu­nate­ly Fedo­ra 10 is end of life since a while. For one of the RPMs (the pan­go one) we where aware of a secu­ri­ty vul­ner­a­bil­i­ty. As we do not know if it is fea­si­ble to update the lin­ux­u­la­tor ports to some­thing more recent, I decid­ed to set­up a VM with Fedo­ra 10 and gen­er­ate a new RPM for the linux-f10-pango port. Thanks to Luchesar V. ILIEV for explain­ing me how to do this.

Set­up of the VM

I used Vir­tu­al­Box 4.0.4 on a Solaris 10 x86 machine. I con­fig­ured a fixed size disk of 16 GB and kept the default net­work set­up (after installing the guest tools / ker­nel mod­ules I switched to vir­tio, as I was not able to do any­thing use­ful besides a ping) and RAM size. The CD/DVD dri­ve was con­fig­ured to use the image of the full Fedo­ra 10 DVD for i386 systems.

Set­up of Fedo­ra 10

Boot­ing the VM from the DVD leads to the graph­i­cal Fedo­ra 10 install soft­ware (after chos­ing to install a new sys­tem on the con­sole). There I accept­ed all the defaults, except for the soft­ware to install. I des­e­lect­ed the Office and Pro­duc­tiv­i­ty group and select­ed the Soft­ware Devel­op­ment group. When I was asked if I want to install some addi­tion­al RPMs I had a look at the com­plete list and installed some I thought are nec­es­sary. I do not remem­ber any­more which ones I chose, but every­thing which looks relat­ed to RPM build­ing is a good candidate.

After a while the install will be fin­ished and you can boot into the new sys­tem (eject the DVD from the dri­ve before reboot). After reboot chose to install the Guest Addi­tions in the menu of the VM. This should mount the ISO image in the VM. As root exe­cute the file for Lin­ux. This will build some ker­nel mod­ules for bet­ter inte­gra­tion (e.g. seam­less inte­gra­tion of the mouse between your desk­top and the VM). At this point I reboot­ed and con­fig­ured vir­tio as the NIC. I also had to con­fig­ure the net­work set­tings by hand, as the GUI tool did not safe all the set­tings correctly.

Update and install of required RPMs

After the VM was up and the net­work con­fig­ured, I updat­ed the entire sys­tem (chose Sys­tem Update in the menu). To update the pan­go port, I had to install the libthai-devel RPM. I had the RPM for it (and all the files I need to build a new pan­go RPM) already down­loaded, so I did a “yum install /path/to/rpm”. At this point I was ready to cre­ate the RPM build environment.

The RPM build environment

As a nor­mal user I exe­cut­ed the com­mand rpmdev-setuptree which cre­ates the direc­to­ry rpm­build and pop­u­lates it with some direc­to­ries. Now you just need to find a suit­able .spec file and put it into rpmbuild/SPECS, put the sources (and maybe patch­es ref­er­enced in the .spec file) into rpmbuild/SOURCES, and you are ready to go (I patched pango.spec for a more recent pan­go ver­sion, basi­cal­ly just chang­ing the ver­sion num­bers). If you want to have a cus­tom pack­ager and ven­dor attribute in the RPM, you can add a line for each to ~/.rpmmacros, e.g. %pack­ager your­name­here and %ven­dor what­ev­eris­ap­pro­pri­ate. I used my @FreeBSD.org EMail address as the pack­ager, and FreeB­SD as the vendor.

Build­ing a RPM

I used rpm­build ‑ba –tar­get i386-redhat-linux-gnu –clean rpmbuild/SPECS/pango.spec to build the new pan­go RPM. If every­thing is OK, the result­ing RPMs (a source RPM, a dev­el RPM, a debug­in­fo RPM and the RPM for the bina­ries) are in rpmbuild/RPMS and rpmbuild/SRPMS. For a FreeB­SD port we just need the source RPM (to com­ply to the (L)GPL) and the RPM for the binaries.

Addi­tion­al info

The i386-redhat-linux-gnu string which is used for the –tar­get option of the rpm­build com­mand is what seems to be used to build the Fedo­ra 10 RPMs. After build­ing pan­go, the RPM has i686-pc-linux-gnu in some file­names instead (the default val­ue for this set­up). The bina­ries seem to be com­piled for i386, so there should be no prob­lem even for old systems.