mksb: Slackware build script creator

This is a simple little shell script that creates SlackBuild scripts given a tarball of source. The idea is that you'd use mksb to make starter scripts, and then modify those to suit your needs.

It's not particularly smart so you're going to have to hand-edit the result. But the amount of editing should be relatively small if the source uses a standard GNU-style "configure"-based thing.

The files output by mksb are meant to be compliant with, but should also work with other repos with a little modification.

Download and Install

Source: mksb-4.0.tar.gz.

Slackware package: mksb-4.0-noarch-1_beej.tgz.

Or if you just want to download and install the script, here it is: mksb.


$ mksb [options] tarball

mksb will try to make semi-intelligent choices about the name of the package and so on. Tarballs of various types are supported. Once you run it, it will prompt for the information, and you can just hit RETURN if you are satisfied with the defaults.

If all goes well, mksb will produce a number of files, up to and including appname.SlackBuild, slack-desc, and, if requested, README,, and

Edit these files to your satisfaction; at the very least, this means going into app.SlackBuild and removing the big comment blocks, preferably after testing it!

Also, you'll want to change the names of the documentation files that are going to be copied, or it'll bomb out at that point.

I usually open the tarball by hand, go in there, see what the doc files are, check out the configure options, and run configure once to see if it goes. All the information I glean then goes back in the Slackbuild script.

Finally: run "app.SlackBuild" to have it build the package! (I recommend running it as fakeroot, if possible, just to make sure it's (a) building properly and (b) not trying to install wacky stuff behind your back.)

The text in the long description will be word-wrapped and double-linebreaks will be preserved.

man page:

MKSB(1)                                                                MKSB(1)

       mksb - create template SlackBuild scripts

       mksb [ options ] tarball

       mksb  is an interactive tool that creates a SlackBuild script and other
       supporting files used in  the  creation of  Slackware  packages.   The
       scripts still  require editing  before use, but should provide a good
       starting point.

       Additionally, mksb attempts to make scripts and files  that  are  com-
       plaint with those used on

       The basic procedure is to download a source tarball, then run mksb with
       that tarball specified on the command line.   (Though  technically  the
       actual  source  tarball is  only  required to generate the .info file,
       since the tarball's MD5 sum must be calculated.)

       The tarball can be either .tar.gz, .tgz, or .bz2.

       -n     Don't prompt for or write a slack-desc file

       -r     Don't prompt for or write a README file

       -i     Don't prompt for or write a .info file

       -d     Generate a file

       -c     Add the config() bash function to

       Some or all of these files will be generated by mksb depending on which
       command line  options  are  present.   They  should all be hand-edited
       before use.

              This in the main build script. It will not  run  without (hope-
              fully minor) modification.

              The  package  description is written to this file.  This is what
              is displayed to the end-user when the package is installed.
              Post-installation commands go in this  script. If  mksb's  -c
              option is specified, a standard Slackware config() function will
              be added to the file.  This script will not run without  modifi-
              This  is a  human-readable  data  file  that  is used by slack-
     for management purposes.  If you're going to be  sub-
              mitting  the  package  to that site, you'll need to include this

       README This is a text file that is  required  by   If
              you're  going  to be submitting the package to that site, you'll
              need to include this file.

       You can set some default prompt values in  your ${HOME}/.mksbrc  file.
       Many of these can be overridden later with environment variables in the
       .SlackBuild script itself, or when the .SlackBuild script is executed.

       Parameters with default values are shown, below:

       defaultUserName="Example Name"
              Package maintainer name (probably your name)

              Package maintainer email (probably your email)

              Tag for the final package

       These are more variables that you can set, but probably won't have to:

              Build number to start with

              Install prefix to use

              Architecture to target

              Temp files needed for the build will go  in  a  subdirectory  of
              this directory.

              Where the final package file should be deposited.

       # download the source tarball:

       # now use mksb to create scripts and files:

       mksb example-1.2.3.tar.bz2
              Create scripts for example-1.2.3.

       mksb -c example-1.2.3.tar.bz2
              Create  all  normal scripts, plus a file with a useful
              config() function.

              Local  configuration  file.  See the  "CONFIGURATION"  section,

       Doesn't work  with  zsh  because  of  the way that shell does variable
       expansion and word splitting.  (It does work with ash, bash, dash,  and

       mksb  used to be a Python script, but that just made for one big unnec-
       essary dependency.  It is now a POSIX-compliant* shell script.

              * Mostly-compliant.  It uses fmt and md5sum which are not  POSIX

       Brian "Beej Jorgensen" Hall <>

       makepkg(8), sbopkg(8).

mksb-4.0                       2009 Mar 16                            MKSB(1)

Sample run:

$ wget
$ mksb -c viking-0.9.7.tar.gz
Package name [viking]: 
Package version [0.9.7]: 
Prefix [/usr]: 
Build [1]: 
Tag [SBo]: beej
Build directory [/tmp/SBo]: /tmp/build
Package destination [/tmp]: /tmp/build
Creator name [Example Name]: Beej Jorgensen
Creator email []:
Project homepage URL:
Short description: GPS data editor and analyzer
Long description:
(^D on a blank line to terminate)
Viking is a free/open source program to manage GPS data. You can import and plo
t tracks and waypoints, show Terraserver maps under it, add coordinate lines, m
ake new tracks and waypoints, hide different things, etc. It is written in C wi
th the GTK+ 2.
Source tarball URL:
And this will generate the files README, slack-desc, viking.SlackBuild, and

Sample Generated Scripts

These scripts are auto-generated by mksb. Once built, you can modify them to suit your needs:

  1. viking.SlackBuild—my fav GPS tool
  2. slack-desc

Customizing and Hacking

The actual scripts are dumped in the functions writeSlackBuild(), writeSlackDesc(), writeDoInst(), writeREADME(), and writeInfo() if you want to customize those.

Author, License

mksb was gouged into existence by me, Brian "Beej Jorgensen" Hall,, and is Copyright 2009. The source is freely distributable under the terms of the MIT license, included at the top of the script.

I'm sure there are all kinds of bugs and flaws to be squished and improvements to be made. Tell me if you find 'em!