我執行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/
可以在不指定這些選項的情況下執行命令,並且仍然會遵守它們。也就是說,我想刪除:
--option Acquire::Check-Valid-Until=false
從apt-get update
DEBIAN_FRONTEND=noninteractive
和--yes --option Dpkg::Options::="--force-confdef" --option Dpkg::Options::="--force-confold"
從apt-get upgrade
和apt-get dist-upgrade
--yes --force-yes
從apt-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-yes
則apt-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
單獨就足夠了。