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 slackbuilds.org, but should also work with other repos with a little modification.
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, doinst.sh, and appname.info.
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) NAME mksb - create template SlackBuild scripts SYNOPSIS mksb [ options ] tarball DESCRIPTION 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 slackbuilds.org. 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. OPTIONS -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 doinst.sh file -c Add the config() bash function to doinst.sh OUTPUT 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. packagename.SlackBuild This in the main build script. It will not run without (hope- fully minor) modification. slack-desc The package description is written to this file. This is what is displayed to the end-user when the package is installed. doinst.sh 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- cation. packagename.info This is a human-readable data file that is used by slack- builds.org for management purposes. If you're going to be sub- mitting the package to that site, you'll need to include this file. README This is a text file that is required by slackbuilds.org. If you're going to be submitting the package to that site, you'll need to include this file. CONFIGURATION 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) defaultUserEmail="name@example.com" Package maintainer email (probably your email) defaultTag="SBo" Tag for the final package These are more variables that you can set, but probably won't have to: defaultBuild="1" Build number to start with defaultPrefix="/usr" Install prefix to use defaultArch="i486" Architecture to target defaultBuildDir="/tmp/SBo" Temp files needed for the build will go in a subdirectory of this directory. defaultPackageDest="/tmp" Where the final package file should be deposited. EXAMPLES # download the source tarball: wget http://www.example.com/example-1.2.3.tar.bz2 # 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 doinst.sh file with a useful config() function. FILES ${HOME}/.mksbrc Local configuration file. See the "CONFIGURATION" section, above. BUGS 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 ksh.) HISTORY 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 utilities. AUTHOR Brian "Beej Jorgensen" Hall <beej@beej.us> SEE ALSO makepkg(8), sbopkg(8). mksb-4.0 2009 Mar 16 MKSB(1)
Sample run:
$ wget http://download.sourceforge.net/viking/viking-0.9.7.tar.gz $ 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 [name@example.com]: beej@beej.us Project homepage URL: http://sourceforge.net/projects/viking/ 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: http://downloads.sourceforge.net/viking/viking-0.9.7.tar.gzAnd this will generate the files README, slack-desc, viking.SlackBuild, and viking.info.
These scripts are auto-generated by mksb. Once built, you can modify them to suit your needs:
The actual scripts are dumped in the functions writeSlackBuild(), writeSlackDesc(), writeDoInst(), writeREADME(), and writeInfo() if you want to customize those.
mksb was gouged into existence by me, Brian "Beej Jorgensen" Hall, beej@beej.us, 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!