CARDS 2.4.140
Package manager for the NuTyX GNU/Linux distribution
Recept Basics

Introduction

A port is a directory containing the files needed for building a package. The command pkgmk will be used to "build" the package, which can be installed afterwards.

This means that this directory must contain as a minimum a file named Pkgfile. The building of the package will be controlled by the contents of this file. It contains all the information necessary to compile and install the package from source.

The name port comes from the BSD world where a port refer to software "ported" to another operating system or platform. In our case, the port is simply the definitions for building a package.

Minimal syntax of a port

The minimum information required for producing a binary are:

  • name: the name of the build package.
  • version: the version of the sources of the package.
  • source: the address of the sources of the package we want to build.
  • build(): the function which contains the recipe if not the standard one.

A little example with comments:

# Name of the package
name=gnome-terminal
# Version of the package
version=2.6.4
# Release of the package if not the first try, need to be specified
release=2
# Location of the sources of the package to be built
source=(http://ftp.gnome.org/pub/gnome/sources/$name/${version%.*}/$name-$version.tar.bz2)
# Recipe for building the package (often uses three standard commands)
build() {
cd $name-$version
./configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info
make
make DESTDIR=$PKG install
}

If you compare this example with an official NuTyX port, you can see that the official one contains more information. We will see this in the next paragraph. One line could catch you:

http://ftp.gnome.org/pub/gnome/sources/$name/${version%.*}/

The syntax ${version%.*} allows us to substitute a variable of N digits for a variable of N-1 digits. It's often necessary for the sources of gnome packages. In our example, the line:

http://ftp.gnome.org/pub/gnome/sources/$name/${version%.*}/

is identical to

http://ftp.gnome.org/pub/gnome/sources/$name/2.6/

since the variable version=2.6.4

Practical example of a port

The xfce4-libutil/Pkgfile file

Listing 1 - "The xfce4-libutil Pkgfile"
description="libxfce4util, base library for Xfce"
url="http://docs.xfce.org/"
maintainer="git.xfce.org/xfce/xfce4-libutils"
contributors="tyrry at nutyx dot org"
packager="tnut at nutyx dot org"
makedepends=(glib intltool)
name=xfce4-libutil
version=4.8.2
release=1
_name=libxfce4util
source=(http://archive.xfce.org/src/xfce/${_name}/${version%.*}/${_name}-$version.tar.bz2)
build() {
cd ${_name}-$version
./configure --prefix=/usr \
--disable-static
make
make DESTDIR=$PKG install
}

If you want to make sure that the build bot is able to compile the package without any problems, it's important to specify all the dependencies needed for the compilation of the package. Dependencies starting from the NuTyX base are always included. Indeed the bot will always build the package by starting from a base NuTyX.

The array variable makedepends is used for this purpose. It defines all the needed dependencies for the compilation of the package. Dependencies are separated by a space.

Conclusion

You can try to build your first package