ubuntu - apt-get更新非交互式

kevin.Zhu 发布于:2024-1-21 22:34  有 71 人浏览,获得评论 0 条  

我正在尝试进行完全非交互的更新。(在 ubuntu 14.04.3 LTS 上) 我认为使用这种类型的命令会很容易:

export DEBIAN_FRONTEND=noninteractive
apt-get update && apt-get upgrade -q -y --force-yes && apt-get dist-upgrade -q -y --force-yes 

但是不...我总是有这样的问题:

Configuration file '/etc/cloud/cloud.cfg' ==> Modified (by you or by a script) since installation.
 ==> Package distributor has shipped an updated version.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** cloud.cfg (Y/I/N/O/D/Z) [default=N] ? 

那么你知道我如何自动接受默认值吗?

最佳答案

您需要将一些dpkg 选项传递给您的命令,例如:

export DEBIAN_FRONTEND=noninteractive
apt-get update && 
    apt-get -o Dpkg::Options::="--force-confold" upgrade -q -y --force-yes && apt-get -o Dpkg::Options::="--force-confold" dist-upgrade -q -y --force-yes 

附带说明一下,我建议使用 only dist-upgrade,如果你使用 upgrade,你最终会破坏依赖关系.