Tue Mar 26 08:24:44 2019 UTC

Build in a chroot


This article explains every step to compile packages in a chroot.

Adjust /etc/cards.conf

To be able to install the compiled packages from your chroot, you need to adjust your /etc/cards.conf file. You will add on the top of this file:

dir /mnt/hd/usr/ports/perso

You are now ready to proceed with your chroot.

Installation of your chroot

VERSION="rolling" install-nutyx

Enter the chroot

install-nutyx -ec
From now on, everything you do, you do it in your isolated chroot.

Development tools installation

The default installation is already adapted so just install the development packages if not already installed:

get cards.devel

The Configurations files


cat >/etc/cards.conf << EOF
dir /usr/ports/perso
dir /usr/ports/gui
dir /usr/ports/cli
dir /usr/ports/base
logdir /var/log/pkgbuild
base /usr/ports/base

A folder containing my personal recipes is added. We do not specify any URL because we don't plan to use cards sync.

Folder /var/log/pkgbuild will contain compilation logs.

I don't need any specific NLS files, they can be all installed.

The folder /usr/ports/base defines the base system when the command cards base -r. is used.


cat > /etc/pkgmk.conf << EOF
export CFLAGS="-O2 -pipe"
export CXXFLAGS="\${CFLAGS}"
case \${PKGMK_ARCH} in
       export MAKEFLAGS="-j$(getconf _NPROCESSORS_ONLN)"
       export MAKEFLAGS="-j$(getconf _NPROCESSORS_ONLN)"
       export CFLAGS="${CFLAGS} -m32"
       export CXXFLAGS="${CXXFLAGS} -m32"
       export LDFLAGS="${LDFLAGS} -m32"
       echo "Unknown architecture selected! Exiting."
       exit 1

It's very important to check all the variables so that the duo pkgmk/cards works fine and as expected.

Source codes are stored in a common folder. I want to keep them even after a successfull compilation.

The produced binaries are compressed in xz format.

I want to keep my binaries once installed.

I wish to have the runtime dependencies automatically added into the binary.

Binaries synchronisation via rsync

This operation consists of download of all the binaries of the base, cli and gui collection. It can take a while depending on the speed of your internet connection.

Luckily, this operation has to be done only once. Laughing Laughing Laughing.

We need to create the root folder first.

mkdir -p /usr/ports/perso

We can now synchronise all the binaries:

The rolling branch

for i in base cli gui
  rsync -avz --delete-after rsync://downloads.nutyx.org/nutyx/`uname -m`/rolling/$i/ \

This can take some time so go get a coffee or a pizza. Laughing, It can be long...

Compilation and installation of your package

You start to create the folder where you want to locate your new package. Let's call it mypackage (you need to adjust to your real one)

mkdir /usr/ports/perso/mypackage

We just need to create the build recipe of our package (you need to adjust to your real one):

# Depends on: python gtk3 librsvg
description="My first package with plenty of  dependancies"
packager="francis perrin"
build() {
   cd $name-$version
   ./configure --prefix=/usr
   make DESTDIR=$PKG install

We can now launch the process of compilation and installation.

cards create -r mypackage

I suggest that you read the man page of cards to understand the way cards create -r this works.

man cards


Following commands should be used:

cards level
cards base -r
cards create -r