1

I am having some trouble using debconf for my package. I ask for the mysql pw in the package.config file:

. /usr/share/debconf/confmodule
db_input high mypkg/mysql_root_pw
db_go

Then, in postinst, I ask debconf for the password and write it to a config file:

. /usr/share/debconf/confmodule
db_get mypkg/mysql_root_pw
# write pw to config file

This works when I do dpkg-reconfigure --force mypkg. However, when using apt-get -f install (which I have to do because it says my pkg is broken) it always fails:

Setting up mypkg (1.5.4-3) ...
debconf (developer): frontend started
debconf (developer): frontend running, package name is mypkg
debconf (developer): starting /var/lib/dpkg/info/mypkg.config configure 
debconf (developer): <-- INPUT low mypkg/mysql_root_pw
debconf (developer): --> 30 question skipped
dpkg: error processing mypkg (--configure):
 subprocess installed post-installation script returned error exit status 30
Errors were encountered while processing:
 mypkg

I edited the scripts in /var/lib/dpkg/info/mypkg.postinst and the error occurs on the line where I source the debconf library:

. /usr/share/debconf/confmodule

This is probably because debconf already has the value from the original install and does not show the question again. But how can I skip asking it if I already have it and why does it fail on that line instead of when when I do db_get?

I have search google and can't seem to find much useful info on this.

1 Answer 1

1

So I finally got this working. debconf would always fail when getting the first question in my postinst if debconf already had the value. I finally had the (obvious) idea to check out the postinst and config files of other packages on my system and this is the trick:

In your config

. /usr/share/debconf/confmodule
db_input high mypkg/mysql_root_pw || true
db_go || true

That's it. When I request the values in my postinst debconf is happy. Obviously you need to have a handling for when you don't get any values.

Also I added a db_stop to my postinst, I don't know if it's necessary but I'll add it for the sake of completion.

mypkg.postinst

. /usr/share/debconf/confmodule
db_get mypkg/mysql_root_pw
mysql_root_pw=$RET
db_get mypkg/some_other_value
some_other_value=$RET
db_stop
# do something with the $mysql_root_pw and $some_other_value vars

Hope this helps someone else someday.

Cheers

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .