From c830c5057c8106de4353821760e3650f97f16c8b Mon Sep 17 00:00:00 2001 From: Aoran Zeng Date: Wed, 21 Jan 2026 17:12:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=20`repoURL`=20=E4=B8=8E=20`s?= =?UTF-8?q?mURL`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/10-如何编写recipe.md | 7 ++++--- doc/11-如何设置换源链接与测速链接.md | 10 +++++----- src/framework/chef.c | 18 ++++++++---------- src/framework/struct.h | 10 +++++----- src/recipe/lang/Dart/Flutter.c | 2 +- src/recipe/lang/Dart/Pub.c | 2 +- src/recipe/lang/Java.c | 2 +- src/recipe/lang/JavaScript/common.h | 4 ++-- src/recipe/lang/Perl.c | 2 +- src/recipe/lang/Python/common.h | 2 +- src/recipe/lang/Rust/rustup.c | 2 +- src/recipe/os/APT/Debian.c | 2 +- src/recipe/os/APT/Ubuntu.c | 4 ++-- src/recipe/os/Alpine-Linux.c | 2 +- src/recipe/os/OpenWrt.c | 2 +- src/recipe/os/Void-Linux.c | 2 +- src/recipe/os/YUM/AlmaLinux.c | 4 ++-- src/recipe/os/YUM/openEuler.c | 2 +- src/recipe/ware/Flatpak.c | 6 +++--- 19 files changed, 42 insertions(+), 43 deletions(-) diff --git a/doc/10-如何编写recipe.md b/doc/10-如何编写recipe.md index 64a2ba0..c35aec1 100644 --- a/doc/10-如何编写recipe.md +++ b/doc/10-如何编写recipe.md @@ -57,10 +57,11 @@ - **换源链接**: 指镜像站所提供的某一个具体的换源使用的URL - **测速链接**: 用来测速的URL,与 "换源链接" 不同,可分为 **精准测速** 和 **模糊测速** - 1. 在代码中,测速链接一般使用 `smurl` (即 `speed measure URL`) 来指代 - 2. 在代码中,换源链接一般使用 `repourl` (即 `repository URL`) 来指代 + 1. 在代码中,测速链接一般使用 `smURL` (即 `speed measure URL`) 或 `speed_measure_url` 来指代 + 2. 在代码中,换源链接一般使用 `repoURL` (即 `repository URL`) 或直接用 `url` 来指代 - 为什么不用 `regurl`,因为使用术语 `repository` 的 target 远多于使用术语 `registry` 的。 + - 为什么不用 `regurl`,因为使用术语 `repository` 的 target 远多于使用术语 `registry` 的。 + - 为什么莫名其妙使用了大小写混合的API? 因为 `smurl` 和 `repourl` 的可读性太差 - **镜像源**: 为了方便,**偶尔**我们将直接称`mirror`和/或`source`为**镜像源**,这只是一种方便性的称呼,可以统称二者,也可以根据上下文指代二者之一 diff --git a/doc/11-如何设置换源链接与测速链接.md b/doc/11-如何设置换源链接与测速链接.md index 003e2c9..0235591 100644 --- a/doc/11-如何设置换源链接与测速链接.md +++ b/doc/11-如何设置换源链接与测速链接.md @@ -28,7 +28,7 @@ def_sources_end() // // 调整上述某一个镜像站的所提供源的 "换源链接" -chef_set_url (this, &UpstreamProvider, "新的换源链接"); +chef_set_repoURL (this, &UpstreamProvider, "新的换源链接"); ```
@@ -59,14 +59,14 @@ def_sources_end() // // 调整/设置上述某一个镜像站的所提供源的 "精准测速链接" -chef_set_smurl (this, &UpstreamProvider, "新的测速链接") +chef_set_smURL (this, &UpstreamProvider, "新的测速链接") // 把所有上述源的 "测速链接" 设置为 "换源链接" + postfix -chef_set_all_smurl_with_postfix (this, "/dir/BigFile.tar.gz"); +chef_set_all_smURL_with_postfix (this, "/dir/BigFile.tar.gz"); // 基于 "换源链接" 做更自定义的操作 -chef_set_all_smurl_with_func (this, func, data); +chef_set_all_smURL_with_func (this, func, data); // 调整某一个镜像站(Provider)的 "测速链接" -chef_set_provider_smurl (&Tencent, "https://mirrors.cloud.tencent.com/npm/BigFile.tar.gz"); +chef_set_provider_smURL (&Tencent, "https://mirrors.cloud.tencent.com/npm/BigFile.tar.gz"); // 调整某一个镜像站(Provider)的 "测速精度" chef_set_provider_sm_accuracy (&UpstreamProvider, ROUGH); ``` diff --git a/src/framework/chef.c b/src/framework/chef.c index 7250e03..491ac5d 100644 --- a/src/framework/chef.c +++ b/src/framework/chef.c @@ -95,7 +95,7 @@ chef_register_contributor (char *id, char *name, char *email, char *display_name * @note 这个修改的是全局 Provider 里的信息。往往用来设置 UpstreamProvider */ void -chef_set_provider_smurl (SourceProvider_t *provider, char *url) +chef_set_provider_smURL (SourceProvider_t *provider, char *url) { provider->psmi.skip = NotSkip; provider->psmi.url = xy_strdup (url); @@ -117,12 +117,12 @@ chef_set_provider_sm_accuracy (SourceProvider_t *provider, bool accuracy) /** - * @brief 修改 或 补充 某个镜像站的换源链接 + * @brief 修改 或 补充 某个镜像站的换源链接,即修改 Source_t.url * * @example 见 os_ubuntu_resetsrc() 中对非 x86_64 架构源地址的修改 */ void -chef_set_url (Target_t *target, SourceProvider_t *provider, char *url) +chef_set_repoURL (Target_t *target, SourceProvider_t *provider, char *url) { xy_cant_be_null (target); xy_cant_be_null (provider); @@ -143,12 +143,10 @@ chef_set_url (Target_t *target, SourceProvider_t *provider, char *url) } /** - * 设置 或 修改 某个镜像站的 *精准*测速链接 - * - * sm = speed measure + * @breif 设置 或 修改 某个镜像站的 *精准*测速链接,即修改 Source_t.speed_measure_url */ void -chef_set_smurl (Target_t *target, SourceProvider_t *provider, char *url) +chef_set_smURL (Target_t *target, SourceProvider_t *provider, char *url) { xy_cant_be_null (target); xy_cant_be_null (provider); @@ -173,7 +171,7 @@ chef_set_smurl (Target_t *target, SourceProvider_t *provider, char *url) * @brief 提供一个函数,这个函数基于 "换源链接" 和用户提供的数据来构造和填充精准测速链接 */ void -chef_set_all_smurl_with_func ( +chef_set_all_smURL_with_func ( Target_t *target, char *(*func)(const char *url, const char *user_data), char *user_data) @@ -203,9 +201,9 @@ chef_set_all_smurl_with_func ( * @brief 给 "换源链接" 增加一个后缀来构造和填充专用测速链接 */ void -chef_set_all_smurl_with_postfix (Target_t *target, char *postfix) +chef_set_all_smURL_with_postfix (Target_t *target, char *postfix) { - chef_set_all_smurl_with_func (target, xy_2strcat, postfix); + chef_set_all_smURL_with_func (target, xy_2strcat, postfix); } diff --git a/src/framework/struct.h b/src/framework/struct.h index 6c5f17b..bef4664 100644 --- a/src/framework/struct.h +++ b/src/framework/struct.h @@ -77,10 +77,10 @@ typedef struct Source_t SourceProvider_t *provider; MirrorSite_t *mirror; }; - /* 用于换源的 URL */ + /* 用于换源的 URL,也称 repoURL */ char *url; - /* 对该 source 的专用测速链接,这就是精准测速 */ + /* 对该 source 的专用测速链接,这就是精准测速,也称 smURL */ char *speed_measure_url; } Source_t; @@ -181,9 +181,9 @@ Target_t; * def_sources_end() * * 若是出于代码美观考虑,上述第三列可以写 FeedByPrelude,然后下面调用函数来填充: - * chef_set_smurl() - * chef_set_all_smurl_with_postfix() - * chef_set_all_smurl_with_func() + * chef_set_smURL() + * chef_set_all_smURL_with_postfix() + * chef_set_all_smURL_with_func() */ #define def_sources_begin() Source_t sources[] = { #define def_sources_end() }; \ diff --git a/src/recipe/lang/Dart/Flutter.c b/src/recipe/lang/Dart/Flutter.c index bef6207..31398a8 100644 --- a/src/recipe/lang/Dart/Flutter.c +++ b/src/recipe/lang/Dart/Flutter.c @@ -29,7 +29,7 @@ pl_dart_flutter_prelude (void) {&Nju, "https://mirror.nju.edu.cn/flutter", FeedByPrelude} def_sources_end() - chef_set_all_smurl_with_postfix (this, "/flutter_infra_release/releases/stable/linux/flutter_linux_v1.0.0-stable.tar.xz"); + chef_set_all_smURL_with_postfix (this, "/flutter_infra_release/releases/stable/linux/flutter_linux_v1.0.0-stable.tar.xz"); } diff --git a/src/recipe/lang/Dart/Pub.c b/src/recipe/lang/Dart/Pub.c index cf63604..eeb5a52 100644 --- a/src/recipe/lang/Dart/Pub.c +++ b/src/recipe/lang/Dart/Pub.c @@ -29,7 +29,7 @@ pl_dart_prelude (void) {&Nju, "https://mirror.nju.edu.cn/dart-pub", FeedByPrelude} def_sources_end() - chef_set_all_smurl_with_postfix (this, "/packages/flutter_vision/versions/1.1.4.tar.gz"); + chef_set_all_smURL_with_postfix (this, "/packages/flutter_vision/versions/1.1.4.tar.gz"); } diff --git a/src/recipe/lang/Java.c b/src/recipe/lang/Java.c index 385a134..5336407 100644 --- a/src/recipe/lang/Java.c +++ b/src/recipe/lang/Java.c @@ -36,7 +36,7 @@ pl_java_prelude () def_sources_end() // 220MB - chef_set_all_smurl_with_postfix (this, "com/tencentcloudapi/tencentcloud-sdk-java/3.1.1033/tencentcloud-sdk-java-3.1.1033-javadoc.jar"); + chef_set_all_smURL_with_postfix (this, "com/tencentcloudapi/tencentcloud-sdk-java/3.1.1033/tencentcloud-sdk-java-3.1.1033-javadoc.jar"); } diff --git a/src/recipe/lang/JavaScript/common.h b/src/recipe/lang/JavaScript/common.h index d4379a9..e42812a 100644 --- a/src/recipe/lang/JavaScript/common.h +++ b/src/recipe/lang/JavaScript/common.h @@ -39,7 +39,7 @@ pl_js_group_prelude (void) def_sources_end() // 29MB 大小 - chef_set_all_smurl_with_postfix (this, "/@tensorflow/tfjs/-/tfjs-4.22.0.tgz"); + chef_set_all_smURL_with_postfix (this, "/@tensorflow/tfjs/-/tfjs-4.22.0.tgz"); } @@ -73,5 +73,5 @@ pl_js_nodejs_binary_prelude (void) {&Tencent, "https://mirrors.cloud.tencent.com/nodejs-release/", FeedByPrelude} def_sources_end() - chef_set_all_smurl_with_postfix (this, "/v23.4.0/node-v23.4.0-linux-x64.tar.xz"); + chef_set_all_smURL_with_postfix (this, "/v23.4.0/node-v23.4.0-linux-x64.tar.xz"); } diff --git a/src/recipe/lang/Perl.c b/src/recipe/lang/Perl.c index 42b4357..01c226b 100644 --- a/src/recipe/lang/Perl.c +++ b/src/recipe/lang/Perl.c @@ -39,7 +39,7 @@ pl_perl_prelude () {&Ali, "https://mirrors.aliyun.com/CPAN/", FeedByPrelude} def_sources_end() - chef_set_all_smurl_with_postfix (this, "authors/id/D/DB/DBAURAIN/Bio-MUST-Apps-FortyTwo-0.213470.tar.gz"); + chef_set_all_smURL_with_postfix (this, "authors/id/D/DB/DBAURAIN/Bio-MUST-Apps-FortyTwo-0.213470.tar.gz"); } diff --git a/src/recipe/lang/Python/common.h b/src/recipe/lang/Python/common.h index 9f38d74..9746cd2 100644 --- a/src/recipe/lang/Python/common.h +++ b/src/recipe/lang/Python/common.h @@ -70,7 +70,7 @@ pl_python_group_prelude (void) // {&Netease, "https://mirrors.163.com/.help/pypi.html", NULL} def_sources_end() - chef_set_all_smurl_with_func (this, pl_python_speed_url_constructor, NULL); + chef_set_all_smURL_with_func (this, pl_python_speed_url_constructor, NULL); } void diff --git a/src/recipe/lang/Rust/rustup.c b/src/recipe/lang/Rust/rustup.c index 72c996f..83d0cf5 100644 --- a/src/recipe/lang/Rust/rustup.c +++ b/src/recipe/lang/Rust/rustup.c @@ -38,7 +38,7 @@ pl_rust_rustup_prelude (void) def_sources_end() // 20MB大小 - chef_set_all_smurl_with_postfix (this, "/dist/2025-06-26/cargo-1.88.0-x86_64-unknown-illumos.tar.gz"); + chef_set_all_smURL_with_postfix (this, "/dist/2025-06-26/cargo-1.88.0-x86_64-unknown-illumos.tar.gz"); } diff --git a/src/recipe/os/APT/Debian.c b/src/recipe/os/APT/Debian.c index 70d3a8d..b91546c 100644 --- a/src/recipe/os/APT/Debian.c +++ b/src/recipe/os/APT/Debian.c @@ -42,7 +42,7 @@ os_debian_prelude () // {&Sohu, "https://mirrors.sohu.com/debian", FeedByPrelude} def_sources_end() - chef_set_all_smurl_with_postfix (this, "/dists/bookworm/main/Contents-all.gz"); + chef_set_all_smURL_with_postfix (this, "/dists/bookworm/main/Contents-all.gz"); } diff --git a/src/recipe/os/APT/Ubuntu.c b/src/recipe/os/APT/Ubuntu.c index abdf98d..f294254 100644 --- a/src/recipe/os/APT/Ubuntu.c +++ b/src/recipe/os/APT/Ubuntu.c @@ -43,7 +43,7 @@ os_ubuntu_prelude () // {&Sohu, "https://mirrors.sohu.com/ubuntu", FeedByPrelude} def_sources_end() - chef_set_all_smurl_with_postfix (this, "/dists/noble/Contents-amd64.gz"); + chef_set_all_smURL_with_postfix (this, "/dists/noble/Contents-amd64.gz"); } @@ -153,7 +153,7 @@ os_ubuntu_resetsrc (char *option) if (strncmp (arch, "x86_64", 6)!=0) { // Ubuntu 非 x86_64 架构的源地址有所不同 - chef_set_url (this, &UpstreamProvider, "http://ports.ubuntu.com/ubuntu"); + chef_set_repoURL (this, &UpstreamProvider, "http://ports.ubuntu.com/ubuntu"); // this->sources[0].url = "http://ports.ubuntu.com/ubuntu"; } os_ubuntu_setsrc (option); diff --git a/src/recipe/os/Alpine-Linux.c b/src/recipe/os/Alpine-Linux.c index e2a36c0..e57db52 100644 --- a/src/recipe/os/Alpine-Linux.c +++ b/src/recipe/os/Alpine-Linux.c @@ -35,7 +35,7 @@ os_alpine_prelude () {&Huawei, "https://mirrors.huaweicloud.com/alpine", FeedByPrelude} def_sources_end() - chef_set_all_smurl_with_postfix (this, "/latest-stable/releases/x86_64/alpine-standard-3.21.0-x86_64.iso"); + chef_set_all_smURL_with_postfix (this, "/latest-stable/releases/x86_64/alpine-standard-3.21.0-x86_64.iso"); } diff --git a/src/recipe/os/OpenWrt.c b/src/recipe/os/OpenWrt.c index e41da2f..026f42c 100644 --- a/src/recipe/os/OpenWrt.c +++ b/src/recipe/os/OpenWrt.c @@ -35,7 +35,7 @@ os_openwrt_prelude () {&Sustech, "https://mirrors.sustech.edu.cn/openwrt", DelegateToMirror} def_sources_end() - chef_set_provider_smurl (&UpstreamProvider, "https://downloads.openwrt.org/releases/23.05.5/targets/x86/64/openwrt-sdk-23.05.5-x86-64_gcc-12.3.0_musl.Linux-x86_64.tar.xz"); + chef_set_provider_smURL (&UpstreamProvider, "https://downloads.openwrt.org/releases/23.05.5/targets/x86/64/openwrt-sdk-23.05.5-x86-64_gcc-12.3.0_musl.Linux-x86_64.tar.xz"); } diff --git a/src/recipe/os/Void-Linux.c b/src/recipe/os/Void-Linux.c index ad5551e..d461b76 100644 --- a/src/recipe/os/Void-Linux.c +++ b/src/recipe/os/Void-Linux.c @@ -30,7 +30,7 @@ os_voidlinux_prelude () {&Bfsu, "https://mirrors.bfsu.edu.cn/voidlinux", FeedByPrelude} def_sources_end() - chef_set_all_smurl_with_postfix (this, "/live/20240314/void-live-x86_64-musl-20240314-xfce.iso"); + chef_set_all_smURL_with_postfix (this, "/live/20240314/void-live-x86_64-musl-20240314-xfce.iso"); } diff --git a/src/recipe/os/YUM/AlmaLinux.c b/src/recipe/os/YUM/AlmaLinux.c index 5285199..0a9dc08 100644 --- a/src/recipe/os/YUM/AlmaLinux.c +++ b/src/recipe/os/YUM/AlmaLinux.c @@ -33,8 +33,8 @@ os_almalinux_prelude () def_sources_end() #define link "/9.6/isos/x86_64/AlmaLinux-9-latest-x86_64-minimal.iso" - chef_set_all_smurl_with_postfix (this, link); - chef_set_provider_smurl (&UpstreamProvider, "https://raw.repo.almalinux.org/almalinux" link); + chef_set_all_smURL_with_postfix (this, link); + chef_set_provider_smURL (&UpstreamProvider, "https://raw.repo.almalinux.org/almalinux" link); #undef link } diff --git a/src/recipe/os/YUM/openEuler.c b/src/recipe/os/YUM/openEuler.c index b841364..731a089 100644 --- a/src/recipe/os/YUM/openEuler.c +++ b/src/recipe/os/YUM/openEuler.c @@ -38,7 +38,7 @@ os_openeuler_prelude () // {&Sohu, "https://mirrors.sohu.com/openeuler/", FeedByPrelude} def_sources_end() - chef_set_all_smurl_with_postfix (this, "https://repo.openeuler.org/openEuler-24.03-LTS/ISO/x86_64/openEuler-24.03-LTS-netinst-x86_64-dvd.iso"); + chef_set_all_smURL_with_postfix (this, "https://repo.openeuler.org/openEuler-24.03-LTS/ISO/x86_64/openEuler-24.03-LTS-netinst-x86_64-dvd.iso"); } diff --git a/src/recipe/ware/Flatpak.c b/src/recipe/ware/Flatpak.c index b5760c2..92185a5 100644 --- a/src/recipe/ware/Flatpak.c +++ b/src/recipe/ware/Flatpak.c @@ -31,7 +31,7 @@ wr_flatpak_prelude () def_sources_end() - chef_set_provider_smurl (&UpstreamProvider, "https://flathub.org/repo/flathub.gpg"); + chef_set_provider_smURL (&UpstreamProvider, "https://flathub.org/repo/flathub.gpg"); /* upstream 默认是 ACCURATE 的,但是我们给了一个超小的文件,测速效果严重失真,所以改为 ROUGH */ chef_set_provider_sm_accuracy (&UpstreamProvider, ROUGH); @@ -41,8 +41,8 @@ wr_flatpak_prelude () * 若无速度,则证明无法访问。 * 注意,这会使得测速的效果严重失真。 */ - chef_set_provider_smurl (&Sjtug_Siyuan, "https://mirror.sjtu.edu.cn/flathub/flathub.gpg"); - chef_set_provider_smurl (&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/flathub/flathub.gpg"); + chef_set_provider_smURL (&Sjtug_Siyuan, "https://mirror.sjtu.edu.cn/flathub/flathub.gpg"); + chef_set_provider_smURL (&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/flathub/flathub.gpg"); /* 由于实在找不到其他可测文件,所以这也只能是 ROUGH */ chef_set_provider_sm_accuracy (&Sjtug_Siyuan, ROUGH); chef_set_provider_sm_accuracy (&Sjtug_Zhiyuan, ROUGH);