Skip to content

Commit bebf1c3

Browse files
committed
fix: 修复 Debian 换源后 sources.list.d/ 下旧格式 deb-src.list 残留官方源的问题
1 parent 80f5f4f commit bebf1c3

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

‎src/recipe/os/APT/Debian.c‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ os_debian_prelude ()
1010
chef_prep_this (os_debian, gsr);
1111

1212
chef_set_recipe_created_on (this, "2023-09-02");
13-
chef_set_recipe_last_updated (this, "2026-06-26");
13+
chef_set_recipe_last_updated (this, "2026-08-08");
1414
chef_set_sources_last_updated (this, "2025-07-11");
1515

1616
chef_set_chef (this, NULL);
@@ -97,6 +97,13 @@ os_debian_setsrc_for_deb822 (char *option)
9797
cmd = xy_strcat (3, "sed -E -i 's@https?://.*/debian-security/?@", source.url, "-security@g' " OS_Debian_SourceList_DEB822);
9898
chsrc_run (cmd, RunOpt_Default);
9999

100+
/* 清理 sources.list.d/ 下旧格式 deb-src.list 等残留的官方源 (deb.debian.org) */
101+
chsrc_backup (OS_Apt_SourceList_D "deb-src.list");
102+
cmd = xy_strcat (3,
103+
"find " OS_Apt_SourceList_D " -name '*.list' -exec sed -i -E 's@https?://deb\\.debian\\.org/debian(-security)?@",
104+
source.url, "\\1@g' {} +");
105+
chsrc_run (cmd, RunOpt_Dont_Abort_On_Failure);
106+
100107
chsrc_run ("apt-get update", RunOpt_No_Last_New_Line);
101108

102109
chsrc_determine_chgtype (ChgType_Auto);
@@ -154,6 +161,14 @@ os_debian_setsrc (char *option)
154161
char *cmd = xy_strcat (3, "sed -E -i \'s@https?://.*/debian/?@", source.url, "@g\' " OS_Debian_old_SourceList);
155162

156163
chsrc_run (cmd, RunOpt_Default);
164+
165+
/* 清理 sources.list.d/ 下旧格式 deb-src.list 等残留的官方源 (deb.debian.org) */
166+
chsrc_backup (OS_Apt_SourceList_D "deb-src.list");
167+
cmd = xy_strcat (3,
168+
"find " OS_Apt_SourceList_D " -name '*.list' -exec sed -i -E 's@https?://deb\\.debian\\.org/debian(-security)?@",
169+
source.url, "\\1@g' {} +");
170+
chsrc_run (cmd, RunOpt_Dont_Abort_On_Failure);
171+
157172
chsrc_run ("apt-get update", RunOpt_No_Last_New_Line);
158173

159174
chsrc_determine_chgtype (ChgType_Auto);

0 commit comments

Comments
 (0)