**This is an old revision of the document!**

SlackBuilds

One of the hallmarks of Slackware is its SlackBuild system, a powerful yet easy-to-understand (and, incidentally, easy-to-learn, if you are interested) method of scripting how an application is built. The SlackBuild system enables the user to script exactly how applications are compiled so that the same SlackBuild can be used on a variety of computers (useful in a production studio with multiple installs). SlackBuilds result in .tgz or .txz files, so managing the applications after they have been compiled is as easy as using pkgtool.

There is a unixy beauty to this system in that there is nothing distribution-specific to it, and nothing redundant about it. It consists simply of a shell script which can be easily hosted on minimal storage, quickly downloaded, and used by anyone. The system has proven so powerful that, for Slackware 11.0, a group of Slackware users established a community around it, which can be found at http://slackbuilds.org. An advantage to this site is that hundreds of applications have had scripts built for them, which are all fully editable by the individual user so that the compiling options are exactly the way the user wants them. Each user can then either maintain their private repository of customized SlackBuilds or simply continue to use the Slackbuilds.org (SBo for short) versions. All of the scripts are reviewed and tested by the SBo administrators but can also be reviewed in advance by the user for security and functionality.

SlackBuild Quickstart

To use a Slackbuild:

  1. Open a web browser
  2. Search for, or navigate to, the tarball of the SlackBuild files and download it.
  3. On your local machine, navigate to the downloaded file and untar it: tar -xzvf foo-sbo.tar.gz
  4. Read the README and *.info files to confirm that you have all the dependencies installed. If you do not, repeat these steps for each dependency, and install each in the order they are required.
  5. Download the source code. A Slackbuild script is just that: a script. It does not contain the source code for the application. The source code must be downloaded from the source code's website.
    1. If there is a stable version of the source code that is more recent than what the Slackbuild was written for, you may change the $VERSION setting in the Slackbuild script to match the new version number.
  6. Move the source code tarball into the SlackBuild directory: mv foo-src.tar.gz foo-sbo/
  7. Change directory into the SlackBuild directory.
  8. Make the SlackBuild script to be executable: chmod +x foo.SlackBuild
  9. Run the SlackBuild, as root: su -c “./foo.SlackBuild”
  10. Install the resulting package: su -c “installpkg /tmp/foo_sbo.tgz”

Using Sbopkg

Prior to the release of Slackware 12.1, a frontend to Slackbuilds.org called sbopkg was released. Sbopkg is a command-line and dialog-based tool to mirror the SlackBuilds.org repository and to operate on the local copy or to operate on a user's own repository of SlackBuild scripts. Sbopkg allows the user to browse the local copy, read associated ChangeLogs, view pertinent README files, read and modify the SlackBuild script itself, the .info file, and the slack-desc files. Sbopkg also allows the user to select packages to build and will even download the source code for the user, check the md5sum, and build a Slackware package. It will also optionally install the package onto the system.

Sbopkg does not check or resolve dependencies. It does not automatically install packages. It does not track what has been installed. In other words, this is in no way apt-get or rpm for Slackware; it is a local front-end for http://slackbuilds.org and does not duplicate or overlap the function of pkgtool or the responsibilities of the user as the primary manager of the system.

To obtain sbopkg, visit http://sbopkg.org and download the Slackware package. Then, open a terminal and use either pkgtool or installpkg:

$ su -c 'installpkg sbopkg-VERSION-noarch_1-cng.tgz'

Among the files installed along with sbopkg is /etc/sbopkg/sbopkg.conf, which contains all pertinent configuration options for sbopkg. You might want to review it, but it is safe to use the default settings. To start sbopkg, launch it as root by typing su -lc sbopkg (the -l obtains the root environment, which some packages require).

The sbopkg interface.

Upon first launch, sbopkg creates, as defined in the sbopkg.conf file, a local copy of the scripts available from slackbuilds.org in /var/lib/sbopkg/SBo/x (where x is the latest stable release of Slackware), a log in /var/log/sbopkg, a queue directory in /var/sbopkg/queues, a cache in /var/cache/sbopkg, and a local tmp directory called /tmp/sbopkg.

