apt-get更新非交互式

Dav*_*vid 7 ubuntu apt-get

我正在尝试进行完全非交互式的更新。(在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
Run Code Online (Sandbox Code Playgroud)

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

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] ?
Run Code Online (Sandbox Code Playgroud)

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

ken*_*orb 8

>= 1.1

如果您使用的是 Apt 1.1 或更高版本,--force-yes则已弃用,因此您必须使用以 开头的选项--allow,例如--allow-downgrades, --allow-remove-essential, --allow-change-held-packages

所以命令是:

DEBIAN_FRONTEND=noninteractive \
  apt-get \
  -o Dpkg::Options::=--force-confold \
  -o Dpkg::Options::=--force-confdef \
  -y --allow-downgrades --allow-remove-essential --allow-change-held-packages
Run Code Online (Sandbox Code Playgroud)

注意:--force-confold用于保持旧--force-confnew配置和保持新配置。

来源:CFE-2360:使 apt_get 包模块版本感知

有关的:

  • 我认为您在命令中的某个地方缺少“更新”一词? (5认同)

rya*_*uen 5

您需要将一些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
Run Code Online (Sandbox Code Playgroud)

附带说明一下,我建议 使用dist-upgrade,如果使用,最终会导致依赖关系破裂upgrade