diff --git a/include/source.h b/include/source.h index 641284a..8a92ecf 100644 --- a/include/source.h +++ b/include/source.h @@ -153,28 +153,12 @@ pl_dotnet_sources[] = { -/** - * @time 2023-09-02 更新 - * @note 源并不完整,且未经测试是否有效 - */ -static SourceInfo -os_fedora_sources[] = { - {&Upstream, NULL}, - {&Ali, "https://mirrors.aliyun.com/fedora"}, - {&Bfsu, "https://mirrors.bfsu.edu.cn/fedora"}, - {&Ustc, "https://mirrors.ustc.edu.cn/fedora"}, - {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/fedora"}, - {&Tencent, "https://mirrors.tencent.com/fedora"}, - {&Netease, "https://mirrors.163.com/fedora"}, - {&Sohu, "https://mirrors.sohu.com/fedora"} -}, - - /** * @time 2024-04-18 更新 * @note 源并不完整,且未经测试是否有效 */ +static SourceInfo os_msys2_sources[] = { {&Upstream, NULL}, {&Ali, "https://mirrors.aliyun.com/msys2"}, @@ -204,18 +188,6 @@ os_rocky_sources[] = { }, -/** - * @time 2024-06-12 更新 - */ -os_alma_sources[] = { - {&Upstream, NULL}, - {&Ali, "https://mirrors.aliyun.com/almalinux"}, - {&Volcengine, "https://mirrors.volces.com/almalinux"}, - {&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/almalinux"}, - {&Zju, "https://mirrors.zju.edu.cn/almalinux"}, - {&Nju, "https://mirror.nju.edu.cn/almalinux"}, -}, - @@ -377,9 +349,8 @@ wr_tex_sources[] = { def_sources_n(pl_clojure); def_sources_n(pl_dotnet); -def_sources_n(os_fedora); def_sources_n(os_msys2); -def_sources_n(os_rocky); def_sources_n(os_alma); +def_sources_n(os_rocky); def_sources_n(os_linuxlite); diff --git a/src/chsrc.c b/src/chsrc.c index 0018785..7546845 100644 --- a/src/chsrc.c +++ b/src/chsrc.c @@ -75,62 +75,24 @@ pl_clojure_setsrc (char *option) #include "recipe/os/apt-family/common.h" #include "recipe/os/apt-family/debian.c" #include "recipe/os/apt-family/ubuntu.c" - // Debian-based #include "recipe/os/apt-family/armbian.c" #include "recipe/os/apt-family/raspberrypi.c" #include "recipe/os/apt-family/kali.c" - // Ubuntu-based #include "recipe/os/apt-family/linuxmint.c" #include "recipe/os/apt-family/trisquel.c" - // Independent #include "recipe/os/apt-family/ros.c" #include "recipe/os/apt-family/deepin.c" -/** - * @note fedora 29 及以下版本暂不支持 - */ -void -os_fedora_setsrc (char *option) -{ - chsrc_ensure_root (); - - SourceInfo source; - chsrc_yield_source (os_fedora); - chsrc_confirm_source (&source); - - chsrc_note2 ("Fedora 29 及以下版本暂不支持"); - - chsrc_backup ("/etc/yum.repos.d/fedora.repo"); - chsrc_backup ("/etc/yum.repos.d/fedora-updates.repo"); - - char* cmd = xy_strjoin (9, "sed -e 's|^metalink=|#metalink=|g' ", - "-e 's|^#baseurl=http://download.example/pub/fedora/linux/|baseurl=", - source.url, - "|g' ", - "-i.bak ", - "/etc/yum.repos.d/fedora.repo ", - "/etc/yum.repos.d/fedora-modular.repo ", - "/etc/yum.repos.d/fedora-updates.repo ", - "/etc/yum.repos.d/fedora-updates-modular.repo"); - - chsrc_run (cmd, RunOpt_Default); - - chsrc_log2 ("已替换文件 /etc/yum.repos.d/fedora.repo"); - chsrc_log2 ("已新增文件 /etc/yum.repos.d/fedora-modular.repo"); - chsrc_log2 ("已替换文件 /etc/yum.repos.d/fedora-updates.repo"); - chsrc_log2 ("已新增文件 /etc/yum.repos.d/fedora-updates-modular.repo"); - - chsrc_run ("dnf makecache", RunOpt_No_Last_New_Line); - chsrc_say_lastly (&source, ChsrcTypeAuto); -} #include "recipe/os/opensuse.c" +#include "recipe/os/yum-family/fedora.c" +#include "recipe/os/yum-family/AlmaLinux.c" /** * HELP: 未经测试 @@ -187,26 +149,6 @@ os_rocky_setsrc (char *option) } -/** - * 参考: https://developer.aliyun.com/mirror/almalinux - */ -void -os_alma_setsrc (char *option) -{ - chsrc_ensure_root (); - - SourceInfo source; - chsrc_yield_source (os_alma); - chsrc_confirm_source (&source); - - char *cmd = xy_strjoin (3, - "sed -e 's|^mirrorlist=|#mirrorlist=|g' -e 's|^#\\s*baseurl=https://repo.almalinux.org/almalinux|baseurl=", source.url, "|g' -i.bak /etc/yum.repos.d/almalinux*.repo"); - - chsrc_run (cmd, RunOpt_Default); - chsrc_run ("dnf makecache", RunOpt_No_Last_New_Line); - chsrc_say_lastly (&source, ChsrcTypeAuto); -} - #include "recipe/os/alpine.c" #include "recipe/os/void.c" diff --git a/src/recipe/catalog.c b/src/recipe/catalog.c index 1c42b7a..4f39c24 100644 --- a/src/recipe/catalog.c +++ b/src/recipe/catalog.c @@ -41,9 +41,7 @@ static const char def_target(os_linuxlite); def_target(os_deepin); def_target(os_openkylin); -def_target_noget(os_fedora); def_target_noget(os_rocky); -def_target_noget(os_alma); def_target_noget(os_openeuler); def_target_noget(os_anolis); def_target_noget(os_msys2); @@ -62,7 +60,7 @@ static const char *os_manjaro [] = {"manjaro", NULL, t(&os_manjaro_target)}, *os_gentoo [] = {"gentoo", NULL, t(&os_gentoo_target)}, *os_rocky [] = {"rocky", "rockylinux", NULL, t(&os_rocky_target)}, -*os_alma [] = {"alma", "almalinux", NULL, t(&os_alma_target)}, +*os_almalinux [] = {"alma", "almalinux", NULL, t(&os_almalinux_target)}, *os_alpine [] = {"alpine", NULL, t(&os_alpine_target)}, *os_void [] = {"void", "voidlinux", NULL, t(&os_void_target)}, *os_solus [] = {"solus", NULL, t(&os_solus_target)}, @@ -85,12 +83,17 @@ static const char **os_systems[] = { - os_debian, os_ubuntu, os_linuxmint, os_fedora, os_opensuse, os_kali, - os_arch, os_archlinuxcn, os_manjaro, os_gentoo, - os_rocky, os_alma, - os_alpine, os_void, os_solus, os_ros, + os_debian, os_ubuntu, os_linuxmint, os_kali, os_trisquel, os_linuxlite, os_raspberrypi, os_armbian, os_openwrt, - os_deepin, os_openeuler, os_anolis, os_openkylin, + os_deepin, os_openkylin, os_ros, + + os_rocky, + os_fedora, os_almalinux, os_opensuse, + + os_arch, os_archlinuxcn, os_manjaro, os_gentoo, + + os_alpine, os_void, os_solus, + os_openeuler, os_anolis, os_msys2, os_freebsd, os_netbsd, os_openbsd, }; diff --git a/src/recipe/os/yum-family/AlmaLinux.c b/src/recipe/os/yum-family/AlmaLinux.c new file mode 100644 index 0000000..2d93f30 --- /dev/null +++ b/src/recipe/os/yum-family/AlmaLinux.c @@ -0,0 +1,44 @@ +/** ------------------------------------------------------------ + * SPDX-License-Identifier: GPL-3.0-or-later + * ------------------------------------------------------------- + * File Authors : Aoran Zeng + * Contributors : Nil Null + * Created On : <2024-06-12> + * Last Modified : <2024-08-16> + * ------------------------------------------------------------*/ + +/** + * @time 2024-06-12 更新 + */ +static SourceInfo +os_almalinux_sources[] = { + {&Upstream, NULL}, + {&Ali, "https://mirrors.aliyun.com/almalinux"}, + {&Volcengine, "https://mirrors.volces.com/almalinux"}, + {&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/almalinux"}, + {&Zju, "https://mirrors.zju.edu.cn/almalinux"}, + {&Nju, "https://mirror.nju.edu.cn/almalinux"}, +}; +def_sources_n(os_almalinux); + +/** + * 参考: https://developer.aliyun.com/mirror/almalinux + */ +void +os_almalinux_setsrc (char *option) +{ + chsrc_ensure_root (); + + SourceInfo source; + chsrc_yield_source (os_almalinux); + chsrc_confirm_source (&source); + + char *cmd = xy_strjoin (3, + "sed -e 's|^mirrorlist=|#mirrorlist=|g' -e 's|^#\\s*baseurl=https://repo.almalinux.org/almalinux|baseurl=", source.url, "|g' -i.bak /etc/yum.repos.d/almalinux*.repo"); + + chsrc_run (cmd, RunOpt_Default); + chsrc_run ("dnf makecache", RunOpt_No_Last_New_Line); + chsrc_say_lastly (&source, ChsrcTypeAuto); +} + +def_target_noget(os_almalinux); diff --git a/src/recipe/os/yum-family/fedora.c b/src/recipe/os/yum-family/fedora.c new file mode 100644 index 0000000..e4e6524 --- /dev/null +++ b/src/recipe/os/yum-family/fedora.c @@ -0,0 +1,66 @@ +/** ------------------------------------------------------------ + * SPDX-License-Identifier: GPL-3.0-or-later + * ------------------------------------------------------------- + * File Authors : Heng Guo <2085471348@qq.com> + * Contributors : Nil Null + * Created On : <2023-09-26> + * Last Modified : <2024-08-16> + * ------------------------------------------------------------*/ + +/** + * @time 2023-09-02 更新 + * @note 源并不完整,且未经测试是否有效 + */ +static SourceInfo +os_fedora_sources[] = { + {&Upstream, NULL}, + {&Ali, "https://mirrors.aliyun.com/fedora"}, + {&Bfsu, "https://mirrors.bfsu.edu.cn/fedora"}, + {&Ustc, "https://mirrors.ustc.edu.cn/fedora"}, + {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/fedora"}, + {&Tencent, "https://mirrors.tencent.com/fedora"}, + {&Netease, "https://mirrors.163.com/fedora"}, + {&Sohu, "https://mirrors.sohu.com/fedora"} +}; +def_sources_n(os_fedora); + + +/** + * @note fedora 29 及以下版本暂不支持 + */ +void +os_fedora_setsrc (char *option) +{ + chsrc_ensure_root (); + + SourceInfo source; + chsrc_yield_source (os_fedora); + chsrc_confirm_source (&source); + + chsrc_note2 ("Fedora 29 及以下版本暂不支持"); + + chsrc_backup ("/etc/yum.repos.d/fedora.repo"); + chsrc_backup ("/etc/yum.repos.d/fedora-updates.repo"); + + char* cmd = xy_strjoin (9, "sed -e 's|^metalink=|#metalink=|g' ", + "-e 's|^#baseurl=http://download.example/pub/fedora/linux/|baseurl=", + source.url, + "|g' ", + "-i.bak ", + "/etc/yum.repos.d/fedora.repo ", + "/etc/yum.repos.d/fedora-modular.repo ", + "/etc/yum.repos.d/fedora-updates.repo ", + "/etc/yum.repos.d/fedora-updates-modular.repo"); + + chsrc_run (cmd, RunOpt_Default); + + chsrc_log2 ("已替换文件 /etc/yum.repos.d/fedora.repo"); + chsrc_log2 ("已新增文件 /etc/yum.repos.d/fedora-modular.repo"); + chsrc_log2 ("已替换文件 /etc/yum.repos.d/fedora-updates.repo"); + chsrc_log2 ("已新增文件 /etc/yum.repos.d/fedora-updates-modular.repo"); + + chsrc_run ("dnf makecache", RunOpt_No_Last_New_Line); + chsrc_say_lastly (&source, ChsrcTypeAuto); +} + +def_target_noget(os_fedora);