Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复fedora换源的一些问题 #117

Merged
merged 2 commits into from
Nov 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions src/recipe/os/YUM/Fedora-Linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
* Contributors : Aoran Zeng <[email protected]>
* | happy game <[email protected]>
* Created On : <2023-09-26>
* Last Modified : <2024-10-09>
* Last Modified : <2024-11-04>
*
* 名称为 Fedora Linux
* ------------------------------------------------------------*/

/**
* @update 2024-10-09
* @update 2024-11-04
*/
static SourceInfo
os_fedora_sources[] = {
{&Upstream, NULL},
{&Upstream, "http://download.example/pub/fedora/linux"},
{&Ali, "https://mirrors.aliyun.com/fedora"},
{&Bfsu, "https://mirrors.bfsu.edu.cn/fedora"},
{&Ustc, "https://mirrors.ustc.edu.cn/fedora"},
Expand Down Expand Up @@ -45,14 +45,23 @@ os_fedora_setsrc (char *option)
chsrc_backup ("/etc/yum.repos.d/fedora.repo");
chsrc_backup ("/etc/yum.repos.d/fedora-updates.repo");

char* cmd = xy_strjoin (7, "sed ",
"-e 's|^#baseurl=http://download.example/pub/fedora/linux/|baseurl=",
source.url,
// 取消注释 baseurl
char* cmd = xy_strjoin (5, "sed ",
"-i 's|^#baseurl=|baseurl=",
"|g' ",
"-i.bak ",
"/etc/yum.repos.d/fedora.repo ",
"/etc/yum.repos.d/fedora-updates.repo");
chsrc_run (cmd, RunOpt_Default);

// fedora的换源涉及 /etc/yum.repos.d/fedora.repo和 /etc/yum.repos.d/fedora-updates.repo
// 需要替换 baseurl=source.url/releases/... 和 baseurl=source.url/releases/...
cmd = xy_strjoin (7, "sed ",
"-i -E 's!^baseurl=.*?/(releases|updates)/!baseurl=",
source.url,
"/\\1/",
"!g' ",
"/etc/yum.repos.d/fedora.repo ",
"/etc/yum.repos.d/fedora-updates.repo");
chsrc_run (cmd, RunOpt_Default);

chsrc_note2 ("已为您更换baseurl, 但fedora默认会优先使用metalink来匹配最快的源, 如您在获取metadata时速度较慢可自行将其注释:");
Expand Down