diff --git a/src/chsrc-main.c b/src/chsrc-main.c index bf41f528..813b91fa 100644 --- a/src/chsrc-main.c +++ b/src/chsrc-main.c @@ -72,6 +72,7 @@ chsrc_register_contributors () chef_register_contributor ("@Mikachu2333", "Mikachu2333", "mikachu.23333@zohomail.com", NULL); chef_register_contributor ("@techoc", "Rui Yang", "techoc@foxmail.com", NULL); chef_register_contributor ("@BingChunMoLi", "BingChunMoLi", "bingchunmoli@bingchunmoli.com", NULL); + chef_register_contributor ("@wcbing", "wcbing", "i@wcbing.top", NULL); // 该注释下一行的用户 ID 为 Gitee ID chef_register_contributor ("@hezonglun", "HeZongLun", "hezonglun123456@outlook.com", NULL); chef_register_contributor ("@Young-Lord", "LY", "ly-niko@qq.com", NULL); diff --git a/src/recipe/os/APT/Debian.c b/src/recipe/os/APT/Debian.c index 6d865c87..10cf357d 100644 --- a/src/recipe/os/APT/Debian.c +++ b/src/recipe/os/APT/Debian.c @@ -10,12 +10,12 @@ os_debian_prelude () chef_prep_this (os_debian, gsr); chef_set_recipe_created_on (this, "2023-09-02"); - chef_set_recipe_last_updated (this, "2025-11-09"); + chef_set_recipe_last_updated (this, "2026-06-26"); chef_set_sources_last_updated (this, "2025-07-11"); chef_set_chef (this, NULL); chef_set_cooks (this, 2, "@ccmywish", "@G_I_Y"); - chef_set_sauciers (this, 1, "@Yangmoooo"); + chef_set_sauciers (this, 2, "@Yangmoooo", "@wcbing"); chef_set_os_scope (this); @@ -86,6 +86,8 @@ os_debian_setsrc_for_deb822 (char *option) { chsrc_use_this_source (os_debian); + ensure_ca_certificates (&source); + chsrc_backup (OS_Debian_SourceList_DEB822); char *cmd = xy_strcat (3, "sed -E -i 's@https?://.*/debian/?@", source.url, "@g' " OS_Debian_SourceList_DEB822); @@ -104,9 +106,6 @@ os_debian_setsrc_for_deb822 (char *option) /** * 处理旧版(非DEB822) sourcelist 的换源 - * - * Debian 10 Buster 以上版本默认支持 HTTPS 源。如果遇到无法拉取 HTTPS 源的情况,请先使用 HTTP 源并安装 - * apt install apt-transport-https ca-certificates */ void os_debian_setsrc (char *option) @@ -147,8 +146,7 @@ os_debian_setsrc (char *option) chsrc_use_this_source (os_debian); - chsrc_alert2 ("如果遇到无法拉取 HTTPS 源的情况,请手动运行:"); - say ("apt install apt-transport-https ca-certificates"); + ensure_ca_certificates (&source); /* 不存在的时候,用的是我们生成的用来填充占位的无效文件,不要备份 */ if (sourcelist_exist) diff --git a/src/recipe/os/APT/Ubuntu.c b/src/recipe/os/APT/Ubuntu.c index 85b1d412..4b4e6457 100644 --- a/src/recipe/os/APT/Ubuntu.c +++ b/src/recipe/os/APT/Ubuntu.c @@ -11,12 +11,12 @@ os_ubuntu_prelude () chef_prep_this (os_ubuntu, gsr); chef_set_recipe_created_on (this, "2023-08-30"); - chef_set_recipe_last_updated (this, "2026-01-21"); + chef_set_recipe_last_updated (this, "2026-06-26"); chef_set_sources_last_updated (this, "2026-01-21"); chef_set_chef (this, NULL); chef_set_cooks (this, 2, "@ccmywish", "@G_I_Y"); - chef_set_sauciers (this, 2, "@XUANJI233", "@usernameisnull"); + chef_set_sauciers (this, 3, "@XUANJI233", "@usernameisnull", "@wcbing"); chef_set_os_scope (this); @@ -85,6 +85,8 @@ os_ubuntu_setsrc_for_deb822 (char *option) { chsrc_use_this_source (os_ubuntu); + ensure_ca_certificates (&source); + chsrc_backup (OS_Ubuntu_SourceList_DEB822); char *arch = chsrc_get_cpuarch (); @@ -128,6 +130,8 @@ os_ubuntu_setsrc (char *option) chsrc_use_this_source (os_ubuntu); + ensure_ca_certificates (&source); + /* 不存在的时候,用的是我们生成的无效文件,不要备份 */ if (sourcelist_exist) { diff --git a/src/recipe/os/APT/common.h b/src/recipe/os/APT/common.h index 77fd3303..a1efef3f 100644 --- a/src/recipe/os/APT/common.h +++ b/src/recipe/os/APT/common.h @@ -2,11 +2,11 @@ * SPDX-License-Identifier: GPL-3.0-or-later * ------------------------------------------------------------- * File Authors : @ccmywish - * Contributors : @happy-game + * Contributors : @happy-game @wcbing * | * Created On : <2024-06-14> - * Major Revision : 3 - * Last Modified : <2025-07-14> + * Major Revision : 4 + * Last Modified : <2026-06-26> * ------------------------------------------------------------*/ #include "rawstr4c.h" @@ -118,3 +118,26 @@ ensure_debian_or_ubuntu_old_sourcelist (int debian_type) fclose (f); return false; } + + +/** + * 确保 ca-certificates 已安装,否则切换到 http 源 + * + * @note Debian 10 Buster 以上版本默认支持 HTTPS 源。如果遇到无法拉取 HTTPS 源的情况,请先使用 HTTP 源并执行 + * apt install ca-certificates + */ +void +ensure_ca_certificates (Source_t *source) +{ + bool has_ca = xy_file_exist ("/usr/share/doc/ca-certificates/copyright") || xy_file_exist ("/usr/sbin/update-ca-certificates"); + if (!has_ca && strncmp (source->url, "https://", 8) == 0) + { + chsrc_warn2 (ENGLISH ? "ca-certificates is not installed, temporarily using http source instead" + : "未检测到 ca-certificates,将临时换为 http 源"); + source->url = xy_strcat (2, "http://", source->url + 8); + + chsrc_warn2 (ENGLISH ? "Suggest running `apt install ca-certificates` later and change source again to support HTTPS sources" + : "建议稍后执行 `apt install ca-certificates` 并重新换源以支持 HTTPS 源"); + } +} +