A well-made SlackBuild makes installation repeatable, removable, and shareable. Avoid manual installs in
/usr/local without control.1. Typical structure
programname/
programname.SlackBuild
slack-desc
doinst.sh # optional
programname.info # optional / SBo style
sources/ or URL
2. Base variables in the SlackBuild
PRGNAM=myprogram
VERSION=${VERSION:-1.0}
BUILD=${BUILD:-1}
TAG=${TAG:-_vl}
ARCH=${ARCH:-x86_64}
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
Using standard variables simplifies rebuilds, upgrades, and maintenance.
3. Recommended workflow
- Clean temporary directories
- Extract sources
- Configure/build
- Install into
$PKG(never directly into the system) - Add
slack-descand correct permissions - Create the package with
makepkg
4. Minimal SlackBuild example
#!/bin/sh
set -e
PRGNAM=helloapp
VERSION=${VERSION:-1.0}
BUILD=${BUILD:-1}
TAG=${TAG:-_vl}
ARCH=${ARCH:-x86_64}
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
tar xf /path/to/$PRGNAM-$VERSION.tar.gz
cd $PRGNAM-$VERSION
./configure --prefix=/usr
make
make install DESTDIR=$PKG
mkdir -p $PKG/install
cp /path/to/slack-desc $PKG/install/slack-desc
find $PKG -type f -perm 777 -exec chmod 755 {} \;
chown -R root:root $PKG
cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.txz
5. slack-desc file
Describes the package in Slackware format (11 lines, package name prefix). Keep it clear and short.
helloapp: helloapp (example utility)
helloapp:
helloapp: Example utility to show the structure of a SlackBuild.
helloapp: Package created for Slackware.
helloapp:
helloapp:
helloapp:
helloapp:
helloapp:
helloapp:
helloapp:
6. Best practices
- Always install into
DESTDIR=$PKG - Avoid non-standard hardcoded paths unless necessary
- Normalize ownership:
root:root - Make the script repeatable (clean start)
- Version
BUILDandTAGsensibly
Do not run
make install without DESTDIR during packaging: you dirty the system and the resulting package will be incomplete.7. Install and test the package
installpkg /tmp/helloapp-1.0-x86_64-1_vl.txz
upgradepkg --install-new /tmp/helloapp-1.0-x86_64-1_vl.txz
removepkg helloapp
8. Quick debug
sh -x ./helloapp.SlackBuild
tree /tmp/SBo/package-helloapp # if tree is installed
less /var/log/packages/helloapp-*
Final checklist
[ ] Script cleans TMP/PKG
[ ] Build repeatable
[ ] make install uses DESTDIR=$PKG
[ ] slack-desc present
[ ] makepkg creates .txz with correct naming
[ ] Package tested with installpkg/removepkg