AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题 / 523064
Accepted
ks1322
ks1322
Asked: 2019-06-06 06:08:48 +0800 CST2019-06-06 06:08:48 +0800 CST 2019-06-06 06:08:48 +0800 CST

如何对已安装的 rpm 包进行拓扑排序?

  • 772

我想根据依赖关系对我的 Fedora 上所有已安装的 rpm 包进行拓扑排序,其中最需要的包位于顶部(例如 glibc),最少需要的包位于底部。我可以用 列出所有已安装的软件包rpm -qa,但它们似乎没有按拓扑排序。

我的目标是查看已安装的软件包,找到我不再需要的软件包并卸载它们。

fedora rpm
  • 3 3 个回答
  • 823 Views

3 个回答

  • Voted
  1. somethingSomething
    2019-06-06T06:58:19+08:002019-06-06T06:58:19+08:00

    人rpm图:

    rpmgraph(8) - Linux man page
    Name
    rpmgraph - Display RPM Package Dependency Graph
    Synopsis
    
    rpmgraph PACKAGE_FILE ...
    Description
    
    rpmgraph uses PACKAGE_FILE arguments to generate a package dependency graph. Each
    PACKAGE_FILE argument is read and added to an rpm transaction set. The elements 
    of the transaction set
    
    are partially ordered using a topological sort.
    
    The partially ordered elements are then printed to standard output.
    
    
    Nodes in the dependency graph are package names, and edges in the directed graph 
    point to the parent of each node. The parent node is defined as the last 
    predecessor of a package when partially ordered using the package dependencies as
    a relation. That means that the parent of a given package is the package's last
    prerequisite.
    
    The output is in dot(1) directed graph format, and can be displayed or printed
    using the dotty graph editor from the graphviz package. There are no rpmgraph
    specific options, only common rpm options. See the rpmgraph usage message for    
    what is currently implemented. 
    
      [1]: https://linux.die.net/man/8/rpmgraph
    

    安装:

    rpm-devel fedora 19 有这个包

    这是 Fedora 30 的 rpm-devel

    使用你的包管理器:

    dnf install rpm-devel
    

    要在 中安装,请wget在CentOS终端窗口中输入以下内容:

    sudo yum install wget
    

    要安装wget在 中Fedora,请输入以下内容:

    sudo dnf install wget
    

    现在,您可以使用 wget 命令下载所需的 .rpm 文件。输入以下内容:

    wget http://some_website/sample_file.rpm
    

    系统应访问网站并将文件下载到您当前的工作目录。

    使用 RPM 命令安装 RPM 文件

    Fedora要在 Linux或Linux中安装 .rpm 包CentOS,请输入以下内容:

    sudo rpm –i sample_file.rpm
    

    –i 开关告诉包管理器您要安装该文件。

    有关 RPM 安装程序的更多信息可以在RPM 文档中找到。

    使用 Yum 安装 RPM 文件

    或者,您可以使用yum包管理器来安装.rpm文件。

    输入以下内容:

    sudo yum localinstall sample_file.rpm
    

    该localinstall选项指示 yum 查看安装文件的当前工作目录。


    https://superuser.com/questions/483307/how-do-i-know-dependent-rpms-of-aa-package

    https://phoenixnap.com/kb/how-to-install-rpm-file-centos-linux

    https://linux.die.net/man/8/rpm

    编辑:

    我无法开始rpmgraph工作,我尝试了三种不同版本的PACKAGE_FILE包列表语法,但它只是给出错误,如果你知道如何使用这个程序,请提供答案或编辑我的。经测试Fedora 28。如何列出所有已安装的扩展名为 .rpm 的软件包。Fedora、Centos、红帽

    # rpmgraph INSTALLED_PACKAGES 
    (null): read manifest failed:
    
    • 3
  2. Best Answer
    ks1322
    2019-06-06T10:30:03+08:002019-06-06T10:30:03+08:00

    经过一番搜索,似乎包中的rpmdep工具rpmorphan最接近我想要的。要查看最需要的已安装软件包,可以使用以下--depending选项运行它:

    rpmdep -all --depending | tac | less -S
    
    • 2
  3. user339730
    2019-06-06T22:36:52+08:002019-06-06T22:36:52+08:00

    我曾经为此编写了一个脚本,但我几乎没有使用过它。

    我会小心处理搬迁。我曾经试图删除一个名为“SimplyHTML”的包,因为它是作为“叶节点”出现的,当我去删除它时,发现“freemind”(我经常使用的思维导图工具)需要它并得到也删了。很奇怪!

    无论如何,FWIW 这是脚本(在我的系统上称为“leaf-rpms”):

    #!/usr/bin/perl
    use strict;
    use warnings;
    use 5.10.0;
    use Data::Dumper;
    
    # a leaf RPM is one that has no deps and you can safely delete
    
    # run it as is, delete any that you think are useless
    
    my @installed = `rpm -qa --queryformat="%{NAME}\n"`;
    chomp(@installed);
    my %count;
    
    @ARGV = ("dnf repograph |");
    
    while (<>) {
        chomp;
        next if /^digraph packages/;
        next unless m({) .. m(});
        next if m({) or m(});
    
        s/"//g;
        $count{$_}++;
    }
    # print Dumper \@installed;
    # print Dumper \@all;
    # print Dumper \%count;
    # print "----\n";
    
    my %dup;
    for my $k (sort @installed) {
        next if $dup{$k}++;
        print "$k\n" unless exists $count{$k};
    }
    
    • 1

相关问题

  • VirtualBox 无法在 Fedora 26 中安装

  • 使用触摸屏时如何禁用屏幕键盘?

  • 如何找出 nmcli 中缺少的插件?

  • 如何正确分区 SSD 以进行双启动设置

  • 可以安装软件包但 yum 或 rpm 命令看不到吗?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve