dnf - 如何显示已选择哪个镜像网址?

dnf - 如何显示已选择哪个镜像网址?

下面是bash日志的一部分,完整的日志可以在https://gist.github.com/limkokhole/f2a423112aa005f10862:

[xiaobai@xiaobai hello]$ dnf --verbose download --source readline
cachedir: /var/cache/dnf
Loaded plugins: noroot, needs-restarting, reposync, copr, playground, kickstart, Query, generate_completion_cache, builddep, download, config-manager, protected_packages, system-upgrade, debuginfo-install
DNF version: 0.6.4
repo: using cache for: spot-chromium
not found deltainfo for: Copr repo for chromium owned by spot
not found updateinfo for: Copr repo for chromium owned by spot
repo: using cache for: rpmfusion-nonfree-updates-testing
not found deltainfo for: RPM Fusion for Fedora 21 - Nonfree - Test Updates
not found updateinfo for: RPM Fusion for Fedora 21 - Nonfree - Test Updates
repo: using cache for: updates-source
...
not found deltainfo for: RPM Fusion for Fedora 21 - Nonfree - Updates Source
not found updateinfo for: RPM Fusion for Fedora 21 - Nonfree - Updates Source
readline-6.3-5.fc21.src.rpm                                                                                                             623 kB/s | 2.4 MB     00:03    
[xiaobai@xiaobai hello]$ 

我也试过了dnf info,网址http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html不是回购网址:

[xiaobai@xiaobai hello]$ dnf info readline
[sudo] password for xiaobai: 
Using metadata from Thu Dec 31 19:18:09 2015 (6:13:33 hours old)
Installed Packages
Name        : readline
Arch        : i686
Epoch       : 0
Version     : 6.3
Release     : 5.fc21
Size        : 446 k
Repo        : @System
Summary     : A library for editing typed command lines
URL         : http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html
License     : GPLv3+
Description : The Readline library provides a set of functions that allow users to
            : edit command lines. Both Emacs and vi editing modes are available. The
            : Readline library includes additional functions for maintaining a list
            : of previously-entered command lines for recalling or editing those
            : lines, and for performing csh-like history expansion on previous
            : commands.

Name        : readline
Arch        : x86_64
Epoch       : 0
Version     : 6.3
Release     : 5.fc21
Size        : 483 k
Repo        : @System
Summary     : A library for editing typed command lines
URL         : http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html
License     : GPLv3+
Description : The Readline library provides a set of functions that allow users to
            : edit command lines. Both Emacs and vi editing modes are available. The
            : Readline library includes additional functions for maintaining a list
            : of previously-entered command lines for recalling or editing those
            : lines, and for performing csh-like history expansion on previous
            : commands.

[xiaobai@xiaobai hello]$ 

我如何知道已选择哪个网址或域来下载此 readline-6.3-5.fc21.src.rpm ?--verbose似乎没有显示链接。退出 bash 会话后,将来如何从 dnf 历史记录中获取此 url 信息?

答案1

对于dnf它本身来说,这是延迟的功能请求。显然dnf不知道网址。参见评论4和5:

我很抱歉,我/我们误解了动机。仅供参考,DNF 实际上不知道 URL。它只知道“metalink”的 URL 和包的文件名(以及一些其他元数据)。底层库 librepo 负责选择最佳镜像、编写 URL 并下载文件。顺便说一句,这意味着我们需要在库中进行一些回调来向您提供信息。仅供参考...


问题是我们不知道来自 metalinks 的 URL,它由 librepo 在较低级别处理。如果有人分享相同的用例并希望看到此功能,请发表评论,您将有更高的机会拥有此功能。

答案2

感谢 @muru 指出负责下载的 librepo。

当前的解决方法是定义 adebug_function并将其传递给set_debug_log_handler(请参阅download_packages.py ) 在repo.py

def download_payloads(payloads, drpm):
    # download packages
    drpm.err.clear()
    targets = [pload.librepo_target() for pload in payloads]
    errs = _DownloadErrors()
    try:

        #START my custom code
        def debug_function(msg, _):
            print("##hole## msg:", msg)
        librepo.set_debug_log_handler(debug_function)
        #END my custom  code

        librepo.download_packages(targets, failfast=True)
    except librepo.LibrepoException as e:
        errs.fatal = e.args[1] or '<unspecified librepo error>'
    ...

repo.py可以通过以下方式手动找到该文件:

[xiaobai@xiaobai log]$ python -c 'import sys, dnf.repo; print(sys.modules["dnf.repo"])'
<module 'dnf.repo' from '/usr/lib/python2.7/site-packages/dnf/repo.py'>
[xiaobai@xiaobai log]$ 

[更新]在 Fedora 24 中,路径为/usr/lib/python3.5/site-packages/dnf/repo.py.

现在我可以获取网址了http://ftp.jaist.ac.jp/pub/Linux/Fedora/releases/21/Everything/source/SRPMS/r/readline-6.3-5.fc21.src.rpm:

[xiaobai@xiaobai test]$ dnf download --source readline
[sudo] password for xiaobai: 
Using metadata from Thu Dec 31 19:18:09 2015 (1 day, 11:59:10 hours old)
...
##hole## msg: select_next_target: Selecting mirror for: r/readline-6.3-5.fc21.src.rpm
##hole## msg: select_suitable_mirror: Skipping rsync url: rsync://ftp.jaist.ac.jp/pub/Linux/Fedora/releases/21/Everything/source/SRPMS/
##hole## msg: prepare_next_transfer: URL: http://ftp.jaist.ac.jp/pub/Linux/Fedora/releases/21/Everything/source/SRPMS/r/readline-6.3-5.fc21.src.rpm
##hole## msg: prepare_next_transfer: Resume ignored, existing file was not originaly being downloaded by Librepo
##hole## msg: lr_download: Downloading started
##hole## msg: lr_headercb: Server returned Content-Length: "2493152" (converted 2493152/2493152 expected)                             ] ---  B/s |   0  B     --:-- ETA
##hole## msg: check_transfer_statuses: Transfer finished: r/readline-6.3-5.fc21.src.rpm (Effective url: http://ftp.jaist.ac.jp/pub/Linux/Fedora/releases/21/Everything/source/SRPMS/r/readline-6.3-5.fc21.src.rpm)
##hole## msg: check_finished_trasfer_checksum: Checksum (sha256) 521bd47a3293e694190a237921a9954b20fa41d0e8e38183d186452d4cc62ac8 is OK
readline-6.3-5.fc21.src.rpm                                                                                                             1.4 MB/s | 2.4 MB     00:01    
##hole## msg: lr_download_packages: Restoring an old SIGINT handler
[xiaobai@xiaobai test]$ 

当然,如果 dnf 记录此 url 以供将来参考(从 commanddnf history或 file检索),那就更好了/var/log/dnf.log

答案3

dnf download readline
cat /var/log/dnf.librepo.log | grep Downloading: | tail -n1

然后你就得到了下载包的 URL。

相关内容