After sbopkg has launched, the user is delivered to an ncurses interface; use the Up and Down arrow keys to navigate through the main menu, Return to make a selection, and the Right and Left arrow keys to select which button on the bottom of the menu (OK, Cancel, Back, etc) the Return key activates.

The first step with sbopkg is to sync with the remote server; this is the top selection in the sbopkg main menu. This copies all available scripts from SlackBuilds.org and saves them into directories corresponding with the categories defined by SlackBuilds.org (academic, accessibility, audio, etc). This allows the user to browse the mirrored repository in sbopkg whether or not the user is online, and also modify the scripts before using them to install software.

After the initial rsync, the user can view the SlackBuilds.org ChangeLog, which documents the most recent updates applied to the SlackBuild repository, whether these are bug fixes in the scripts or updated packages. A user may also subscribe to the SlackBuild user mailing list at http://lists.slackbuilds.org/ mailman/listinfo/slackbuilds-users.

A list of all SlackBuild packages installed on the user's system may be viewed via the Packages menu selection, which looks at /var/log/sbopkg and displays the packages installed whose tags match the currently active repo's tags (by default, _SBo). Similarly, selecting the Update menu item will compare installed packages to those available in the local mirror and identify any packages that have updates available.

Finding a package to install is done with the Browse menu selection, or the Search selection. Browse takes the user to a list of top-level categories as defined by SlackBuilds.org; use the Return key to select a category and browse through the packages. Hitting Return again will display the details about a package, such as the README file, the SlackBuild script itself, and more. To go back in the list of packages or to the list of categories, use the Right arrow to select the Back button on the bottom row of sbopkg's interface, and press Return or type Alt+B. The convention of using the Up and Down arrow keys (or accelerators) for the top menu of sbopkg and the Right and Left arrows (or Alt+ accelerator) for the bottom row is used throughout sbopkg, except in textbox dialogs where the arrows scroll the text.

The search function in sbopkg works as would be expected: hit Return on Search to be taken to a pop-up search field, type in the term you are searching for (it is case-insensitive) and hit Return again. Sbopkg returns all packages matching the search term; i.e., if a search is performed for the term “ink” then sbopkg will return “link-grammar”, “inkscape”, “libnfnetlink”, “elinks”, “wink”, etc. Common bash wildcard characters are also supported, such that a search for “?ink*” returns the same list minus “inkscape” which has no character prior to “ink”.

Building and Installing Software with Sbopkg

Sbopkg can build and install software. These are two separate processes. If you elect to only build software, the resulting Slackware package (.tgz file) is left in /tmp by default. This location is controlled by the OUTPUT variable in the config file. It can then be installed via pkgtool or installpkg, or taken to other machines of the same architecture and installed on those, or simply stored for later use. Alternatively, sbopkg can be set to install the software after it has been compiled.

Building and/or installing can be done from different places; the Build item is the final menu item on each individual package menu of unbuilt packages, and it is invoked with the Process Queue item in the Queue sub-menus. Sbopkg will prompt the user to perform only a build of the software or a build-and-install. Slackermedia recommends build-and-install for single or small groups of users in which compile time is not an issue; for building larger install bases, it may be more efficient to build once and install the resulting binary rather than having each computer compile it individually.

To build or install a package via sbopkg, the first step should always be to view the README file. This displays a brief description of the application about to be installed, any options that may be passed to the SlackBuild, and any applications upon which the application depends (required dependencies can always be found on SlackBuilds.org). Sbopkg does not automatically resolve dependencies so it is up to the user to ensure that all listed dependencies are installed on the system before proceeding. READMEs can be viewed from various places, including selecting Queue ? Process ? View READMEs when using the dialog interface or using the -R flag from the command line.

Assuming, for the purpose of this example, that there are no dependencies, the next step might be to view the .info file, which is a SlackBuilds.org-specific file of metadata which lists the canonical program name, the version for which the SlackBuild script was written, the project's homepage, the exact link where the source code for the program can be downloaded, the md5sum of that downloadable package, the SlackBuild script's maintainer's name and email, and the SlackBuilds.org administrator who approved the script.

