The CDD Toolkit

Author: Sergio Talens-Oliag
email:sto@debian.org
Date: 2005-06-30 14:15:20 +0200 (dj, 30 jun 2005)

Introduction

There is a lot of people working on Custom Debian Distributions, but it seems that everyone is reinventing the wheel to do it.

This document proposes the design of a CDD Toolkit that tries to standardize the way developers define their CDD and provides tools to distribute, install, update and manage the customized system.

This toolkit is being developed on the current CDD Project on alioth and discussed on the debian-custom@lists.debian.org mailing list.

The CDD Metadata Package

The basic idea is that each CDD can be distributed in source or in binary form using a single deb package that contains a description of the CDD and all the metadata needed to install it (or to generate an installer for it).

For this toolkit, a CDD is defined as a set of tasks that can be used to install and configure packages on the system for a given purpose.

A task definition has to include a list of packages (or CDD tasks) that have to be installed to provide the task's functionality and the information needed to configure those packages or, at least, give pointers to that information. Besides the needed dependencies, a task can also recommend and suggest other packages and tasks.

The CDD Description is written using a format similar to the Debian Control File, and is distibuted as one file (or on multiple ones, if we use the include feature). The file declares one or more tasks and the all information needed to configure, update and remove the packages related to them.

The description and any aditional files needed to install the different tasks will be distributed on the binary CDD debian package (the source file will contain only the description and related data, but some files distributed on the binary will be generated by the CDD tookit tools).

Currently the configuration data that can be included and distributed includes preseeding (for the debian-installer and the system's debconf), scripts that have to be executed to generate configuration files after package installation (that scripts are only used to generate modified configuration files that can't be generated using debconf) and task control scripts, that is, scripts that have to be executed before and after task installation or removal (like the package control scripts).

Other configuration data like special user menus can also be included on the CDD metadata, but for other things (like branding), proper debian packages are probably a better idea and can be included on the task dependencies.

Toolkit Components

The system is divided into two sets of tools:

The CDD Control File (CDD Description)

The CDD definition is written using a control file with a syntax similar to the one used for Debian Control files.

The control file consists of one or more paragraphs. The paragraphs are separated by blank lines.

Each paragraph consists of a series of data fields; each field consists of the field name, followed by a colon and then the data/value associated with that field. It ends at the end of the line. Horizontal whitespace (spaces and tabs) may occur immediately before or after the value and is ignored there; it is conventional to put a single space after the colon.

Some fields' values may span several lines; in this case each continuation line must start with a space or a tab. Any trailing spaces or tabs at the end of individual lines of a field value are ignored.

Except when stated, only a single line of data is allowed and whitespace is not significant in a field body. Whitespace must not appear inside names (of packages, architectures, files or anything else) or version numbers, or between the characters of multi-character version relationships.

Field names are not case-sensitive, but it is usual to capitalize the field names using mixed case as shown on the fields description below.

Blank lines, or lines consisting only of spaces and tabs, are not allowed within field values or between fields - that would mean a new paragraph.

Control File Fields

For fields not defined here we will use the prefix X- and they will be ignored by the cdd-tool system.

The control file can include comments using the # symbol at the beginning of a line (ONLY).

The CDDTool

The idea is to have a single tool that acts as a fronted to all the CDD utilities, the syntax would be something like the following:

cddtool OPTIONS COMMAND CMND_ARGS

Where OPTIONS is a list of options common to all tools, like:

--version --help --debug --verbose --conf=FILENAME 

COMMAND is one of:

And the CMND_ARGS usually include optional SUBCOMMANDS, the name of the CDD and a TASK_LIST to work with:

cddtool OPTIONS COMMAND CDDNAME TASK_LIST 

Note that the tool is work in progress and possibly there will be additional commands and a configuration file (not already defined).

Support programs

Into this secction we will discuss the programs we plan to use to support the installation of custom distributions.

The tools are related to the different installation systems:

cddtk-apt and configuration file handling

This proposal talks about Task and Package paragraphs, but the idea is that each task is one entity, so debconf preseeds and configuration scripts are used for all the packages of the task. It also says that the cddtool could be used to install, update and remove packages, but there is no indication of how that could be integrated with the usual Debian tools (that is, with apt).

Currenlty CDD handle other package's configuration files using two techniques:

  1. Using debconf preseeding
  2. Changing the files after installation using cfengine or something similar.

The preferred system is the first one, but it is not applicable in a lot of situations or breaks used after upgrades.

..Note:
I no longer believe that preseeding the best way of doing things, it is a very good tool for first time installation but it is not good for already installed systems or for updates (there is no clean way to modify configuration values on an installed system using presseding, the changes have to be applied to the configuration files directly).

The second method is not very clean and makes upgrades noisy for the user, as dpkg tells him that files that he does not know how to handle have been modified.

We propose a third mechanism that could be useful to install and remove customizations without interference with the Debian packages, at least in controlled environments.

The idea is that we could support CDD updates using a common system for the cfg-scripts described on the proposal and installing hooks for apt with the cddtool (or, better, with a specialized cddtk-apt written for the shell).

To do it we will install the following file:

DPkg::Post-Invoke { "test -x /usr/sbin/cddtk-apt && /usr/sbin/cddtk-apt post-invoke"; };
DPkg::Pre-Install-Pkgs { "/usr/sbin/cddtk-apt pre-install-pkgs"; };
DPkg::Tools::Options::/usr/bin/cddtk-apt::Version "2";

as /etc/apt/apt.conf.d/10cddtk.

The Pre-Install-Pkgs script is called when the packages are already on the local filesystem, but before calling dpkg to unpack and configure them (the DPkg::Tools::Options is used to get a list of the actions that are going to be done on the standard input of the cddtool invocation).

The Post-Invoke script is called after all packages are installed and configured.

..Note:
This system will break if the user calls dpkg directly, maybe we should install a wrapper for dpkg that calls the cddtk-apt or a similar program before and after the real dpkg run?

The idea is to use those scripts to disable non-policy compliant customizations while installing or upgrading packages and reaply the customizations after installation.

Note that this system's usage has to be kept to a minimum (i.e. we should use it only to enable the inclusion of external configuration files when possible), and that all files related to a customization that are not going to conflict with the normal system should be handled using normal debian packages (the main custom package or packages linked to a task).

See the cddtk-apt document (included on the cddtk-runtime package) to see how the tools are going to be implemented.

debian-installer integration: cddtk-di and cddtk-bi

To integrate our system with the debian-installer we could generate tasksel tasks or metapackages, but we also want to be able to have a very simple debian-installer, so we have defined a way to be able to select the cdd-tasks at the very begining of the installation process, to be able to choose them since the beging and preseed the debian-installer accordingly.

What's not on this document

To build a really custom distribution almost all derived distributions apply a lot of changes to the debian packages; with some help of the Debian Developers that could be avoided changing the way the packages read configuration files (i.e. not installing conffiles if they are complicated or can't be generated by debconf for the general case), adding debconf support to them (possibly using very low priority questions) or simply adding some kind of support for branding (i.e. using a standard file that is in fact a link handled by update-alternatives or a similar system).

Once we have a common cdd toolkit there will probably be more custom distributions and we will have a better position to ask all debian developers to help us make debian more customizable.