首页 > 代码库 > [CentOS][daily][yum] 删除包的同时一同清理掉安装时一起装进来的依赖包
[CentOS][daily][yum] 删除包的同时一同清理掉安装时一起装进来的依赖包
说起来有点绕口,这个需求是这样的。
就是我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 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 dpdkdpdk-2.2.0-3.el7.x86_64dpdk-devel-2.2.0-3.el7.x86_64[root@dpdk ~]# yum autoremove dpdk-develLoaded plugins: fastestmirrorResolving 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-develFound and removing 1 unneeded dependencies--> Running transaction check---> Package dpdk.x86_64 0:2.2.0-3.el7 will be erased--> Finished Dependency ResolutionDependencies Resolved======================================================================================================================================================================== Package Arch Version Repository Size========================================================================================================================================================================Removing: dpdk-devel x86_64 2.2.0-3.el7 @extras 1.4 MRemoving for dependencies: dpdk x86_64 2.2.0-3.el7 @extras 2.7 MTransaction Summary========================================================================================================================================================================Remove 1 Package (+1 Dependent package)Installed size: 4.1 MIs this ok [y/N]: yDownloading packages:Running transaction checkRunning transaction testTransaction test succeededRunning 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] 删除包的同时一同清理掉安装时一起装进来的依赖包
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。