Introduction to src2pkg

src2pkg is a system for creating installable Linux software packages that can be installed or removed using Slackware-style pkgtools or other similar tools.  src2pkg includes several executable scripts or programs written in BASH and a copy of the small installwatch library.

Purpose

src2pkg is a system for creating installable Linux software packages that can be installed or removed using Slackware-style pkgtools or other similar tools. It can create packages from several kinds of sources:
  1. Compiled Sources
  2. RPM or Debian conversion
  3. Generic Binary content
  4. no-arch or custom content
Compiled Sources - The original purpose of src2pkg (originally called PkgBuild) is for creating packages from compiled source code, performing all the steps needed to download, uncompress, configure and compile the sources and then create a package from that content. Supported source-code archive formats include .tbz, tar.bz2, .tgz, .tar.gz, .rpm and .deb.

RPM or Debian conversion - src2pkg can convert binary .rpm or .deb packages into Slackware-type packages. It does a better job than rpm2tgz because it inserts a slack-desc file in the package and, as with all src2pkg packages, the content is thoroughly checked and corrected for proper directory structure and file/directory permissions. It works the same for Debian binary archives.

Generic Binary content - src2pkg can be used to create packages from generic binary content which is usually installed by running an install.sh script, .run file or other installation routine. This includes archives like the Opera browser or pre-compiled drivers for ATI, etc. It also works with binary content that has no installation routine at all. If it sees that the content of the archive has an installable directory structure it will package that. This feature lets you package pre-structured content as used with many SlackBuilds as 'skeleton' archives with a '_' prefix. It will even recognize Slackware-type packages and re-package them -this is useful if you download an 'untrusted' package from some third-party and want to make sure it's correct, or if you just want to change the name of the package or add/remove content.

Custom Content/noarch - src2pkg scripts can be endlessly customized to create or modify package content as you wish. Even those who know nothing about BASH scripting can modify them to customize the package content. The scripts are really more like spec files, using a simple and easy-to-use syntax which also gives your .src2pkg scripts more portability for other users or architectures.

What's included

src2pkg includes several executable scripts or programs written in BASH, a copy of the small installwatch.so library, configuration files and documentation.

Most of the code used by the programs or .src2pkg scripts is contained in the FUNCTIONS file in /usr/libexec/src2pkg/FUNCTIONS.

The file /usr/libexec/src2pkg/DEFINES contains some important default definitions used by the code in the FUNCTIONS file. The code is kept apart for convenience.

src2pkg includes its' own copy of the installwatch library which is used to track and log the creation of files on your system during package making. It gets installed under /usr/libexec/src2pkg so it will not interfere with any existing installation of the installwatch libraries and insure we are using the correct version.

It also includes a copy of the BASH-based program called 'disrpm', which is used for decompressing .rpm and .deb archives. It does not need the rpm program to be installed and will unpack many archives which rpm2cpio or rpm2tgz will not. It's installed to /usr/bin so it can be easily used separately if you just want to decompress and rpm or deb archive.

The command-line programs src2pkg and trackinstall are installed to /usr/sbin, since they are meant to be used by the user 'root'.

3 Configuration files are installed to /etc/src2pkg. They are optional, but useful for customizing many things -mostly the general way and location that src2pkg uses to handle source and package content, and things like default prompting preferences, package 'signing', etc.

All the above except the installwatch.so library contain more information in the form of comments, but documentation and examples are also installed under /usr/doc/src2pkg-$VERSION. man-pages are also installed with the package under /usr/man/man1.

Requirements

src2pkg is written using the BASH shell-scripting language and may not work correctly if used with shells other than bash. It calls many of the small programs found any POSIX-compliant system such sed, awk, grep, tar, gzip, bzip2 and others. And you should have a working development environment also if you are working with source code.

Invocation

Running the src2pkg program is done by typing 'src2pkg [options] <archive-name-or-url>'.
Running a <program-name>.src2pkg script can be done several ways.
  1. Make the script executable using 'chmod 755 *.src2pkg' and call it directly with: './*.src2pkg'
  2. Run a non-executable script with bash: 'bash ./*.src2pkg'
  3. Run the script using the src2pkg program: 'src2pkg *.src2pkg' or 'src2pkg -X'
Making the scripts executable and calling them directly is the most straight-forward way, but has two disadvantages -clicking on the file from a filer may cause them to run accidentally and makes it harder to open the file for editing or viewing.
By default src2pkg creates new scripts as non executable, so the second method is preferable to the first.
Using src2pkg itself to execute the script has the advantage that it allows you to control some of the basic User Options from the command-line, while still running the fixed-code and options found in your *.src2pkg script. Using the -X option causes src2pkg to run the first *.src2pkg or *.src2pkg.auto script found in the current directory.