如何从Centos,Fedora中的特定存储库中删除已安装的软件包

时间:2020-03-21 11:46:47  来源:igfitidea点击:

从特定存储库中删除已安装的软件包

在Rhel,CentOS,Scientific Linux:

在基于yum的系统中,如Red Hat及其克隆等CentOS和Scienific Linux,我们可以使用命令用作root用户的命令从特定存储库中删除已安装的软件包:

$yum remove $(yum list installed | grep epel | awk '{ print  }')

示例输出:

Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package dnf.noarch 0:0.6.4-2.el7 will be erased
---> Package dnf-conf.noarch 0:0.6.4-2.el7 will be erased
---> Package dnf-plugins-core.noarch 0:0.1.5-3.el7 will be erased
---> Package epel-release.noarch 0:7-9 will be erased
---> Package libcomps.x86_64 0:0.1.6-13.el7 will be erased
---> Package python-dnf.noarch 0:0.6.4-2.el7 will be erased
---> Package python-libcomps.x86_64 0:0.1.6-13.el7 will be erased
--> Finished Dependency Resolution
Dependencies Resolved
==========================================================================================
 Package Arch Version Repository Size
==========================================================================================
Removing:
 dnf noarch 0.6.4-2.el7 @epel 652 k
 dnf-conf noarch 0.6.4-2.el7 @epel 29 k
 dnf-plugins-core noarch 0.1.5-3.el7 @epel 167 k
 epel-release noarch 7-9 @epel 24 k
 libcomps x86_64 0.1.6-13.el7 @epel 202 k
 python-dnf noarch 0.6.4-2.el7 @epel 1.8 M
 python-libcomps x86_64 0.1.6-13.el7 @epel 140 k
Transaction Summary
==========================================================================================
Remove 7 Packages
Installed size: 3.0 M
Is this ok [y/N]:

上面的命令将从epel存储库一起删除所有已安装的软件包以及所有依赖项。
而且,它将删除EPEL存储库本身。

如果要仅删除包,而不是依赖项,请输入以下命令作为root用户:

$rpm -e --nodeps `yum list installed | grep epel | awk '{ print  }'`

请注意,上述命令不会在删除软件包时询问任何确认。

关于Fedora:

在Fedora中,我们可以使用以下命令作为root用户卸载特定存储库的所有包:

# dnf repository-packages <repo-id> remove

例子:

# dnf repository-packages zyga-snapcore remove

示例输出:

Last metadata expiration check: 0:05:43 ago on Fri Jun 23 15:37:20 2016.
Dependencies resolved.
==========================================================================================
 Package Arch Version Repository Size
==========================================================================================
Removing:
 lz4 i686 r131-1.fc23 @fedora 322 k
 snap-confine i686 1.0.40-1.fc23 @updates 80 k
 snapd i686 2.14-1.fc23 @zyga-snapcore 17 M
 squashfs-tools i686 4.3-11.fc23 @fedora 405 k
Transaction Summary
==========================================================================================
Remove 4 Packages
Installed size: 18 M
Is this ok [y/N]:

其中Zyga-Snapcore是由Zyga拥有的Snapcore的COPR存储库的repo id。

上面的命令将删除从其他存储库安装的依赖项。
如果要仅删除包,而不是依赖项,刚刚运行:

$sudo rpm -e --nodeps `dnf list installed | grep zyga-snapcore | awk '{ print  }'`

要查找存储库ID,请运行:

$dnf repolist

Fedora系统的示例输出:

Last metadata expiration check: 0:07:39 ago on Fri Jun 23 15:37:20 2016.
repo id repo name status
*fedora Fedora 23 - i386 38,811
*updates Fedora 23 - i386 - Updates 18,174
zyga-snapcore Copr repo for snapcore owned by zyga 11