Build & Install Slackware Packages Automatically
Wielding sbopkg queuefiles
Many popular Linux distributions include a package management system like yum
, dnf
, or apt
. Those package managers make it easy for the user to do something like the following:
yum install software
In the example above, yum
handles downloading and installing any dependencies for software
as well as downloading and installing software
itself. The user doesn’t need to care how this works. If all goes well, the end result is that software
is magically installed.
Slackware’s Package Management System
Slackware Linux takes a different approach.
Slackware’s package management system ( pkgtool
, installpkg
, removepkg
) is stupid simple. It assumes that you, the system administrator, know your system the best. That assumption includes assuming that you are capable of:
- Compiling or finding your own software.
- Tracking any dependencies.
That may sound scary and hard, but Slackware gives you a platform and a community that makes doing this kind of thing yourself fairly simple.
Slackware packages are just simple gzipped tarball files. They are all organized using the same simple convention.
Once you’ve acquired a Slackware package for software
, installing it is as simple as:
installpkg software.tgz
installpkg
simply ungizps and untars the software package to the correct location (plus some additional, minimal administrative work). That’s it. It doesn’t handle downloading software
. It doesn’t manage dependencies for you. And that’s by design.
Why Do This?
I believe that by practicing system administration this way ultimately results in you becoming a more competent, savvy, and educated system administrator.
BUT…
The learning curve can be painful, and sometimes you just need software installed right now. Fortunately, Slackware’s keep-it-simple approach lends itself very nicely to simple and straight forward automation.
In the rest of this post, we’ll take a bottom-up approach towards a very automated approach for installing software and their dependencies on Slackware.
Automatically Build & Install Slackware Packages
SlackBuilds.org is the Slackware community that enables Slackware users to build their own slackware packages with relative ease.
There are simple instructions on how to use the “SlackBuilds” that are available on the site, and are really worth a read if you’ve never used SlackBuilds.org before. Seriously, go read them.
Assuming you’ve read them, let’s work out a real example.
SlackBuilding jq
jq is like sed
for JSON data - you can use it to slice and filter and map and transform structured data with the same ease that sed
, awk
, grep
and friends let you play with text.
jq
does not come with Slackware, out of the box. So let’s use SlackBuilds.org to go ahead and build it.
This is the link to the current jq
SlackBuild for Slackware 14.2: https://slackbuilds.org/repository/14.2/system/jq/
Note: This may not work if you’ve configured your Slackware 14.2 system to use Slackware-Current.
Notice the This requires line. That tells us that we need to go and build all SlackBuilds listed before we attempt to build this one. In our case, jq
only has one: oniguruma.
So, building a SlackBuild turns into a depth-first traversal through This requires lines. This can be a major pain, if it turns out there are tons of dependencies and probably drives people to use yum
or apt
.
Fortunately, there is a simple solution that spares you the pain of doing this by hand, which we will get to later. For now, let’s go ahead and see about building oniguruma: https://slackbuilds.org/repository/14.2/development/oniguruma/
Build & Install oniguruma
This is the key part to any page on SlackBuilds.org:
Building a SlackBuild always follows this general approach:
cd ~
mkdir tmp
cd tmp# Get the Source Downloads
#
# I got the URL by right-clicking the link and
# copying the link address
#
wget https://github.com/kkos/oniguruma/releases/download/v5.9.6_p1/onig-5.9.6_p1.tar.gz# Get the SlackBuild
wget https://slackbuilds.org/slackbuilds/14.2/development/oniguruma.tar.gz# Extract the SlackBuild:
tar xvzf oniguruma.tar.gz# Move the Source Downloads into the Extracted SlackBuild
mv onig-5.9.6_p1.tar.gz oniguruma/cd oniguruma# If sudo not configured, become root before running
sudo ./oniguruma.SlackBuild
A SlackBuild script always finishes by telling you where the Slackware package was created for you. In our case:
Slackware package /tmp/oniguruma-5.9.6_p1-x86_64-1_SBo.tgz created.
So, we’ll go ahead and install it:
sudo su
installpkg /tmp/oniguruma-5.9.6_p1-x86_64-1_SBo.tgz
exit
Now that we’ve installed the dependencies ofjq
, we’re all set to go ahead and build and install jq
itself.
Build and Install jq
Back to the jq
SlackBuild page: https://slackbuilds.org/repository/14.2/system/jq/
We’ve taken care of dependencies, so on to the main event!
cd ~
cd tmp# Get the Source Downloads
wget https://github.com/stedolan/jq/releases/download/jq-1.6/jq-1.6.tar.gz# Get the SlackBuild
wget https://slackbuilds.org/slackbuilds/14.2/system/jq.tar.gz# Extract the SlackBuild:
tar xvzf jq.tar.gz# Move the Source Downloads into the Extracted SlackBuild
mv jq-1.6.tar.gz jq/cd jq# If sudo not configured, become root before running
sudo ./jq.SlackBuild
Success!
Slackware package /tmp/jq-1.6-x86_64-1_SBo.tgz created.
Install it:
sudo su
installpkg /tmp/jq-1.6-x86_64-1_SBo.tgz
exit
which jq
jq --version
Success!
Moar Automated!
Compared to yum install jq
, the process we just went through still seems like a tremendous pain. Admittedly, it is. Unpacking the reasons why I think going through those motions has a lot of value could really take up an entire post. I’ll just leave a few hints, here:
- Every
*.SlackBuild
script is just a simple shell script. You can read them yourself. You should read them. They will teach you a lot about building software for free. - You come away with a much better and clearer sense about the origin of your software.
sbopkg
OK, fine. If you’re trying to get stuff done for a day job, you don’t always have time to be in student mode. You’re in the Wild West. You have to shoot first and ask questions later.
Thankfully, for these kinds of situations, there is the wonderful sbopkg project.
Sbopkg is a command-line and dialog-based tool to synchronize with the SlackBuilds.org (“SBo”) repository.
Crucially, sbopkg
helps you
- Automatically download the source code, check the md5sum, and build or build and install a Slackware package from either the original .info file and SlackBuild or the locally-edited copies.
- Batch queue packages for building or building and installing.
- Load, save, and use sbopkg queuefiles (.sqf), several of which are included with the package.
Let’s see what that looks like for our jq
example.
Install sbopkg
Installation instructions are simple, straight forward and located here: https://sbopkg.org/index.php
At the time of this writing, installation looks like this:
cd ~
cd tmp
wget https://github.com/sbopkg/sbopkg/releases/download/0.38.1/sbopkg-0.38.1-noarch-1_wsr.tgz
sudo su
installpkg sbopkg-0.38.1-noarch-1_wsr.tgz
sbopkg -r
exit
Install jq and Its Dependencies
sbopkg
has a bunch of great features. I’m not going to cover them. Let’s cut to the chase.
sbopkg
has this concept of a “queuefile” — essentially the instructions needed to SlackBuild whatever dependencies are required to SlackBuild and install the software you want. The queuefile does that depth-first traversal of dependencies that we did by hand earlier in this post.
sbopkg
uses the file extension .sqf
as a naming convention to remind you that a file is a sbopkg
queuefile.
sbopkg
also comes with a utility named sqg
— sbopkg
queuefile generator.
This all comes together and you use them like so:
sqg -p jq# Optional, but educational...
# View the contents of the sbopkg queuefile:cat /var/lib/sbopkg/queues/jq.sqf# Use the queuefile to build and install everything:
sbopkg -B -i jq.sqf
And just like that, everything you need is automatically downloaded from SlackBuilds.org, extracted, built, and installed for you.
Bonus Tip: Handling SlackBuilds.org Packages
Certain packages on SlackBuilds.org can take a long time to compile. If you find yourself in a situation where you repeatedly have to compile and install a SlackBuild with a long compile time, it’s much more efficient to compile once, and make a backup resulting *.tgz
packages (i.e. on a server, on a USB hard drive, etc.) That way, to install those packages again, there’s no need to spend time compiling the code — all you have to do is use installpkg
to install the work you’ve already done.
Have fun!