Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/chsrc-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 5 additions & 7 deletions src/recipe/os/APT/Debian.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions src/recipe/os/APT/Ubuntu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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 ();
Expand Down Expand Up @@ -128,6 +130,8 @@ os_ubuntu_setsrc (char *option)

chsrc_use_this_source (os_ubuntu);

ensure_ca_certificates (&source);

/* 不存在的时候,用的是我们生成的无效文件,不要备份 */
if (sourcelist_exist)
{
Expand Down
29 changes: 26 additions & 3 deletions src/recipe/os/APT/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 源");
}
}