About two or three years ago I met the SlackBuilds Project on a mail list and learned to love it! As all slack users know, the philosophy of our distribution is the principle of KISS (Keep It Simple Stupid) and the strong support for developers.

What I don’t understand is why some other slackwares don’t know and/or use the SlackBuilds git tree in his local system to build packages, one in twelve times that I look for some cool app I do not found there, so I decide to put here some of what I do to build at least 70% of my packages.

1. First download all the slackbuilds git tree to your local file system.

$ git clone git://slackbuilds.org/slackbuilds.git

2. Keep updated!

$ cd slackbuilds && git fetch origin && git pull

3. Browse your options by category

slackbuilds# ls -l
total 416
-rw-r--r-- 1 root root 233080 Nov 11 20:24 ChangeLog.txt
-rw-r--r-- 1 root root 258 Sep 15 2013 README
drwxr-xr-x 189 root root 4096 Nov 11 20:24 academic/
drwxr-xr-x 15 root root 4096 Apr 13 2014 accessibility/
drwxr-xr-x 268 root root 12288 Oct 17 22:27 audio/
drwxr-xr-x 12 root root 4096 Oct 17 22:27 business/
drwxr-xr-x 286 root root 12288 Oct 17 22:27 desktop/
drwxr-xr-x 401 root root 12288 Nov 11 20:24 development/
drwxr-xr-x 374 root root 12288 Oct 17 22:27 games/
drwxr-xr-x 46 root root 4096 Oct 17 22:27 gis/
drwxr-xr-x 184 root root 4096 Nov 11 20:24 graphics/
drwxr-xr-x 41 root root 4096 Oct 17 22:27 ham/
drwxr-xr-x 87 root root 4096 Apr 13 2014 haskell/
drwxr-xr-x 728 root root 20480 Nov 11 20:24 libraries/
drwxr-xr-x 141 root root 4096 Nov 11 20:24 misc/
drwxr-xr-x 162 root root 4096 Nov 11 20:24 multimedia/
drwxr-xr-x 520 root root 20480 Nov 11 20:24 network/
drwxr-xr-x 146 root root 4096 Oct 17 22:27 office/
drwxr-xr-x 333 root root 20480 Nov 11 20:24 perl/
drwxr-xr-x 270 root root 12288 Nov 11 20:24 python/
drwxr-xr-x 14 root root 4096 Oct 17 22:27 ruby/
drwxr-xr-x 582 root root 20480 Nov 11 20:24 system/

4. Search and see the directory structure

slackbuilds# find . -iname '*vlc*'
./multimedia/vlc
./multimedia/vlc/vlc.info
./multimedia/vlc/vlc.SlackBuild
slackbuilds# cd multimedia/vlc/
slackbuilds/multimedia/vlc# ls
README doinst.sh.in patch-freerdp.diff patch-projectM-fontpath.diff slack-desc vlc.SlackBuild vlc.info

5. Install with just three commands

# source *info; wget -c $DOWNLOAD; sh *SlackBuild
And that's it! It will generate a .t?z package of slackware on '/tmp' directory to you run 'installpkg' permitting you to run the binary/script installed. Easy and cool way to find your packages quickly and compile them with your architecture optimized.

# upgradepkg --reinstall --install-new /tmp/SBo/*vlc*

And if I can’t find my package there!?

Can you build yourself this new package? Why not? A slackbuild is just a basic shell script and in this case have almost the same code of all others, you just need to change a few things to make your Slackbuild script too, and perhaps put they on github or something like that,

You just need four files! Like in the example below with ‘gmrun’:

$ README gmrun.SlackBuild gmrun.info slack-desc

Lets look a sample of ‘.info’ file

PRGNAM="gmrun"
VERSION="0.9.2"
HOMEPAGE="http://sourceforge.net/projects/gmrun/"
DOWNLOAD="http://downloads.sourceforge.net/gmrun/gmrun-0.9.2.tar.gz"
MD5SUM="6cef37a968006d9496fc56a7099c603c"
DOWNLOAD_x86_64=""
MD5SUM_x86_64=""
MAINTAINER="Binh Nguyen"
EMAIL="binhnguyen@fastmail.fm"
APPROVED="rworkman"

Now take a look into ‘slack-desc’ file

# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description.  Line
# up the first '|' above the ':' following the base package name, and the '|'
# on the right side marks the last column you can put a character in.  You must
# make exactly 11 lines for the formatting to be correct.  It's also
# customary to leave one space after the ':'.

     |-----handy-ruler----------------------------------------------------|
gmrun: gmrun (A simple program which provides a run program window)
gmrun:
gmrun: gmrun is a simple GTK program which provides a "run program" window.
gmrun: It features a bash-like TAB completion, Ctrl-R/Ctrl-S for searching
gmrun: through the history and URL handlers for any user defined prefix.
gmrun:
gmrun: Homepage: http://sourceforge.net/projects/gmrun/
gmrun:
gmrun:
gmrun:
gmrun:

And finally into an .SlackBuild file

#!/bin/sh

PRGNAM=gmrun
VERSION=${VERSION:-0.9.2}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}

if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) export ARCH=i486 ;;
    arm*) export ARCH=arm ;;
       *) export ARCH=$( uname -m ) ;;
  esac
fi

CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

if [ "$ARCH" = "i486" ]; then
  SLKCFLAGS="-O2 -march=i486 -mtune=i686"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
  SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
  LIBDIRSUFFIX="64"
else
  SLKCFLAGS="-O2"
  LIBDIRSUFFIX=""
fi

set -eu

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
cd $PRGNAM-$VERSION

chown -R root:root .
find -L .
 ( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555
  -o -perm 511 ) -exec chmod 755 {} ; -o
 ( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444
 -o -perm 440 -o -perm 400 ) -exec chmod 644 {} ;

CFLAGS="$SLKCFLAGS"
./configure
  --prefix=/usr
  --libdir=/usr/lib${LIBDIRSUFFIX}
  --localstatedir=/var
  --sysconfdir=/etc
  --build=$ARCH-slackware-linux

make
make install DESTDIR=$PKG

find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF
  | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a AUTHORS COPYING ChangeLog INSTALL NEWS README $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}

The variables PRGNAM, VERSION and BUILD are respectively the name of program, his version and perhaps a build number, you also need to understand the basic aspects of install to build your new package, be him a tar or zip file or a have a python setup, to put your own build scheme change lines 51-60 and if you want browse the source and know how the things happen on this software just move your mind to ‘/tmp/SBo’ ;) Hope you enjoy it and share your builds with us!