From 9f3ef4060dcf1fc9ecd34a0e44b9838af47bb054 Mon Sep 17 00:00:00 2001 From: Aoran Zeng Date: Sun, 24 Sep 2023 19:17:43 +0800 Subject: [PATCH] Add support for `rocky` Gitee close #I8025X --- chsrc.c | 34 ++++++++++++++++++++++++++++++++++ sources.h | 23 ++++++++++++++++++++--- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/chsrc.c b/chsrc.c index d684b0d..9b3db98 100644 --- a/chsrc.c +++ b/chsrc.c @@ -1277,6 +1277,37 @@ os_gentoo_setsrc(char* option) } + +/** + * 参考: https://help.mirrors.cernet.edu.cn/rocky/ + */ +void +os_rocky_setsrc (char* option) +{ + ensure_root(); + + int index = 0; + + if (NULL!=option) { + index = lets_find_mirror(os_rocky, option); + } else { + index = lets_test_speed(os_rocky); + } + + source_info source = os_rocky_sources[index]; + chsrc_say_selection(&source); + + char* cmd = xy_strjoin(3, + "sudo 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_runcmd(cmd); + chsrc_say_thanks(&source); +} + + + /** * HELP: 未经测试 */ @@ -1906,6 +1937,7 @@ target_info os_arch_target = {os_arch_setsrc, NULL, os_arch_sources, os_arch_sources_n}, os_manjaro_target = {os_manjaro_setsrc, NULL, NULL, 0}, os_gentoo_target = {os_gentoo_setsrc, NULL, os_gentoo_sources, os_gentoo_sources_n}, + os_rocky_target = {os_rocky_setsrc, NULL, os_rocky_sources, os_rocky_sources_n}, os_freebsd_target = {os_freebsd_setsrc, NULL, os_freebsd_sources, os_freebsd_sources_n}, os_netbsd_target = {os_netbsd_setsrc, NULL, os_netbsd_sources, os_netbsd_sources_n}, os_openbsd_target = {os_openbsd_setsrc, NULL, os_openbsd_sources, os_openbsd_sources_n}, @@ -1922,6 +1954,7 @@ static const char *os_arch [] = {"arch", NULL, targetinfo(&os_arch_target)}, *os_manjaro [] = {"manjaro", NULL, targetinfo(&os_manjaro_target)}, *os_gentoo [] = {"gentoo", NULL, targetinfo(&os_gentoo_target)}, +*os_rocky [] = {"rocky", "rockylinux", NULL, targetinfo(&os_rocky_target)}, *os_freebsd [] = {"freebsd", NULL, targetinfo(&os_freebsd_target)}, *os_netbsd [] = {"netbsd", NULL, targetinfo(&os_netbsd_target)}, *os_openbsd [] = {"openbsd", NULL, targetinfo(&os_openbsd_target)}, @@ -1932,6 +1965,7 @@ static const char { os_ubuntu, os_debian, os_fedora, os_opensuse, os_kali, os_arch, os_manjaro, os_gentoo, + os_rocky, os_freebsd, os_netbsd, os_openbsd, os_msys2, os_deepin, os_openeuler, os_openkylin, diff --git a/sources.h b/sources.h index 434082c..5ae3115 100644 --- a/sources.h +++ b/sources.h @@ -430,6 +430,21 @@ os_kali_sources[] = { +/** + * 2023-09-24 更新 + */ +os_rocky_sources[] = { + {&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/rocky"}, + {&Sustech, "https://mirrors.sustech.edu.cn/rocky-linux"}, + {&Zju, "https://mirrors.zju.edu.cn/rocky"}, + {&Lzuoss, "https://mirror.lzu.edu.cn/rocky"}, + {&Sohu, "https://mirrors.sohu.com/Rocky"}, + {&Netease, "https://mirrors.163.com/rocky"}, + {&Ali, "https://mirrors.aliyun.com/rockylinux"}, +}, + + + /** * 2023-09-02 更新 * @@ -673,10 +688,12 @@ def_target_sources_n(pl_ocaml); def_target_sources_n(pl_r); def_target_sources_n(pl_julia); def_target_sources_n(os_ubuntu); def_target_sources_n(os_debian); def_target_sources_n(os_fedora); -def_target_sources_n(os_kali); def_target_sources_n(os_openbsd); def_target_sources_n(os_msys2); -def_target_sources_n(os_arch); def_target_sources_n(os_gentoo); def_target_sources_n(os_netbsd); +def_target_sources_n(os_kali); def_target_sources_n(os_opensuse); +def_target_sources_n(os_arch); def_target_sources_n(os_gentoo); def_target_sources_n(os_rocky); +def_target_sources_n(os_msys2); +def_target_sources_n(os_freebsd); def_target_sources_n(os_netbsd); def_target_sources_n(os_openbsd); def_target_sources_n(os_deepin); def_target_sources_n(os_openeuler); def_target_sources_n(os_openkylin); -def_target_sources_n(os_freebsd); def_target_sources_n(os_opensuse); + def_target_sources_n(wr_brew); def_target_sources_n(wr_flathub); def_target_sources_n(wr_nix); def_target_sources_n(wr_guix);