Skip to content

Commit 6e40cfe

Browse files
committed
Add sources prepare for Debian
1 parent 6e2b332 commit 6e40cfe

File tree

3 files changed

+67
-13
lines changed

3 files changed

+67
-13
lines changed

src/framework/core.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,42 @@ measure_speed_for_every_source (Source_t sources[], int size, double speed_recor
818818

819819

820820

821+
/**
822+
* @brief 填充专用测速链接
823+
*
824+
* 该宏的作用是将某个 target 源的专用测速链接填充到 Source_t 中的 speed_url 字段中
825+
*
826+
* 即使不需要该宏也是可以的,但是代价就是维护者要维护比较重复的两个字段: url 和 speed_url
827+
*
828+
* @note 该宏仅当在 recipe 中使用, 由 <category>_<target>_sources_prepare() 调用
829+
*/
830+
#define chsrc_sources_prepare_speedurl_with_postfix(target,str) sources_prepare_speedurl_with_postfix(target##_sources, target##_sources_n, str)
831+
static void
832+
sources_prepare_speedurl_with_postfix (Source_t sources[], int n, char *postfix)
833+
{
834+
for (int i=0; i<n; i++)
835+
{
836+
Source_t *src = &sources[i];
837+
838+
ProviderType_t type = src->provider->type;
839+
840+
if (IS_DedicatedMirrorSite==type || IS_UpstreamProvider==type)
841+
{
842+
/* 这两个不用填,因为定义这二者的时候如果给了整体测速URL,则就是ACCURATE的,我们直接会DelegateTo那里 */
843+
continue;
844+
}
845+
846+
if (src->url)
847+
{
848+
/* 为空时才修改 或者里面是脏数据 */
849+
if (NULL==src->speed_measure_url || !is_url(src->speed_measure_url))
850+
src->speed_measure_url = xy_2strjoin (src->url, postfix);
851+
}
852+
}
853+
}
854+
855+
856+
821857
/**
822858
* 自动测速选择镜像站和源
823859
*/

src/framework/struct.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ Source_t;
9292
#define DelegateToMirror NULL
9393
/* 看到该注释的贡献者,你可以帮忙寻找专用测速链接 */
9494
#define NeedContribute NULL
95+
/* 由 _sources_prepare 填充 */
96+
#define FeedBySourcesPrepare NULL
9597

9698
#define def_sources_n(t) const size_t t##_sources_n = xy_arylen(t##_sources)
9799

src/recipe/os/APT/Debian.c

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
* |
99
* Created On : <2023-09-02>
1010
* Major Revision : 3
11-
* Last Modified : <2025-06-16>
11+
* Last Modified : <2025-07-11>
1212
* ------------------------------------------------------------*/
1313

14+
#define OS_Debian_Speed_URL_Postfix "/dists/bookworm/main/Contents-all.gz"
15+
1416
static SourceProvider_t os_debian_upstream =
1517
{
1618
def_upstream, "https://ftp.debian.org/debian/",
@@ -19,25 +21,39 @@ static SourceProvider_t os_debian_upstream =
1921

2022

2123
/**
22-
* @update 2024-11-21
24+
* @update 2025-07-11
2325
*/
2426
static Source_t os_debian_sources[] =
2527
{
26-
{&os_debian_upstream, "http://deb.debian.org/debian"},
27-
{&MirrorZ, "https://mirrors.cernet.edu.cn/debian/"},
28-
{&Ali, "https://mirrors.aliyun.com/debian"},
29-
{&Volcengine, "https://mirrors.volces.com/debian"},
30-
{&Bfsu, "https://mirrors.bfsu.edu.cn/debian"},
31-
{&Ustc, "https://mirrors.ustc.edu.cn/debian"},
32-
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/debian"},
33-
{&Tencent, "https://mirrors.tencent.com/debian"},
34-
// {&Tencent_Intra, "https://mirrors.tencentyun.com/debian"},
35-
// {&Netease, "https://mirrors.163.com/debian"}, /* 不启用原因:过慢 */
36-
// {&Sohu, "https://mirrors.sohu.com/debian"} /* 不启用原因:过慢 */
28+
{&os_debian_upstream, "http://deb.debian.org/debian", DelegateToUpstream},
29+
30+
/* MirrorZ 的速度这么测也是可以的 */
31+
{&MirrorZ, "https://mirrors.cernet.edu.cn/debian/", FeedBySourcesPrepare },
32+
{&Ali, "https://mirrors.aliyun.com/debian", FeedBySourcesPrepare},
33+
{&Volcengine, "https://mirrors.volces.com/debian", FeedBySourcesPrepare},
34+
{&Bfsu, "https://mirrors.bfsu.edu.cn/debian", FeedBySourcesPrepare},
35+
{&Ustc, "https://mirrors.ustc.edu.cn/debian", FeedBySourcesPrepare},
36+
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/debian", FeedBySourcesPrepare},
37+
{&Tencent, "https://mirrors.tencent.com/debian", FeedBySourcesPrepare},
38+
39+
// {&Tencent_Intra, "https://mirrors.tencentyun.com/debian", FeedBySourcesPrepare},
40+
41+
/* 不启用原因:过慢 */
42+
// {&Netease, "https://mirrors.163.com/debian", FeedBySourcesPrepare},
43+
44+
/* 不启用原因:过慢 */
45+
// {&Sohu, "https://mirrors.sohu.com/debian", FeedBySourcesPrepare}
3746
};
3847
def_sources_n(os_debian);
3948

4049

50+
void
51+
os_debian_sources_prepare ()
52+
{
53+
chsrc_sources_prepare_speedurl_with_postfix (os_debian, OS_Debian_Speed_URL_Postfix);
54+
}
55+
56+
4157
void
4258
os_debian_getsrc (char *option)
4359
{

0 commit comments

Comments
 (0)