Where should I place templates and config file in debian hierarchy
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:
- 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?
- 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
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 :)
I had the same issue that my question was only asked with a dpkg-reconfigure
and not an install dpkg -i
.
My solution was to add a
db_fset package-name/question_name seen false
before
db_input high package-name/question_name || true
db_go