问题描述
在Ubuntu 10.04上运行apt-get -y install <packages ...>
时,我希望apt-get
(或aptitude
,如果这样更容易)在安装其他依赖项时没有提示我(-y
的行为,据我所知)但是没有提示我有关覆盖配置文件,而是假设保留总是存在的(通常是默认的)。不幸的是,--trivial-only
似乎与-y
相反,并且不会影响显示的提示,根据man
页面。
特别是作为samba,nullmailer,localepurge和lighttpd的包auch强迫我与终端交互,即使整个过程是脚本化的并且意味着是non-interactive。
最佳解决方法
你可以使用:
sudo apt-get update
sudo apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade
仅适用于特定包装,例如mypackage1 mypackage2:
sudo apt-get update
sudo apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install mypackage1 mypackage2
资料来源:http://raphaelhertzog.com/2010/09/21/debian-conffile-configuration-file-managed-by-dpkg/
Avoiding the conffile prompt
Every time that dpkg must install a new conffile that you have modified
(and a removed file is only a particular case of a modified file in dpkg’s eyes),
it will stop the upgrade and wait your answer. This can be particularly annoying for
major upgrades. That’s why you can give predefined answers to dpkg with the help
of multiple --force-conf* options:
--force-confold: do not modify the current configuration file, the new version
is installed with a .dpkg-dist suffix. With this option alone, even configuration
files that you have not modified are left untouched. You need to combine it with
--force-confdef to let dpkg overwrite configuration files that you have not modified.
--force-confnew: always install the new version of the configuration file, the
current version is kept in a file with the .dpkg-old suffix.
--force-confdef: ask dpkg to decide alone when it can and prompt otherwise. This
is the default behavior of dpkg and this option is mainly useful in combination with
--force-confold.
--force-confmiss: ask dpkg to install the configuration file if it’s currently
missing (for example because you have removed the file by mistake).
If you use Apt, you can pass options to dpkg with a command-line like this:
$ apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade
You can also make those options permanent by creating /etc/apt/apt.conf.d/local:
Dpkg::Options {
"--force-confdef";
"--force-confold";
}
您可以在http://manpages.ubuntu.com/manpages/xenial/en/man1/dpkg.1.html或man dpkg
的dpkg手册中找到更多信息和更多选项,即查找”confdef”。