[daily][CentOS][yum] 删除包的同时一同清理掉安装时一起装进来的依赖包

说起来有点绕口,这个需求是这样的。

就是我yum装A包的时候,同时安装了A的依赖包a1,a2,a3。

当我们使用yum remove A卸载A包的是,a1,a2,a3包并不会一同被卸载掉。如果他们没有用了,即除了A并没有其他包依赖他们的话,他们也应该一同被卸载掉。

在arch里,我们有pacman -Rsun等复杂的命令搞定这件事.

并且我们还有,pacman -Qdt。pacman -Qet 。pactree,等命令来清澈的管理所有包和他们直接的依赖树,以及谁是孤立的,谁是曾经被依赖如今可以删的。

 

所以,在CentOS里,yum该怎么做才能达到这些目的呢?我当前的要求很简单,就是remove的时候,把依赖一起带走就可以了。

分别 man yum 和man yum.conf 之后发现是可以的。

方法一:使用 yum autoremove

       autoremove

              With one or more arguments this command works like running the "remove" command with the clean_requirements_on_remove turned on. However you can also
              specify no arguments, at which point it tries to remove any packages that weren't installed explicitly by the user and which aren't required by  any‐
              thing (so called leaf packages).

              Because  autoremove  does  a  lot  of  work  to make it as easy as possible to use, there are also a few specific autoremove commands "autoremove-n",
              "autoremove-na" and "autoremove-nevra". These only work on package names, and do not process wildcards etc.

方法二:在yum.conf中设置参数 clean_requirements_on_remove 然后使用 yum remove xxx

              clean_requirements_on_remove When removing packages (by removal, update or obsoletion) go through each package's dependencies. If any of them are  no
              longer required by any other package then also mark them to be removed.  Boolean (1, 0, True, False, yes, no) Defaults to False

 

好吧,说的这么费劲其实答案就是 aoturemove

复制代码
[root@dpdk ~]# rpm -qa |grep dpdk
dpdk-2.2.0-3.el7.x86_64
dpdk-devel-2.2.0-3.el7.x86_64
[root@dpdk ~]# yum autoremove dpdk-devel
Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package dpdk-devel.x86_64 0:2.2.0-3.el7 will be erased
--> Finished Dependency Resolution
--> Finding unneeded leftover dependencies
---> Marking dpdk to be removed - no longer needed by dpdk-devel
Found and removing 1 unneeded dependencies
--> Running transaction check
---> Package dpdk.x86_64 0:2.2.0-3.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================
 Package                                  Arch                                 Version                                      Repository                             Size
========================================================================================================================================================================
Removing:
 dpdk-devel                               x86_64                               2.2.0-3.el7                                  @extras                               1.4 M
Removing for dependencies:
 dpdk                                     x86_64                               2.2.0-3.el7                                  @extras                               2.7 M

Transaction Summary
========================================================================================================================================================================
Remove  1 Package (+1 Dependent package)

Installed size: 4.1 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : dpdk-devel-2.2.0-3.el7.x86_64                                                                                                                        1/2 
  Erasing    : dpdk-2.2.0-3.el7.x86_64                                                                                                                              2/2 
  Verifying  : dpdk-devel-2.2.0-3.el7.x86_64                                                                                                                        1/2 
  Verifying  : dpdk-2.2.0-3.el7.x86_64                                                                                                                              2/2 

Removed:
  dpdk-devel.x86_64 0:2.2.0-3.el7                                                                                                                                       

Dependency Removed:
  dpdk.x86_64 0:2.2.0-3.el7                                                                                                                                             

Complete!
[root@dpdk ~]# rpm -qa |grep dpdk
[root@dpdk ~]# 
复制代码

 

posted on   toong  阅读(11311)  评论(1编辑  收藏  举报

编辑推荐:
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 上周热点回顾(3.3-3.9)

统计

点击右上角即可分享
微信分享提示