CAPS Universe documentation  1.0.4
All you need to know to be successful
Install libcapsbase

The corresponding:

An Install Example

All build instructions in the sections above will use default paths which might not be suitable for your system. So the filesystem paths CAPS will use in the filesystem must be defined manually, refer Filesystem Paths for details.

A simple but useful configuration can be:

./configure --sysconfdir=/etc --prefix=/usr

This example configuration leads to the following directory structure:

  /
  |
  +--- etc
  |     |
  |     +--- caps                        (CAPS Configuration Directory)
  |     |      |
  |     |      +--- drivers              (CAPS Printer Driver Configuration Directory)
  |
  +--- usr
  |     |
  |     +--- bin                         (Tools Directory)
  |     |
  |     +--- lib                         (Library Directory)
  |     |
  |     +--- libexec
  |     |      |
  |     |      +--- caps                 (CAPS Printer Driver Executables Directory)
  |     |      |
  |     |
  |     +--- include                     (Header File Directory)
  |     |
  |     +--- sbin                        (Service Executables Directory)
  |     |
  |     +--- share
  |     |      |
  |     |      +--- caps
  |     |      |     |
  |     |      |     +--- drivers        (CAPS Printer Driver Database Directory)
  |
  +--- var
  |     |
  |     +--- lib
  |     |     |
  |     |     +--- caps                  (CAPS Printer Device Database Directory)
  |     |     |      |
  |     |     |      +--- printer_dhfgez (CAPS Printer Device Parameter Directory)
  |     |
  |     +--- spool
  |     |     |
  |     |     +--- caps                  (CAPS Document Storage Directory)
  |     |     |
Note
The printer_dhfgez" in the "CAPS Device Parameter Directory is an example here. Refer CAPS Printer Device Parameter Directory for more details.

After that its time to build and install the package:

make && make install

This install step will install the pkg-config file caps.pc which contains all these paths and will be used by all other CAPS packages to install their components to the correct and expected filesystem locations.

Configuring libcapsbase in Detail

Debugging Support

Debugging support is passive by default. You can enable it with:

--enable-debug
Note
The absence of this option, --enable-debug or --disable-debug all have a different meaning.
Refer Setting up Debugging Support for details.

Enable debugging compiles-in the support of environment variables to replace the CAPS filesystem paths at run-time for development purposes. It also implies the --disable-hide (Hiding Internal Symbols) to enable debugging via a debugger.

Abort or Exit Choice

On some kind of errors libcapsbase will terminate the whole process. This can happen via exit() or abort().

--enable-abort

The abort() call enables a developer to get a core-dump on demand and --enable-abort forces the use of abort() to terminate the process.

National Language Support

By default the National Language Support (aka NLS) is enabled. You can disable it with:

--disable-nls

Profiling

You can enable profiling with:

--enable-profile
Attention
This is a development feature and not required for regular use.

Hiding Internal Symbols

By default all internal symbols are hidden (e.g. not exported). Only the API functions are accessible. This makes debugging hard. So it can be disabled with:

--disable-hide

Hiding is disabled automatically when --enable-debug (Debugging Support) is given.

Attention
This is a development feature and not required for regular use.

Use libasan to detect programming errors

Instrument the code to detect programming errors at run-time. This links the libcapsbase against libasan (e.g. address sanitizer, aka ASAN).

--enable-asan

Refer https://github.com/google/sanitizers/wiki/AddressSanitizer for details.

Attention
You should enable the address sanitizer in all CAPS components or in none of it. Else confusing error messages might happen at run-time. It still works if the address sanitizer is enabled for some CAPS components only. But it needs some tweaks to make them run again.

You might see an error like this:

==39148==ASan runtime does not come first in initial library list; you should
  either link runtime to your application or manually preload it with LD_PRELOAD.

One explanation is, the executable you want to run isn't ASAN enabled, but some or all other components (libraries) it uses are.

To make it run again, you can set:

ASAN_OPTIONS=verify_asan_link_order=0

But in this case ASAN might interfere with other libraries and does not work as expected. Take a closer look into the /etc/ld.so.preload what kind of other libraries (maybe) are loaded first.

A more robust solution is from the website mentioned above: Run the executable with an

LD_PRELOAD=path/to/asan/runtime/lib

to ensure ASAN is the first library in the list.

Note
Keep in mind if only some parts of the whole process are ASAN enabled, the result of its checks might be confusing due to false positives.

Setup the Compilation Goal

You can define the compilation goal with the configuration parameter

--with-goal=<value>

