Skip to content

Commit 8e144ca

Browse files
yayoinoyumeccmywish
authored andcommitted
fix(recipe): arch 换源幂等(仅 x86),清掉累积 Server 行并补官方兜底
- x86_64 换源前先清空 /etc/pacman.d/mirrorlist 中所有生效 Server 行(含多次换源累积的旧行) - 再写入「新源 + 官方源兜底」,保证每次换源后文件状态确定 - 幂等仅作用于 x86_64;ARM 分支保持原有行为(不清理、仅 prepend),不触及 ARM - 仅作用于 mirrorlist,不影响 pacman.conf 中的 archlinuxcn - 修正官方源地址:上游写的 repo.archlinux.org 域名不存在(DNS 无法解析,官方 mirrorlist 无此项),修正为 Arch 官方推荐的 geo.mirror.pkgbuild.com(自动按地理位置选最近镜像) - 按 doc/50 更新 recipe 时间戳(2026-09-06)、登记贡献者 @yayoinoyume(sauciers 2→3)
1 parent f2f86a4 commit 8e144ca

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

‎src/recipe/os/pacman/Arch-Linux.c‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,19 @@ def_dish(os_arch, "arch/archlinux");
77
#define OS_Pacman_MirrorList "/etc/pacman.d/mirrorlist"
88
#define OS_Pacman_ArchLinuxCN_MirrorList "/etc/pacman.conf"
99

10+
/* Arch 官方源(geo 自动选最近镜像),换源后作兜底 */
11+
#define OS_Arch_Upstream "https://geo.mirror.pkgbuild.com"
12+
1013
void
1114
os_arch_prepare ()
1215
{
13-
chef_prep_this_dish (os_arch, gs);
16+
chef_prep_this_dish (os_arch, gsr);
1417

1518
chef_set_recipe_created_on (this, "2023-09-05");
16-
chef_set_recipe_last_updated (this, "2025-10-30");
19+
chef_set_recipe_last_updated (this, "2026-09-06");
1720

1821
chef_set_chefs (this, 2, "@ccmywish", "@G_I_Y");
19-
chef_set_sauciers (this, 2, "@happy-game", "@Young-Lord");
22+
chef_set_sauciers (this, 3, "@happy-game", "@Young-Lord", "@yayoinoyume");
2023

2124
chef_set_os_scope (this);
2225
chef_deny_english(this);
@@ -30,7 +33,7 @@ os_arch_prepare ()
3033
* @note 不要给后面加 / ,因为ARM情况下,还要额外加一个 arm 后缀
3134
*/
3235
def_sources_begin()
33-
{&UpstreamProvider, "https://repo.archlinux.org", DelegateToUpstream},
36+
{&UpstreamProvider, "https://geo.mirror.pkgbuild.com", DelegateToUpstream},
3437
{&Ali, "https://mirrors.aliyun.com/archlinux", DelegateToMirror},
3538
{&Bfsu, "https://mirrors.bfsu.edu.cn/archlinux", DelegateToMirror},
3639
{&Ustc, "https://mirrors.ustc.edu.cn/archlinux", DelegateToMirror},
@@ -77,6 +80,12 @@ os_arch_setsrc (char *option)
7780
{
7881
is_x86 = true;
7982
to_write = xy_strcat (3, "Server = ", source.url, "/$repo/os/$arch\n");
83+
/* 新源后补官方兜底(目标即官方时不重复) */
84+
if (!xy_streql (source.url, OS_Arch_Upstream))
85+
to_write = xy_strcat (2, to_write, "Server = " OS_Arch_Upstream "/$repo/os/$arch\n");
86+
87+
/* 换源前先清掉已累积的 Server 行再写入,保证幂等(仅 x86) */
88+
chsrc_run ("sed -i '/^Server = /d' " OS_Pacman_MirrorList, RunOpt_Default);
8089
}
8190
else
8291
{
@@ -101,6 +110,13 @@ os_arch_setsrc (char *option)
101110
}
102111

103112

113+
/* reset = 恢复官方源,走同一 setsrc(框架会令 source 落到官方源) */
114+
void
115+
os_arch_resetsrc (char *option)
116+
{
117+
os_arch_setsrc (option);
118+
}
119+
104120

105121
/** ------------------------------------------------------------
106122
* archlinuxcn dish

0 commit comments

Comments
 (0)