Linux Mastering Development Ubuntu

How to customise both choices and description of a debconf question?

I’m currently working on a package script where I need to provide customised choices and also wish to provide an extended description based on those choices.

I’ve successfully modified a Linux installer before with a preseed and custom scripts using Debconf to ask questions so I am familiar with how it works.

Where I am stuck is changing the description in the template. According to all the Debconf manuals I looked up online both choices and description can be customised, although the information is brief. There are plenty of examples customising Choices with db_subst and this works fine.

Where I am stuck is customising the Description text and in this case the extended description. I’ve tried using db_subst but with no satisfactory results. The problem is I need to extend the description with more lines of text. But I’ve found Debconf only uses one line. If I put newline markers like “\n” in text it interprets them literally which looks messed up.

Can Debconf be programmed to customise a Description with a few extra lines of text? Or do I need to give up and just create a customised template file by hand for this one question? I see I may have gone beyond the features of what Debconf provides but to me it didn’t seem so complicated.

Here is my example script and template so you can see how and what I have done to test it.


# Debconf testing script.
# Testing dynamic changing of choices and description in question.

export DEBCONF_DEBUG=developer
#export DEBIAN_FRONTEND=gnome

. /usr/share/debconf/confmodule

db_x_loadtemplatefile ./testing.template testing
db_settitle testing/title

list="1, 2, 3, 4"
extended="One\n Two\n Three\n Four\n"

# Use real newlines in text
#extended=`echo "${extended}"`

db_subst testing/list list "${list}"
db_subst testing/list extended "${extended}"
db_reset testing/list
db_input critical testing/list 
db_get testing/list


exit 0

# testing.template

Template: testing/title
Type: title
Description: Testing title

Template: testing/list
Type: select
Choices: ${list}
Description: Please select option below.
 Extended description.

Leave a Reply

Your email address will not be published. Required fields are marked *