增加 APT 换源前的 https 支持检测#364
Open
wcbing wants to merge 1 commit into
Open
Conversation
|
Hi @wcbing ❤️ 感谢你的贡献!我们将在最少半小时,最多5天内阅读此 PR 并回复你 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题描述
修复 #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,所以暂时不增加判断逻辑。