Skip to content

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

Merged
ccmywish merged 1 commit into
RubyMetric:devfrom
wcbing:main
Jul 1, 2026
Merged

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

Conversation

@wcbing

@wcbing wcbing commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

问题描述

修复 #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 并回复你

@ccmywish ccmywish added os_target os target Linux Linux相关 labels Jul 1, 2026
@ccmywish ccmywish added this to the v0.2.6 milestone Jul 1, 2026
@ccmywish ccmywish merged commit 17d0deb into RubyMetric:dev Jul 1, 2026

@ccmywish ccmywish left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

很好的代码!👍👍👍

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

Labels

Linux Linux相关 os_target os target

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants