This page contains a proposal for a way to handle upgrades where a user's data and the package maintainer data are merged with minimal interaction with user. The package approx will be used as an example.

Status

Automatic configuration merge is provided with lcdproc >= 0.5.6

Introduction

For a casual user (like you mother-in-law or your neighbor), the questions asked during package upgrades can be intimidating. Casual users barely know that some files exist outside of their home directory and are completely lost when looking at the /etc directory. Unfortunately, during package upgrade, user is faced with cryptic questions whether to keep his configuration, use the maintainers configuration or look at a diff. The casual user will seldom know what to do in this case.

This situation can be made worse if user's configuration was edited with a tool (e.g. cups configuration is edited through a web browser): the user has no knowledge of the syntax of the configuration file.

This proposal aims to provide a way for Debian package to minimize the number of questions raised to the user when upgrading packages. If questions are necessary, an interface will be provided to the user. Hopefully, manual editing of configuration files will not be necessary.

Upgrades with Config::Model

Config-Model provides a framework for editing and validating the content of any configuration file or data. With a configuration model (expressed in a data structure), Config-Model provides a user interface and a tool to validate configuration.

A typical configuration model contains the following specifications :

The structure of the configuration model. This structure is a tree that can be flat (for simple files like approx.conf) or quite deep (for complex configuration like xorg.conf). The configuration tree nodes are instances of configuration class and the tree leaves contain the configuration values.

In postinst, run cme to load old configuration file using new configuration model and write back the updated data in new configuration file (i.e. merged values from user's data and data from new configuration model).

If the last step fails, inform the user to launch cme in interactive mode

The same principles can be applied to downgrade with some limitations (see below for more details)

Apply configuration upgrade using an existing model: lcdproc example

Current lcdproc situation

Up to version 0.5.5, lcdproc is shipped with several configuration files, including /etc/LCDd.conf. This file is modified upstream at every lcdproc release to bring configuration for new lcdproc drivers. On the other hand, this file is always customized to suit the specific hardware of the user's system. So upgrading a package will *always* lead to a conflict during upgrade. User will always be required to choose whether to use current version or upstream version.

What will change for user

When lcdproc is upgraded to the new version featuring automatic upgrade, the following changes will be visible: * lcdproc will depend on libconfig-model-lcdproc-perl* user will be asked *once* by debconf whether to use automatic configuration upgrades or not. * no further question will be asked (no ucf style questions).

Note: the automatic upgrade currently applies only to LCDd.conf. The other configuration files of lcdproc are handled the usual way.

cme-command: fix specifies the command used by cme. By default, cme will use migrate command during upgrade. Due to multi arch, DriverPath may contain library path without multi-arch triplet. Using fix will ensure that DriverPath is set to the correct multi-arch path.

cme-options: -force is required to upgrade LCDd.conf from upstream. Upstream config contains configuration for driver which are removed from Debian. This configuration must also be removed from the file. Using -force will ensure that.

cme-purge: /etc/LCDd.conf*: with this option, dh_cme_upgrade will insert a postinst script that will remove the specified file on package purge.

If you want to apply config-model based upgrades to your favorite package

lcdproc did start from an existing configuration model. Let's see what is required to create a minimal configuration model so that your package can also feature automatic configuration upgrade.

You will have to:

Create a minimal model that describe:

items that need special treatment during upgrades

how to handle other parameters

Find a backend that supports the syntax of the configuration file of your package. If none exists, ask on config-model-users at lists.sourceforge.net, we'll find a solution that won't require you to learn Perl.

Well, that was the theory. Let's experiment with Approx configuration file and work out the details.

Approx example

configuration analysis

From approx.conf(5) man page, we find that approx has a very simple configuration. Approx will need one configuration class that will have:

a bunch configuration parameters, either boolean, integer or string. All of them have default built in approx.

a hash containing distribution names and their URL. These will be modeled with a hash of uniline values

You can view the actual model on Approx model on github. This model is more complex as all parameters and help text are provided.

Any Debian specific requirement (e.g. default value) will have to be implemented in the model and not in the template configuration file provided to the user (e.g. not in /etc/approx/approx.conf)

Configuraion upgrade during package upgrade

This can use modification similar to the lcdproc example shown above.

Config::Model commands to manage configuration upgrade

For reference, cme can also be used outside of package script to manually migrate a configuration file. These commands are not specific to Debian and can be applied to other distros or OS.

Let's start with a simple approx.conf file:

debian http://ftp.fr.debian.org/debian
$max_wait 12

In most cases, simply running cme migrate will be enough to upgrade a configuration files. Even if the configuration model is changed from package version N to version N+1, the upgrade will work most to the time. cme will exit on error if some data to upgrade are not recognized.

cme migrate approx

cme will:

parse the old configuration file (or create one in case of first installation)

# This file was written by Config::Model with Approx model
# You may modify the content of this file. Configuration
# modification will be preserved.
$max_wait 12
debian http://ftp.fr.debian.org/debian

If you want to keep a backup of the old configuration file, you can run cme migrate approx -backup. The old configuration will be in approx.conf.old

Working with Debconf

Warning: just a bunch of ideas, no working implementation

Main ideas:

Run config-edit -ui debconf -saveindebconf in pre-inst

Run config-edit -ui debconf -loadfromdebconf -save in postinst

Translate data from model into debconf template. Debconf template will be used by