Thalasar Ventures

How to add pac?ages to older versions of BSD systems

This article started on the basis of a review of my software product – KarmaBSD, which is reviewed on the following forum: http://www.daemonforums.org/showthread.php?t=3092

The writer of the text in the above forum is interested to know how to add applications into KarmaBSD but does not know how, so I decided to add some words on this topic.

As some people think (as the author of the text in the forum) that it is a complication to install OpenBSD 4.1 today – when the version 4.7 of OpenBSD is already available and the version 4.1 is rather quite old, I decided to publish a solution how packages can be instantly (and easily) transported from any OpenBSD (or FreeBSD) system to any OpenBSD (or FreeBSD, NetBSD, etc.) system – the solution is to compile packages statically. What does it mean?

Ports and the base system

Before you compile packages (from ports), you may decide to add the “–enable-static” option to your makefiles. Without this, the result of compilation (binary application) of packages on OpenBSD 4.4, for example, depends always on this system’s libraries. Every compilation is made against these global libraries (OpenBSD 4.7, FreeBSD 8.0, etc). Thus, if you compile packages in OpenBSD 4.7, which has different versions of libraries than OpenBSD 4.6, 4.5, etc., you cannot use these binaries in other versions of OpenBSD.

Static versus dynamic

The concept of the shared (dynamic) libraries (when many programs use certain libraries) started on the premise of saving space. But today, when a 40 GB hard drive is cheaper than ice cream in a very good European restaurant, the philosophy to save a few dozens of megabytes is, on the other hand, a very big barrier to portability of packages (if libraries are embedded in binary packages, you may use such binaries almost in any version of the system they were built for).

Programs (and sources) contained in the base system – not Linux, but BSD (fdisk, ifconfig, chmod, etc.) are also dependent on the kernel they are distributed with. If you deal with sources of ifconfig in OpenBSD 4.7, for example, you must compile them against the OpenBSD 4.7 kernel.

This is a very important hint, as we must differentiate compilation of sources from 1) the BSD base system (binaries are not easily transportable, as they are kernel dependent) and from 2) ports (add-on packages). The “–enable-static” option in your makefiles must only be used in source files that are not kernel-version dependent (that is – /usr/ports).

Base system tools like fdisk, mount, ifconfig, etc., are kernel(system)-version dependent (like OpenBSD 4.7, FreeBSD 5.2, etc.) and although they, too, can be compiled statically, using them with a different kernel would bring a number of system failures.

However, packages (in /usr/ports), i.e. binaries of ports compiled on OpenBSD 4.5, for example, are only library dependent (they require shared libraries used in OpenBSD 4.5), but not kernel dependent. They cannot be used on other versions of OpenBSD only because they were compiled against libraries that are missing in other versions of OpenBSD. To solve the issue (backward compatibility), you may install the so-called compatibility libraries. But if you work with a small floppy (or CD) system, it is a bit hard to install such compatibility libraries into the floppy (or minimal CD) environment. The workaround is to compile packages (in /usr/ports) statically.

When you compile your sources this way (statically), the system’s libraries get embedded into the resulting binaries. Packages (not the base system) statically compiled on OpenBSD 4.5, for example, will run on any OpenBSD system including KarmaBSD. The binary of mpg123 in KarmaBSD was compiled statically too.

As most floppy systems are space limited, the best way is to make some additional room in memory and then copy such a statically compiled binary there from another floppy.

KarmaBSD and SONaFR run in memory, too, so their floppies, after you boot with them, can be taken out from your computer.

To prepare a memory file system in KarmaBSD, type (the number “4917” may vary in dependence of free RAM):

mount_mfs -s 4917 -o async,nosuid,nodev,noatime swap /mnt

The above two floppy systems can be downloaded here:

SONaFR – http://www.freebsd.nfo.sk/opbsd/openbsdeng.htm

KarmaBSD – http://www.freebsd.nfo.sk/opbsd/karmabsdeng.htm

They both were made with crunchgen. A crunched binary (result of crunchgen) is a program (kernel/system-version dependent) made up of many other programs (like fdisk, mount, chown, ifconfig, etc.) and libraries linked together into one single executable. The crunchgen utility is a tool that will make such a binary.

Juraj’s karma

Both comments and pings are currently closed.

Comments are closed.