<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>www.vangoor.eu</title>
	<atom:link href="http://www.vangoor.eu/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.vangoor.eu</link>
	<description>The world of Linux</description>
	<lastBuildDate>Thu, 09 Apr 2009 20:58:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PO-Debconf</title>
		<link>http://www.vangoor.eu/2009/03/po-debconf/</link>
		<comments>http://www.vangoor.eu/2009/03/po-debconf/#comments</comments>
		<pubDate>Fri, 06 Mar 2009 15:26:43 +0000</pubDate>
		<dc:creator>enrico</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[debconf]]></category>
		<category><![CDATA[l10n]]></category>
		<category><![CDATA[man]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[translate]]></category>

		<guid isPermaLink="false">http://www.vangoor.eu/?p=23</guid>
		<description><![CDATA[PO-DEBCONF(7)                                                                    po-debconf                                                                    PO-DEBCONF(7)
NAME
po-debconf &#8211; introduction
DESCRIPTION
The goal of &#8220;debconf&#8221; was to make package configuration user-friendly.  In order to achieve this, it is important to ensure that users will get the question in their
own language.  Translators need a framework to easily work on translations without having to track down package development; &#8220;po-debconf&#8221; was designed to be able [...]]]></description>
			<content:encoded><![CDATA[<p>PO-DEBCONF(7)                                                                    po-debconf                                                                    PO-DEBCONF(7)</p>
<p><strong>NAME</strong><br />
po-debconf &#8211; introduction</p>
<p><strong>DESCRIPTION</strong><br />
The goal of &#8220;debconf&#8221; was to make package configuration user-friendly.  In order to achieve this, it is important to ensure that users will get the question in their<br />
own language.  Translators need a framework to easily work on translations without having to track down package development; &#8220;po-debconf&#8221; was designed to be able to<br />
work with standard &#8220;gettext&#8221; tools when translating debconf templates files.<br />
<span id="more-23"></span><br />
<strong>ADDING I18N SUPPORT TO DEBCONF TEMPLATES FILES</strong><br />
If you are adding debconf support to your package, you have written a templates file containing English text.  To add proper i18n support into your package, you need<br />
to:</p>
<p>- Create debian/po/POTFILES.in<br />
This file contains the list of master templates.  It typically contains a single line</p>
<p>[type: gettext/rfc822deb] templates</p>
<p>Paths are relative to the parent directory.</p>
<p>- Prepend an underscore before translatable fields<br />
Normally &#8220;Description&#8221;, &#8220;Choices&#8221; and sometimes &#8220;Default&#8221; fields can be translated.</p>
<p>- Run debconf-updatepo<br />
This will create the debian/po/templates.pot file that translators will translate into their language.</p>
<p>- Add a build dependency on &#8220;po-debconf&#8221; in debian/control</p>
<p><strong>UPDATE TEMPLATES</strong><br />
In order to help translators, PO files in your package should always be up-to-date, otherwise they may lose their time with unused strings.  For that, simply call<br />
the following command without arguments:</p>
<p>$ debconf-updatepo</p>
<p>You should run this command every time you change templates in English, but also when you receive new or updated translations, because translators may have worked on<br />
an obsolete PO file.</p>
<p>If you rename, add or remove some templates files, remember also to edit debian/po/POTFILES.in accordingly, otherwise English strings are missing from PO files and<br />
will be displayed to users even if PO files are fully translated.</p>
<p>The debconf-updatepo program is idempotent, it modifies PO files only if their content has been updated.  Thus the best solution to provide up-to-date PO files in<br />
your source package is to call this command from the &#8220;clean&#8221; target of the debian/rules file.<br />
Please note that you need to run debconf-updatepo even if you use dh_installdebconf.  The latter calls po2debconf which used to call debconf-updatepo if outdated<br />
files were detected, but this is no more the case because it was not a good solution for at least two reasons:</p>
<p>1. po2debconf relied on timestamps to detect outdated files, and may be abused when using &#8220;pbuilder&#8221; or if an outdated translation has been stored on disk after tem‐<br />
plates have been modified</p>
<p>2. dh_installdebconf is called long after &#8220;.diff.gz&#8221; file has been generated</p>
<p><strong>MERGE TRANSLATIONS AND ORIGINAL</strong><br />
You have to make sure that when your package is compiled, translations will get into the built package. You can do that manually, or automatically using the<br />
dh_installdebconf script (make sure to have a versionned build dependency against &#8220;debhelper (&gt;= 4.1.16)&#8221;).</p>
<p>To do that manually, you’ll have to merge the templates and the translations at compile time (and to have a build depend against &#8220;po-debconf&#8221;) like this:</p>
<p>$ po2debconf debian/templates &gt; debian/tmp/DEBIAN/templates</p>
<p>BE CAREFUL: the two files called templates are not the same at all.  The first one contains only the English text, and mark some fields to be translated while the<br />
second contains all languages.  That is to say that you CANNOT keep only the merged templates, or you won’t be able to deal with translations as people submit them<br />
to you.</p>
<p><strong>NEW MASTER TEMPLATES</strong><br />
The new templates file source format is almost identical to one of distributed templates files, but translatable fields are prepended with an underscore.  Example:</p>
<p>Template: debconf/frontend<br />
Type: select<br />
_Choices: Dialog, Readline, Gnome, Editor, Noninteractive<br />
Default: Dialog<br />
_Description: Interface to use for configuring packages:<br />
Packages that use debconf for configuration share a common look and<br />
feel.  You can select the type of user interface they use.<br />
.<br />
The dialog frontend is a full-screen, character based interface,<br />
while the readline frontend uses a more traditional plain text<br />
interface, and the gnome frontend is a modern X interface.  The<br />
editor frontend lets you configure things using your favorite text<br />
editor. The noninteractive frontend never asks you any questions.</p>
<p><strong>SPLITTING CHOICES LIST</strong><br />
Since &#8220;po-debconf&#8221; 0.6.0, localized fields may contain two leading underscores.  In this case, field value is supposed to be a comma separated list of values, which<br />
are put in separate msgids.  Thus if the previous example did contain</p>
<p>__Choices: Dialog, Readline, Gnome, Editor, Noninteractive</p>
<p>there would be 5 different msgids.  Note that spaces after commas are not significant.</p>
<p>Basically when a choices list never changes, &#8220;_Choices&#8221; is fine, but otherwise &#8220;__Choices&#8221; will ease translator’s life.</p>
<p>Unfortunately if you decide to switch between these two forms, all translations become fuzzy.  Here is an explanation to make this change without translation loss<br />
(it requires &#8220;po-debconf&#8221; &gt;= 1.0).  Suppose that we want to switch the previous example to &#8220;__Choices&#8221;.  You copy the templates file into a temporary file.</p>
<p>$ cp debian/templates debian/foo</p>
<p>Edit debian/foo and keep only &#8220;Template&#8221;, &#8220;Type&#8221; and &#8220;_Choices&#8221; fields, which are in this example</p>
<p>Template: debconf/frontend<br />
Type: select<br />
_Choices: Dialog, Readline, Gnome, Kde, Editor, Noninteractive</p>
<p>Run debconf-gettextize with &#8220;&#8211;merge&#8221; and &#8220;&#8211;choices&#8221; flags to build PO files as if &#8220;__Choices&#8221; was written, and merge these PO files to existing ones:</p>
<p>$ debconf-gettextize &#8211;merge &#8211;choices debian/foo</p>
<p>Eventually you have to remove foo and manually edit debian/templates to replace &#8220;_Choices&#8221; by &#8220;__Choices&#8221; before debconf-updatepo is run.</p>
<p><strong>PUTTING COMMENTS FOR TRANSLATORS</strong></p>
<p>&#8220;Dpkg&#8221; maintainers decided that by convention lines beginning with a number sign (&#8221;#&#8221;) are comments in debian/control files, and &#8220;po-debconf&#8221; follows this rule.<br />
Since &#8220;po-debconf&#8221; 0.8.0, such comments are written into PO files, and can then contain valuable informations for translators.  Incidentally all previous &#8220;po-deb‐<br />
conf&#8221; versions ignore lines which do not contain a colon, thus if your comments does not contain any colon, there is no need to add a versioned build dependency<br />
against &#8220;po-debconf&#8221;.  Here is an example:</p>
<p>Template: debconf/button-yes<br />
Type: text<br />
# Translators, this text will appear on a button, so KEEP IT SHORT<br />
_Description: Yes</p>
<p>Special comments have been introduced in &#8220;po-debconf&#8221; 1.0 to deal with strings which are composed of several items (as with Choices field) or paragraphs (like<br />
Description).  With these directives, developers have a better control over what is exposed to translators.  They are in the form &#8220;#flag:directive&#8221;; directives are<br />
detailed below.<br />
translate:spec, translate!:spec<br />
Mark only some items as translatable; spec is a comma separated list of numbers, it specifies which strings will be printed into PO files.  Ranges can also be<br />
defined via a minus sign (for instance &#8220;2-6&#8243;), and a star (&#8221;*&#8221;) means all strings.  For instance, with</p>
<p>Template: partman-basicfilesystems/fat_mountpoint<br />
Type: select<br />
#flag:translate:3,4<br />
__Choices: /dos, /windows, Enter manually, Do not mount it<br />
_Description: Mount point for this partition:</p>
<p>&#8220;Enter manually&#8221; and &#8220;Do not mount it&#8221; will appear in PO files but not &#8220;/dos&#8221; and &#8220;/windows&#8221;.  When an exclamation mark follows the translate keyword, spec speci‐<br />
fies which strings will be discarded from PO files, all other strings are printed.  Previous example is similar to</p>
<p>Template: partman-basicfilesystems/fat_mountpoint<br />
Type: select<br />
#flag:translate!:1,2<br />
__Choices: /dos, /windows, Enter manually, Do not mount it<br />
_Description: Mount point for this partition:</p>
<p>The same keyword can also be applied to the Description field to make sure that some strings are not translated.</p>
<p>Template: partman-crypto/options_missing<br />
Type: error<br />
#flag:translate!:3<br />
_Description: Required encryption options missing<br />
The encryption options for ${DEVICE} are incomplete. Please<br />
return to the partition menu and select all required options.<br />
.<br />
${ITEMS}</p>
<p>But this is hazardous because context may be dropped from PO files, please add comments in this case so that translators are not confused.</p>
<p>comment:spec, comment!:spec<br />
The comment just below this directive applies to the strings specified by spec, which is defined above.  By default, a comment written before a translatable field<br />
is printed along with all strings belonging to this field.  (Note: with &#8220;po-debconf&#8221; &lt; 1.0, the comment was written only with the first string)</p>
<p>Template: arcboot-installer/prom-variables<br />
Type: note<br />
# Translators, the 4th string of this description has been dropped<br />
# from PO files.  It contains shell commands and should not be<br />
# translated.<br />
#flag:comment:3<br />
# &#8220;Stop for Maintenance&#8221; should be left in English<br />
#flag:translate!:4<br />
_Description: Setting PROM variables for Arcboot<br />
If this is the first Linux installation on this machine, or if the<br />
hard drives have been repartitioned, some variables need to be set<br />
in the PROM before the system is able to boot normally.<br />
.<br />
At the end of this installation stage, the system will reboot.<br />
After this, enter the command monitor from the &#8220;Stop for<br />
Maintenance&#8221; option, and enter the following commands:<br />
.<br />
setenv OSLoader arcboot<br />
setenv OSLoadFilename Linux<br />
.<br />
You will only need to do this once.  Afterwards, enter the &#8220;boot&#8221;<br />
command or reboot the system to proceed to the next stage of the<br />
installation.</p>
<p>The example above has a comment without &#8220;#flag:comment&#8221; directive, an implicit &#8220;#flag:comment:*&#8221; is added.  This comment appears with all strings, but the one<br />
about Stop for Maintenance is printed only before the relevant string.</p>
<p>partial<br />
This keyword tells po2debconf to keep translated strings even if all strings have not been translated.  Please use with caution, this keyword has been introduced<br />
for very specific purposes.</p>
<p><strong>GIVING NOTICES TO TRANSLATORS BEFORE UPLOADING</strong></p>
<p>Usually translators notice on the status web pages (see below) that translations are outdated, and send patches which will be included in future uploads.  But devel‐<br />
opers are encouraged to send outdated files to translators before an upload, for instance one week in advance.  A dedicated tool, podebconf-report-po, has been<br />
written for this purpose.  Do not hesitate to abuse it!</p>
<p><strong>CAVEATS</strong><br />
· &#8220;Debconf&#8221; 1.2.0 recognizes fields in the form Name-lang.encoding, e.g.  &#8220;Description-de.ISO-8859-1&#8243; or &#8220;Choices-ru.KOI8-R&#8221;.  By default po2debconf writes templates<br />
files in that new format.  Older &#8220;debconf&#8221; will ignore these fields, and English text is displayed.  See po2debconf(1) to know how to change encoding and output<br />
format.</p>
<p>· A given English string may have only one unique translation in a given language.  It is impossible to give two different translations, depending on the context.<br />
To solve this issue, you have to add special markups to the different occurrences of a given string to make them different.  (These markers will only be visible to<br />
translators, and they will be removed from the string before being displayed to user)</p>
<p>Such markers must be added to the end of the strings to translate, they must start with &#8220;[ " (a left bracket followed by a space) and end with "]&#8221; (right bracket),<br />
and may contain any character but brackets or new lines. For example &#8220;[ blahblah]&#8221; is a valid marker while &#8220;[ bla[bla]bla]&#8221; isn’t. For Perl regexp addicts, the<br />
markers are recognized (and removed) using this rule:</p>
<p>$msg =~ s/\[\s[^\[\]]*\]$//s;</p>
<p>· Spacing is not handled exactly the same way by &#8220;po-debconf&#8221; and &#8220;debconf-utils&#8221;; with the latter, paragraphs are reformatted when updating and merging transla‐<br />
tions, so &#8220;debconf-utils&#8221; is very smart and spaces are not considered as being part of strings when determining fuzzy entries.  (ie, the ones needing translator’s<br />
attention because the original changed)</p>
<p>On the other hand &#8220;po-debconf&#8221; relies on &#8220;gettext&#8221; to detect fuzzy entries, and it does not treat spaces as special characters.  Thus superfluous spaces must be<br />
removed at end of lines in master templates files, or they will appear in PO and POT files.</p>
<p>For the same reason, debconf-gettextize can mark fuzzy text because of mismatch with space characters, and translators have to manually unfuzzy such strings.  This<br />
only happens once when converting templates to &#8220;po-debconf&#8221; format, unless you randomly change spaces in master templates files, which will be painful for transla‐<br />
tors.</p>
<p>· Normally the Default: field must not be translated when template type is Select or Multiselect. Under rare circumstances (e.g. when selecting the default language<br />
for an application) localized values may be meaningful.</p>
<p>The localized value must not be translated, but chosen from the English values listed in the Choices field.  The best way to achieve this goal is to insert a com‐<br />
ment in your templates file which will be copied into PO files.</p>
<p>Template: geneweb/lang<br />
Type: select<br />
__Choices: Danish (da), Dutch (nl), English (en), Esperanto (eo)<br />
#  You must NOT translate this string, but you can change its value.<br />
#  The comment between brackets is used to distinguish this msgid<br />
#  from the one in the Choices list; you do not have to worry about<br />
#  them, and have to simply choose a msgstr among the English values<br />
#  listed in the Choices field above, e.g. msgstr &#8220;Dutch (nl)&#8221;<br />
_Default: English (en)[ default language]<br />
_Description: Geneweb default language<br />
The default value also apears in the Choices field, and both have different translations: the former is an untranslated value chosen among Choices values, whereas<br />
the latter is a normal translation.  As &#8220;gettext&#8221; cannot hae two different translations for the same msgid, both msgids must be different by using bracketed com‐<br />
ments as described in a previous subsection.</p>
<p>Prior to &#8220;po-debconf&#8221; 0.8.0, such comments were not available and maintainers had to replace the _Default: field by _DefaultChoice: in order to highlight such<br />
fields in PO files:</p>
<p>#. DefaultChoice<br />
msgid &#8220;&#8221;<br />
&#8220;English[ default: do not translate bracketed material, put your "<br />
"own language here but UNTRANSLATED.  If it is not in the list, "<br />
"put English (without bracketed material)]&#8221;<br />
msgstr &#8220;&#8221;<br />
&#8220;Swedish&#8221;</p>
<p>Plain comments in templates files are less error prone and are encouraged.</p>
<p><strong>STATUS WEB PAGES</strong><br />
Statistics for &#8220;po-debconf&#8221; translations are available at &lt;http://www.debian.org/intl/l10n/po-debconf/&gt; (or from mirrors); they are automatically updated when new<br />
packages are uploaded.  Only packages shipping debian/po/templates.pot and debian/po/POTFILES.in files are considered, so you should make sure your source package do<br />
provide them.</p>
<p>Translators can grab PO and POT files from there, but they must always get in touch with the previous translator (her mail address can be found in the PO file)<br />
and/or their fellow translators on debian-l10n-&lt;language&gt;@lists.debian.org (if such a list does exist) to make sure that noone is currently working on the same<br />
translation, and read current bugreports against the package they are going to translate to see if a translation has already been reported.</p>
<p>After translating these files, they should submit their work to the maintainer as bug report of severity minor with the patch tag.</p>
<p><strong>SEE ALSO</strong><br />
debconf-gettextize(1), debconf-updatepo(1), dh_installdebconf(1), podebconf-report-po(1).  po2debconf(1).</p>
<p><strong>AUTHORS</strong><br />
Martin Quinson &lt;Martin.Quinson@ens-lyon.fr&gt;<br />
Denis Barbier &lt;barbier@linuxfr.org&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vangoor.eu/2009/03/po-debconf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>debconf-devel manpage</title>
		<link>http://www.vangoor.eu/2009/02/debconf-devel-manpage/</link>
		<comments>http://www.vangoor.eu/2009/02/debconf-devel-manpage/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 12:24:43 +0000</pubDate>
		<dc:creator>enrico</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Howto]]></category>
		<category><![CDATA[man]]></category>

		<guid isPermaLink="false">http://www.vangoor.eu/?p=14</guid>
		<description><![CDATA[This is a guide for developing packages that use debconf. This manual assumes that you are familiar with debconf as a user, and are familiar with the basics of debian package construction. This manual begins by explaining two new files that are added to debian packages that use debconf. Then it explains how the debconf protocol works, and points you at some libraries that will let your programs speak the protocol. It discusses other maintainer scripts that debconf is typically used in: the postinst and postrm scripts. Then moves on to more advanced topics like shared debconf templates, debugging, and some common techniques and pitfalls of programming with debconf. It closes with a discussion of debconf's current shortcomings.  ]]></description>
			<content:encoded><![CDATA[<p>DEBCONF-DEVEL<br />
Section: Environments, Tables, and Troff Macros (7)<br />
Index Return to Main Contents<br />
NAME<br />
debconf &#8211; developers guide<br />
<strong>DESCRIPTION</strong><br />
This is a guide for developing packages that use debconf. This manual assumes that you are familiar with debconf as a user, and are familiar with the basics of debian package construction. This manual begins by explaining two new files that are added to debian packages that use debconf. Then it explains how the debconf protocol works, and points you at some libraries that will let your programs speak the protocol. It discusses other maintainer scripts that debconf is typically used in: the postinst and postrm scripts. Then moves on to more advanced topics like shared debconf templates, debugging, and some common techniques and pitfalls of programming with debconf. It closes with a discussion of debconf&#8217;s current shortcomings.</p>
<p><span id="more-14"></span><br />
<strong>THE CONFIG SCRIPT</strong><br />
Debconf adds an additional maintainer script, the config script, to the set of maintainer scripts that can be in debian packages (the postinst, preinst, postrm, and prerm). The config script is responsible for asking any questions necessary to configure the package. Note: It is a little confusing that dpkg refers to running a package&#8217;s postinst script as &#8220;configuring&#8221; the package, since a package that uses debconf is often fully pre-configured, by its config script, before the postinst ever runs. Oh well. Like the postinst, the config script is passed two parameters when it is run. The first tells what action is being performed, and the second is the version of the package that is currently installed. So, like in a postinst, you can use dpkg &#8211;compare-versions on $2 to make some behavior happen only on upgrade from a particular version of a package, and things like that. The config script can be run in one of three ways:</p>
<ol>
<li> If a package is pre-configured, with dpkg-preconfigure, its config script is run, and is passed the parameters &#8220;configure&#8221;, and installed-version.</li>
<li>When a package&#8217;s postinst is run, debconf will try to run the config script then too, and it will be passed the same parameters it was passed when it is pre-configured. This is necessary because the package might not have been pre-configured, and the config script still needs to get a chance to run. See HACKS for details.</li>
<li>If a package is reconfigured, with dpkg-reconfigure, its config script it run, and is passed the parameters &#8220;reconfigure&#8221; and installed-version. Note that since a typical package install or upgrade using apt runs steps 1 and 2, the config script will typically be run twice. It should do nothing the second time (to ask questions twice in a row is annoying), and it should definitely be idempotent. Luckily, debconf avoids repeating questions by default, so this is generally easy to accomplish. Note that the config script is run before the package is unpacked. It should only use commands that are in essential packages. The only dependency of your package that is guaranteed to be met when its config script is run is a dependency (possibly versioned) on debconf itself. The config script should not need to modify the filesystem at all. It just examines the state of the system, and asks questions, and debconf stores the answers to be acted on later by the postinst script. Conversely, the postinst script should almost never use debconf to ask questions, but should instead act on the answers to questions asked by the config script.</li>
</ol>
<p><strong>THE TEMPLATES FILE</strong><br />
A package that uses debconf probably wants to ask some questions. These questions are stored, in template form, in the templates file. Like the config script, the templates file is put in the control.tar.gz section of a deb. Its format is similar to a debian control file; a set of stanzas separated by blank lines, with each stanza having a RFC822-like form:<br />
Template: foo/bar<br />
Type: string<br />
Default: foo<br />
Description: This is a sample string question.<br />
This is its extended description.<br />
.<br />
Notice that:</p>
<ul>
<li> Like in a debian package description, a dot on its own line sets off a new paragraph.</li>
<li> Most text is word-wrapped, but doubly-indented text is left alone, so you can use it for lists of items, like this list. Be careful, since it is not word-wrapped, if it&#8217;s too wide it will look bad. Using it for short itemsis best (so this is a bad example).</li>
</ul>
<p>Template: foo/baz<br />
Type: boolean<br />
Description: Clear enough, no?<br />
This is another question, of boolean type. For some real-life examples of templates files, see /var/lib/dpkg/info/debconf.templates, and other .templates files in that directory. Let&#8217;s look at each of the fields in turn..</p>
<p><em>Template</em><br />
The name of the template, in the &#8216;Template&#8217; field, is generally prefixed with the name of the package. After that the namespace is wide open; you can use a simple flat layout like the one above, or set up &#8220;subdirectories&#8221; containing related questions.<br />
<em>Type</em><br />
The type of the template determines what kind of widget is displayed to the user. The currently supported types are:</p>
<p style="padding-left: 30px;"><em>string</em><br />
Results in a free-form input field that the user can type any string into.<br />
<em>password</em><br />
Prompts the user for a password. Use this with caution; be aware that the password the user enters will be written to debconf&#8217;s database. You should probably clean that value out of the database as soon as is possible.<br />
<em>boolean</em><br />
A true/false choice.<br />
<em>select</em><br />
A choice between one of a number of values. The choices must be specified in a field named &#8216;Choices&#8217;. Separate the possible values with commas and spaces, like this:</p>
<p style="padding-left: 30px;">Choices: yes, no, maybe</p>
<p style="padding-left: 30px;"><em>multiselect</em><br />
Like the select data type, except the user can choose any number of items from the choices list (or chose none of them).<br />
<em>note</em><br />
Rather than being a question per se, this datatype indicates a note that can be displayed to the user. It should be used only for important notes that the user really should see, since debconf will go to great pains to make sure the user sees it; halting the install for them to press a key, and even mailing the note to them in some cases. It&#8217;s best to use these only for warning about very serious problems.<br />
<em>text</em><br />
This datatype can be used for fragments of text, such as labels, that can be used for cosmetic reasons in the displays of some frontends. Other frontends will not use it at all. There is no point in using this datatype yet, since no frontends support it well. It may even be removed in the future.<br />
title<br />
This datatype is used for titles, to be set with the SETTITLE command.</p>
<p><em>Default</em></p>
<p>The &#8216;Default&#8217; field tells debconf what the default value should be. For multiselect, it can be a list of choices, separated by commas and spaces, similar to the &#8216;Choices&#8217; field. For select, it should be one of the choices. For boolean, it is &#8220;true&#8221; or &#8220;false&#8221;, while it can be anything for a string, and it is ignored for passwords. Don&#8217;t make the mistake of thinking that the default field contains the &#8220;value&#8221; of the question, or that it can be used to change the value of the question. It does not, and cannot, it just provides a default value for the first time the question is displayed. To provide a default that changes on the fly, you&#8217;d have to use the SET command to change the value of a question.</p>
<p>Description</p>
<p>The &#8216;Description&#8217; field, like the description of a Debian package, has two parts: A short description and an extended description. Note that some debconf frontends don&#8217;t displays the long description, or might only display it if the user asks for help. So the short description should be able to stand on its own. If you can&#8217;t think up a long description, then first, think some more. Post to debian-devel. Ask for help. Take a writing class! That extended description is important. If after all that you still can&#8217;t come up with anything, leave it blank. There is no point in duplicating the short description. Text in the extended description will be word-wrapped, unless it is prefixed by additional whitespace (beyond the one required space). You can break it up into separate paragraphs by putting &#8221; .&#8221; on a line by itself between them.</p>
<p><strong>QUESTIONS</strong><br />
A question is an instantiated template. By asking debconf to display a question, your config script can interact with the user. When debconf loads a templates file (this happens whenever a config or postinst script is run), it automatically instantiates a question from each template. It is actually possible to instantiate several independent questions from the same template (using the REGISTER command), but that is rarely necessary. Templates are static data that comes from the templates file, while questions are used to store dynamic data, like the current value of the question, whether a user has seen a question, and so on. Keep the distinction between a template and a question in mind, but don&#8217;t worry too much about it.<br />
<strong>SHARED TEMPLATES</strong><br />
It&#8217;s actually possible to have a template and a question that are shared among a set of packages. All the packages have to provide an identical copy of the template in their templates files. This can be useful if a bunch of packages need to ask the same question, and you only want to bother the user with it once. Shared templates are generally put in the shared/ pseudo-directory in the debconf template namespace.<br />
<strong>THE DEBCONF PROTOCOL</strong><br />
Config scripts communicate with debconf using the debconf protocol. This is a simple line-oriented protocol, similar to common internet protocols such as SMTP. The config script sends debconf a command by writing the command to standard output. Then it can read debconf&#8217;s reply from standard input. Debconf&#8217;s reply can be broken down into two parts: A numeric result code (the first word of the reply), and an optional extended result code (the remainder of the reply). The numeric code uses 0 to indicate success, and other numbers to indicate various kinds of failure. For full details, see the table in Debian policy&#8217;s debconf specification document. The extended return code is genrally free form and unspecified, so you should generally ignore it, and should certianly not try to parse it in a program to work out what debconf is doing. The exception is commands like GET, that cause a value to be returned in the extended return code. Generally you&#8217;ll want to use a language-specific library that handles the nuts and bolts of setting up these connections to debconf and communicating with it. For now, here are the commands in the protocol. This is not the definitive definition, see Debian policy&#8217;s debconf specification document for that.</p>
<p>VERSION number<br />
You generally don&#8217;t need to use this command. It exchanges with debconf the protocol version number that is being used. The current protocol version is 2.0, and versions in the 2.x series will be backwards-compatible. You may specify the protocol version number you are speaking and debconf will return the version of the protocol it speaks in the extended result code. If the version you specify is too low, debconf will reply with numeric code 30.<br />
CAPB capabilities<br />
You generally don&#8217;t need to use this command. It exchanges with debconf a list of supported capabilities. Capabilities that both you and debconf support will be used, and debconf will reply with all the capabilities it supports.<br />
TITLE string<br />
This sets the title debconf displays to the user. You rarely need to use this commands since debconf can automatically generate a title based on your package&#8217;s name.<br />
SETTITLE question<br />
This sets the title to the short description of the template for the specified question. The template should be of type title. The advantage this has over the TITLE command is that it allows for titles to be stored in the same place as the rest of the debconf questions, and allows them to be translated.<br />
INPUT priority question</p>
<p>Ask debconf to prepare to display a question to the user. The question is not actually displayed until a GO command is issued; this lets several INPUT commands be given in series, to build up a set of questions, which might all be asked on a single screen. The priority field tells debconf how important it is that this question be shown to the user. The priority values are:</p>
<p>low<br />
Very trivial items that have defaults that will work in the vast majority of cases; only control freaks see these.<br />
medium<br />
Normal items that have reasonable defaults.<br />
high<br />
Items that don&#8217;t have a reasonable default.<br />
critical<br />
Items that will probably break the system without user intervention. Debconf decides if the question is actually displayed, based on its priority, and whether the user has seen it before, and which frontend is being used. If the question will not be displayed, debconf replies with code 30.</p>
<p>GO</p>
<p>Tells debconf to display the accumulated set of questions (from INPUT commands) to the user. If the backup capability is supported and the user indicates they want to back up a step, debconf replies with code 30.</p>
<p>CLEAR<br />
Clears the accumulated set of questions (from INPUT commands) without displaying them.<br />
BEGINBLOCK<br />
ENDBLOCK<br />
Some debconf frontends can display a number of question to the user at once. Maybe in the future a frontend will even be able to group these questions into blocks on screen. BEGINBLOCK and ENDBLOCK can be placed around a set of INPUT commands to indicate blocks of questions (and blocks can even be nested). Since no debconf frontend is so sophisticated yet, these commands are ignored for now.<br />
STOP<br />
This command tells debconf that you&#8217;re done talking to it. Often debconf can detect termination of your program and this command is not necessary.<br />
GET question<br />
After using INPUT and GO to display a question, you can use this command to get the value the user entered. The value is returned in the extended result code.<br />
SET question value<br />
This sets the value of a question, and it can be used to override the default value with something your program calculates on the fly.<br />
RESET question<br />
This resets the question to its default value (as is specified in the &#8216;Default&#8217; field of its template).<br />
SUBST question key value<br />
Questions can have substitutions embedded in their &#8216;Description&#8217; and &#8216;Choices&#8217; fields (use of substitutions in &#8216;Choices&#8217; fields is a bit of a hack though, and better mechanism will eventually be developed). These substitutions look like &#8220;${key}&#8221;. When the question is displayed, the substitutions are replaced with their values. This command can be used to set the value of a substitution. This is useful if you need to display some message to the user that you can&#8217;t hard-code in the templates file.<br />
Do not try to use SUBST to change the default value of a question; it won&#8217;t work since there is a SET command explicitely for that purpose.<br />
FGET question flag<br />
Questions can have flags associated with them. The flags can have a value of &#8220;true&#8221; or &#8220;false&#8221;. This command returns the value of a flag.<br />
FSET question flag value</p>
<p>This sets the value of a question&#8217;s flag. The value must be either &#8220;true&#8221; or &#8220;false&#8221;. One common flag is the &#8220;seen&#8221; flag. It is normally only set if a user already seen a question. Debconf usually only displays questions to users if they have the seen flag set to &#8220;false&#8221; (or if it is reconfiguring a package). Sometimes you want the user to see a question again &#8212; in these cases you can set the seen flag to false to force the debconf to redisplay it.</p>
<p>METAGET question field<br />
This returns the value of any field of a question&#8217;s associated template (the Description, for example).<br />
REGISTER template question<br />
This creates a new question that is bound to a template. By default each template has an associated question with the same name. However, any number of questions can really be associated with a template, and this lets you create more such questions.<br />
UNREGISTER question<br />
This removes a question from the database.<br />
PURGE<br />
Call this in your postrm when your package is purged. It removes all of your package&#8217;s questions from debconf&#8217;s database. Here is a simple example of the debconf protocol in action.<br />
INPUT medium debconf/frontend<br />
30 question skipped<br />
FSET debconf/frontend seen false<br />
0 false<br />
INPUT high debconf/frontend<br />
0 question will be asked<br />
GO<br />
[ Here debconf displays a question to the user. ]<br />
0 ok<br />
GET no/such/question<br />
10 no/such/question doesn&#8217;t exist<br />
GET debconf/frontend<br />
0 Dialog</p>
<p><strong>LIBRARIES</strong><br />
Setting things up so you can talk to debconf, and speaking the debconf protocol by hand is a little too much work, so some thin libraries exist to relieve this minor drudgery. For shell programming, there is the /usr/share/debconf/confmodule library, which you can source at the top of a shell script, and talk to debconf in a fairly natural way, using lower-case versions of the debconf protocol commands, that are prefixed with &#8220;db_&#8221; (ie, &#8220;db_input&#8221; and &#8220;db_go&#8221;). For details, see confmodule(3). Perl programmers can use the Debconf::Client::ConfModule(3) perl module, and python programmers can use the debconf python module. The rest of this manual will use the /usr/share/debconf/confmodule library in example shell scripts. Here is an example config script using that library, that just asks a question:<br />
#!/bin/sh<br />
set -e<br />
. /usr/share/debconf/confmodule<br />
db_set mypackage/reboot-now false<br />
db_input high mypackage/reboot-now || true<br />
db_go || true Notice the uses of &#8220;|| true&#8221; to prevent the script from dying if debconf decides it can&#8217;t display a question, or the user tries to back up. In those situations, debconf returns a non-zero exit code, and since this shell script is set -e, an untrapped exit code would make it abort. And here is a corresponding postinst script, that uses the user&#8217;s answer to the question to see if the system should be rebooted (a rather absurd example..):<br />
#!/bin/sh<br />
set -e<br />
. /usr/share/debconf/confmodule<br />
db_get mypackage/reboot-now<br />
if [ "$RET" = true ]; then<br />
shutdown -r now</p>
<p>fi Notice the use of the $RET variable to get at the extended return code from the GET command, which holds the user&#8217;s answer to the question.<br />
<strong>THE POSTINST SCRIPT</strong><br />
The last section had an example of a postinst script that uses debconf to get the value of a question, and act on it. Here are some things to keep in mind when writing postinst scripts that use debconf:</p>
<p>*<br />
Avoid asking questions in the postinst. Instead, the config script should ask questions using debconf, so that pre-configuration will work.<br />
*<br />
Always source /usr/share/debconf/confmodule at the top of your postinst, even if you won&#8217;t be running any db_* commands in it. This is required to make sure the config script gets a chance to run (see HACKS for details).<br />
*<br />
Avoid outputting anything to stdout in your postinst, since that can confuse debconf, and postinst should not be verbose anyway. Output to stderr is ok, if you must.<br />
*<br />
If your postinst launches a daemon, make sure you tell debconf to STOP at the end, since debconf can become a little confused about when your postinst is done otherwise.<br />
*<br />
Make your postinst script accept a first parameter of &#8220;reconfigure&#8221;. It can treat it just like &#8220;configure&#8221;. This will be used in a later version of debconf to let postinsts know when they are reconfigured.</p>
<p><strong>OTHER SCRIPTS</strong><br />
Besides the config script and postinst, you can use debconf in any of the other maintainer scripts. Most commonly, you&#8217;ll be using debconf in your postrm, to call the PURGE command when your package is removed, to clean out its entries in the debconf database. (This is automatically set up for you by dh_installdebconf(1), by the way. A more involved use of debconf would be if you want to use it in the postrm when your package is purged, to ask a question about deleting something. Or maybe you find you need to use it in the preinst or prerm for some reason. All of these uses will work, though they&#8217;ll probably involve asking questions and acting on the answers in the same program, rather than separating the two activities as is done in the config and postinst scripts. Note that if your package&#8217;s sole use of debconf is in the postrm, you should make your package&#8217;s postinst sources /usr/share/debconf/confmodule, to give debconf a chance to load up your templates file into its database. Then the templates will be available when your package is being purged. You can also use debconf in other, stand alone programs. The issue to watch out for here is that debconf is not intended to be, and must not be used as a registry. This is unix after all, and programs are configured by files in /etc, not by some nebulous debconf database (that is only a cache anyway and might get blown away). So think long and hard before using debconf in a standalone program. There are times when it can make sense, as in the apt-setup program which uses debconf to prompt the user in a manner consistent with the rest of the debian install process, and immediately acts on their answers to set up apt&#8217;s sources.list.<br />
<strong>LOCALIZATION</strong><br />
Debconf supports localization of templates files. This is accomplished by adding more fields, with translated text in them. Any of the fields can be translated. For example, you might want to translate the description into Spanish. Just make a field named &#8216;Description-es&#8217; that holds the translation. If a translated field is not available, debconf falls back to the normal English field. Besides the &#8216;Description&#8217; field, you should translate the &#8216;Choices&#8217; field of a select or multiselect template. Be sure to list the translated choices in the same order as they appear in the main &#8216;Choices&#8217; field. You do not need to translate the &#8216;Default&#8217; field of a select of multiselect question, and the value of the question will be automatically returned in English. You will find it easier to manage translations if you keep them in separate files; one file per translation. In the past, the debconf-getlang(1) and debconf-mergetemplate(1) programs were used to manage debian/template.ll files. This has been supsesceded by the po-debconf package, which lets you deal with debconf translations in .po files, just like any other translations. Your translators will thank you for using this new improved mechanism. For the details on po-debconf, see its README file. If you&#8217;re using debhelper, converting to po-debconf is as simple as running the debconf-gettextize(1) command once, and adding a Build-Dependency on po-debconf and on debhelper (&gt;= 4.1.13).<br />
<strong>PUTTING IT ALL TOGETHER</strong><br />
So you have a config script, a templates file, a postinst script that uses debconf, and so on. Putting these pieces together into a debian package isn&#8217;t hard. You can do it by hand, or can use dh_installdebconf(1) which will merge your translated templates, copy the files into the right places for you, and can even generate the call to PURGE that should go in your postrm script. Make sure that your package depends on debconf (&gt;= 0.5), since earlier versions were not compatible with everything described in this manual. And you&#8217;re done. Well, except for testing, debugging, and actually using debconf for more interesting things than asking a few basic questions. For that, read on..<br />
<strong>DEBUGGING</strong><br />
So you have a package that&#8217;s supposed to use debconf, but it doesn&#8217;t quite work. Maybe debconf is just not asking that question you set up. Or maybe something weirder is happening; it spins forever in some kind of loop, or worse. Luckily, debconf has plenty of debugging facilities.</p>
<p>DEBCONF_DEBUG</p>
<p>The first thing to reach for is the DEBCONF_DEBUG environment variable. If you set and export DEBCONF_DEBUG=developer, debconf will output to stderr a dump of the debconf protocol as your program runs. It&#8217;ll look something like this &#8212; the typo is made clear:<br />
debconf (developer): &lt;&#8211; input high debconf/frontand<br />
debconf (developer): &#8211;&gt; 10 &#8220;debconf/frontand&#8221; doesn&#8217;t exist<br />
debconf (developer): &lt;&#8211; go<br />
debconf (developer): &#8211;&gt; 0 ok It&#8217;s rather useful to use debconf&#8217;s readline frontend when you&#8217;re debugging (in the author&#8217;s opinion), as the questions don&#8217;t get in the way, and all the debugging output is easily preserved and logged.</p>
<p>debconf-communicate<br />
Another useful tool is the debconf-communicate(1) program. Fire it up and you can speak the raw debconf protocol to debconf, interactively. This is a great way to try stuff out on the fly.<br />
debconf-show<br />
If a user is reporting a problem, debconf-show(1) can be used to dump out all the questions owned by your package, displaying their values and whether the user has seen them.<br />
.debconfrc</p>
<p>To avoid the often tedious build/install/debug cycle, it can be useful to load up your templates with debconf-loadtemplate(1) and run your config script by hand with the debconf(1) command. However, you still have to do that as root, right? Not so good. And ideally you&#8217;d like to be able to see what a fresh installation of your package looks like, with a clean debconf database. It turns out that if you set up a ~/.debconfrc file for a normal user, pointing at a personal config.dat and template.dat for the user, you can load up templates and run config scripts all you like, without any root access. If you want to start over with a clean database, just blow away the *.dat files. For details about setting this up, see debconf.conf(5), and note that /etc/debconf.conf makes a good template for a personal ~/.debconfrc file.</p>
<p><strong>ADVANCED PROGRAMING WITH DEBCONF</strong></p>
<p>Config file handling<br />
Many of you seem to want to use debconf to help manage config files that are part of your package. Perhaps there is no good default to ship in a conffile, and so you want to use debconf to prompt the user, and write out a config file based on their answers. That seems easy enough to do, but then you consider upgrades, and what to do when someone modifies the config file you generate, and dpkg-reconfigure, and &#8230; There are a lot of ways to do this, and most of them are wrong, and will often earn you annoyed bug reports. Here is one right way to do it. It assumes that your config file is really just a series of shell variables being set, with comments in between, and so you can just source the file to &#8220;load&#8221; it. If you have a more complicated format, reading (and writing) it becomes a bit trickier. Your config script will look something like this:<br />
#!/bin/sh<br />
CONFIGFILE=/etc/foo.conf<br />
set -e<br />
. /usr/share/debconf/confmodule</p>
<p># Load config file, if it exists.<br />
if [ -e $CONFIGFILE ]; then<br />
. $CONFIGFILE || true</p>
<p># Store values from config file into</p>
<p># debconf db.</p>
<p>db_set mypackage/foo FOO</p>
<p>db_set mypackage/bar BAR</p>
<p>fi</p>
<p># Ask questions.<br />
db_input medium mypackage/foo || true<br />
db_input medium mypackage/bar || true<br />
db_go || true And the postinst will look something like this:<br />
#!/bin/sh<br />
CONFIGFILE=/etc/foo.conf<br />
set -e<br />
. /usr/share/debconf/confmodule</p>
<p># Generate config file, if it doesn&#8217;t exist.<br />
# An alternative is to copy in a template<br />
# file from elsewhere.<br />
if [ ! -e $CONFIGFILE ]; then<br />
echo &#8220;# Config file for my package&#8221; &gt; $CONFIGFILE</p>
<p>echo &#8220;FOO=&#8221; &gt;&gt; $CONFIGFILE</p>
<p>a      echo &#8220;BAR=&#8221; &gt;&gt; $CONFIGFILE</p>
<p>fi</p>
<p># Substitute in the values from the debconf db.<br />
# There are obvious optimizations possible here.<br />
# The cp before the sed ensures we do not mess up<br />
# the config file&#8217;s ownership and permissions.<br />
db_get mypackage/foo<br />
FOO=&#8221;$RET&#8221;<br />
db_get mypackage/bar<br />
BAR=&#8221;$RET&#8221;<br />
cp -a -f $CONFIGFILE $CONFIGFILE.tmp</p>
<p># If the admin deleted or commented some variables but then set<br />
# them via debconf, (re-)add them to the conffile.<br />
test -z &#8220;$FOO&#8221; || grep -Eq &#8216;^ *FOO=&#8217; || echo &#8220;FOO=&#8221; &gt;&gt; $CONFIGFILE<br />
test -z &#8220;$BAR&#8221; || grep -Eq &#8216;^ *BAR=&#8217; || echo &#8220;BAR=&#8221; &gt;&gt; $CONFIGFILE</p>
<p>sed -e &#8220;s/^ *FOO=.*/FOO=&#8221;$FOO&#8221;/&#8221;<br />
-e &#8220;s/^ *BAR=.*/BAR=&#8221;$BAR&#8221;/&#8221;<br />
&lt; $CONFIGFILE &gt; $CONFIGFILE.tmp<br />
mv -f $CONFIGFILE.tmp $CONFIGFILE Consider how these two scripts handle all the cases. On fresh installs the questions are asked by the config script, and a new config file generated by the postinst. On upgrades and reconfigures, the config file is read in, and the values in it are used to change the values in the debconf database, so the admin&#8217;s manual changes are not lost. The questions are asked again (and may or may not be displayed). Then the postinst substitutes the values back into the config file, leaving the rest of it unchanged.<br />
Letting the user back up<br />
Few things are more frustrating when using a system like debconf than being asked a question, and answering it, then moving on to another screen with a new question on it, and realizing that hey, you made a mistake, with that last question, and you want to go back to it, and discovering that you can&#8217;t. Since debconf is driven by your config script, it can&#8217;t jump back to a previous question on its own but with a little help from you, it can accomplish this feat. The first step is to make your config script let debconf know it is capable of handling the user pressing a back button. You use the CAPB command to do this, passing backup as a parameter. Then after each GO command, you must test to see if the user asked to back up (debconf returns a code of 30), and if so jump back to the previous question. There are several ways to write the control structures of your program so it can jump back to previous questions when necessary. You can write goto-laden spaghetti code. Or you can create several functions and use recursion. But perhaps the cleanest and easiest way is to construct a state machine. Here is a skeleton of a state machine that you can fill out and expand.<br />
#!/bin/sh<br />
set -e<br />
. /usr/share/debconf/confmodule<br />
db_capb backup</p>
<p>STATE=1<br />
while true; do<br />
case &#8220;$STATE&#8221; in</p>
<p>1)</p>
<p># Two unrelated questions.</p>
<p>db_input medium my/question || true</p>
<p>db_input medium my/other_question || true</p>
<p>;;</p>
<p>2)</p>
<p># Only ask this question if the</p>
<p># first question was answered in</p>
<p># the affirmative.</p>
<p>db_get my/question</p>
<p>if [ "$RET" = "false" ]; then</p>
<p>db_input medium my/dep_question || true</p>
<p>fi</p>
<p>;;</p>
<p>*)</p>
<p># The default case catches when $STATE is greater than the</p>
<p># last implemented state, and breaks out of the loop. This</p>
<p># requires that states be numbered consecutively from 1</p>
<p># with no gaps, as the default case will also be entered</p>
<p># if there is a break in the numbering</p>
<p>break # exits the enclosing &#8220;while&#8221; loop<br />
;;</p>
<p>esac</p>
<p>if db_go; then</p>
<p>STATE=$(($STATE + 1))</p>
<p>else</p>
<p>STATE=$(($STATE &#8211; 1))</p>
<p>fi</p>
<p>done</p>
<p>if [ $STATE -eq 1 ]; then<br />
# The user has asked to back up from the first</p>
<p># question. This case is problematical. Regular</p>
<p># dpkg and apt package installation isn&#8217;t capable</p>
<p># of backing up questions between packages as this</p>
<p># is written, so this will exit leaving the package</p>
<p># unconfigured &#8211; probably the best way to handle</p>
<p># the situation.</p>
<p>exit 10</p>
<p>fi Note that if all your config script does is ask a few unrelated questions, then there is no need for the state machine. Just ask them all, and GO; debconf will do its best to present them all in one screen, and the user won&#8217;t need to back up.<br />
Preventing infinite loops<br />
One gotcha with debconf comes up if you have a loop in your config script. Suppose you&#8217;re asking for input and validating it, and looping if it&#8217;s not valid:<br />
ok=&#8221;<br />
do while [ ! "$ok" ];<br />
db_input low foo/bar || true</p>
<p>db_go || true</p>
<p>db_get foo/bar</p>
<p>if [ "$RET" ]; then</p>
<p>ok=1</p>
<p>fi</p>
<p>done This looks ok at first glance. But consider what happens if the value of foo/bar is &#8220;&#8221; when this loop is entered, and the user has their priority set high, or is using a non-interactive frontend, and so they are not really asked for input. The value of foo/bar is not changed by the db_input, and so it fails the test and loops. And loops &#8230; One fix for this is to make sure that before the loop is entered, the value of foo/bar is set to something that will pass the test in the loop. So for example if the default value of foo/bar is &#8220;1&#8243;, then you could RESET foo/bar just before entering the loop. Another fix is to check the return code of the INPUT command. If it is 30 then the user is not being shown the question you asked them, and you should break out of the loop.<br />
Choosing among related packages<br />
Sometimes a set of related packages can be installed, and you want to prompt the user which of the set should be used by default. Examples of such sets are window managers, or ispell dictionary files. While it would be possible for each package in the set to simply prompt, &#8220;Should this package be default?&#8221;, this leads to a lot of repetitive questions if several of the packages are installed. It&#8217;s possible with debconf to present a list of all the packages in the set and allow the user to choose between them. Here&#8217;s how. Make all the packages in the set use a shared template. Something like this:<br />
Template: shared/window-manager<br />
Type: select<br />
Choices: ${choices}<br />
Description: Select the default window manager.<br />
Select the window manager that will be started by<br />
default when X starts. Each package should include a copy of the template. Then it should include some code like this in its config script:<br />
db_metaget shared/window-manager owners<br />
OWNERS=$RET<br />
db_metaget shared/window-manager choices<br />
CHOICES=$RET</p>
<p>if [ "$OWNERS" != "$CHOICES" ]; then<br />
db_subst shared/window-manager choices $OWNERS</p>
<p>db_fset shared/window-manager seen false</p>
<p>fi</p>
<p>db_input medium shared/window-manager || true<br />
db_go || true A bit of an explanation is called for. By the time your config script runs, debconf has already read in all the templates for the packages that are being installed. Since the set of packages share a question, debconf records that fact in the owners field. By a strange coincidence, the format of the owners field is the same as that of the choices field (a comma and space delimited list of values). The METAGET command can be used to get the list of owners and the list of choices. If they are different, then a new package has been installed. So use the SUBST command to change the list of choices to be the same as the list of owners, and ask the question. When a package is removed, you probably want to see if that package is the currently selected choice, and if so, prompt the user to select a different package to replace it. This can be accomplished by adding something like this to the prerm scripts of all related packages (replacing<br />
with the package name):<br />
if [ -e /usr/share/debconf/confmodule ]; then<br />
. /usr/share/debconf/confmodule</p>
<p># I no longer claim this question.</p>
<p>db_unregister shared/window-manager</p>
<p># See if the shared question still exists.</p>
<p>if db_get shared/window-manager; then</p>
<p>db_metaget shared/window-manager owners</p>
<p>db_subst shared/window-manager choices $RET</p>
<p>db_metaget shared/window-manager value</p>
<p>if [ "<br />
" = "$RET" ] ; then</p>
<p>db_fset shared/window-manage seen false</p>
<p>db_input high shared/window-manager || true</p>
<p>db_go || true</p>
<p>fi</p>
<p># Now do whatever the postinst script did</p>
<p># to update the window manager symlink.</p>
<p>fi</p>
<p>fi<br />
<strong>HACKS</strong><br />
Debconf is currently not fully integrated into dpkg (but I want to change this in the future), and so some messy hacks are currently called for. The worst of these involves getting the config script to run. The way that works now is the config script will be run when the package is pre-configured. Then, when the postinst script runs, it starts up debconf again. Debconf notices it is being used by the postinst script, and so it goes off and runs the config script. This can only work if your postinst loads up one of the debconf libraries though, so postinsts always have to take care to do that. We hope to address this later by adding explicit support to dpkg for debconf. The debconf(1) program is a step in this direction. A related hack is getting debconf running when a config script, postinst, or other program that uses it starts up. After all, they expect to be able to talk to debconf right away. The way this is accomplished for now is that when such a script loads a debconf library (like /usr/share/debconf/confmodule), and debconf is not already running, it is started up, and a new copy of the script is re-execed. The only noticeable result is that you need to put the line that loads a debconf library at the very top of the script, or weird things will happen. We hope to address this later by changing how debconf is invoked, and turning it into something more like a transient daemon. It&#8217;s rather hackish how debconf figures out what templates files to load, and when it loads them. When the config, preinst, and postinst scripts invoke debconf, it will automatically figure out where the templates file is, and load it. Standalone programs that use debconf will cause debconf to look for templates files in /usr/share/debconf/progname.templates. And if a postrm wants to use debconf at purge time, the templates won&#8217;t be available unless debconf had a chance to load them in its postinst. This is messy, but rather unavoidable. In the future some of these programs may be able to use debconf-loadtemplate by hand though. /usr/share/debconf/confmodule&#8217;s historic behavior of playing with file descriptors and setting up a fd #3 that talks to debconf, can cause all sorts of trouble when a postinst runs a daemon, since the daemon ends up talking to debconf, and debconf can&#8217;t figure out when the script terminates. The STOP command can work around this. In the future, we are considering making debconf communication happen over a socket or some other mechanism than stdio. Debconf sets DEBCONF_RECONFIGURE=1 before running postinst scripts, so a postinst script that needs to avoid some expensive operation when reconfigured can look at that variable. This is a hack because the right thing would be to pass $1 = &#8220;reconfigure&#8221;, but doing so without breaking all the postinsts that use debconf is difficult. The migration plan away from this hack is to encourage people to write postinsts that accept &#8220;reconfigure&#8221;, and once they all do, begin passing that variable.<br />
<strong>SEE ALSO</strong><br />
debconf(7) is the debconf user&#8217;s guide. The debconf specification in debian policy is the canonical definition of the debconf protocol. /usr/share/doc/debian-policy/debconf_specification.txt.gz debconf.conf(5) has much useful information, including some info about the backend database.<br />
<strong>AUTHOR</strong><br />
Joey Hess</p>
<p>Index</p>
<p>NAME<br />
DESCRIPTION<br />
THE CONFIG SCRIPT<br />
THE TEMPLATES FILE<br />
QUESTIONS<br />
SHARED TEMPLATES<br />
THE DEBCONF PROTOCOL<br />
LIBRARIES<br />
THE POSTINST SCRIPT<br />
OTHER SCRIPTS<br />
LOCALIZATION<br />
PUTTING IT ALL TOGETHER<br />
DEBUGGING<br />
ADVANCED PROGRAMING WITH DEBCONF</p>
<p>Config file handling<br />
Letting the user back up<br />
Preventing infinite loops<br />
Choosing among related packages</p>
<p>HACKS<br />
SEE ALSO<br />
AUTHOR</p>
<p>This document was created by man2html, using the manual pages.<br />
Time: 12:23:17 GMT, February 12, 2009</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vangoor.eu/2009/02/debconf-devel-manpage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PXE boot</title>
		<link>http://www.vangoor.eu/2009/02/pxe-boot/</link>
		<comments>http://www.vangoor.eu/2009/02/pxe-boot/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 20:50:46 +0000</pubDate>
		<dc:creator>enrico</dc:creator>
				<category><![CDATA[Debian]]></category>

		<guid isPermaLink="false">http://www.vangoor.eu/?p=8</guid>
		<description><![CDATA[To provide PXEboot service in your network you need a server basically with only 2 services DHCP and TFTP.
]]></description>
			<content:encoded><![CDATA[<p>To provide PXEboot service in your network you need a server basically with only 2 services DHCP and TFTP.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vangoor.eu/2009/02/pxe-boot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
