mirror of
https://github.com/RubyMetric/chsrc.git
synced 2025-01-22 20:44:01 +08:00
os-debian
This commit is contained in:
parent
1f0e465997
commit
2bd959991e
27
chsrc.c
27
chsrc.c
|
@ -874,13 +874,17 @@ os_ubuntu_setsrc (char* option)
|
|||
void
|
||||
os_debian_setsrc (char* option)
|
||||
{
|
||||
int selected = 0;
|
||||
for (int i=0;i<sizeof(os_ubuntu_sources);i++) {
|
||||
// 循环测速
|
||||
int index = 0;
|
||||
|
||||
if (NULL!=option) {
|
||||
index = lets_find_mirror(os_debian, option);
|
||||
} else {
|
||||
index = lets_test_speed(os_debian);
|
||||
}
|
||||
const char* source_name = os_ubuntu_sources[selected].mirror->name;
|
||||
const char* source_abbr = os_ubuntu_sources[selected].mirror->abbr;
|
||||
const char* source_url = os_ubuntu_sources[selected].url;
|
||||
|
||||
|
||||
source_info source = os_ubuntu_sources[index];
|
||||
chsrc_say_selection(&source);
|
||||
|
||||
xy_info("如果遇到无法拉取 HTTPS 源的情况,我们会使用 HTTP 源并 需要您 安装");
|
||||
xy_info("sudo apt install apt-transport-https ca-certificates");
|
||||
|
@ -888,19 +892,16 @@ os_debian_setsrc (char* option)
|
|||
char* backup = "cp -rf /etc/apt/sources.list /etc/apt/sources.list.bak";
|
||||
system(backup);
|
||||
|
||||
xy_info ("chsrc: 备份文件名: /etc/apt/sources.list.bak");
|
||||
|
||||
char* cmd = xy_strjoin(3, "sed -E \'s@(^[^#]* .*)http[:|\\.|\\/|a-z|A-Z]*\\/debian\\/@\\1",
|
||||
source_url,
|
||||
xy_info ("chsrc: 备份文件名: /etc/apt/.*)http[:|\\.|\\/|a-z|A-Z]*\\/debian\\/@\\1",
|
||||
source.url,
|
||||
"@\'< /etc/apt/sources.list.bak | cat > /etc/apt/sources.list");
|
||||
chsrc_logcmd(cmd);
|
||||
system(cmd);
|
||||
free(cmd);
|
||||
|
||||
// char* rm = "rm -rf /etc/apt/source.list.bak";
|
||||
// system(rm);
|
||||
|
||||
xy_info ("chsrc: 为 debian 命令换源");
|
||||
xy_success (xy_2strjoin("chsrc: 感谢镜像提供方:", source_name));
|
||||
chsrc_say_thanks(&source);
|
||||
}
|
||||
/**
|
||||
* fedora29版本及以下暂不支持
|
||||
|
|
Loading…
Reference in New Issue
Block a user