码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2016-09-29 21:42:40      阅读:1498      评论:0      收藏:0      [点我收藏+]

标签:

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

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

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

在arch里,我们有pacman -Rsun等复杂的命令搞定这件事(pacman这一套我确实也没用学的很明白,有时间还有再好好学一学。

并且我们还有,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 werent installed explicitly by the user and which arent 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 packages 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 ~]# 

 

最后,亲测可用,当当当当!:)

 

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

标签:

原文地址:http://www.cnblogs.com/hugetong/p/5921007.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!