`sudo apt autoclean` 不起作用;而 `sudo apt clean` 有效

`sudo apt autoclean` 不起作用;而 `sudo apt clean` 有效

我使用的是 Debian Bullseye Xfce。请在下面找到我的系统的相关详细信息:

vrgovinda@krishna:~$ uname -a
Linux krishna 5.10.0-8-amd64 #1 SMP Debian 5.10.46-5 (2021-09-23) x86_64 GNU/Linux

版本apt-get如下:

vrgovinda@krishna:~$ apt-get -v
apt 2.2.4 (amd64)
Supported modules:
*Ver: Standard .deb
*Pkg:  Debian dpkg interface (Priority 30)
 Pkg:  Debian APT solver interface (Priority -1000)
 Pkg:  Debian APT planner interface (Priority -1000)
 S.L: 'deb' Debian binary tree
 S.L: 'deb-src' Debian source tree
 Idx: Debian Source Index
 Idx: Debian Package Index
 Idx: Debian Translation Index
 Idx: Debian dpkg status file
 Idx: Debian deb file
 Idx: Debian dsc file
 Idx: Debian control file
 Idx: EDSP scenario file
 Idx: EIPP scenario file

当我运行时sudo apt autoclean,预计.deb除最新版本之外的所有文件都应被删除,即无法再下载的文件,但在我的系统中不会发生这种情况。我已在下面发布了示例:

/var/cache/apt/archives$ ls
libuuid1_2.36.1-7_amd64.deb  libuuid1_2.36.1-8_amd64.deb  lock
libuuid1_2.36.1-7_i386.deb   libuuid1_2.36.1-8_i386.deb   partial

现在我跑autoclean

/var/cache/apt/archives$ sudo apt autoclean 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done

该文件夹的内容archives保持原样:

/var/cache/apt/archives$ ls
libuuid1_2.36.1-7_amd64.deb  libuuid1_2.36.1-8_amd64.deb  lock
libuuid1_2.36.1-7_i386.deb   libuuid1_2.36.1-8_i386.deb   partial

令人惊讶的是,按预期sudo apt clean清理了文件夹。archives因此奇怪的是只有该autoclean功能不起作用。

vrgovinda@krishna:~$ sudo apt clean
[sudo] password for vrgovinda: 
vrgovinda@krishna:~$ cd /var/cache/apt/archives/
vrgovinda@krishna:/var/cache/apt/archives$ ls
lock  partial

结果apt policy libuuid1

vrgovinda@krishna:/var/cache/apt/archives$ apt policy libuuid1
 libuuid1: 
 Installed: 2.36.1-8
 Candidate: 2.36.1-8
Version table:
*** 2.36.1-8 500
500 file:/home/vrgovinda/bullseye-deb-files ./ Packages
500 deb.debian.org/debian bullseye/main amd64 Packages
100 /var/lib/dpkg/status
2.36.1-7 500
 500 file:/home/vrgovinda/bullseye-deb-files ./ Packages

答案1

你说 ”...预计除最新版本之外的所有 .deb 文件都应被删除“。那不是autoclean。来自man apt-get

clean

clean清除检索到的包文件的本地存储库。它会删除和lock中除文件 之外的所有内容。/var/cache/apt/archives//var/cache/apt/archives/partial/

autoclean(以及auto-clean自 1.1 以来的别名)

与 类似cleanautoclean清除已检索包文件的本地存储库。不同之处在于它只删除无法再下载的包文件,并且基本上无用。这使得缓存可以长期维护,而不会失去控制。APT::Clean-Installed如果设置为 ,该配置选项将防止已安装的软件包被删除off

(我添加了额外的格式和粗体强调)

答案2

感谢@StephenKitt。我从他的评论中得到了线索。他让我检查一下输出结果apt policy libuuid1如下:

$ apt policy libuuid1
 libuuid1: 
 Installed: 2.36.1-8
 Candidate: 2.36.1-8
Version table:
*** 2.36.1-8 500
500 file:/home/vrgovinda/bullseye-deb-files ./ Packages
500 deb.debian.org/debian bullseye/main amd64 Packages
100 /var/lib/dpkg/status
2.36.1-7 500
500 file:/home/vrgovinda/bullseye-deb-files ./ Packages

它显示我的本地存储库/home/vrgovinda/bullseye-deb-files具有.deb与该文件夹中相同的文件archives

.deb每次操作后我都移动了所有文件install,只是为了备份下载的.deb文件。我还包含了/home/vrgovinda/bullseye-deb-files作为受信任的存储库,sources.list如下所示:

deb [trusted=yes] file:/home/vrgovinda/bullseye-deb-files/ ./
#BULLSEYE
deb http://deb.debian.org/debian/ bullseye non-free contrib main  

#BULLSEYE UPDATES
deb http://deb.debian.org/debian/ bullseye-updates non-free contrib main  
#deb-src http://deb.debian.org/debian/ buster-updates main contrib non-free 

# SECURITY
deb http://security.debian.org/debian-security/ bullseye-security non-free contrib main  

答案:当我/home/vrgovinda/bullseye-deb-files从 中删除时sources.listsudo apt autoclean它的功能符合预期。

~$ sudo apt autoclean
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Del libuuid1 2.36.1-7 [83.6 kB]
Del libuuid1 2.36.1-7 [84.4 kB]

正如 @cas 和 @terdon 所指出的,autoclean不会删除.deb其他存储库中其他位置存在的那些文件。

感谢大家的热情投入。

相关内容