Sat Oct 27 13:49:52 2018 UTC

Scenario B

Introduction

You are happy with your NuTyX installation. However, you desire more packages as part of the system, and you prefer to install and compile them yourself. This is when NuTyX really become interesting and exciting. Get ready for the challenge ahead: tons of self-determination and heaps of patience is required Tongue outLaughing. It's a long haul. But very, very rewarding and enjoyable all the way through the building processes.

Good advice when using Scenario B: avoid at all costs any attempt to compile any external/foreign builds/packages which will conflict with the NuTyX “base-collection”. If you do this, you will face many errors relating to dependency issues when installing the NuTyX cards-devel package, which is not installed by default. If you really want to go ahead with something like this, you should choose Scenario C.

The /etc/cards.conf file

A folder containing my personal packages needs to be added. This folder should never be updated by the command cards sync, so we should not specify any associated URL pointing to this folder.

Binary collections are enabled; this will allow me to add any missing dependencies easily... .

The language used on the machine is adjusted.

The file defines the basic system, in case we wish to return to this.

The typical content of your /etc/cards.conf file for Scenario B:

dir /usr/ports/personal
dir /var/lib/pkg/depot/gui|http://downloads.nutyx.org
dir /var/lib/pkg/depot/cli|http://downloads.nutyx.org
dir /var/lib/pkg/depot/base|http://downloads.nutyx.org
locale fr
locale de
base /var/lib/pkg/depot/base

Development tools installation

We can now begin to install the Development packages, such as, a compiler, libraries C and C ++ tools autoconf, automake, etc... etc... .

sudo mkdir -p /usr/ports/personal

And now we install the tools:

sudo cards sync
/var/lib/pkg/depot/gui/.PKGREPO
/var/lib/pkg/depot/cli/.PKGREPO
/var/lib/pkg/depot/base/.PKGREPO
sudo cards install cards.devel
Retrieve info about the 66 packages: 100 %
/var/lib/pkg/depot/base/cards/.PKGREPO
/var/lib/pkg/depot/base/cards/cards.devel1429192050x86_64.cards.tar.xz
661020 Bytes - 671821 Bytes/Sec - 100% - 0 Sec remain  remain
/var/lib/pkg/depot/base/acl/.PKGREPO
/var/lib/pkg/depot/base/acl/acl.devel1412540285x86_64.cards.tar.xz
...

The /etc/pkgmk.conf file

In this scenario, it is good to check some variables:

My processor has 8 cores, so for more speed and power:

export MAKEFLAGS="-j8"

Sources can be stored in the folder containing the packages or in a separate folder. Personally, I prefer to put them together in a separate folder. I choose the /tmp folder so that they will be removed automatically before the next boot. I do not need the sources once the package is compiled and successfully installed. And finally, I prefer to have the working folder in /tmp/work instead of the default folder defined:

PKGMK_SOURCE_DIR="/tmp"
PKGMK_KEEP_SOURCES="no"
PKGMK_WORK_DIR="/tmp/work"

I do not want to have to specify each time that sources must be downloaded if not available locally. A variable lets you do this automatically:

PKGMK_DOWNLOAD="yes"

In this scenario, I do not wish to manage dependencies automatically at compile time and so I do not need the .PKGREPO file .. . I will only use the pkgmk command.

PKGMK_IGNORE_REPO="yes"
PKGMK_IGNORE_COLLECTION="yes"

I do not want the pkgmk command to split the binary package into sub packages (devel, doc, man, etc). I am happy with a single package since I compiled it myself. For my locale, I will only use (French) fr and German de.

PKGMK_GROUPS=()
PKGMK_LOCALES=(fr de)

I do not want pkgmk to compress the packages it builds and I do not wish to keep archives after installation:

PKGMK_COMPRESSION_PACKAGE="no"
PKGMK_CLEAN="yes"

Here's what the /etc/pkgmk.conf file looks like for the Scenario B:

export CFLAGS="-O2 -pipe"
export CXXFLAGS="${CFLAGS}"
case ${PKGMK_ARCH} in
    "x86_64"|"")
       export MAKEFLAGS="-j8"
       ;;
    "i686")
       export CFLAGS="${CFLAGS} -m32"
       export CXXFLAGS="${CXXFLAGS} -m32"
       export LDFLAGS="${LDFLAGS} -m32"
       ;;
    *)
       echo "Unknown architecture selected! Exiting."
       exit 1
       ;;
