Skip to content

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

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

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_dish os_dish 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.

很好的代码!👍👍👍

social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
chsrc 0.2.6

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>该附件二进制文件为预编译供用户提前使用

版本:`v0.2.5`
日期:2026-07-25
更新:RubyMetric/chsrc@v0.2.5...v0.2.6
内容:

1. 支持 Windows Arm64 的预编译文件
2. 支持检测更特殊的 Windows 环境
3. Windows 上柔性检测 Python 微软商店占位符
4. 移除 POSIX installer 中的 `awk` 依赖
5. 强制实施 `user_define` 能力

换源方法(recipe):
1. 增加 APT 换源前的 `http(s)` 检测

源:
1. 修复 `Alpine` 的测速链接
2. `Kali` 源: 新增华为源、移除阿里源

<br>

## 新贡献者
* @boilcy made their first contribution in RubyMetric/chsrc#362
* @wcbing made their first contribution in RubyMetric/chsrc#364
* @NewbieXvwu made their first contribution in RubyMetric/chsrc#366
</pre>
  <p>View the full release notes at <a href="https://github.com/RubyMetric/chsrc/releases/tag/v0.2.6">https://github.com/RubyMetric/chsrc/releases/tag/v0.2.6</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!15101
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Linux Linux相关 os_dish os_dish

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants