How to Remove Specific Values from Debconf Database: A Technical Guide for Package Management


1 views

When managing Debian-based systems, you might encounter situations where incorrect preseed values in the debconf database cause package installations to fail. This commonly happens during automated installations or when reconfiguring packages like gitolite.

The debconf database stores configuration values used during package installation and configuration. These values persist even after package removal, which can cause issues when reinstalling or reconfiguring packages.

The most reliable way to remove specific debconf values is using the debconf-utils package. First install it if you haven't:

sudo apt-get install debconf-utils

Use the debconf-show command to view current values for a package:

debconf-show gitolite

To remove specific values, use debconf-set-selections with empty values:

echo "gitolite gitolite/admin_pubkey string" | sudo debconf-set-selections
echo "gitolite gitolite/git_user string" | sudo debconf-set-selections

For a complete reset of a package's debconf values:

sudo apt-get purge gitolite
sudo apt-get purge debconf

Then reinstall the packages:

sudo apt-get install debconf
sudo apt-get install gitolite

For direct database manipulation (use with caution):

sudo nano /var/cache/debconf/config.dat

Search for and remove the problematic entries, then save the file.

After making changes, verify the values are cleared:

debconf-show gitolite

Here's a bash script to automate clearing gitolite settings:

#!/bin/bash
PACKAGE="gitolite"
FIELDS=("admin_pubkey" "git_user")

for field in "${FIELDS[@]}"; do
  echo "${PACKAGE} ${PACKAGE}/${field} string" | sudo debconf-set-selections
  echo "${PACKAGE} ${PACKAGE}/${field} seen false" | sudo debconf-set-selections
done

When working with Debian/Ubuntu package configuration, the debconf database can sometimes store problematic values that interfere with package installations or reconfigurations. This commonly occurs with:

  • Automated installations (preseed)
  • Failed package configurations
  • Migration between different versions

First, check existing debconf values for your package. For gitolite as mentioned in the question:

sudo debconf-show gitolite

This will display all stored debconf values for the package.

To remove individual values, use the debconf-communicate command. For example, to clear the gitolite admin key setting:

echo "RESET gitolite/gitolite-admin-key" | sudo debconf-communicate
echo "FSC gitolite/gitolite-admin-key" | sudo debconf-communicate

The RESET command clears the value, and FSC (fset seen flag) marks it as unset.

To completely remove a package's configuration from debconf:

sudo apt-get purge --auto-remove gitolite
sudo rm /var/cache/debconf/*-old
sudo rm /var/lib/dpkg/info/gitolite.*

Then reinstall the package:

sudo apt-get install gitolite

For interactive value reset:

sudo dpkg-reconfigure -freadline gitolite

This will walk you through all configuration options while respecting your terminal type.

As a last resort (not recommended for production systems):

sudo rm /var/cache/debconf/*-old
sudo rm /var/lib/debconf/*

Warning: This will remove all debconf data for all packages!

Here's a script to safely clear specific debconf values:

#!/bin/bash
PACKAGE="gitolite"
KEYS=(
    "gitolite/gitolite-admin-key"
    "gitolite/mailnotify"
)

for key in "${KEYS[@]}"; do
    echo "Clearing $key"
    echo "RESET $key" | sudo debconf-communicate
    echo "FSC $key" | sudo debconf-communicate
done

After clearing values, verify with:

sudo debconf-show gitolite

The cleared values should now show as empty or with default values.