Next: , Previous: , Up: Package Manager   [Contents]

2.4 Packaging System

A package is formed of several files, these are:

Any other file can be added to the package directory at the discretion of the package maintainer. Everything in the package directory will also be added to the package database that is located on ’/var/db/cpt/installed’. These can be patches, configuration files, etc.

2.4.1 build

Typically build files are shell scripts that run commands to prepare the source code to be installed on the target system. Even though we will be assuming that the build file is a POSIX shell script (for portability’s sake), build files can be any executable program from binary programs to perl scripts.

The contents of a build script do not need to follow a certain rule for the package manager, except for the fact that the user needs the permission to execute the file.

An important advice is to append an ’-e’ to the shebang (#!/bin/sh -e) so that the build script exits on compilation error.

Build is run with three arguments ($#)

  1. Location of the package directory (DESTDIR)
  2. Package version
  3. System architecture

2.4.2 sources

sources file is a list of files and sources that will be put to the build directory during the build process. Those can be remote sources (such as tarballs), git repositories, and files that reside on the package directory.

The syntax is pretty simple for the soures file; src dest. The dest parameter is optional. It is the directory that the source will be placed in. Here is the sources file for the gst-plugins package: good   bad ugly               libav

This file is read from the package manager as space seperated. Files that begin with a ’#’ comment are ignored. The first value points to the location of the source.

If it starts with a protcol url, (such as ftp:// http:// https://) it will be downloaded with curl.

If the source is a git repository, it shall be prefixed with a git+ git(1) will be used to do a shallow clone of the repository. If the commit is suffixed by a history pointer, git will checkout the relevant revision. So,


will checkout the tag named ’v1.2.3’


will checkout the branch named ’development’


will checkout the commit named ’1a314s87’

Other files are assumed to be residing in the package directory. They should be added with their paths relative to the package directory.

2.4.3 checksums

checksums file is generated by the cpt c pkg command. It is generated according to the order of the sources file. That’s why you shouldn’t be editing it manually. The checksums file is created with the digests of the files using the sha256 algorithm.

2.4.4 version

The version file includes the version of the software and the release number of of the package on a space seperated format. The contents of the file should look like below.

1.3.2 1

The version should always match to the number of the upstream release. For drastic changes that require a rebuild Those can be,

When a version bump occurs, the release should be reset to 1.

2.4.5 depends

This is a list of dependencies that must be installed before a package build. You can append “make” after a dependency to mark a package is only required during the build process of a package. Packages marked as a make dependency can be removed after the build. There are also “test” dependencies. These dependencies are only installed if either the CPT_TEST is set to 1, or the build is run with the -t or --test options. So, a package package could have the following depends file:

linux-headers make
python        test

2.4.6 post-install

post-install files have the same requirements as the build script. They will be run after the package is installed as root (or as the user if the user has write permissions on CPT_ROOT).

2.4.7 message

This plaintext file will be outputted with cat after every package is installed.

2.4.8 test

Test files are mainly for the repository maintainer to test the packages, and will only run if the user has the CPT_TEST variable set, or the build is run with the -t or --test options. This script is run on the build directory. It is run right after the build script is finished.

Next: , Previous: , Up: Package Manager   [Contents]