esac
PKGMK_DOWNLOAD="yes"
PKGMK_SOURCE_DIR="/tmp"
PKGMK_KEEP_SOURCES="no"
PKGMK_WORK_DIR="/tmp/work"
PKGMK_IGNORE_REPO="yes"
PKGMK_IGNORE_COLLECTION="yes"
PKGMK_GROUPS=()
PKGMK_LOCALES=(fr de)
PKGMK_COMPRESSION_PACKAGE="no"
PKGMK_CLEAN="yes"

That's all you need for the /etc/pkgmk.conf configuration file.

Compiling a package without dependencies

!!!

Let's start by switching to your root account

su -
Password:

Very important to write down your password, in case you forget, unless its a code burnt into your memory. Cool. Note the dash; it makes this a login shell so that essential configuration files for the root user will be read.

You will notice that prompt for the root user is red.

If you are reading this, make sure you have completed all the manipulations for this exercise provided by the example using the scenario B.

I propose to build the small JOE text editor. The object of this training, although you already have JOE, is to show you how to get hold of a single package without dependencies and compile it.

For a package to compile and install correctly, it is important to create a folder with a name identical to the package name. In our case, the folder and package name is: joe

Folder creation

mkdir -p /usr/ports/personal/joe

Package creation

I am using the method set out in BLFS, so please type all this text in your recipe Laughing, (please make sure their names are correctly spelt) to give deserved credit to those who Maintain and Package the package joe:

cat > /usr/ports/personnel/joe/Pkgfile << "EOF"
description="JOE (Joe's own editor) is a small text editor."
url="http://joe-editor.sourceforge.net/"
maintainer="JHallen, JJJordan, Marx_sk, shallot"
packager="François Perrin"

name=joe
version=3.7
release=1
source=( http://downloads.sourceforge.net/$name-editor/$name-$version.tar.gz)
build() {
  cd $name-$version
  ./configure --prefix=/usr --sysconfdir=/etc
  make
  make DESTDIR=$PKG install
}
EOF

Package compilation

The script is now completed and ready to be used for compiling your new package. yippee

cd /usr/ports/personnel/joe
pkgmk -d
=======> PKGMK_INSTALL: no
=======> PKGMK_WORK_DIR: /usr/ports/personnel/joe/work
=======> PKGMK_SOURCE_DIR: /usr/ports/personnel/joe
=======> WARNING: CLEAN IGNORED
=======> WARNING: KEEP SOURCES
=======> PKGMK_UPDATE_SIGNATURE:
=======> PKGMK_IGNORE_FOOTPRINT: yes
=======> PKGMK_IGNORE_MD5SUM: yes
=======> .PKGREPO file will not be generated
=======> PKGMK_COMPRESS_PACKAGE: no
=======> name: joe
=======> version: 3.7
=======> Downloading 'http://downloads.sourceforge.net/joe-editor/joe-3.7.tar.gz'.
...
...
Saving to: '/usr/ports/personnel/joe/joe-3.7.tar.gz.partial'
2014-10-26 22:27:47 (1.01 MB/s) - '/usr/ports/personnel/joe/joe-3.7.tar.gz.partial' saved [696036/696036]

=======> Building '/usr/ports/personnel/joe/joe1414362465x86_64.cards.tar.xz'.
bsdtar -p -o -C /usr/ports/personnel/joe/work/src -xf /usr/ports/personnel/joe/joe-3.7.tar.gz
+ build
+ cd joe-3.7
+ ./configure --prefix=/usr --sysconfdir=/etc
...
...
make[3]: Leaving directory '/usr/ports/personnel/joe/work/src/joe-3.7'
make[2]: Leaving directory '/usr/ports/personnel/joe/work/src/joe-3.7'
make[1]: Leaving directory '/usr/ports/personnel/joe/work/src/joe-3.7'
=======> WARNING: Footprint ignored.

Install your package

To install this compiled package, just type the command:

pkgadd joe1414362465x86_64.cards.tar

Conclusion

pkgmk
pkgadd

These commands will always be launched in your personal package folder.