本文介绍: 实际上yum命令执行过程中,会先在每个repoprimary列表文件搜索没有这个名称的包,匹配到再进行下载。最重要的是这个我们拼接primary.xml.gz这个路径location标签内容为Packages/containerd.io-1.3.7-3.1.el8.x86_64.rpm。在每个repo中都有一个baseurl这里dockerce.repo下载dockercerpm为例。我们通常用的yum install命令是怎么找到我们想要的下载地址的,这里简单做一下分析

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

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

 在每个repo中都有一个baseurl这里dockerce.repo下载containerd.iorpm为例

dockerce部分repo

[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://download.docker.com/linux/centos/$releasever/$basearch/stable
enabled=1
gpgcheck=1
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

这里获取结果

{
  "arch": "x86_64",
  "basearch": "x86_64",
  "releasever": "8"
}

所以实际的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

文件内容如下

<?xml version="1.0" encoding="UTF-8"?&gt;
<repomd xmlns="http://linux.duke.edu/metadata/repo" xmlns:rpm="http://linux.duke.edu/metadata/rpm"&gt;
  <revision&gt;1668722787</revision&gt;
  <data type="primary"&gt;
    <checksum type="sha256">be17658b784892066fdfbfe9ec068b16ee160f2a4c0d32f17cdb4571b6354755</checksum>
    <open-checksum type="sha256">a5c7c260751e6ca1ea7c77f6c991bb207d1e81055a6e0d7e5935084bc6981297</open-checksum>
    <location href="repodata/be17658b784892066fdfbfe9ec068b16ee160f2a4c0d32f17cdb4571b6354755-primary.xml.gz"/>
    <timestamp>1668722787</timestamp>
    <size>14654</size>
    <open-size>266294</open-size>
  </data>
  <data type="filelists">
    <checksum type="sha256">cf1a791d6c576477dda984611b48b44f1857a6914f291f1f66f2956a8c7f9ef3</checksum>
    <open-checksum type="sha256">c44aba02e3e5e6d1a2ee3ab957200908f04a18f52dc7a86b74a4fa9efa3ea4ac</open-checksum>
    <location href="repodata/cf1a791d6c576477dda984611b48b44f1857a6914f291f1f66f2956a8c7f9ef3-filelists.xml.gz"/>
    <timestamp>1668722787</timestamp>
    <size>16970</size>
    <open-size>370747</open-size>
  </data>
  <data type="other">
    <checksum type="sha256">abceebf147a05e99f2c07a0f31f61b5eaa15468c62bbe036c8627ed15db66885</checksum>
    <open-checksum type="sha256">12b2f5856fcee45052acfb910504a5da4d4c8dac588c069d2f990dda93a41382</open-checksum>
    <location href="repodata/abceebf147a05e99f2c07a0f31f61b5eaa15468c62bbe036c8627ed15db66885-other.xml.gz"/>
    <timestamp>1668722787</timestamp>
    <size>7245</size>
    <open-size>60645</open-size>
  </data>
  <data type="primary_db">
    <checksum type="sha256">fd30a988d4fac2906713cd09631c352fae8ba760649a3a23563afb20469c0f94</checksum>
    <open-checksum type="sha256">6c8f98ca6820379b70483f7bed54f9f47c32f8b420c88ea588e113746383afd0</open-checksum>
    <location href="repodata/fd30a988d4fac2906713cd09631c352fae8ba760649a3a23563afb20469c0f94-primary.sqlite.bz2"/>
    <timestamp>1668722787</timestamp>
    <size>49764</size>
    <open-size>360448</open-size>
    <database_version>10</database_version>
  </data>
  <data type="filelists_db">
    <checksum type="sha256">20e7bc1d075a56626855bf991b490ceede97aff17a4679a63f018e78905aa00a</checksum>
    <open-checksum type="sha256">91b51edaba3236b72a39b2d896b06aa54518fc1c9d1f1ee68712cca06c5aa286</open-checksum>
    <location href="repodata/20e7bc1d075a56626855bf991b490ceede97aff17a4679a63f018e78905aa00a-filelists.sqlite.bz2"/>
    <timestamp>1668722787</timestamp>
    <size>31574</size>
    <open-size>258048</open-size>
    <database_version>10</database_version>
  </data>
  <data type="other_db">
    <checksum type="sha256">073a126a1c676d7f28f6627b0ce62334599032e86819db0b1db5caa2c0200a29</checksum>
    <open-checksum type="sha256">ee2bd9ab4c2f461aa0ba80c5768f6691f519b35d0aebf72a12ccd593f064e7d7</open-checksum>
    <location href="repodata/073a126a1c676d7f28f6627b0ce62334599032e86819db0b1db5caa2c0200a29-other.sqlite.bz2"/>
    <timestamp>1668722787</timestamp>
    <size>12236</size>
    <open-size>77824</open-size>
    <database_version>10</database_version>
  </data>
  <data type="updateinfo">
    <checksum type="sha256">65c4f66e2808d328890505c3c2f13bb35a96f457d1c21a6346191c4dc07e6080</checksum>
    <open-checksum type="sha256">ded9c95e1b88197c906603b5d9693c579cb0afeade3bc7f8ec6cae06b962477d</open-checksum>
    <location href="repodata/65c4f66e2808d328890505c3c2f13bb35a96f457d1c21a6346191c4dc07e6080-updateinfo.xml.gz"/>
    <timestamp>1668722787</timestamp>
    <size>55</size>
    <open-size>42</open-size>
  </data>
</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文件中还定义了一些依赖关系需要安装依赖才能安装完这个包。

原文地址:https://blog.csdn.net/gsls200808/article/details/128037661

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_34852.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注