From c67a9b31949ab6afbe712d114122d954ccdf90d4 Mon Sep 17 00:00:00 2001 From: Zenithal Date: Tue, 5 Jan 2021 13:06:04 +0800 Subject: [PATCH] Update centos help page for 7 and 8 closes tuna/issues/issues/1115 with reference to https://github.com/ustclug/mirrorhelp/commit/042d1e6e2caa0f9932b69af1b97de005fb56ec74 --- help/_posts/1970-01-01-centos.md | 136 +++---------------------------- 1 file changed, 13 insertions(+), 123 deletions(-) diff --git a/help/_posts/1970-01-01-centos.md b/help/_posts/1970-01-01-centos.md index 57c997b..cd88893 100644 --- a/help/_posts/1970-01-01-centos.md +++ b/help/_posts/1970-01-01-centos.md @@ -6,134 +6,24 @@ mirrorid: centos ## CentOS 镜像使用帮助 -建议先备份 CentOS-Base.repo +该文件夹只提供 CentOS 7 与 8,架构仅为 `x86_64` ,如果需要较早版本的 CentOS,请参考 centos-vault 的帮助,若需要其他架构,请参考 centos-altarch 的帮助。 + +建议先备份 `/etc/yum.repos.d/` 内的文件(CentOS 7 及之前为 `CentOS-Base.repo`,CentOS 8 为`CentOS-Linux-*.repo`) + +然后编辑 `/etc/yum.repos.d/` 中的相应文件,在 `mirrorlist=` 开头行前面加 `#` 注释掉;并将 `baseurl=` 开头行取消注释(如果被注释的话),把该行内的域名(例如`mirror.centos.org`)替换为 `{{ site.hostname }}`。 + +以上步骤可以被下方的命令一步完成 ``` -sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak +sudo sed -e 's|^mirrorlist=|#mirrorlist=|g' \ + -e 's|^#baseurl=http://mirror.centos.org|baseurl=https://{{ site.hostname }}|g' \ + -i.bak \ + /etc/yum.repos.d/CentOS-*.repo ``` -然后编辑 /etc/yum.repos.d/CentOS-Base.repo 文件,在 `mirrorlist=` 开头行前面加 `#` 注释掉;并将 `baseurl=` 开头行取消注释(如果被注释的话),把该行内的域名(例如`mirror.centos.org`)替换为 `{{ site.hostname }}`。 +注意其中的`*`通配符,如果只需要替换一些文件中的源,请自行增删。 -或者,你也可以直接使用如下内容覆盖掉 /etc/yum.repos.d/CentOS-Base.repo 文件:(未经充分测试) - - - -{% raw %} - -{% endraw %} - -
- -
-
-
-
+注意,如果需要启用其中一些 repo,需要将其中的 `enabled=0` 改为 `enabled=1`。
最后,更新软件包缓存