当前位置:   article > 正文

CentOS中yum install命令如何找到安装包的下载地址_查看yum下载目录

查看yum下载目录

我们通常用的yum install命令是怎么找到我们想要的下载地址的,这里简单做一下分析

首先,搜索所有/etc/yum.repos.d下所有repo

 在每个repo中都有一个baseurl,这里以docker-ce.repo下载containerd.io 的rpm包为例

docker-ce的部分repo为

  1. [docker-ce-stable]
  2. name=Docker CE Stable - $basearch
  3. baseurl=https://download.docker.com/linux/centos/$releasever/$basearch/stable
  4. enabled=1
  5. gpgcheck=1
  6. gpgkey=https://download.docker.com/linux/centos/gpg

它的baseurl为

https://download.docker.com/linux/centos/$releasever/$basearch/stable

其中有两个变量$releasever和$basearch为yum里的变量

centos8获取

/usr/libexec/platform-python -c 'import dnf, json; db = dnf.dnf.Base(); print(json.dumps(db.conf.substitutions, indent=2))'

centos6/7获取

python -c 'import yum, json; yb = yum.YumBase(); print json.dumps(yb.conf.yumvar, indent=2)'

其他获取命令arch获取$basearch

我这里获取的结果

  1. {
  2. "arch": "x86_64",
  3. "basearch": "x86_64",
  4. "releasever": "8"
  5. }

所以实际的baseurl为

https://download.docker.com/linux/centos/8/x86_64/stable

首先他会去找baseurl + /repodata/repomd.xml,拼接后的路径为

https://download.docker.com/linux/centos/8/x86_64/stable/repodata/repomd.xml

