Debconf in Debian Packages
- 3 minsAs part of my GSoC project, I had to find a way to ask users questions and install the packages depending on their given answers, my specific case was to ask the users to select an entry from multiple choices and download an archive from the chosen one, to achieve this, I used debconf.
So what is debconf ?
Debconf is a backend database, with a frontend that talks to it and presents an interface to the user. There can be many different types of frontends, from plain text to a web frontend. The frontend also talks to a special config script in the control section of a Debian package, and it can talk to postinst scripts and other scripts as well, all using a special protocol. These scripts tell the frontend what values they need from the database, and the frontend asks the user questions to get those values if they aren’t set.
Even better, we can make sure that the users get the questions in their own languages by using po-debconf
.
Steps:
- Install
debconf
andpo-debconf
:
- Create
debian/templates
file. An underscore before a field name indicates that this field is translatable. Example:
- Create debian/config file (
packagename/somthing
is the same as indebian/templates
):
- Create the folder
debian/po
- Create the file
debian/po/PORFILES.in
:
- Generate the
debian/po/templates.pot
:
- Add
debconf
andpo-debconf
todebconf/control
as dependenties:
- Get and use the result (in
debian/postinit
for example with the variable$RET
):
- We can purge the database when purging the package with the command
db_purge
command indebian/postrm
, example:
- Finaly, We can add the entry
packagename.postrm.debhelper
to.gitignore
.