From 10d376885c75bfb10ed93f2beed8d979315d724f Mon Sep 17 00:00:00 2001 From: Aoran Zeng Date: Thu, 22 Aug 2024 17:13:50 +0800 Subject: [PATCH] Support Rocky Linux 8 [GitHub link #49] --- include/source.h | 3 ++- src/recipe/os/YUM/Rocky-Linux.c | 38 +++++++++++++++++++++++++++------ 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/include/source.h b/include/source.h index 6ae4438..20f7edc 100644 --- a/include/source.h +++ b/include/source.h @@ -6,7 +6,7 @@ * Contributors : Shengwei Chen <414685209@qq.com> * | * Created on : <2023-08-29> - * Last modified : <2024-08-17> + * Last modified : <2024-08-22> * * 镜像站与换源信息 * ------------------------------------------------------------*/ @@ -163,6 +163,7 @@ typedef struct TargetInfo_t { // 大部分target还不支持reset,所以暂时先默认设置为NULL来过渡 #define def_target(t) TargetInfo t##_target = {def_target_inner_gs(t),def_target_sourcesn(t)} +#define def_target_gs(t) TargetInfo t##_target = {def_target_inner_gs(t),def_target_sourcesn(t)} #define def_target_gsr(t) TargetInfo t##_target = {def_target_inner_gsr(t),def_target_sourcesn(t)} #define def_target_gsf(t) TargetInfo t##_target = {def_target_inner_gsf(t),def_target_sourcesn(t)} #define def_target_gsrf(t) TargetInfo t##_target = {def_target_inner_gsrf(t),def_target_sourcesn(t)} diff --git a/src/recipe/os/YUM/Rocky-Linux.c b/src/recipe/os/YUM/Rocky-Linux.c index 9ddd4c6..1cb8641 100644 --- a/src/recipe/os/YUM/Rocky-Linux.c +++ b/src/recipe/os/YUM/Rocky-Linux.c @@ -4,7 +4,7 @@ * File Authors : Aoran Zeng * Contributors : Nil Null * Created On : <2023-09-24> - * Last Modified : <2024-08-16> + * Last Modified : <2024-08-22> * ------------------------------------------------------------*/ /** @@ -13,6 +13,7 @@ static SourceInfo os_rockylinux_sources[] = { {&Upstream, NULL}, + {&MirrorZ, "https://mirrors.cernet.edu.cn/rocky"}, {&Ali, "https://mirrors.aliyun.com/rockylinux"}, {&Volcengine, "https://mirrors.volces.com/rockylinux"}, {&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/rocky"}, @@ -35,14 +36,39 @@ os_rockylinux_setsrc (char *option) chsrc_yield_source_and_confirm (os_rockylinux); - char *cmd = xy_strjoin (3, - "sed -e 's|^mirrorlist=|#mirrorlist=|g' " - "-e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=", source.url, "|g' " - "-i.bak /etc/yum.repos.d/rocky-extras.repo /etc/yum.repos.d/rocky.repo" - ); + + char *version_str = xy_run ("sed -nr 's/ROCKY_SUPPORT_PRODUCT_VERSION=(.*)/\\1/p' " ETC_os_release, 0, NULL); + version_str = xy_str_delete_suffix (version_str, "\n"); + double version = atof (version_str); + + char *cmd = NULL; + + if (version < 9) + { + cmd = xy_strjoin (3, + "sed -e 's|^mirrorlist=|#mirrorlist=|g' " + "-e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=", source.url, "|g' " + "-i.bak /etc/yum.repos.d/Rocky-*.repo" + ); + // Rocky-AppStream.repo + // Rocky-BaseOS.repo + // Rocky-Extras + // Rocky-PowerTools + } + else + { + cmd = xy_strjoin (3, + "sed -e 's|^mirrorlist=|#mirrorlist=|g' " + "-e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=", source.url, "|g' " + "-i.bak /etc/yum.repos.d/rocky-extras.repo /etc/yum.repos.d/rocky.repo" + ); + } + + chsrc_run (cmd, RunOpt_Default); chsrc_run ("dnf makecache", RunOpt_No_Last_New_Line); chsrc_conclude (&source, ChsrcTypeUntested); } + def_target_s(os_rockylinux);