[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 2016-09-29 19:31  toong  阅读(11260)  评论(1编辑  收藏  举报