Add support for alpine

Gitee close #I80262
This commit is contained in:
Aoran Zeng 2023-09-24 20:01:46 +08:00
parent 9f3ef4060d
commit 91711185b0
2 changed files with 52 additions and 1 deletions

35
chsrc.c
View File

@ -1308,6 +1308,38 @@ os_rocky_setsrc (char* option)
/**
* : https://help.mirrors.cernet.edu.cn/alpine/
*/
void
os_alpine_setsrc (char* option)
{
// ensure_root(); // HELP: 不确定是否需要root
int index = 0;
if (NULL!=option) {
index = lets_find_mirror(os_alpine, option);
} else {
index = lets_test_speed(os_alpine);
}
source_info source = os_alpine_sources[index];
chsrc_say_selection(&source);
char* cmd = xy_strjoin(3,
"sed -i 's#https\\?://dl-cdn.alpinelinux.org/alpine#", source.url, "#g' /etc/apk/repositories"
);
chsrc_runcmd(cmd);
cmd = "apk update";
chsrc_runcmd(cmd);
chsrc_say_thanks(&source);
}
/**
* HELP:
*/
@ -1938,6 +1970,7 @@ target_info
os_manjaro_target = {os_manjaro_setsrc, NULL, NULL, 0},
os_gentoo_target = {os_gentoo_setsrc, NULL, os_gentoo_sources, os_gentoo_sources_n},
os_rocky_target = {os_rocky_setsrc, NULL, os_rocky_sources, os_rocky_sources_n},
os_alpine_target = {os_alpine_setsrc, NULL, os_alpine_sources, os_alpine_sources_n},
os_freebsd_target = {os_freebsd_setsrc, NULL, os_freebsd_sources, os_freebsd_sources_n},
os_netbsd_target = {os_netbsd_setsrc, NULL, os_netbsd_sources, os_netbsd_sources_n},
os_openbsd_target = {os_openbsd_setsrc, NULL, os_openbsd_sources, os_openbsd_sources_n},
@ -1955,6 +1988,7 @@ static const char
*os_manjaro [] = {"manjaro", NULL, targetinfo(&os_manjaro_target)},
*os_gentoo [] = {"gentoo", NULL, targetinfo(&os_gentoo_target)},
*os_rocky [] = {"rocky", "rockylinux", NULL, targetinfo(&os_rocky_target)},
*os_alpine [] = {"alpine", NULL, targetinfo(&os_alpine_target)},
*os_freebsd [] = {"freebsd", NULL, targetinfo(&os_freebsd_target)},
*os_netbsd [] = {"netbsd", NULL, targetinfo(&os_netbsd_target)},
*os_openbsd [] = {"openbsd", NULL, targetinfo(&os_openbsd_target)},
@ -1966,6 +2000,7 @@ static const char
os_ubuntu, os_debian, os_fedora, os_opensuse, os_kali,
os_arch, os_manjaro, os_gentoo,
os_rocky,
os_alpine,
os_freebsd, os_netbsd, os_openbsd,
os_msys2,
os_deepin, os_openeuler, os_openkylin,

View File

@ -445,6 +445,21 @@ os_rocky_sources[] = {
/**
* 2023-09-24
*/
os_alpine_sources[] = {
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/alpine"},
{&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/alpine"},
{&Sustech, "https://mirrors.sustech.edu.cn/alpine"},
{&Zju, "https://mirrors.zju.edu.cn/alpine"},
{&Lzuoss, "https://mirror.lzu.edu.cn/alpine"},
{&Ali, "https://mirrors.aliyun.com/alpine"},
{&Tencent, "https://mirrors.cloud.tencent.com/alpine"}
},
/**
* 2023-09-02
*
@ -689,7 +704,8 @@ def_target_sources_n(pl_r); def_target_sources_n(pl_julia);
def_target_sources_n(os_ubuntu); def_target_sources_n(os_debian); def_target_sources_n(os_fedora);
def_target_sources_n(os_kali); def_target_sources_n(os_opensuse);
def_target_sources_n(os_arch); def_target_sources_n(os_gentoo); def_target_sources_n(os_rocky);
def_target_sources_n(os_arch); def_target_sources_n(os_gentoo); def_target_sources_n(os_alpine);
def_target_sources_n(os_rocky);
def_target_sources_n(os_msys2);
def_target_sources_n(os_freebsd); def_target_sources_n(os_netbsd); def_target_sources_n(os_openbsd);
def_target_sources_n(os_deepin); def_target_sources_n(os_openeuler); def_target_sources_n(os_openkylin);