Next, the SlackBuild script itself can be reviewed. Although all SlackBuild scripts have been reviewed and tested by SlackBuild maintainers, it is a good idea to review the script, both for security purposes as well as to ensure that the application is going to be installed the way the user thinks it's going to be installed. There are some scripts that feature options that the user can take advantage of (like turning off or on codec or plugin support), while other scripts simply help elucidate optional components that the application will use if available but that are not dependencies themselves. Other applications feature an unusual build process such that a SlackBuild script may be more convenient for most users but a disadvantage to a user who relies on that program and would be better off installing directly from the project's code repository.

If additional options are available in the SlackBuild script, the user's local copy of the script and/or .info file can be edited from within sbopkg by selecting the Custom menu item. This will open the SlackBuild script in the user's text editor of choice (defined by the EDITOR environmental variable). For example, if the SlackBuild script for LiVES was written for version 1.1.8 but a new version of LiVES has been released and a user wishes to install the newer version, all that is required of the user is that the version number be changed from 1.1.8 to, for instance, 1.2.0 (making the corresponding changes to the .info file's VERSION and DOWNLOAD fields). The script can be saved and run in sbopkg and the correct version of LiVES would be downloaded, compiled, and optionally installed.

Any change can be made to a SlackBuild script in this way, whether the user wishes to hard code a unique feature into the script, or define a variable that is described in the README file, update the version number, modify build paths, and so on. If the only thing that is desired is to set a build option, however, this can be done by selecting the Options item and typing OPTION=value ? in the entry field. While editing the SlackBuild is a persistent change, the edited version would have to be kept in sync with version changes which happen often. Using custom options also persists but only needs to be kept in sync with option changes which happen rarely. Changing a SlackBuild script, of course, requires at least some very basic knowledge of bash scripting and the installation process. It may be that a software package has changed substantially from one version to the next and so a simple update of the version number may not be all that is required, so if a user is opening a SlackBuild script for modification then the user should truly understand what is being done in the script, or be prepared for the build to potentially fail.

The Sbopkg Queue

One of the most powerful features of sbopkg is its queue, which makes it possible for a user to create a list of packages to have installed in a particular order and use the list on other computers. Slackermedia makes extensive use of queue files to co-ordinate which packages should be installed as a basis for a good multimedia system. From the main sbopkg menu, select Queue and press Return. The Queue menu contains items to view the current queue, to modify the queue, load an existing queue, save a queue, rename or delete existing queues, add all installed packages to the queue (for creating package templates to enable restoration of the current package list or to transfer to another machine), and to process the current queue.

A queue is created from the sbopkg GUI by finding a package via either Browse or Search and selecting Add to Queue. This adds the package to a temporary session-only queue file.

A typical use for this would be, for instance, when installing Inkscape. Doing a search for Inkscape reveals that there is a SlackBuild available, but that it depends on a number of other packages such as pangomm, cairomm, and others. Adding Inkscape to the queue allows the user to then go seek out SlackBuild packages for Inkscape's dependencies and either install them one by one, or add them to the queue as well. If they are added to the queue, then obviously the queue will attempt to install Inkscape before it installs the dependencies, so there are special functions in the Sort Queue submenu of sbopkg's Queue menu to either manually rearrange the order of the queue, or simply reverse the queue such that it is processed in reverse order. A simple reversal of the queue sometimes does work, but it may be insufficient since a dependency of one application may have its own dependencies which may require manual re-ordering to do subsorts in the queue. Alternatively, queuefiles can be created and edited with a text editor.

The Queue menu is accessed from the main sbopkg menu by selecting Queue and contains items to view the current queue, which is dynamically created by the user during an sbopkg session and will be erased (unless saved) when sbopkg is stopped. The Sort item allows the user to reorder the list of applications in the queue while Remove allows the user to delete items from the queue. Save allows a queue file to be saved to the harddrive for later use; this is useful when doing multiple installs of Slackware on a number of machines; a queue file can be used on each machine so that the same packages are installed with minimal effort. By default, queue files are saved in /var/lib/sbopkg/queues.

To load a pre-existent queue file into sbopkg, select Queue ? Load and check the desired queuefile(s) in the list. To run a queue file, select Process Queue from the Queue menu.

For example, if you have downloaded the av queue file from Slackermedia, then to load it into sbopkg, simply invoke sbopkg as QUEUEDIR=/path/to/dir/ containing/queuefile sbopkg and it will appear in the checklist and can be checked as usual. The queue file would then be loaded into sbopkg and you can view it, modify it, remove or reorder applications, and finally process it.

Advanced Uses of sbopkg

Sbopkg can also be used directly from the command line. Its options can be listed with sbopkg -h and details can be found via its manual page (man sbopkg ), but the most direct and simple command is (to use the earlier example) su -lc 'sbopkg -i av' which will search for an application or queue file called “av” and install it (if an application) or the programs in it (if a queuefile). If both a program and queuefile exist with the same name, you'll be prompted to specify which. If a queuefile is intended, specifying the .sqf extension will avoid the prompt. If you know the name of an application and feel confident that you you have met all its dependencies (or can meet them all within the same command), this is probably both easier and simpler than loading sbopkg's graphical environment.

Other command line options include causing sbopkg to rsync to slackbuilds.org, building without installing, diverse search options, viewing changelogs, and so on.

It is also possible to maintain a local repository of customized SlackBuilds rather than, or in addition to, synchronizing with SlackBuilds.org. The local repository is stored in /var/lib/sbopkg/local by default and can be made active by either selecting it from Utilities ? Repository or by invoking sbopkg as sbopkg -V local. Additionally, the location of the sbopkg repository can be defined in the /etc/sbopkg/sbopkg.conf file. If necessary, you may also pass the -d flag to specify an alternate directory for SlackBuilds repositories or by maintaining two configuration files, since sbopkg can be passed an alternate configuration file (sbopkg -f FILE) on the command line.

sport

Sport, the “Slackware Port” system, is a simple shell frontend to Slackbuilds.org. It is meant to be simpler and less interactive than sbopkg, and instead emulate the BSD port system, or Gentoo's emerge.

Like other Slackware package installation applications, sport is not a package manager. However, it does help you search through your collection of SlackBuilds, read relevant files about each SlackBuild, and then execute the build and install processes.

Note

Since the most prolific and uniform collection of SlackBuilds is SlackBuilds.org, and since Slackermedia is so heavily reliant upon SlackBuilds.org, sport was largely modeled after the structure of SB.o, although it is not restricted to it and technically will work with any collection of builds (such as your own personal collection of modified builds, or those of trusted associates).

To install sport, download its source code and use sport to install sport (yes, you can use sport to install itself):

$ git clone gitorious.org/slackport/sport.git sport.git
$ cd sport.git
$ su -c
'./sport install .'

To use sport, you must have a local repository of SlackBuilds. Since Slackermedia relies heavily upon slackbuilds.org, it is worth while to pull the entire listing of SlackBuild scripts from the site:

$ su -c 'mkdir -p /usr/ports'
$ su -c 'rsync -av rsync://slackbuilds.org/slackbuilds/$(awk '{print $2}' /etc/slackware-version)/ /usr/ports/'

If you want to use sport and sbopkg on the same system, you should use the same location that sbopkg uses (or else use the sport location for sbopkg). An example of the former:

$ su -c 'mkdir -p /var/lib/sbopkg/SBo/$(awk '{print $2}'
$ su -c 'rsync -av rsync://slackbuilds.org/slackbuilds/$(awk '{print $2}' /etc/slackware-version) /var/lib/sbopkg/SBo/xx.x/'

Before you can use sport, you must set the location of your local SlackBuild repository. Open /etc/sport.conf and edit the SBOPATH and MASTER variables. For example, assuming xx.x is your version of Slackware:

  SBOPATH=/usr/ports
  MASTER="rsync:?/slackbuilds.org/slackbuilds/xx.x"

There are a few different ways to use sport, but it was written with BSD Ports in mind, so its intended workflow mimics the way that the BSD Handbook guides users through the intended usage of their Ports system.

In general, the workflow would be:

  1. Search for a term or package name that you want to install
  2. Read about the package you find in order to learn about what libraries and other applications it depends on, as well as any important build notes
  3. Download, build, install

These tasks are each individual commands within the sport toolset. For each flag, you can use every common convention for switches. For example, these would all do the same thing:

  • sport –search foo
  • sport search foo
  • sport s foo
  • sport -s foo

Sport Walkthrough

The first step in the workflow is to find what you want to install. If you only have an idea of what you want, then you'll want to search for matches to some keyword:

# sport search foo

network/emacs-foo.tar.gz ... emacs-foo
(simple Emacs interface of foo)

network/foo.tar.gz ... foo (text based web
browser and pager)

The search function of sport performs a fuzzy search on any term you provide. A search for “foo” therefore returns the category and packages names for both the stand-alone foo and the Emacs foo mode.

Note

If you only want to browse through your SlackBuilds tree without having to think up search terms, cd into /usr/ports (or whatever you have set SBOPATH to) and browse its contents.

If you find something of interest but want to see if you already have it installed, use sport check:

# sport check foo

If nothing is returned, then you do not have that application installed.

The next step in the typical workflow is to read about the package you are about to install, so that you know about any important build configuration options, or dependencies that you should install first. Use sport cat to see all relevant notes in a SlackBuild. If the package search returned only one match, then you can use just the packagename, but if there were multiple matches then you should provide both the category and package name:

$ sport c net*/foo

If you have changed directories into your SlackBuild tree and are in the same directory as the SlackBuild file, you can cheat and provide the path to the package with a dot-slash:

$ sport cat ./foo

Or if you are in the SlackBuild's directory, just use a dot.

$ sport cat .

This displays the README and the .info files of the package, so that you can see what the application claims to do, and what dependencies are recommended and required.

If the package you want to install has dependencies, you should resolve those dependencies before continuing. Unlike the BSD Ports and Gentoo emerge systems, sport does not resolve dependencies for you. That way, if you have already have a package or a SlackBuild for a dependency (or you prefer to compile it yourself), you can use it instead of whatever an automated “package manager” happens to find lying around.

Note

“Resolving dependencies” may sound mysterious but all it means is that you will have to install some additional system libraries or smaller applications before you install the application you are trying to obtain. To resolve the dependencies of foo, you would take note of the libraries it requires (bar and baz) and then use sport to install each one before then installing foo itself.

Once you have resolved all dependencies, you are ready to build the package. There are two commands you can use; sport install will build the package and install it onto your system (leaving a copy of the finished Slack package in the default build location for SBo packages: /tmp), while sport install –build-only only builds but does not install the package.

# sport install foo

Again, if you are in the directory containing the SlackBuild you want to install, you can cheat and provide the path to the package with a dot, meaning that the build script is in the current directory:

# sport -i .

If you are fastidious about disk space or keeping a tidy SlackBuilds tree, use sport clean foo to remove the directory containing the source code and SlackBuild. It of course leaves any compressed copy of your SlackBuild directory (the SlackBuild.org structure).

Warning

If you are not using the SlackBuild.org tree, then you should either keep your originals as compressed .tar.gz archives or you should either modify or not use the clean command.

As you can see, sport may be used from anywhere in your filesystem, or you can use it as you “crawl” through your SlackBuild tree. It's a handy and flexible tool that can help make the potentially repetitious process of downloading, compiling, and installing software easier.

Advanced Sport Usage

Since sport is just a BASH script, you can use the usual BASH conventions to add flexibility to your commands.

To pass build options through sport, provide the option (usually defined in the README of the SlackBuild).

# WIDGETS=yes sport install foo

To pass make flags through sport, use MAKEOPTS.

# MAKEOPTS='-j8' sport install foo

If you need to do some special kind of install (such as an upgradepkg rather than an installpkg) then preface your sport -i command with the INSTALLER environment variable:

# INSTALLER=upgradepkg sport i .

Or something more complex:

# INSTALLER="upgradepkg --install-new" sport -i multi*/foo 

And so on.

Queue Files

Sport supports batch, or queue, files.

For your initial Slackermedia install actions, you will use a Slackermedia queue files (slackermedia-huge.sqf, for example) but you can also create and maintain your own queue files. To create your own queue, just echo the package names into a plain text file, newline delimited, in the order you wish for them to be installed.

Note

In the event of two packages sharing the same name, use both the category and package name, but usually just the package name will do.

Here is an example of a simple queue file for foo:

baz bar foo

Save these three lines as foo.list (or any filename) and then have sport process it using standard BASH re-direction:

sport $( < foo.list)

For full details on using sport, view the man and info pages bundled with it.