設定檔中的 apt 選項

設定檔中的 apt 選項

我執行apt-get如下:

rm -rf /var/lib/apt/lists/*'
apt-get clean
apt-get --option Acquire::Check-Valid-Until=false update
DEBIAN_FRONTEND=noninteractive apt-get --yes --option Dpkg::Options::="--force-confdef" --option Dpkg::Options::="--force-confold" upgrade
DEBIAN_FRONTEND=noninteractive apt-get --yes --option Dpkg::Options::="--force-confdef" --option Dpkg::Options::="--force-confold" dist-upgrade
apt-get autoremove --yes --force-yes
apt-get clean

我想刪除設定檔中的選項,以便/etc/apt/apt.conf.d/可以在不指定這些選項的情況下執行命令,並且仍然會遵守它們。也就是說,我想刪除:

  1. --option Acquire::Check-Valid-Until=falseapt-get update
  2. DEBIAN_FRONTEND=noninteractive--yes --option Dpkg::Options::="--force-confdef" --option Dpkg::Options::="--force-confold"apt-get upgradeapt-get dist-upgrade
  3. --yes --force-yesapt-get autoremove

雖然我看了手冊頁,我不知道如何正確地做到這一點。

我希望詳細解釋如何實現它。

如果需要,這裡是有關我的系統的一些資訊:

$ cat /etc/*release* | grep -i dist
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.1 LTS"

$ dpkg -l | grep -i apt | head -n 1
ii  apt  1.2.15ubuntu0.2  amd64  commandline package manager

答案1

您可以將--option沒有的部分新增=到文件中:

Acquire::Check-Valid-Until "false";
Dpkg::Options:: "--force-confdef";
Dpkg::Options:: "--force-confold";

至於 和--yes--force-yesapt-get線上說明頁說:

-y, --yes, --assume-yes
   Automatic yes to prompts; assume "yes" as answer to all prompts and
   run non-interactively. If an undesirable situation, such as
   changing a held package, trying to install a unauthenticated
   package or removing an essential package occurs then apt-get will
   abort. Configuration Item: APT::Get::Assume-Yes.

--force-yes
   Force yes; this is a dangerous option that will cause apt to
   continue without prompting if it is doing something potentially
   harmful. It should not be used except in very special situations.
   Using force-yes can potentially destroy your system! Configuration
   Item: APT::Get::force-yes. This is deprecated and replaced by
   --allow-downgrades, --allow-remove-essential,
   --allow-change-held-packages in 1.1.

所以:

APT::Get::Assume-Yes "true";
APT::Get::force-yes "true";

您應該將第二行替換為將APT::Get::allow-downgrades, APT::Get::allow-remove-essential,中的一項或多項APT::Get::allow-change-held-packages設為 true 的行。

DEBIAN_FRONTEND=noninteractive是一個 debconf 設置,應該在debconf.conf.這線上說明頁有例子。

我強烈建議您編寫一個腳本,而不是在設定檔中設定它們。另外,upgrade在 - 之前運行沒有意義dist-upgrade-dist-upgrade單獨就足夠了。

相關內容