This article covers the very basic steps on building Slackware packages. There is an completer one and even more available on linuxpackages.net. You may use both as this article covers things not contained in the one on linuxpackages.net.
Before you build your own package, you should have a look at:
- Slackware current on the web
- Linuxpackages.net
- Bottom of the “Slackware .. because it rockz!” article
Important: Build your package in a “clean” area, e.g. a dedicated computer with only necessary stuff installed. You know what I mean, it is kind of a security measure and is also dependency related. In addition you should define a directory (I call it “install_dir” below) where all your installs go. I use /usr/local/contrib/packages for “install_dir”.
In this guidance we package version 2.1.12 of the fwbuilder source code.
Step 1:
Get the source code of the program you would like to have packaged. The tarball is named fwbuilder-2.1.12.tar.gz
Step 2:
Extract the tarball in a directory of your choice and change into the new directory fwbuilder-2.1.12. Check for correct ownership and file permissions. Root should be owner, file perms = 644, directory perms = 755.
Step 3:
Next step is to configure the source. To prevent the software to install somewhere, apply the following Slackware style:
./configure \
--prefix=/usr \
--sysconfdir=/etc \
--localstatedir=/var
You may apply other configure options, depending on your needs and the software’s capabilities. Be also aware to check for dependencies the software may have before configuring / compiling. For example, fwbuilder depends on the library libfwbuilder.
Step 4:
After configure has finished, compile the sources with:
make
Step 5:
So far so good, that was no different than installing it the common way, but that’s going to change from here.
The “DESTDIR” variable is supported by current versions of “automake”. This variable controls where files are installed when issuing “make install”. We check whether the Makefile contains this variable by issuing (still inside the fwbuilder source directory):
grep –r DESTDIR *
Depending on whether DESTDIR is supported or not, the install string changes. In this example the DESTDIR variable has been found in the fwbuilder makefile . The typical install string in this case would be:
make install DESTDIR=/install_dir/ fwbuilder-2.1.12
This string normally just works fine in conjunction with DESTDIR. However, I found fwbuilder to be stubborn using that command, instead this one works:
make install INSTALL_ROOT=/install_dir/ fwbuilder-2.1.12
In case Makefile has no support for DESTDIR, you should use something like:
make install prefix=/install_dir/ fwbuilder-2.1.12/usr
In summary these are the install strings I have seen:
make install DESTDIR=/install_dir/ fwbuilder-2.1.12
make install INSTALL_ROOT=/install_dir/ fwbuilder-2.1.12
make install prefix=/install_dir/ fwbuilder-2.1.12/usr
make install ROOT=/install_dir/ fwbuilder-2.1.12
However you should watch very closely during make install whether it all went to “install_dir/package” and not somewhere else. You do not need to create the install_dir or the package directory (fwbuilder-2.1.12) in advance, as it is done by make install (assumed you have write access).
The "slack-desc" file
Step 6:
Now change into the directory “install_dir/fwuilder-2.1.12” and you will (hopefully) see directories created by “make install”. We could now create the package, but would be missing the package description. Each Slackware package should have a descriptive file – this file has to be placed in the directory ./install und is labeled “slack-desc”. The directory ./install would be created when issuing the “makepkg” command, but since we need the “slack-desc” file in advance, the install dir has to be created manually.
mkdir install
The Slackware description file has to follow a strict set of rules. If the format is not correct the package tools will not display the information about the package correctly. The file must contain exactly 11 lines even if there is not enough text to fill up the lines. Do not exceed the right margin – follow the ruler. Also note that each descriptive line must start with the name of the package.
The "slack-desc" file ruler
As an example see the name of the fwbuilder package below:
|-----handy-ruler--------------------------------------------------------------|
fwbuilder: Firewall Builder (firewall tool)
fwbuilder:
fwbuilder: Multi-platform firewall configuration and management tool.
fwbuilder: It consists of a GUI and set of policy compilers for various
fwbuilder: firewall platforms. Firewall Builder uses object-oriented
fwbuilder: approach, it helps administrator maintain a database of
fwbuilder: network objects and allows policy editing using simple
fwbuilder: drag-and-drop operations.
fwbuilder: Requires libfwbuilder, iptables, iproute2, libxml2, libxslt,
fwbuilder: libmng, Qt
fwbuilder: Packaged by Oliver Brunner (
The "doinst.sh" file
There is another file that goes in the ./install directory called “doinst.sh”. The file will be created by the “makepkg” command if you have symlinks in your package – so not all packages will have a doinst.sh file. I strongly recommend letting “makepkg” remove your symlinks. In addition, “doinst.sh” is the right place for anything special that need to be done post install. You can check for files, add users, change permissions and so on.
The "makepkg" command
Step 7:
Ok, now we are ready to go ahead and make the package. Still inside “install_dir/fwbuilder-2.1.12, type:
makepkg fwbuilder-2.1.12-`uname –m`-1.tgz
Naming package convention goes like this: “name-version-arch-build.tgz”
If “makepkg” detects any symlinks, it asks you whether to remove them and let the install program recreate them: If so, say yes. “Makepkg” creates these directions in the “doinst.sh” file. Also when asked about changing owner and group permissions choose “yes” unless you have checked them (as I recommended in the outset) and are happy. If you choose “yes”, ownership is changed to “root”. There is a problem with this as the directory /usr/bin and the files inside are supposed to be owned by the group “bin” - keep this in mind.
You are now ready to install the package. If you don’t know how to do this, proceed to the article about “package management”.