apt-get update非交互式

问题描述 投票:3回答:2

我正在尝试完全非交互式更新。(在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] ?

所以你知道我如何自动接受默认值吗?

ubuntu apt-get
2个回答
4
投票

您需要将一些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

在旁注中,我建议仅使用dist-upgrade,如果使用upgrade,最终会出现破坏的依赖关系。


1
投票

>= Apt 1.1

如果您使用的是Apt 1.1或更高级别的--force-yes has been deprecated,那么您必须使用以--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

注意:使用--force-confold保持旧,并使用--force-confnew保持新的配置。

资料来源:CFE-2360: Make apt_get package module version aware

有关:

© www.soinside.com 2019 - 2024. All rights reserved.