1

I'm trying to make my own debian package to deploy some scripts. I need some parameters from the user, I'm gathering them using debconf.

So I made a DEBIAN subfolder, and put control, templates and config files into it.

Then I build my package with dpkg-deb.

When I install the package with apt install packagename.deb, debconf questions are asked and everything goes well. But when I install with dpkg -i packagename.deb, no questions are asked, and installation fails lacking necessary variables. I also tested to run dpkg-preconfigure packagename.deb, and questions are asked.

Why dpkg doesn't trigger the config script ?

Thanks

Some logs showing there isn't "Preconfiguring" with dpkg :

root@test-deploy:~# dpkg -i /tmp/packagename-6.5.deb 
Selecting previously unselected package packagename.
(Reading database ... 41282 files and directories currently installed.)
Preparing to unpack /tmp/packagename-6.5.deb ...
Unpacking packagename (6.5-1) ...
Setting up packagename (6.5-1) ...

root@test-deploy:~# apt install /tmp/packagename-6.5.deb
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'packagename' instead of '/tmp/packagename-6.5.deb'
The following NEW packages will be installed:
  packagename
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/381 MB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 /tmp/packagename-6.5.deb packagename amd64 6.5-1 [381 MB]
Preconfiguring packages ...
Selecting previously unselected package packagename.
(Reading database ... 41282 files and directories currently installed.)
Preparing to unpack /tmp/packagename-6.5.deb ...
Unpacking packagename (6.5-1) ...`

Just to be sure, I extracted control information from the deb file : it is OK.
root@test-deploy:/tmp# dpkg -e packagename-6.5.deb root@test-deploy:/tmp# ls -l DEBIAN/ total 20 -rwxr-xr-x 1 root root 3337 Aug 21 16:21 config -rw-r--r-- 1 root root 357 Aug 19 11:55 control -rwxr-xr-x 1 root root 293 Aug 13 15:44 postinst -rwxr-xr-x 1 root root 366 Aug 21 15:10 prerm -rw-r--r-- 1 root root 2384 Aug 19 15:39 templates

  • I don't know too much about packaging Debian packages, but man dpkg says: -i [...] 3. Run preinst script, if provided by the package., so I'd assume you need a file preinst just as you have a postinst – Lenniey Aug 21 at 14:44
  • According to debian documentation (debian.org/doc/debian-policy/ch-binary.html#s-maintscriptprompt), config is the right script to ask debconf questions. – mooky Aug 22 at 15:18
1

Finally found why in the HACKS chapter on this page :
https://manpages.debian.org/buster/debconf-doc/debconf-devel.7.en.html

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.

You need to call the debconf library at the beginning of your postinst script, using this code :
. /usr/share/debconf/confmodule

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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