The supported values are:

  • speed
    • enables the use of so called compiler built-ins
    • disables stack protection instrumentation
  • secure
    • enables the fortify feature
    • disables the use of so called compiler built-ins to improve the fortify feature
    • enables stack protection instrumentation

Disable systemd's journald for logging

Usually all messages are sent to stderr. If at run-time the presence of journald is detected (via environment variable JOURNAL_STREAM), the messages are sent directly to journald instead via the systemd library.

If journald is used via the systemd library, the CAPS's loglevels are transformed into jounald's loglevels and thus, are kept for filtering later on.

Additionally if the verbosity setting is LIBCAPS_LOUD or higher, the source file and its line number is logged as well.

You can disable this behaviour with:

--without-journald

In this case libcapsbase isn't linked against libsystemd

Setup the Group ID

You need to define the group a few directories with write permissions should belong to. This is valid for the CAPS Printer Driver Database Directory and CAPS Document Storage Directory. This is the numerical ID of usually the group 'lp'. This ID will also be used by CAPS services like the CAPS printing coordinator to define their run-time group.

This group ID is used by the CAPS Printing System Integration printer driver launcher as well. Select this group ID carefully to ensure it can open the printer device node as a regular user if running with this group ID.

--with-capsgroup=<value>

In my case it is the '7':

$ cat /etc/group | grep lp
lp:x:7:
lpadmin:x:116:val
Note
If undefined, it defaults to '150', which is not a value you want.

Setup the root ID

This value defaults to '0' and needs (in most use cases) no adaptions. This ID is used for the CAPS Printer Driver Database Directory and CAPS Document Storage Directory directories.

--with-capsroot=<value>

Setup the user ID

This value defines the user ID for CAPS services like the CAPS printing coordinator to define their run-time user.

This user ID is used by the CAPS Printing System Integration printer driver launcher as well. Select this user ID carefully to ensure it can open the printer device node as a regular user if running with this user ID.

Note
If undefined, it defaults to '150', which is not a value you want.
--with-capsuser=<value>

Filesystem Paths

The following filesystem paths are required and are configured within libcapsbase and thus, used in the whole CAPS universe, because each other CAPS component will link against libcapsbase:

All of these paths have a default value which can be overwritten when configuring the libcapsbase package.

Setup the CAPS Configuration Directory

Refer CAPS Configuration Directory for details about this directory.

The default path of this directory is:

${sysconf}/caps

where ${sysconf} expands to /usr/local/etc by default.

${sysconf} can be defined via --prefix=DIR or individually via --sysconfdir=DIR when configuring the libcapsbase package.

Note
This directory can be part of a read-only filesystem.

Setup the CAPS Driver Configuration Directory

Refer CAPS Printer Driver Configuration Directory for details about this directory.

The default path of this directory is:

${sysconf}/caps/drivers

where ${sysconf} expands to /usr/local/etc by default.

${sysconf} can be defined via --prefix=DIR or individually via --sysconfdir=DIR when configuring the libcapsbase package.

Note
This directory can be part of a read-only filesystem.

Setup the CAPS Driver Database Directory

Refer CAPS Printer Driver Database Directory for details about this directory.

The default path of this directory is:

${datarootdir}/caps/drivers

where ${datarootdir} expands to /usr/local/share by default.

${datarootdir} can be defined via --prefix=DIR or individually via --datarootdir=DIR when configuring the libcapsbase package.

Note
This directory can be part of a read-only filesystem.

Setup CAPS Driver Executables Directory

Refer CAPS Printer Driver Executables Directory for details about this directory.

The default path of this directory is:

${libexecdir}/caps

where ${libexecdir} expands to /usr/local/libexec by default.

${libexecdir} can be defined via --prefix=DIR or individually via --libexecdir=DIR when configuring the libcapsbase package.

Note
This directory can be part of a read-only filesystem.

Setup the CAPS Device Database Directory

Refer CAPS Printer Device Database Directory for details about this directory.

The default path of this directory is:

${localstatedir}/lib/caps

where ${localstatedir} expands to /var by default.

${localstatedir} can be defined via --prefix=DIR or individually via --localstatedir=DIR when configuring the libcapsbase package.

Note
This directory can be part of a read-only filesystem if no new printers occur at run-time (e.g. static configuration).

Setup CAPS Document Storage Directory

The default path of this directory is:

${localstatedir}/spool/caps

where ${localstatedir} expands to /var by default.

${localstatedir} can be defined via --prefix=DIR or individually via --localstatedir=DIR when configuring the libcapsbase package.

Attention
This directory has special requirements to the underlying filesystem. Refer CAPS Document Storage Directory for details about this directory.