AttributeError: ‘Sack‘ object has no attribute ‘_rpmdb_version‘

Posted rtoax

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了AttributeError: ‘Sack‘ object has no attribute ‘_rpmdb_version‘相关的知识,希望对你有一定的参考价值。

AttributeError: 'Sack' object has no attribute '_rpmdb_version'

荣涛
2022-04-30

文档修改日志

日期修改内容修改人备注
2022-04-30创建荣涛

问题描述

当我执行sudo dnf up更新操作系统时候发生:

[SKIPPED] xdg-desktop-portal-1.12.3-1.el9.x86_64.rpm: Already downloaded                               
[SKIPPED] xorg-x11-drv-fbdev-0.5.0-11.el9.x86_64.rpm: Already downloaded                               
[SKIPPED] xorg-x11-drv-vmware-13.2.1-18.el9.x86_64.rpm: Already downloaded                             
[SKIPPED] xorg-x11-drv-wacom-1.0.0-1.el9.x86_64.rpm: Already downloaded                                
[SKIPPED] zlib-devel-1.2.11-32.el9.x86_64.rpm: Already downloaded                                      
[SKIPPED] google-chrome-stable-101.0.4951.41-1.x86_64.rpm: Already downloaded                          
[SKIPPED] code-1.66.2-1649664637.el7.x86_64.rpm: Already downloaded                                    
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'dnf clean packages'.
Traceback (most recent call last):
  File "/bin/dnf", line 58, in <module>
    main.user_main(sys.argv[1:], exit_code=True)
  File "/usr/lib/python3.9/site-packages/dnf/cli/main.py", line 201, in user_main
    errcode = main(args)
  File "/usr/lib/python3.9/site-packages/dnf/cli/main.py", line 67, in main
    return _main(base, args, cli_class, option_parser_class)
  File "/usr/lib/python3.9/site-packages/dnf/cli/main.py", line 106, in _main
    return cli_run(cli, base)
  File "/usr/lib/python3.9/site-packages/dnf/cli/main.py", line 130, in cli_run
    ret = resolving(cli, base)
  File "/usr/lib/python3.9/site-packages/dnf/cli/main.py", line 176, in resolving
    base.do_transaction(display=displays)
  File "/usr/lib/python3.9/site-packages/dnf/cli/cli.py", line 246, in do_transaction
    tid = super(BaseCli, self).do_transaction(display)
  File "/usr/lib/python3.9/site-packages/dnf/base.py", line 983, in do_transaction
    tid = self._run_transaction(cb=cb)
  File "/usr/lib/python3.9/site-packages/dnf/base.py", line 1049, in _run_transaction
    rpmdbv = self.sack._rpmdb_version()
AttributeError: 'Sack' object has no attribute '_rpmdb_version'

解决方案

因为提示:

  File "/usr/lib/python3.9/site-packages/dnf/base.py", line 1049, in _run_transaction
    rpmdbv = self.sack._rpmdb_version()
AttributeError: 'Sack' object has no attribute '_rpmdb_version'

我尝试了下载dnf,rpm相关的rpm包进行手动安装,发现仍旧提示上面的错误,所以我尝试了一种奇葩的方法,结果成功了,那就是:

修改代码/usr/lib/python3.9/site-packages/dnf/base.py1049行代码,将_rpmdb_version函数直接替换成了字符串,字符串是:

[rongtao@192 ~]$ rpmdb --version
RPM version 4.16.1.3

直接替换。

其实我在更新操作系统后发现,原来调用’_rpmdb_version’的地方没有了:

        if self._record_history():
            using_pkgs_pats = list(self.conf.history_record_packages)
            installed_query = self.sack.query().installed()
            using_pkgs = installed_query.filter(name=using_pkgs_pats).run()
            rpmdbv = self._ts.dbCookie()
            lastdbv = self.history.last()
            if lastdbv is not None:
                lastdbv = lastdbv.end_rpmdb_version

            if lastdbv is None or rpmdbv != lastdbv:
                logger.debug(_("RPMDB altered outside of prog.").format(
                    prog=dnf.util.MAIN_PROG_UPPER))

Copyright (C) Rong Tao.

以上是关于AttributeError: ‘Sack‘ object has no attribute ‘_rpmdb_version‘的主要内容,如果未能解决你的问题,请参考以下文章

AttributeError: ‘Sack‘ object has no attribute ‘_rpmdb_version‘

AttributeError:“模块”对象没有属性“百分位”

tcp的ack和sack比较

TCP 标头选项:允许 SACK(选择性确认)协商

TCP 的演化史-sack 与 reordering metric

Linux内核TCP协议多个SACK功能拒绝服务漏洞分析