3

I have a package, lets call it foo, that has a dependency which is in turn dependent on postfix. I am trying to automate the install of foo by answering the questions using debconf. The requirements for foo is that it has to be able to install and configure everything and must be installed using

sudo apt-get install foo

So something like this wouldn't be acceptable:

DEBIAN_FRONTEND=noninteractive apt-get install -y foo

Also, note that foo is being installed on a fresh install of Ubuntu.

The first thing I tried was this (in my preinst script):

echo "postfix postfix/mailname string your.hostname.com" | debconf-set-selections
echo "postfix postfix/main_mailer_type string 'Internet Site'" | debconf-set-selections

But that didn't work. The questions still appeared in the installation.

Then I tried this:

echo "postfix postfix/mailname string your.hostname.com" | debconf-set-selections
echo "postfix postfix/main_mailer_type string 'Internet Site'" | debconf-set-selections
DEBIAN_FRONTEND=noninteractive apt-get install -y postfix

And this:

echo "postfix postfix/mailname string your.hostname.com" | debconf-set-selections
echo "postfix postfix/main_mailer_type string 'Internet Site'" | debconf-set-selections
DEBIAN_FRONTEND=noninteractive apt-get install -y postfix << _EOT
y
EOT

And then I thought:

What if debconf-utils were put in Pre-Depends? That didn't work.

However, if I do the following (from the command line rather then the preinst script), then the installation works without questions:

sudo apt-get install debconf-utils
echo "postfix postfix/mailname string your.hostname.com" | debconf-set-selections
echo "postfix postfix/main_mailer_type string 'Internet Site'" | debconf-set-selections
sudo apt-get install foo

However, that isn't acceptable for the requirements I've been given.

So now I'm stuck. If anyone can pick out what I'm doing wrong that would be much appreciated as I've searched for a while looking for the answer.

Community
  • 1
  • 1
wc250
  • 129
  • 3
  • 10

1 Answers1

1

It seems weird, you don't need to install debconf-utils to set data for dpkg.

If you want to prevent dialog windows, try to use dpkg options:
--force-confdef(force to keep default option without prompting)
--force-confold (force to keep old conf files)

At the end, it will be something like that:
echo "postfix postfix/mailname string your.hostname.com" | debconf-set-selections
echo "postfix postfix/main_mailer_type string 'Internet Site'" | debconf-set-selections
sudo apt-get install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" foo
I hope, it will help. If not, please inform us here.

antonbormotov
  • 1,821
  • 2
  • 20
  • 32
  • I added that to my preinst (using postfix instead of foo). The dialog windows still appeared. – wc250 Jul 07 '15 at 13:06
  • I even tried something else in the preinst script: 1) source the debconf module 2) using db_set postfix/mailname your.hostname.com This didn't work either. – wc250 Jul 07 '15 at 13:07
  • I see. So, could you please explain, why last example given in question by you, does not meet requirements? – antonbormotov Jul 07 '15 at 15:56