Using Debconf
Debconf is Debian’s configuration management system. It stores user inputs and configuration options for packages during installation, upgrade, and removal.
Structure of the templates File
A templates file consists of multiple template entries, each defining a specific question. Each entry follows this format:
| debian/templates | |
|---|---|
| Field | Description |
|---|---|
| Template | Unique identifier for the question (mypackage/question_name). |
| Type | The type of input expected (see below for options). |
| Default | The default answer if the user does not provide one. |
| Description | The message displayed to the user. |
Types
- string: User enters a free-text string.
- boolean: Yes/No question.
- select: User selects from predefined options.
- multiselect: User selects multiple options.
- note: Displays a message but does not ask a question.
- password: Hides user input for security.
| Boolean (Yes/No) | |
|---|---|
| Select (Multiple Choices) | |
|---|---|
| Multiselect (Multiple Selections) | |
|---|---|
| Note (Just a Message, No Input) | |
|---|---|
Read the User's Input in postinst
Once the user enters values during installation, you can retrieve them in debian/postinst:
| postinst | |
|---|---|
Tells Debconf to show a prompt for mypackage/config_value. high is the priority (other options: low, medium, critical). || true ensures the script does not fail if db_input encounters an issue.
Displays all pending Debconf questions in one go. Must be called after db_input to show the prompt to the user.
Retrieves the user's input from Debconf. Stores the value in the $RET variable.
postrm
| postrm | |
|---|---|
other debconf commands
- Debugging and Testing
To check stored values:
To manually set a value:
To reset and ask the questions again:
package script file location