使用debconf

时间:2015-07-06 20:50:02

标签: ubuntu installation automation software-packaging debconf

我有一个包,我们称之为 foo ,它具有依赖性,而依赖性依赖于后缀。我试图通过使用debconf回答问题来自动安装 foo foo 的要求是它必须能够安装和配置所有内容,并且必须使用

进行安装。
sudo apt-get install foo

所以这样的事情是不可接受的:

DEBIAN_FRONTEND=noninteractive apt-get install -y foo

另请注意,在全新安装的Ubuntu上安装 foo

我尝试的第一件事就是这个(在我的preinst脚本中):

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

但那并没有奏效。问题仍然出现在安装中。

然后我尝试了这个:

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

而且:

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

然后我想:

如果将debconf-utils置于Pre-Depends中怎么办?那没用。

但是,如果我执行以下操作(从命令行而不是preinst脚本),则安装无问题:

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

但是,对于我已经给出的要求,这是不可接受的。

所以现在我被卡住了。如果有人能够找出我做错的事情,我会非常感激,因为我已经搜索了一段时间寻找答案。

1 个答案:

答案 0 :(得分:1)

看起来很奇怪,你不需要安装debconf-utils来设置dpkg的数据。

如果要阻止对话框窗口,请尝试使用dpkg选项:
--force-confdef(force to keep default option without prompting)
--force-confold (force to keep old conf files)

最后,它会是这样的:
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
我希望,这会有所帮助。如果没有,请在此告知我们。