我正在执行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
仅此就足够了。