Wed Oct 4 08:03:23 2017 UTC

What's a port?

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 refers 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.
  • release: the nth attempt at building the package. Its value will always start at 1
  • source: the address of the sources of the package we want to build.
  • build(): the function which contains the recipe.

A little example with comments:

# Name of the package
name=gnome-terminal

# Version of the package
version=2.6.4

# Release of the package
release=1

# 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

# Depends on: glib intltool

description="libxfce4util, base library for Xfce"
url="http://docs.xfce.org/"
maintainer="git.xfce.org/xfce/xfce4-libutils"
packager="tyrry at nutyx dot org, tnut at nutyx dot org"

_name=libxfce4util

name=xfce4-libutil
version=4.8.2
release=1

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 the NuTyX base.

The line # Depends on: is used for this purpose. It defines all the needed dependencies for the compilation of the package. Dependencies are separated by a comma, a space or both Laughing.

Conclusion

You could now try to build your first package.