Skip to content

增加 APT 换源前的 https 支持检测#364

Open
wcbing wants to merge 1 commit into
RubyMetric:devfrom
wcbing:main
Open

增加 APT 换源前的 https 支持检测#364
wcbing wants to merge 1 commit into
RubyMetric:devfrom
wcbing:main

Conversation

@wcbing

@wcbing wcbing commented Jun 26, 2026

Copy link
Copy Markdown

问题描述

修复 #363

创建 Debian/Ubuntu 容器(或某些最小化安装的服务器系统,它们未安装 ca-certificates 所以无法正常访问 https),直接使用 chsrc set <debian/ubuntu> mirrorz 换系统源。

chsrc 默认是更换 https 源,且脚本并没有判断,只要执行就会换源。一旦换 https 源后 apt 会因为 update 失败而在后续操作中报错。


方案与实现

换源前先判断是否安装了 ca-certificates,如果没安装就直接更换 http 源(同时提醒如何换 https 源)。

判断是否安装 ca-certificates,常规办法是通过 dpkg/apt,但还要截取字符串稍显麻烦。结合现有代码,判断 /usr/share/doc/ca-certificates/copyright 等文件是否存在可能更方便。

deepin、Kali Linux 等衍生版一般功能较完整,预装 ca-certificates,所以暂时不增加判断逻辑。

@github-actions

Copy link
Copy Markdown

Hi @wcbing

❤️ 感谢你的贡献!我们将在最少半小时,最多5天内阅读此 PR 并回复你

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant