1

I am writing a debian binary package for my application (foo). The postinst (post install) script wants to ask the user few questions and get the answers as well. I am trying to achieve this using debconf. But I am not able to see the UI screen, prompting user with questions. I doubt if my config and templates are even called by dpkg. I am using all the instructions as per the link debconf tutorial Could someone please clarify me on the below questions:

  1. I am placing the “config” script and “templates “ file inside /debian/tmp/DEBIAN/ . So is it the correct location in debian hierarchy? Are the names correct?
  2. Are my below scripts correct?

Snippet of control file (only relevant fields I am posting)

Depends: debconf (>= 0.2.17)

Snippet of config file

#!/bin/sh
set -e

#echo "Config being called"

# Source debconf library.
. /usr/share/debconf/confmodule

# Do you like debian?
db_input medium foo/like_debian || true
db_go

# Check their answer.
db_get foo/like_debian
if [ "$RET" = "false" ]; then
    # Poor misguided one..
    db_input high foo/why_debian_is_great || true
    db_go
fi

Snippet of templates file

Template: foo/like_debian
Type: boolean
Description: Do you like Debian?
We'd like to know if you like the Debian GNU/Linux system.

Template: foo/why_debian_is_great
Type: note
Description: Poor misguided one. Why are you installing this package?
Debian is great. As you continue using Debian, we hope you will
discover the error in your ways.

Snippet of preinst:

#!/bin/sh
set -e
#echo "Stage preinst" $1

exit 0

Snippet of postinst:

#!/bin/sh
set -e
#echo "Stage postinst" $1

# Source debconf library.
. /usr/share/debconf/confmodule

db_get foo/like_debian
if [ "$RET" = "false" ]; then
    touch "/home/myhome/ITWORKED"
fi

exit 0

Snippet of prerm:

#!/bin/sh
set -e
#echo "Stage prerm" $1

exit 0

Snippet of postrm:

#!/bin/sh
set -e
#echo "postrm" $1

exit 0

Thanks, -Sandeep

3

I made a blog post about creating your own debian packages at:

http://www.leaseweblabs.com/2013/06/creating-custom-debian-packages/

To save you from some reading, the directory structure should be like this:

  • DEBIAN
    • control (required)
    • templates (optional)
    • preinst (optional, chmod 0755)
    • postinst (optional, chmod 0755)
    • prerm (optional, chmod 0755)
    • postrm (optional, chmod 0755)
  • … (files to be installed at specified location)

Make sure the permissions and locations are like this, and it should work :)

  • thanks, but I have made half progress still. I have ensured the directory structure is correct. What I mean is control, config, templates, preinst, postinst, prerm, postrm are all in just 1 directory, that is "DEBIAN". Secondly all maintainer scripts (preinst, postinst, prerm, postrm) and config have 755 permissions. The templates and control have 644 permissions. What I mean by half progress is, if I run dpkg -i myapp.deb I do not see a UI poping out asking for interactive questions. But if I run dpkg-reconfigure myapp then a UI pops out with the questions. What am I doing wrong? – Sandeep Jul 18 '13 at 9:56
0

I solved the issue by typing

echo PURGE | debconf-communicate <packagename>

This command clears all the selections in the debconf database. I realized that when the selections present in the debconf database, the package installer never executes the input commands in the config file. Therefore, I put the purge command in the postrm file.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.