mirror of
https://github.com/RubyMetric/chsrc
synced 2025-08-13 15:59:32 +08:00
Add set by postfix
This commit is contained in:
parent
341369f347
commit
caa90fee32
@ -829,42 +829,6 @@ measure_speed_for_every_source (Source_t sources[], int size, double speed_recor
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief 填充专用测速链接
|
||||
*
|
||||
* 该宏的作用是将某个 target 源的专用测速链接填充到 Source_t 中的 speed_url 字段中
|
||||
*
|
||||
* 即使不需要该宏也是可以的,但是代价就是维护者要维护比较重复的两个字段: url 和 speed_url
|
||||
*
|
||||
* @note 该宏仅当在 recipe 中使用, 由 <category>_<target>_sources_prepare() 调用
|
||||
*/
|
||||
#define chsrc_sources_prepare_speedurl_with_postfix(target,str) sources_prepare_speedurl_with_postfix(target##_sources, target##_sources_n, str)
|
||||
static void
|
||||
sources_prepare_speedurl_with_postfix (Source_t sources[], int n, char *postfix)
|
||||
{
|
||||
for (int i=0; i<n; i++)
|
||||
{
|
||||
Source_t *src = &sources[i];
|
||||
|
||||
ProviderType_t type = src->provider->type;
|
||||
|
||||
if (IS_DedicatedMirrorSite==type || IS_UpstreamProvider==type)
|
||||
{
|
||||
/* 这两个不用填,因为定义这二者的时候如果给了整体测速URL,则就是ACCURATE的,我们直接会DelegateTo那里 */
|
||||
continue;
|
||||
}
|
||||
|
||||
if (src->url)
|
||||
{
|
||||
/* 为空时才修改 或者里面是脏数据 */
|
||||
if (NULL==src->speed_measure_url || !chef_is_url (src->speed_measure_url))
|
||||
src->speed_measure_url = xy_2strjoin (src->url, postfix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 自动测速选择镜像站和源
|
||||
*/
|
||||
@ -1124,6 +1088,38 @@ chsrc_set_provider_speed_measure_accuracy (SourceProvider_t *provider, bool accu
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 填充专用测速链接
|
||||
*/
|
||||
static void
|
||||
chsrc_set_sources_speed_measure_url_with_postfix (Target_t *target, char *postfix)
|
||||
{
|
||||
Source_t *sources = &target->sources;
|
||||
|
||||
for (int i=0; i<n; i++)
|
||||
{
|
||||
Source_t *src = &sources[i];
|
||||
|
||||
ProviderType_t type = src->provider->type;
|
||||
|
||||
if (IS_DedicatedMirrorSite==type)
|
||||
{
|
||||
/* 这个不用填,因为定义它的时候如果给了整体测速URL,则就是ACCURATE的,我们直接会DelegateTo那里 */
|
||||
continue;
|
||||
}
|
||||
|
||||
if (src->url)
|
||||
{
|
||||
/* 为空时才修改 或者里面是脏数据 */
|
||||
if (NULL==src->speed_measure_url || !chef_is_url (src->speed_measure_url))
|
||||
src->speed_measure_url = xy_2strjoin (src->url, postfix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
chsrc_determine_chgtype (ChgType_t type)
|
||||
{
|
||||
|
@ -92,9 +92,7 @@ Source_t;
|
||||
/* 看到该注释的贡献者,你可以帮忙寻找专用测速链接 */
|
||||
#define NeedContribute NULL
|
||||
/* 由 _sources_prepare 填充 */
|
||||
#define FeedBySourcesPrepare NULL
|
||||
/* 由 prelude() 修改 */
|
||||
#define ChangedByPrelude NULL
|
||||
#define FeedByPrelude NULL
|
||||
|
||||
#define def_sources_n(t) const size_t t##_sources_n = xy_arylen(t##_sources)
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
#define PL_Dart_Pub_Speed_URL_Postfix "/packages/flutter_vision/versions/1.1.4.tar.gz"
|
||||
|
||||
def_target(pl_dart);
|
||||
|
||||
void
|
||||
@ -26,24 +24,19 @@ pl_dart_prelude (void)
|
||||
chef_allow_set();
|
||||
chef_allow_reset();
|
||||
|
||||
chef_allow_local_mode (this, FullyCan, "Pub 支持项目级换源", "Pub supports project-level source changing");
|
||||
chef_allow_local_mode (this, FullyCan, NULL, NULL);
|
||||
chef_allow_english(this);
|
||||
chef_allow_user_define(this);
|
||||
|
||||
def_sources_begin()
|
||||
{&upstream, "https://pub.dev", "https://pub.dev" PL_Dart_Pub_Speed_URL_Postfix},
|
||||
{&FlutterCN, "https://pub.flutter-io.cn",
|
||||
"https://pub.flutter-io.cn" PL_Dart_Pub_Speed_URL_Postfix},
|
||||
|
||||
{&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/dart-pub",
|
||||
"https://mirror.sjtu.edu.cn/dart-pub" PL_Dart_Pub_Speed_URL_Postfix},
|
||||
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/dart-pub",
|
||||
"https://mirrors.tuna.tsinghua.edu.cn/dart-pub" PL_Dart_Pub_Speed_URL_Postfix},
|
||||
|
||||
{&Nju, "https://mirror.nju.edu.cn/dart-pub",
|
||||
"https://mirror.nju.edu.cn/dart-pub" PL_Dart_Pub_Speed_URL_Postfix}
|
||||
{&upstream, "https://pub.dev", FeedByPrelude},
|
||||
{&FlutterCN, "https://pub.flutter-io.cn", FeedByPrelude},
|
||||
{&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/dart-pub", FeedByPrelude},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/dart-pub", FeedByPrelude,
|
||||
{&Nju, "https://mirror.nju.edu.cn/dart-pub", FeedByPrelude}
|
||||
def_sources_end()
|
||||
|
||||
chsrc_set_sources_speed_measure_url_with_postfix (this, "/packages/flutter_vision/versions/1.1.4.tar.gz");
|
||||
}
|
||||
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
#define OS_Debian_Speed_URL_Postfix "/dists/bookworm/main/Contents-all.gz"
|
||||
|
||||
def_target(os_debian);
|
||||
|
||||
void
|
||||
@ -35,45 +33,25 @@ os_debian_prelude ()
|
||||
chef_set_note(this, NULL, NULL);
|
||||
|
||||
def_sources_begin()
|
||||
{&upstream, "http://deb.debian.org/debian", DelegateToUpstream},
|
||||
{&upstream, "http://deb.debian.org/debian", FeedByPrelude},
|
||||
{&MirrorZ, "https://mirrors.cernet.edu.cn/debian/", FeedByPrelude},
|
||||
{&Ali, "https://mirrors.aliyun.com/debian", FeedByPrelude},
|
||||
{&Volcengine, "https://mirrors.volces.com/debian", FeedByPrelude},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/debian", FeedByPrelude},
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn/debian", FeedByPrelude},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/debian", FeedByPrelude},
|
||||
{&Tencent, "https://mirrors.tencent.com/debian", FeedByPrelude}
|
||||
|
||||
/* MirrorZ 的速度这么测也是可以的 */
|
||||
{&MirrorZ, "https://mirrors.cernet.edu.cn/debian/",
|
||||
"https://mirrors.cernet.edu.cn/debian/" OS_Debian_Speed_URL_Postfix},
|
||||
|
||||
{&Ali, "https://mirrors.aliyun.com/debian",
|
||||
"https://mirrors.aliyun.com/debian" OS_Debian_Speed_URL_Postfix},
|
||||
|
||||
{&Volcengine, "https://mirrors.volces.com/debian",
|
||||
"https://mirrors.volces.com/debian" OS_Debian_Speed_URL_Postfix},
|
||||
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/debian",
|
||||
"https://mirrors.bfsu.edu.cn/debian" OS_Debian_Speed_URL_Postfix},
|
||||
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn/debian",
|
||||
"https://mirrors.ustc.edu.cn/debian" OS_Debian_Speed_URL_Postfix},
|
||||
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/debian",
|
||||
"https://mirrors.tuna.tsinghua.edu.cn/debian" OS_Debian_Speed_URL_Postfix},
|
||||
|
||||
{&Tencent, "https://mirrors.tencent.com/debian",
|
||||
"https://mirrors.tencent.com/debian" OS_Debian_Speed_URL_Postfix}
|
||||
|
||||
// {&Tencent_Intra, "https://mirrors.tencentyun.com/debian", FeedBySourcesPrepare},
|
||||
// {&Tencent_Intra, "https://mirrors.tencentyun.com/debian", FeedByPrelude},
|
||||
|
||||
/* 不启用原因:过慢 */
|
||||
// {&Netease, "https://mirrors.163.com/debian", FeedBySourcesPrepare},
|
||||
// {&Netease, "https://mirrors.163.com/debian", FeedByPrelude},
|
||||
|
||||
/* 不启用原因:过慢 */
|
||||
// {&Sohu, "https://mirrors.sohu.com/debian", FeedBySourcesPrepare}
|
||||
// {&Sohu, "https://mirrors.sohu.com/debian", FeedByPrelude}
|
||||
def_sources_end()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
os_debian_sources_prepare ()
|
||||
{
|
||||
chsrc_sources_prepare_speedurl_with_postfix (os_debian, OS_Debian_Speed_URL_Postfix);
|
||||
chsrc_set_sources_speed_measure_url_with_postfix (this, "/dists/bookworm/main/Contents-all.gz");
|
||||
}
|
||||
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
#define OS_Ubuntu_Speed_URL_Postfix "/dists/noble/Contents-amd64.gz"
|
||||
|
||||
def_target(os_ubuntu);
|
||||
|
||||
void
|
||||
@ -34,47 +32,25 @@ os_ubuntu_prelude ()
|
||||
chef_set_note(this, NULL, NULL);
|
||||
|
||||
def_sources_begin()
|
||||
{&upstream, "http://archive.ubuntu.com/ubuntu/", /* 不支持https */
|
||||
DelegateToUpstream},
|
||||
|
||||
{&MirrorZ, "https://mirrors.cernet.edu.cn/ubuntu/",
|
||||
"https://mirrors.cernet.edu.cn/ubuntu/" OS_Ubuntu_Speed_URL_Postfix },
|
||||
|
||||
{&Ali, "https://mirrors.aliyun.com/ubuntu",
|
||||
"https://mirrors.aliyun.com/ubuntu" OS_Ubuntu_Speed_URL_Postfix},
|
||||
|
||||
{&Volcengine, "https://mirrors.volces.com/ubuntu",
|
||||
"https://mirrors.volces.com/ubuntu" OS_Ubuntu_Speed_URL_Postfix},
|
||||
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/ubuntu",
|
||||
"https://mirrors.bfsu.edu.cn/ubuntu" OS_Ubuntu_Speed_URL_Postfix},
|
||||
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn/ubuntu",
|
||||
"https://mirrors.ustc.edu.cn/ubuntu" OS_Ubuntu_Speed_URL_Postfix},
|
||||
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/ubuntu",
|
||||
"https://mirrors.tuna.tsinghua.edu.cn/ubuntu" OS_Ubuntu_Speed_URL_Postfix},
|
||||
|
||||
{&Tencent, "https://mirrors.tencent.com/ubuntu",
|
||||
{&Tencent, "https://mirrors.tencent.com/ubuntu",
|
||||
"https://mirrors.tencent.com/ubuntu" OS_Ubuntu_Speed_URL_Postfix},
|
||||
|
||||
// {&Tencent_Intra, "https://mirrors.tencentyun.com/ubuntu",
|
||||
// "https://mirrors.tencentyun.com/ubuntu" OS_Ubuntu_Speed_URL_Postfix},
|
||||
|
||||
{&Huawei, "https://mirrors.huaweicloud.com/ubuntu",
|
||||
"https://mirrors.huaweicloud.com/ubuntu" OS_Ubuntu_Speed_URL_Postfix}
|
||||
{&upstream, "http://archive.ubuntu.com/ubuntu/", FeedByPrelude}, /* 不支持https */
|
||||
{&MirrorZ, "https://mirrors.cernet.edu.cn/ubuntu/",FeedByPrelude},
|
||||
{&Ali, "https://mirrors.aliyun.com/ubuntu",FeedByPrelude},
|
||||
{&Volcengine, "https://mirrors.volces.com/ubuntu",FeedByPrelude},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/ubuntu",FeedByPrelude},
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn/ubuntu",FeedByPrelude},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/ubuntu",FeedByPrelude},
|
||||
{&Tencent, "https://mirrors.tencent.com/ubuntu", FeedByPrelude},
|
||||
// {&Tencent_Intra, "https://mirrors.tencentyun.com/ubuntu",FeedByPrelude},
|
||||
{&Huawei, "https://mirrors.huaweicloud.com/ubuntu",FeedByPrelude}
|
||||
|
||||
/* 不启用原因:过慢 */
|
||||
// {&Netease, "https://mirrors.163.com/ubuntu",
|
||||
// "https://mirrors.163.com/ubuntu" OS_Ubuntu_Speed_URL_Postfix},
|
||||
// {&Netease, "https://mirrors.163.com/ubuntu", FeedByPrelude},
|
||||
|
||||
/* 不启用原因:过慢 */
|
||||
// {&Sohu, "https://mirrors.sohu.com/ubuntu",
|
||||
// "https://mirrors.sohu.com/ubuntu" OS_Ubuntu_Speed_URL_Postfix}
|
||||
// {&Sohu, "https://mirrors.sohu.com/ubuntu", FeedByPrelude}
|
||||
def_sources_end()
|
||||
|
||||
chsrc_set_provider_speed_measure_url (&upstream, "http://archive.ubuntu.com/ubuntu/dists/noble/Contents-amd64.gz");
|
||||
chsrc_set_sources_speed_measure_url_with_postfix (this, "/dists/noble/Contents-amd64.gz");
|
||||
}
|
||||
|
||||
|
||||
|
@ -30,18 +30,18 @@ os_alpine_prelude ()
|
||||
chef_set_note(this, NULL, NULL);
|
||||
|
||||
def_sources_begin()
|
||||
{&upstream, "http://dl-cdn.alpinelinux.org/alpine", DelegateToUpstream},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/alpine", DelegateToMirror},
|
||||
{&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/alpine", DelegateToMirror},
|
||||
{&Sustech, "https://mirrors.sustech.edu.cn/alpine", DelegateToMirror},
|
||||
{&Zju, "https://mirrors.zju.edu.cn/alpine", DelegateToMirror},
|
||||
{&Lzuoss, "https://mirror.lzu.edu.cn/alpine", DelegateToMirror},
|
||||
{&Ali, "https://mirrors.aliyun.com/alpine", DelegateToMirror},
|
||||
{&Tencent, "https://mirrors.cloud.tencent.com/alpine", DelegateToMirror},
|
||||
{&Huawei, "https://mirrors.huaweicloud.com/alpine", DelegateToMirror}
|
||||
{&upstream, "http://dl-cdn.alpinelinux.org/alpine", FeedByPrelude},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/alpine", FeedByPrelude},
|
||||
{&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/alpine", FeedByPrelude},
|
||||
{&Sustech, "https://mirrors.sustech.edu.cn/alpine", FeedByPrelude},
|
||||
{&Zju, "https://mirrors.zju.edu.cn/alpine", FeedByPrelude},
|
||||
{&Lzuoss, "https://mirror.lzu.edu.cn/alpine", FeedByPrelude},
|
||||
{&Ali, "https://mirrors.aliyun.com/alpine", FeedByPrelude},
|
||||
{&Tencent, "https://mirrors.cloud.tencent.com/alpine", FeedByPrelude},
|
||||
{&Huawei, "https://mirrors.huaweicloud.com/alpine", FeedByPrelude}
|
||||
def_sources_end()
|
||||
|
||||
chsrc_set_provider_speed_measure_url (&upstream, "https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/x86_64/alpine-standard-3.21.0-x86_64.iso");
|
||||
chsrc_set_sources_speed_measure_url_with_postfix (this, "/latest-stable/releases/x86_64/alpine-standard-3.21.0-x86_64.iso");
|
||||
}
|
||||
|
||||
|
||||
|
@ -30,13 +30,13 @@ os_voidlinux_prelude ()
|
||||
chef_set_note(this, NULL, NULL);
|
||||
|
||||
def_sources_begin()
|
||||
{&upstream, "https://repo-default.voidlinux.org", DelegateToUpstream},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/voidlinux", DelegateToMirror},
|
||||
{&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/voidlinux", DelegateToMirror},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/voidlinux", DelegateToMirror}
|
||||
{&upstream, "https://repo-default.voidlinux.org", FeedByPrelude},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/voidlinux", FeedByPrelude},
|
||||
{&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/voidlinux", FeedByPrelude},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/voidlinux", FeedByPrelude}
|
||||
def_sources_end()
|
||||
|
||||
chsrc_set_provider_speed_measure_url (&upstream, "https://repo-default.voidlinux.org/live/20240314/void-live-x86_64-musl-20240314-xfce.iso");
|
||||
chsrc_set_sources_speed_measure_url_with_postfix (this, "/live/20240314/void-live-x86_64-musl-20240314-xfce.iso");
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,12 +28,12 @@ os_almalinux_prelude ()
|
||||
chef_set_note(this, NULL, NULL);
|
||||
|
||||
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}
|
||||
{&upstream, "http://repo.almalinux.org/almalinux", FeedByPrelude},
|
||||
{&Ali, "https://mirrors.aliyun.com/almalinux", FeedByPrelude},
|
||||
{&Volcengine, "https://mirrors.volces.com/almalinux", FeedByPrelude},
|
||||
{&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/almalinux", FeedByPrelude},
|
||||
{&Zju, "https://mirrors.zju.edu.cn/almalinux", FeedByPrelude},
|
||||
{&Nju, "https://mirror.nju.edu.cn/almalinux", FeedByPrelude}
|
||||
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");
|
||||
|
@ -31,21 +31,21 @@ os_openeuler_prelude ()
|
||||
chef_set_note(this, NULL, NULL);
|
||||
|
||||
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},
|
||||
{&upstream, "https://repo.openeuler.org/", FeedByPrelude},
|
||||
{&Ali, "https://mirrors.aliyun.com/openeuler/", FeedByPrelude},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/openeuler/", FeedByPrelude},
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn/openeuler/", FeedByPrelude},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/openeuler/", FeedByPrelude},
|
||||
{&Tencent, "https://mirrors.tencent.com/openeuler/", FeedByPrelude}
|
||||
// {&Tencent_Intra, "https://mirrors.tencentyun.com/openeuler/", FeedByPrelude},
|
||||
|
||||
/* 不启用原因:过慢 */
|
||||
// {&Netease, "https://mirrors.163.com/openeuler/", DelegateToMirror}
|
||||
// {&Netease, "https://mirrors.163.com/openeuler/", FeedByPrelude}
|
||||
/* 不启用原因:过慢 */
|
||||
// {&Sohu, "https://mirrors.sohu.com/openeuler/", DelegateToMirror}
|
||||
// {&Sohu, "https://mirrors.sohu.com/openeuler/", FeedByPrelude}
|
||||
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");
|
||||
chsrc_set_sources_speed_measure_url_with_postfix (this, "https://repo.openeuler.org/openEuler-24.03-LTS/ISO/x86_64/openEuler-24.03-LTS-netinst-x86_64-dvd.iso");
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user