CARDS 2.3.94.1
Package manager for the NuTyX GNU/Linux distribution
Recept Syntax

Introduction

A port is a directory containing the files needed for building a package. This directory will contains various files. The Pkgfile will alway be present. A pre-installation script file and / or a post-installation script file can also be found in this directory.

The command pkgmk will be used to "build" the package, which can be installed afterwards.

The collection directory

A collection directory contains a set of ports. It can also contains a file named .pkgmk.conf. This file will contains info that can be share between ports of the collection. It's very usefull to use such a file when we have to produce many packages that shares a lot of information like version, url, packager, contributors and even the build() function.

The port directory

A package directory will always be named by the package name. The lenght of the name of the folder (means the lenght of the name of the package) should not exceed 50 characters.

  • It should never contains capital letters and never start with a number.
  • It has to start with a lowercase letter.
  • It can contains the 26 lowercase letters, the 10 chiffers 0 to 9 and one of following three sympols: -, _ or +

Exemple of a directory name:

/usr/ports/mypackages/libstd+-10

The port directory contents

In the directory of a port, we should at least find a file named Pkgfile. We can also find pre-install and post-install scripts. Those scripts will have the name of the port as prefix.

For example:

xmms.pre-install
glib.post-install

We can also find a README file. As for the scripts above, it will take the name of the package as prefix

For example:

samba.README
rsync.service.README

The Pkgfile file

The dependencies

Dependencies are used to specify which other binaries packages needs to be installed before cards can compile the port without dependencies failures.

The syntax of declaring dependencies is done via a comment line as a follow example:

# Depends on: glibc gtk2 glib libvorbis python

Dependencies are found by cards recursively, means you don't have to repeat dependencies that are already declard in the dependencies ports packages

Here, We are only talking about sources or compilations dependencies. Runtime dependencies are normaly not specified as cards will find them for you. See runtime dependencies below

Available Variables

A recept is always following a choosen template depending of the kind of package we want to produce. Variables are then usefull when it comes to customisation our template with a minimum of effort. We can then easily produce a specific recept.

The mandatory variables

The minimum information required for producing a binary are:

  • version: the version of the sources of the package.
  • release: the nth attempt at building the package. Its value will always start at 1
version=3.2.1-b1
release=945

The High recommended variables

Even if it is not mandatory, the name variable is highly recommended for improved readability of the recept

name=libstd++-

One or more alias can be defined, they permit cards to call the binary package via one of those. The alias variable is declare in a array of strings An alias may contains uppercase letters. You should alias with great care as you are not allow to use an existing Package name for an alias.

alias=(name1 name2 name3)

A description can contains up to 110 characters maximum. Try to be as consistent as possible and avoid unecessary worlds.

description="Text editor with colored syntax supporting many languages"

Information available on the net can be pass to the url variable, for example:

url="http://www.gtk.org/documentation.php"

The name of all the peoples that has ones contribute to the construction of the package can be specify via the contributors variable. If it's a new package, they will be no contributors yet:

contributors="pierre at nutyx dot org, tnut at nutyx dot org"

The name of the last packager who modify the recept can be specify via the packager variable:

packager="tnut at nutyx dot org"

The name of the upstream(s) maintainer(s) can be specify via the maintainer variable:

maintainer="Daniel Stenberg and many more"

The name of a group can be provide if necessary via the group variable:

group=kf5

Dependencies not automaticaly detect by cards should be pass via the run array variable:

run=(python gawk)

The sources of the package will be insert via the source array variable, here is an complete example:

source=(http://ftp.gnome.org/pub/gnome/sources/glib/${version:0:4}/$name-$version.tar.xz
glib-revert-warn-glib-compile-schemas.patch)

The available variables

All the defined variables located into the /etc/pkgmk.conf file can be reused into our Pkgfile recept Consult the manual of pkgmk.conf

man pkgmk.conf

Following variables are just examples you can use:

PKGMK_KEEP_SOURCES="no"
PKGMK_GROUPS=()
PKGMK_COMPRESSION_MODE="xz"
PKGMK_NO_STRIP="yes"

The Available functions

All the available functions are using TWO specific variables, thoses two variables are set onces and should never be set again.

  • SRC is the variable which define the root working folder
  • PKG is the variable which define the root packaging folder

They are define in the /etc/pkgmk.conf file via the PKGMK_WORK_DIR variable (parent folder of SRC and PKG)

The specific build() function

In case your build() function look like the mostly used one :

build() {
cd $name-$version
./configure --prefix=/usr
make
make DESTDIR=$PKG install
}

In this case you can ommit the build() function, cards will provide automatically the default one (which is the code of the above one)

In all other cases, you will need to create your own one.

The optionnal reconize functions

Possible functions are:

prepare() {
...
}
package() {
...
}
man(){
...
}
devel() {
...
}
service() {
...
}
doc() {
...
}
lib() {
...
}

Conclusion

To conclude, a full example with all the possible variables:

# Depends on: gtk-doc shared-mime-info,xorg-libxinerama,xorg-libxrandr,cairo,pango,pangox-compat,atk,libtiff,cups,gdk-pixbuf,xorg-libxi,xorg-libxcursor,hicolor-icon-theme,gtk-update-icon-cache
description="GTK+ is a multi-platform toolkit (version 2)"
url="http://www.gtk.org/"
contributors="tyrry at nutyx dot org, pierre at nutyx dot org"
packager="tnut at nutyx dot org"
name=gtk2
version=2.46.3
release=1
alias=(Gtk+ gtk+)
run=(python)
PKGMK_KEEP_SOURCES="no"
_name=gtk+
source=(http://ftp.gnome.org/pub/gnome/sources/${_name}/${version%.*}/${_name}$version.tar.xz)
build() {
cd ${_name}-$version
sed -i 's#l \(gtk-.*\).sgml#& -o \1#' docs/{faq,tutorial}/Makefile.in
sed -i "/seems to be moved/s/^/#/" ltmain.sh
./configure --prefix=/usr \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--sysconfdir=/etc
make
make DESTDIR=$PKG install
mkdir -p $PKG/etc/gtk-2.0
echo 'gtk-fallback-icon-theme = "Tango"' > $PKG/etc/gtk-2.0/gtkrc
# Already build in gtk-update-icon-cache
rm -f $PKG/usr/bin/gtk-update-icon-cache
rm -f $PKG/usr/share/man/man1/gtk-update-icon-cache.1
}
doc() {
cd $PKG
bsdtar -cf \
$PKGMK_PACKAGE_DIR/${name}.doc${PKGMK_BUILDVER}any.cards.tar \
usr/share/gtk-doc usr/share/gtk-2.0/demo
rm -r usr/share/{gtk-doc,gtk-2.0/demo}
}
devel() {
cd $PKG
bsdtar -cf \
$PKGMK_PACKAGE_DIR/$name.devel${PKGMK_BUILDVER}any.cards.tar \
usr/lib/pkgconfig \
usr/include \
usr/share/gir-1.0
rm -r usr/{share/gir-1.0,lib/pkgconfig,include}
}