I use a certain piece of sofware (Asterisk) which includes in its source tree a nifty little script to automatically download and install all packages it needs from your distro's repositories, including of course Ubuntu. One of these prerequisites (libvpb1) requires a piece of information (the default country phone prefix), so the script becomes not so automatic:
It's innocuous to have this library installed in a system that doesn't run telephony stuff, so you can test it yourself.
My question is: How do I feed the answer non-interactively beforehand so apt-get install (or, rather, dpkg -i) grabs that and uses it as if it had been typed in that ncurses screen?
A generic solution would be better, like, how do I know if any package requires information like this, and how do I set it from a script?
Question linked in comment by @user535733 had the answer; I'll try to generalize the procedure here.
First, install the package interactively and feed the values you need;
Second, run this:
Next time you have to install the package, just feed the output from that to
debconf-get-selections
beforehand:In Ubuntu 20.04,
debconf-get-selections
is in thedebconf-utils
package.