为什么“apt”不再存储下载的软件包?

doa*_*oak 7 linux apt-get apt

我习惯于apt将下载的包存储在 中/var/cache/apt/archives/,但它不再这样做了,我不明白为什么。

恕我直言,配置已相应设置:

# apt-config dump | grep -i cache
Dir::Cache "var/cache/apt";
Dir::Cache::archives "archives/";
Dir::Cache::srcpkgcache "srcpkgcache.bin";
Dir::Cache::pkgcache "pkgcache.bin";
Binary::apt::APT::Cache "";
Binary::apt::APT::Cache::Show "";
Binary::apt::APT::Cache::Show::Version "2";
Binary::apt::APT::Cache::AllVersions "0";
Binary::apt::APT::Cache::ShowVirtuals "1";
Binary::apt::APT::Cache::Search "";
Binary::apt::APT::Cache::Search::Version "2";
Binary::apt::APT::Cache::ShowDependencyType "1";
Binary::apt::APT::Cache::ShowVersion "1";
Run Code Online (Sandbox Code Playgroud)

虽然我对那些东西一无所知Binary::*

它似乎也与任何权限问题无关,因为/var/cache/apt/archives/在使用时会重新创建apt install <arbitrary-package>

有什么提示吗?

A.B*_*A.B 5

2016 年出现了一个专门的设置(包括 Debian 9 稳定版本):

apt (1.2~exp1) experimental; urgency=medium

  [ Automatic removal of debs after install ]
  After packages are successfully installed by apt(8),
  the corresponding .deb package files will be
  removed from the /var/cache/apt/archives cache directory.

  This can be changed by setting the apt configuration option
    "Binary::apt::APT::Keep-Downloaded-Packages" to "true". E.g:

  # echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' \
      > /etc/apt/apt.conf.d/01keep-debs

  Please note that the behavior of apt-get is unchanged. The
  downloaded debs will be kept in the cache directory after they
  are installed. To enable the behavior for other tools, you can set
  "APT::Keep-Downloaded-Packages" to false.
Run Code Online (Sandbox Code Playgroud)

所以有两个切换:

命令apt特定切换:

Binary::apt::APT::Keep-Downloaded-Packages
Run Code Online (Sandbox Code Playgroud)

可以设置为"true"更改apt默认值。

和全局切换:

APT::Keep-Downloaded-Packages
Run Code Online (Sandbox Code Playgroud)

可以设置为"false"更改其他工具apt-get的默认值。

因此,例如,如果您想完全反转Debian 10 中apt(“不保留” 为 “保留”) 和apt-get(“保留” 为 “不保留”) 的当前行为,您可以将其添加到以下位置/etc/apt/apt.conf.d/

Binary::apt::APT::Keep-Downloaded-Packages "true";
APT::Keep-Downloaded-Packages "false";
Run Code Online (Sandbox Code Playgroud)

注意:如果文件已经存在(例如:之前使用 下载--download-only),则设置可能不会产生任何效果,文件将保留。这可能取决于apt的版本。至少当命令下载包安装它时,行为是一致的。