Sat Apr 8 16:58:07 2017 UTC

How to build a package

Introduction

We have provided the required Know-how, the available base commands, the minimum syntax of instructions and a list of available packages for you to choose from.

Come and join the many participants of all ages, male and female, from all over the world, and venture along this exciting road we call NuTyX. We can promise you a rewarding experience as you build your very first NuTyX system, following our (NuTyX) rules Laughing.

Build my first package

We will see how to build and install a first package in a very straigtforward way.

This tutorial explain you in a very simple way the construction of your first binary package.

They are no prerequest, this exercice can be done regardless the state of your NuTyX.

The choosen receipt is a little text editor which don't need any dependencies.

[Important] For this package, we won't use an isolate environment named chroot. We will see in the next article, how to build in such isolate environment. Because that's the only working method if we need to build a package having dependencies.

Make the recept

sudo mkdir -p /usr/ports/perso/nano
echo '
description="Text Editor"
maintainer="Nano team"
packager="Fran├žois Perrin francois dot perrin at myworld dot com"
url="http://www.nano-editor.org/"

name=nano
version=2.7.2
release=1

source=(${url}/dist/v${version:0:3}/$name-$version.tar.xz)

build() {
cd $name-$version
./configure --prefix=/usr \
--sysconfdir=/etc \
--enable-utf8 \
--enable-color \
--enable-multibuffer \
--enable-nanorc \
--docdir=/usr/share/doc/$name-$version
make
make DESTDIR=$PKG install
rm $PKG/usr/share/info/dir
}' > /usr/ports/perso/nano/Pkgfile

Install the development packages

get cards.devel

Compile the package

cd /usr/ports/perso/nano
sudo pkgmk -d

Install the package

sudo pkgadd nano1*

The configuration files

The /etc/cards.conf file

This file is always present on a NuTyX installation.

It's a bit like "the spine" of your NuTyX.

The /etc/cards.conf file will reflect the way you use NuTyX.

All the collections that you want to use in your NuTyX can be specified in two way:

  1. configuration example of cli collection in binaries from a remote server
    dir /var/lib/pkg/depot/cli|http://downloads.nutyx.org
  2. configuration example of cli in local ports
    dir /usr/ports/cli

This file is also responsible for the list of packages you want to keep when you execute the command:

cards base -r
And finaly, it's specify which locale should be installed.

You can find more information by reading the cards.conf manual

man cards.conf

The /etc/pkgmk.conf file

This file is used when compiling news ports. It specify all the variables used by the pkgmk command.

Please take the time to read the man page of pkgmk.conf

man pkgmk.conf

Example of /etc/pkgmk.conf file

export CFLAGS="-O2 -pipe"
export CXXFLAGS="${CFLAGS}"

case ${PKGMK_ARCH} in
        "x86_64"|"")
		export MAKEFLAGS="-j$(getconf _NPROCESSORS_ONLN)"
                ;;
        "i686")
                export CFLAGS="${CFLAGS} -m32"
                export CXXFLAGS="${CXXFLAGS} -m32"
                export LDFLAGS="${LDFLAGS} -m32"
                ;;
        *)
                echo "Unknown architecture selected! Exiting."
                exit 1
                ;;
esac
# Those settings are typically set for packaging
# without sub packages and only french locale
# They are also the default ones
#
# PKGMK_GROUPS=()
# PKGMK_LOCALES=(fr)
# PKGMK_COMPRESS_PACKAGE="no"
# PKGMK_CLEAN="yes"
# PKGMK_IGNORE_FOOTPRINT="yes"
# PKGMK_KEEP_SOURCES="no"
# PKGMK_SOURCE_DIR="$PWD"
# PKGMK_WORK_DIR="$PWD/work"
# PKGMK_IGNORE_REPO="yes"
# PKGMK_IGNORE_COLLECTION="yes"
# PKGMK_IGNORE_RUNTIMEDEPS="yes"

Conclusion

We are now ready to build our packages in a chroot.