From 0180558cb78446580976e0b8d7454e51751a9cd4 Mon Sep 17 00:00:00 2001 From: Aoran Zeng Date: Wed, 21 Jan 2026 18:12:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9API=E4=B8=BA=20`chef=5Fset=5F?= =?UTF-8?q?rest=5FsmURL=5F`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/11-如何设置换源链接与测速链接.md | 12 ++++++++---- src/framework/chef.c | 10 +++++----- src/framework/struct.h | 5 +---- 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 | 2 +- src/recipe/os/Alpine-Linux.c | 2 +- src/recipe/os/Void-Linux.c | 2 +- src/recipe/os/YUM/AlmaLinux.c | 2 +- src/recipe/os/YUM/openEuler.c | 2 +- 16 files changed, 28 insertions(+), 27 deletions(-) diff --git a/doc/11-如何设置换源链接与测速链接.md b/doc/11-如何设置换源链接与测速链接.md index 0235591..82d03d4 100644 --- a/doc/11-如何设置换源链接与测速链接.md +++ b/doc/11-如何设置换源链接与测速链接.md @@ -59,11 +59,15 @@ def_sources_end() // // 调整/设置上述某一个镜像站的所提供源的 "精准测速链接" -chef_set_smURL (this, &UpstreamProvider, "新的测速链接") -// 把所有上述源的 "测速链接" 设置为 "换源链接" + postfix -chef_set_all_smURL_with_postfix (this, "/dir/BigFile.tar.gz"); +chef_set_smURL (this, &UpstreamProvider, "新的测速链接"); +// 设置上述某一个镜像站的所提供源的 "精准测速链接" 设置为 "换源链接" + postfix +chef_set_smURL_with_postfix (this, &UpstreamProvider, "/dir/BigFile.tar.gz"); // 基于 "换源链接" 做更自定义的操作 -chef_set_all_smURL_with_func (this, func, data); +chef_set_smURL_with_func (this, &UpstreamProvider, func, data); + +// 把所有上述源中还未设置 "精准测速链接" 的源进行设置 +chef_set_rest_smURL_with_postfix (this, "/dir/BigFile.tar.gz"); +chef_set_rest_smURL_with_func (this, func, data); // 调整某一个镜像站(Provider)的 "测速链接" chef_set_provider_smURL (&Tencent, "https://mirrors.cloud.tencent.com/npm/BigFile.tar.gz"); diff --git a/src/framework/chef.c b/src/framework/chef.c index e2adf77..4cfcdf0 100644 --- a/src/framework/chef.c +++ b/src/framework/chef.c @@ -209,10 +209,10 @@ chef_set_smURL (Target_t *target, SourceProvider_t *provider, char *url) /** - * @brief 提供一个函数,这个函数基于 "换源链接" 和用户提供的数据来构造和填充精准测速链接 + * @brief 针对每一个剩下的还未设置专用测速链接的源,对其 "换源链接" 使用函数 `func` 来生成专用测速链接 */ void -chef_set_all_smURL_with_func ( +chef_set_rest_smURL_with_func ( Target_t *target, char *(*func)(const char *url, const char *user_data), char *user_data) @@ -239,12 +239,12 @@ chef_set_all_smURL_with_func ( /** - * @brief 给 "换源链接" 增加一个后缀来构造和填充专用测速链接 + * @brief 针对每一个剩下的还未设置专用测速链接的源,对其 "换源链接" 增加一个后缀来生成专用测速链接 */ void -chef_set_all_smURL_with_postfix (Target_t *target, char *postfix) +chef_set_rest_smURL_with_postfix (Target_t *target, char *postfix) { - chef_set_all_smURL_with_func (target, xy_2strcat, postfix); + chef_set_rest_smURL_with_func (target, xy_2strcat, postfix); } diff --git a/src/framework/struct.h b/src/framework/struct.h index bef4664..b259af3 100644 --- a/src/framework/struct.h +++ b/src/framework/struct.h @@ -180,10 +180,7 @@ Target_t; * {&某镜像站2, "换源URL", NULL }, // 若精准测速链接为空,则为模糊测速,默认使用该镜像站的整体测速链接 * def_sources_end() * - * 若是出于代码美观考虑,上述第三列可以写 FeedByPrelude,然后下面调用函数来填充: - * chef_set_smURL() - * chef_set_all_smURL_with_postfix() - * chef_set_all_smURL_with_func() + * 出于代码美观考虑,上述第三列可以写 FeedByPrelude,然后下面使用文档 ./doc/11-如何设置换源链接与测速链接.md 中的函数来填充 */ #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 31398a8..cb7df72 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_rest_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 eeb5a52..820b3f4 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_rest_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 5336407..ceaefe0 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_rest_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 e42812a..c8ffd1a 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_rest_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_rest_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 01c226b..ff4acf3 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_rest_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 9746cd2..9a965b2 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_rest_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 83d0cf5..d822219 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_rest_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 b91546c..a9e71e3 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_rest_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 f294254..56ee02d 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_rest_smURL_with_postfix (this, "/dists/noble/Contents-amd64.gz"); } diff --git a/src/recipe/os/Alpine-Linux.c b/src/recipe/os/Alpine-Linux.c index e57db52..c041b6e 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_rest_smURL_with_postfix (this, "/latest-stable/releases/x86_64/alpine-standard-3.21.0-x86_64.iso"); } diff --git a/src/recipe/os/Void-Linux.c b/src/recipe/os/Void-Linux.c index d461b76..2a5d663 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_rest_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 0a9dc08..b8e6512 100644 --- a/src/recipe/os/YUM/AlmaLinux.c +++ b/src/recipe/os/YUM/AlmaLinux.c @@ -33,7 +33,7 @@ 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_rest_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 731a089..4ebbfae 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_rest_smURL_with_postfix (this, "https://repo.openeuler.org/openEuler-24.03-LTS/ISO/x86_64/openEuler-24.03-LTS-netinst-x86_64-dvd.iso"); }