I have a problem with postinst script, I have to ask root password for MySQL to create some user for my application. I know, it's bad practice to use db_input in postinst however I really need it. Why this postinst doesn't work when I install my app form repository but works properly when I install it as .deb package?
postinst:
#!/bin/bash -e
. /usr/share/debconf/confmodule
db_input high my_app/mysql_root_password || true
db_go
error:
dpkg: error processing my-app (--configure):
subprocess installed post-installation script returned error exit status 30
configured to not write apport reports
Errors were encountered while processing:
my-app
E: Sub-process /usr/bin/dpkg returned an error code (1)
The difference probably has something to do with how the terminal is set up when your postinst is run; probably apt does something differently from what happens when you run dpkg on its own. Maybe apt-wrapped postinst invocations don't even have a TTY allocated; I'm not sure, offhand.
But I don't think that putting
db_input
in a postinst is even supported, so it may be difficult for you to fix it as is. If you really, really need to ask questions from the postinst script itself, you may be able to debug by setting$DEBCONF_DEBUG
to "developer" in the environment where the debhelper commands run.However, I think a more useful solution will be this: you really should use a
debian/config
script fordb_input
, as is recommended. What is stopping you?