From 4d100239936a0a4f05a5231f697bcd5293a1f87b Mon Sep 17 00:00:00 2001 From: Aoran Zeng Date: Sun, 10 Aug 2025 13:15:58 +0800 Subject: [PATCH] Update YUM recipes using chef DSL --- src/recipe/os/YUM/AlmaLinux.c | 66 +++++++++++++++++++------------- src/recipe/os/YUM/Anolis-OS.c | 54 +++++++++++++++++--------- src/recipe/os/YUM/Fedora-Linux.c | 64 ++++++++++++++++++++----------- src/recipe/os/YUM/Rocky-Linux.c | 66 +++++++++++++++++++++----------- src/recipe/os/YUM/openEuler.c | 65 ++++++++++++++++++++----------- 5 files changed, 203 insertions(+), 112 deletions(-) diff --git a/src/recipe/os/YUM/AlmaLinux.c b/src/recipe/os/YUM/AlmaLinux.c index d2a485f..e4cb383 100644 --- a/src/recipe/os/YUM/AlmaLinux.c +++ b/src/recipe/os/YUM/AlmaLinux.c @@ -1,28 +1,44 @@ -chef_set_created_on ("2024-06-12"); -chef_set_authors ("Aoran Zeng "); -chef_set_contributors ("Yangmoooo "); -chef_allow_set(); -use_this; +/** ------------------------------------------------------------ + * SPDX-License-Identifier: GPL-3.0-or-later + * ------------------------------------------------------------*/ -static SourceProvider_t os_almalinux_upstream = -{ - def_upstream, "http://repo.almalinux.org/almalinux", - {NotSkip, NA, NA, "https://raw.repo.almalinux.org/almalinux/9.5/isos/x86_64/AlmaLinux-9-latest-x86_64-minimal.iso", ACCURATE} -}; +def_target(os_almalinux); -/** - * @update 2024-12-18 - */ -static Source_t os_almalinux_sources[] = +void +os_almalinux_prelude () { - {&os_almalinux_upstream , "http://repo.almalinux.org/almalinux", DelegateToUpstream}, - {&Ali, "https://mirrors.aliyun.com/almalinux", DelegateToMirror}, - {&Volcengine, "https://mirrors.volces.com/almalinux", DelegateToMirror}, - {&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/almalinux", DelegateToMirror}, - {&Zju, "https://mirrors.zju.edu.cn/almalinux", DelegateToMirror}, - {&Nju, "https://mirror.nju.edu.cn/almalinux", DelegateToMirror}, -}; -def_sources_n(os_almalinux); + use_this(os_almalinux); + + chef_set_created_on (this, "2024-06-12"); + chef_set_last_updated (this, "2025-08-10"); + chef_set_sources_last_updated (this, "2024-12-18"); + + chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com"); + chef_set_chef (this, NULL, NULL); + chef_set_sous_chefs (this, 0); + chef_set_contributors (this, 1, + "Yangmoooo", "yangmoooo@outlook.com"); + + chef_allow_set(); + + chef_allow_local_mode (this, CanNot, NULL, NULL); + chef_forbid_english(this); + chef_forbid_user_define(this); + + chef_set_note(this, NULL, NULL); + + def_upstream("http://repo.almalinux.org/almalinux"); + def_sources_begin() + {&upstream, "http://repo.almalinux.org/almalinux", DelegateToUpstream}, + {&Ali, "https://mirrors.aliyun.com/almalinux", DelegateToMirror}, + {&Volcengine, "https://mirrors.volces.com/almalinux", DelegateToMirror}, + {&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/almalinux", DelegateToMirror}, + {&Zju, "https://mirrors.zju.edu.cn/almalinux", DelegateToMirror}, + {&Nju, "https://mirror.nju.edu.cn/almalinux", DelegateToMirror} + def_sources_end() + + chsrc_set_provider_speed_measure_url (&upstream, "https://raw.repo.almalinux.org/almalinux/9.5/isos/x86_64/AlmaLinux-9-latest-x86_64-minimal.iso"); +} /** * @consult: https://developer.aliyun.com/mirror/almalinux @@ -32,7 +48,8 @@ os_almalinux_setsrc (char *option) { chsrc_ensure_root (); - chsrc_yield_source_and_confirm (os_almalinux); + use_this(os_almalinux); + Source_t source = chsrc_yield_source_and_confirm (this, option); 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"); @@ -43,6 +60,3 @@ os_almalinux_setsrc (char *option) chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } - - -def_target(os_almalinux); diff --git a/src/recipe/os/YUM/Anolis-OS.c b/src/recipe/os/YUM/Anolis-OS.c index 28428c1..3ffe24e 100644 --- a/src/recipe/os/YUM/Anolis-OS.c +++ b/src/recipe/os/YUM/Anolis-OS.c @@ -1,19 +1,39 @@ -chef_set_created_on ("2023-09-24"); -chef_set_authors ("Aoran Zeng "); -chef_set_contributors ("Nil Null "); -chef_allow_set(); -use_this; +/** ------------------------------------------------------------ + * SPDX-License-Identifier: GPL-3.0-or-later + * ------------------------------------------------------------*/ -/** - * @update 2024-06-12 - */ -static Source_t os_anolis_sources[] = +def_target(os_anolis); + +void +os_anolis_prelude () { - {&UpstreamProvider, NULL, NULL}, - {&Ali, "https://mirrors.aliyun.com/anolis", DelegateToMirror}, - {&Hust, "https://mirrors.hust.edu.cn/anolis", DelegateToMirror} -}; -def_sources_n(os_anolis); + use_this(os_anolis); + + chef_set_created_on (this, "2023-09-24"); + chef_set_last_updated (this, "2025-08-10"); + chef_set_sources_last_updated (this, "2024-06-12"); + + chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com"); + chef_set_chef (this, NULL, NULL); + chef_set_sous_chefs (this, 0); + chef_set_contributors (this, 1, + "Nil Null", "nil@null.org"); + + chef_allow_set(); + + chef_allow_local_mode (this, CanNot, NULL, NULL); + chef_forbid_english(this); + chef_forbid_user_define(this); + + chef_set_note(this, NULL, NULL); + + def_upstream("https://mirrors.openanolis.cn/anolis"); + def_sources_begin() + {&upstream, "https://mirrors.openanolis.cn/anolis", DelegateToUpstream}, + {&Ali, "https://mirrors.aliyun.com/anolis", DelegateToMirror}, + {&Hust, "https://mirrors.hust.edu.cn/anolis", DelegateToMirror} + def_sources_end() +} /** @@ -24,7 +44,8 @@ os_anolis_setsrc (char *option) { chsrc_ensure_root (); - chsrc_yield_source_and_confirm (os_anolis); + use_this(os_anolis); + Source_t source = chsrc_yield_source_and_confirm (this, option); char *cmd = xy_strjoin (3, "sed -i.bak -E 's|https?://(mirrors\\.openanolis\\.cn/anolis)|", source.url, "|g' /etc/yum.repos.d/*.repo"); chsrc_run (cmd, RunOpt_Default); @@ -35,6 +56,3 @@ os_anolis_setsrc (char *option) chsrc_determine_chgtype (ChgType_Untested); chsrc_conclude (&source); } - - -def_target(os_anolis); diff --git a/src/recipe/os/YUM/Fedora-Linux.c b/src/recipe/os/YUM/Fedora-Linux.c index 4d87d03..d5dd040 100644 --- a/src/recipe/os/YUM/Fedora-Linux.c +++ b/src/recipe/os/YUM/Fedora-Linux.c @@ -1,29 +1,51 @@ -chef_set_created_on ("2023-09-26"); -chef_set_authors ("Heng Guo <2085471348@qq.com>", "happy game "); -chef_set_contributors ("Aoran Zeng "); -chef_allow_set(); -chef_allow_reset(); -use_this; +/** ------------------------------------------------------------ + * SPDX-License-Identifier: GPL-3.0-or-later + * ------------------------------------------------------------*/ -/** - * @update 2025-06-20 - */ -static Source_t os_fedora_sources[] = +def_target(os_fedora); + +void +os_fedora_prelude () { - {&UpstreamProvider, "http://download.example/pub/fedora/linux", DelegateToUpstream}, - {&Ali, "https://mirrors.aliyun.com/fedora", DelegateToMirror}, - {&Bfsu, "https://mirrors.bfsu.edu.cn/fedora", DelegateToMirror}, - {&Ustc, "https://mirrors.ustc.edu.cn/fedora", DelegateToMirror}, - {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/fedora", DelegateToMirror}, - {&Tencent, "https://mirrors.tencent.com/fedora", DelegateToMirror}, + use_this(os_fedora); + + chef_set_created_on (this, "2023-09-26"); + chef_set_last_updated (this, "2025-08-10"); + chef_set_sources_last_updated (this, "2025-06-20"); + + chef_set_authors (this, 2, + "Heng Guo", "2085471348@qq.com", + "happy game", "happygame1024@gmail.com"); + chef_set_chef (this, NULL, NULL); + chef_set_sous_chefs (this, 0); + chef_set_contributors (this, 1, + "Aoran Zeng", "ccmywish@qq.com"); + + chef_allow_set(); + chef_allow_reset(); + + chef_allow_local_mode (this, CanNot, NULL, NULL); + chef_forbid_english(this); + chef_forbid_user_define(this); + + chef_set_note(this, NULL, NULL); + + def_upstream("http://download.example/pub/fedora/linux"); + def_sources_begin() + {&upstream, "http://download.example/pub/fedora/linux", DelegateToUpstream}, + {&Ali, "https://mirrors.aliyun.com/fedora", DelegateToMirror}, + {&Bfsu, "https://mirrors.bfsu.edu.cn/fedora", DelegateToMirror}, + {&Ustc, "https://mirrors.ustc.edu.cn/fedora", DelegateToMirror}, + {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/fedora", DelegateToMirror}, + {&Tencent, "https://mirrors.tencent.com/fedora", DelegateToMirror} // {&Tencent_Intra, "https://mirrors.tencentyun.com/fedora", DelegateToMirror}, /* 不启用原因:过慢 */ // {&Netease, "https://mirrors.163.com/fedora", DelegateToMirror}, /* 不启用原因:过慢 */ // {&Sohu, "https://mirrors.sohu.com/fedora", DelegateToMirror}" -}; -def_sources_n(os_fedora); + def_sources_end() +} /** @@ -36,7 +58,8 @@ os_fedora_setsrc (char *option) { chsrc_ensure_root (); - chsrc_yield_source_and_confirm (os_fedora); + use_this(os_fedora); + Source_t source = chsrc_yield_source_and_confirm (this, option); chsrc_alert2 ("Fedora 38 及以下版本暂不支持"); @@ -79,6 +102,3 @@ os_fedora_resetsrc (char *option) { os_fedora_setsrc (option); } - - -def_target(os_fedora); diff --git a/src/recipe/os/YUM/Rocky-Linux.c b/src/recipe/os/YUM/Rocky-Linux.c index 7b90413..ee11e74 100644 --- a/src/recipe/os/YUM/Rocky-Linux.c +++ b/src/recipe/os/YUM/Rocky-Linux.c @@ -1,30 +1,47 @@ -chef_set_created_on ("2023-09-24"); -chef_set_authors ("Aoran Zeng "); -chef_set_contributors ("happy game "); -chef_allow_set(); -chef_allow_reset(); -use_this; +/** ------------------------------------------------------------ + * SPDX-License-Identifier: GPL-3.0-or-later + * ------------------------------------------------------------*/ -/** - * @update 2025-06-20 - */ -static Source_t os_rockylinux_sources[] = +def_target(os_rockylinux); + +void +os_rockylinux_prelude () { - {&UpstreamProvider, NULL, NULL}, - {&MirrorZ, "https://mirrors.cernet.edu.cn/rocky", DelegateToMirror}, - {&Ali, "https://mirrors.aliyun.com/rockylinux", DelegateToMirror}, - {&Volcengine, "https://mirrors.volces.com/rockylinux", DelegateToMirror}, - {&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/rocky", DelegateToMirror}, - {&Sustech, "https://mirrors.sustech.edu.cn/rocky-linux", DelegateToMirror}, - {&Zju, "https://mirrors.zju.edu.cn/rocky", DelegateToMirror}, - {&Lzuoss, "https://mirror.lzu.edu.cn/rocky", DelegateToMirror}, + use_this(os_rockylinux); + chef_set_created_on (this, "2023-09-24"); + chef_set_last_updated (this, "2025-08-10"); + chef_set_sources_last_updated (this, "2025-06-20"); + + chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com"); + chef_set_chef (this, NULL, NULL); + chef_set_sous_chefs (this, 0); + chef_set_contributors (this, 1, + "happy game", "happygame1024@gmail.com"); + + chef_allow_set(); + chef_allow_reset(); + + chef_allow_local_mode (this, CanNot, NULL, NULL); + chef_forbid_english(this); + chef_forbid_user_define(this); + + def_upstream ("https://dl.rockylinux.org/"); + def_sources_begin() + {&upstream, "https://dl.rockylinux.org", DelegateToUpstream}, + {&MirrorZ, "https://mirrors.cernet.edu.cn/rocky", DelegateToMirror}, + {&Ali, "https://mirrors.aliyun.com/rockylinux", DelegateToMirror}, + {&Volcengine, "https://mirrors.volces.com/rockylinux", DelegateToMirror}, + {&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/rocky", DelegateToMirror}, + {&Sustech, "https://mirrors.sustech.edu.cn/rocky-linux", DelegateToMirror}, + {&Zju, "https://mirrors.zju.edu.cn/rocky", DelegateToMirror}, + {&Lzuoss, "https://mirror.lzu.edu.cn/rocky", DelegateToMirror}, /* 不启用原因:过慢 */ // {&Netease, "https://mirrors.163.com/rocky", DelegateToMirror}, - /* 不启用原因:过慢 */ + /* 不启用原因:过慢 */ // {&Sohu, "https://mirrors.sohu.com/Rocky", DelegateToMirror} -}; -def_sources_n(os_rockylinux); + def_sources_end() +} /** @@ -67,9 +84,12 @@ os_rockylinux_setsrc (char *option) chsrc_run (cmd, RunOpt_Default); chsrc_run ("dnf makecache", RunOpt_No_Last_New_Line); - chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } -def_target(os_rockylinux); +void +os_rockylinux_resetsrc (char *option) +{ + os_rockylinux_setsrc (option); +} diff --git a/src/recipe/os/YUM/openEuler.c b/src/recipe/os/YUM/openEuler.c index c1419da..7f0dd88 100644 --- a/src/recipe/os/YUM/openEuler.c +++ b/src/recipe/os/YUM/openEuler.c @@ -1,35 +1,53 @@ -chef_set_created_on ("2023-09-06"); -chef_set_authors ("Heng Guo <2085471348@qq.com>"); -chef_set_contributors ("Aoran Zeng ", "Yangmoooo ", "happy game "); -chef_allow_set(); -use_this; +/** ------------------------------------------------------------ + * SPDX-License-Identifier: GPL-3.0-or-later + * ------------------------------------------------------------*/ -static SourceProvider_t os_openEuler_upstream = +def_target(os_openeuler); + +void +os_openeuler_prelude () { - def_upstream, "https://repo.openeuler.org/", - {NotSkip, NA, NA, "https://repo.openeuler.org/openEuler-24.03-LTS/ISO/x86_64/openEuler-24.03-LTS-netinst-x86_64-dvd.iso", ACCURATE} // 896MB -}; + use_this(os_openeuler); + chef_set_created_on (this, "2023-09-06"); + chef_set_last_updated (this, "2025-08-10"); + chef_set_sources_last_updated (this, "2025-06-20"); -/** - * @update 2025-06-20 - */ -static Source_t os_openeuler_sources[] = -{ - {&os_openEuler_upstream, "https://repo.openeuler.org/", DelegateToUpstream}, - {&Ali, "https://mirrors.aliyun.com/openeuler/", DelegateToMirror}, - {&Bfsu, "https://mirrors.bfsu.edu.cn/openeuler/", DelegateToMirror}, - {&Ustc, "https://mirrors.ustc.edu.cn/openeuler/", DelegateToMirror}, - {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/openeuler/", DelegateToMirror}, - {&Tencent, "https://mirrors.tencent.com/openeuler/", DelegateToMirror}, + chef_set_authors (this, 1, "Heng Guo", "2085471348@qq.com"); + chef_set_chef (this, NULL, NULL); + chef_set_sous_chefs (this, 0); + chef_set_contributors (this, 3, + "Aoran Zeng", "ccmywish@qq.com", + "Yangmoooo", "yangmoooo@outlook.com", + "happy game", "happygame1024@gmail.com"); + + chef_allow_get(); + chef_allow_set(); + + chef_allow_local_mode (this, CanNot, NULL, NULL); + chef_forbid_english(this); + chef_forbid_user_define(this); + + chef_set_note(this, NULL, NULL); + + def_upstream("https://repo.openeuler.org/"); + def_sources_begin() + {&upstream, "https://repo.openeuler.org/", DelegateToUpstream}, + {&Ali, "https://mirrors.aliyun.com/openeuler/", DelegateToMirror}, + {&Bfsu, "https://mirrors.bfsu.edu.cn/openeuler/", DelegateToMirror}, + {&Ustc, "https://mirrors.ustc.edu.cn/openeuler/", DelegateToMirror}, + {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/openeuler/", DelegateToMirror}, + {&Tencent, "https://mirrors.tencent.com/openeuler/", DelegateToMirror} // {&Tencent_Intra, "https://mirrors.tencentyun.com/openeuler/", DelegateToMirror}, /* 不启用原因:过慢 */ // {&Netease, "https://mirrors.163.com/openeuler/", DelegateToMirror} /* 不启用原因:过慢 */ // {&Sohu, "https://mirrors.sohu.com/openeuler/", DelegateToMirror} -}; -def_sources_n(os_openeuler); + def_sources_end() + + chsrc_set_provider_speed_measure_url (&upstream, "https://repo.openeuler.org/openEuler-24.03-LTS/ISO/x86_64/openEuler-24.03-LTS-netinst-x86_64-dvd.iso"); +} /** @@ -50,7 +68,8 @@ os_openeuler_setsrc (char *option) { chsrc_ensure_root (); - chsrc_yield_source_and_confirm (os_openeuler); + use_this(os_openeuler); + Source_t source = chsrc_yield_source_and_confirm (this, option); chsrc_backup (OS_openEuler_SourceList);