From e1210e82ce2f64b59026a7b08ad4749e3737fb38 Mon Sep 17 00:00:00 2001 From: happy-game Date: Mon, 4 Nov 2024 09:06:12 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dfedora=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E5=86=8D=E6=AC=A1=E6=8D=A2=E6=BA=90=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/recipe/os/YUM/Fedora-Linux.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/recipe/os/YUM/Fedora-Linux.c b/src/recipe/os/YUM/Fedora-Linux.c index ab021ef..f03597d 100644 --- a/src/recipe/os/YUM/Fedora-Linux.c +++ b/src/recipe/os/YUM/Fedora-Linux.c @@ -5,7 +5,7 @@ * Contributors : Aoran Zeng * | happy game * Created On : <2023-09-26> - * Last Modified : <2024-10-09> + * Last Modified : <2024-11-04> * * 名称为 Fedora Linux * ------------------------------------------------------------*/ @@ -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时速度较慢可自行将其注释:");