文件内容如下

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <repomd xmlns="http://linux.duke.edu/metadata/repo" xmlns:rpm="http://linux.duke.edu/metadata/rpm">
  3. <revision>1668722787</revision>
  4. <data type="primary">
  5. <checksum type="sha256">be17658b784892066fdfbfe9ec068b16ee160f2a4c0d32f17cdb4571b6354755</checksum>
  6. <open-checksum type="sha256">a5c7c260751e6ca1ea7c77f6c991bb207d1e81055a6e0d7e5935084bc6981297</open-checksum>
  7. <location href="repodata/be17658b784892066fdfbfe9ec068b16ee160f2a4c0d32f17cdb4571b6354755-primary.xml.gz"/>
  8. <timestamp>1668722787</timestamp>
  9. <size>14654</size>
  10. <open-size>266294</open-size>
  11. </data>
  12. <data type="filelists">
  13. <checksum type="sha256">cf1a791d6c576477dda984611b48b44f1857a6914f291f1f66f2956a8c7f9ef3</checksum>
  14. <open-checksum type="sha256">c44aba02e3e5e6d1a2ee3ab957200908f04a18f52dc7a86b74a4fa9efa3ea4ac</open-checksum>
  15. <location href="repodata/cf1a791d6c576477dda984611b48b44f1857a6914f291f1f66f2956a8c7f9ef3-filelists.xml.gz"/>
  16. <timestamp>1668722787</timestamp>
  17. <size>16970</size>
  18. <open-size>370747</open-size>
  19. </data>
  20. <data type="other">
  21. <checksum type="sha256">abceebf147a05e99f2c07a0f31f61b5eaa15468c62bbe036c8627ed15db66885</checksum>
  22. <open-checksum type="sha256">12b2f5856fcee45052acfb910504a5da4d4c8dac588c069d2f990dda93a41382</open-checksum>
  23. <location href="repodata/abceebf147a05e99f2c07a0f31f61b5eaa15468c62bbe036c8627ed15db66885-other.xml.gz"/>
  24. <timestamp>1668722787</timestamp>
  25. <size>7245</size>
  26. <open-size>60645</open-size>
  27. </data>
  28. <data type="primary_db">
  29. <checksum type="sha256">fd30a988d4fac2906713cd09631c352fae8ba760649a3a23563afb20469c0f94</checksum>
  30. <open-checksum type="sha256">6c8f98ca6820379b70483f7bed54f9f47c32f8b420c88ea588e113746383afd0</open-checksum>
  31. <location href="repodata/fd30a988d4fac2906713cd09631c352fae8ba760649a3a23563afb20469c0f94-primary.sqlite.bz2"/>
  32. <timestamp>1668722787</timestamp>
  33. <size>49764</size>
  34. <open-size>360448</open-size>
  35. <database_version>10</database_version>
  36. </data>
  37. <data type="filelists_db">
  38. <checksum type="sha256">20e7bc1d075a56626855bf991b490ceede97aff17a4679a63f018e78905aa00a</checksum>
  39. <open-checksum type="sha256">91b51edaba3236b72a39b2d896b06aa54518fc1c9d1f1ee68712cca06c5aa286</open-checksum>
  40. <location href="repodata/20e7bc1d075a56626855bf991b490ceede97aff17a4679a63f018e78905aa00a-filelists.sqlite.bz2"/>
  41. <timestamp>1668722787</timestamp>
  42. <size>31574</size>
  43. <open-size>258048</open-size>
  44. <database_version>10</database_version>
  45. </data>
  46. <data type="other_db">
  47. <checksum type="sha256">073a126a1c676d7f28f6627b0ce62334599032e86819db0b1db5caa2c0200a29</checksum>
  48. <open-checksum type="sha256">ee2bd9ab4c2f461aa0ba80c5768f6691f519b35d0aebf72a12ccd593f064e7d7</open-checksum>
  49. <location href="repodata/073a126a1c676d7f28f6627b0ce62334599032e86819db0b1db5caa2c0200a29-other.sqlite.bz2"/>
  50. <timestamp>1668722787</timestamp>
  51. <size>12236</size>
  52. <open-size>77824</open-size>
  53. <database_version>10</database_version>
  54. </data>
  55. <data type="updateinfo">
  56. <checksum type="sha256">65c4f66e2808d328890505c3c2f13bb35a96f457d1c21a6346191c4dc07e6080</checksum>
  57. <open-checksum type="sha256">ded9c95e1b88197c906603b5d9693c579cb0afeade3bc7f8ec6cae06b962477d</open-checksum>
  58. <location href="repodata/65c4f66e2808d328890505c3c2f13bb35a96f457d1c21a6346191c4dc07e6080-updateinfo.xml.gz"/>
  59. <timestamp>1668722787</timestamp>
  60. <size>55</size>
  61. <open-size>42</open-size>
  62. </data>
  63. </repomd>

 repomd.xml包含primary/filelist/other/group时间戳、检验等等之类。

primary.xml里包含所有rpm文件列表、依赖关系、软件包安装列表。最重要的是这个,我们拼接primary.xml.gz这个路径

路径为

https://download.docker.com/linux/centos/8/x86_64/stable/repodata/be17658b784892066fdfbfe9ec068b16ee160f2a4c0d32f17cdb4571b6354755-primary.xml.gz

下载后解压打开,可以看到第一个包是containerd.io-1.3.7-3.1.el8.x86_64.rpm

 location标签的内容为Packages/containerd.io-1.3.7-3.1.el8.x86_64.rpm

那么拼接上的下载地址为

https://download.docker.com/linux/centos/8/x86_64/stable/Packages/containerd.io-1.3.7-3.1.el8.x86_64.rpm

我们使用wget命令就可以下载下来

wget https://download.docker.com/linux/centos/8/x86_64/stable/Packages/containerd.io-1.3.7-3.1.el8.x86_64.rpm

下载结果如图

 实际上yum命令执行的过程中,会先在每个repo的primary列表文件先搜索有没有这个名称的包,匹配到再进行下载。primary文件中还定义了一些依赖关系,需要先安装完依赖才能安装完这个包。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/179293
推荐阅读
相关标签
  

闽ICP备14008679号