1

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:

Installing libvpb1

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?

JCCyC
  • 319
  • 2
  • 16
  • 1
    Seems like a duplicate of https://unix.stackexchange.com/questions/96215/feeding-input-values-to-dpkg-reconfigure-in-a-non-interactive-way – user535733 Oct 23 '20 at 23:36
  • 1
    You should be able to use `dpkg-set-selections` - see for example [How can I prevent apt-get/aptitude from showing dialogs during installation?](https://askubuntu.com/questions/339790/how-can-i-prevent-apt-get-aptitude-from-showing-dialogs-during-installation) – steeldriver Oct 23 '20 at 23:41

1 Answers1

3

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:

root@myhost:~# PACKAGE_NAME=libvpb1
root@myhost:~# debconf-get-selections | grep "^${PACKAGE_NAME}[[:blank:]]"
libvpb1 libvpb1/countrycode     string  55
root@myhost:~#

Next time you have to install the package, just feed the output from that to debconf-get-selections beforehand:

root@myhost:~# echo 'libvpb1 libvpb1/countrycode string 55' | sudo debconf-set-selections -v
root@myhost:~# apt-get -y install libvpb1

In Ubuntu 20.04, debconf-get-selections is in the debconf-utils package.

JCCyC
  • 319
  • 2
  • 16