wiki:SlackBuilds

Simplepkg SlackBuild specification

According to the Slackware Book,

SlackBuild scripts are executable shell scripts that you run as root to
configure, compile, and create Slackware packages. You can freely modify these
scripts in the source directory and run them to create your own versions of the
default Slackware packages.

A SlackBuild is a script that automate package creation, saving time and allowing people to share automatic procedures to create packages between themselves.

Simplepkg applications are capable to create SlackBuild scripts, but not all third party SlackBuild scripts can be used by simplepkg because simplepkg needs special and standardized behaviour for SlackBuilds. So, in short, all SlackBuilds that simplepkg builds can be valid SlackBuilds, but not all existing SlackBuilds can be easily managed by simplepkg.

This page contains a general overview of simplepkg SlackBuild specification. The most up to date SlackBuild specification is found directly into simplepkg source code. For now and on, when we refer to a SlackBuild, we'll be talking about Simplepkg's SlackBuild specification.

Using a SlackBuild

The first feature a SlackBuild has is to support special environment variables like these:

ARCH=desired-arch ./program-name.SlackBuild

For example, to build lm_sensors package with arch i486, simply type

ARCH=i486 ./lm_sensors.SlackBuild

The script will take care to download the software, compile it and create the package. You can also specify a build id like

ARCH=i486 BUILD=3rha ./lm_sensors.SlackBuild

You can also specify the temporary folder to be using during package construction and the folder where the source code should be downloaded to:

ARCH=i486 BUILD=3rha TMP=/stuff/tmp SRC=/stuff/src ./lm_sensors.SlackBuild

Dependencies

The SlackBuild don't solve dependencies by itself. This should be done by the user or by a special tool intended for this purpose.

Specification

Environment variable support

To make the SlackBuild more generic as possible, it should support environment variables to allow the user to choose temporary folder, etc:

VERSION: specify the software version that should be used.
ARCH: specify build architecture.
BUILD: specify build number.
TMP: set the temporary folder.
SRC_DIR: set where the source code should or is stored.
CLEANUP: if ''yes'', make SlackBuild delete the temporary files after creating the package.
REPOS: sets where the package should be moved after its creationg (default: $TMP)

Environment variables that controls special instruction sets:

HAVE_ALTIVEC: if ''true'', make the programs to be built with altivec

If these variables aren't set, standard values should be used. Then, to build postfix with version 2.2.10, buildnumber 2rha and source code storage place to /scratch/postfix, we can use a command like

VERSION=2.2.10 BUILD=2rha SRC=/scratch/postfix ./postfix.SlackBuild

This convention allows:

  • To maintain a SlackBuild tree apart from the programs source code.
  • Easily development and support of multiple architecture and program versions without the need to change the SlackBuild scripts.

slackbuildrc

To make life easier and prevent people to always type their prefered values for SRC, TMP, ARCH or any other variable every time a SlackBuild is called, it's possible to create a file which contains variable assignment in bash format, like

SRC_DIR=${SRC_DIR:=/scratch}
TMP=${TMP:=/scratch/build}
ARCH=${ARCH:=x86_64}

This lines can be added at the user profile or any other place. By convention, a SlackBuild supports a ~/.slackbuildrc or /etc/slackbuildrc files for this purpose. You can create a ~/.slackbuildrc and put your favorite options and then add

source ~/.slackbuildrc

at your ~/.profile or just setup an /etc/slackbuildrc file. Although a slackbuildrc file is supported by the SlackBuild, we recommend that you properly configure simplepkg in order to take advantage of SlackBuild flexibility.

Source code downloading

The SlackBuild should have routines to downloaded the source code if they're not already downloaded at $SRC_DIR/package-name.

Multi-arch support

The SlackBuild should support most architectures as possible so we can unify efforts to build packages for all pkgtool distros. As Patrick's example, it should contain blocks like these:

  if [ "$ARCH" = "i386" ]; then
    SLKCFLAGS="-O2 -march=i386 -mtune=i686"
  elif [ "$ARCH" = "i486" ]; then
    SLKCFLAGS="-O2 -march=i486 -mtune=i686"
  elif [ "$ARCH" = "s390" ]; then
    SLKCFLAGS="-O2"
  elif [ "$ARCH" = "x86_64" ]; then
    SLKCFLAGS="-O2"
  fi

slack-desc

The SlackBuild should have the slack-desc file builtin. Again, we'll use Patrick's example:

  cat << EOF > $PKG/install/slack-desc
  (...)
  Descrição do pacote
  (...)
  EOF

Workfolders

To avoid messing things, the work folder where the source code is unpacked and where the compilation and package building takes place should be in a folder like $TMP/package-name and not just $TMP. $TMP.

slack-required

Together with the SlackBuild an optional slack-required should come, pointing existing dependencies required to build the package.

Exit codes

We have also the following exit codes in order to help external programs what happened after thet call the SlackBuild:

ERROR_WGET = 31: source code download error
ERROR_MAKE = 32: compilation error
ERROR_INSTALL = 33: installation error
ERROR_MD5 = 34: md5sum error
ERROR_CONF = 35: source code configuration error
ERROR_HELP = 36: this is not an error, but provided when help is called
ERROR_TAR = 37: source unpacking error
ERROR_MKPKG = 38: makepkg error
ERROR_GPG = 39: source code signature checking error
ERROR_PATCH = 40: error when attempting to patch the source code
ERROR_VCS = 41: error when downloading the source code through a version control system
ERROR_MKDIR = 42: error when attempting to create a folder

Execution permission

When distributed in a way that allow to, the SlackBuild should come with execution permission (specifically, with 755 octal permission).

SlackBuild and package names

The SlackBuild should be named as closest as possible with the real program name, case sensitive.

Last modified 9 years ago Last modified on Jan 17, 2009, 10:02:16 PM