Add basic support for homebrew

Gitee close #I803P8
This commit is contained in:
Aoran Zeng 2023-09-10 21:05:21 +08:00
parent cbd429214f
commit 44822d0922
2 changed files with 53 additions and 3 deletions

42
chsrc.c
View File

@ -1611,6 +1611,44 @@ wr_emacs_setsrc(char* option)
void
wr_brew_getsrc(char* option)
{
char* cmd = "echo HOMEBREW_API_DOMAIN=$HOMEBREW_API_DOMAIN;"
"echo HOMEBREW_BOTTLE_DOMAIN=$HOMEBREW_BOTTLE_DOMAIN;"
"echo HOMEBREW_BREW_GIT_REMOTE=$HOMEBREW_BREW_GIT_REMOTE;"
"echo HOMEBREW_CORE_GIT_REMOTE=$HOMEBREW_CORE_GIT_REMOTE;";
system(cmd);
}
void
wr_brew_setsrc(char* option)
{
int index = 0;
if (NULL!=option) {
index = lets_find_mirror(wr_brew, option);
} else {
index = lets_test_speed(wr_brew);
}
source_info source = wr_brew_sources[index];
chsrc_say_selection (&source);
char* api_domain = xy_strjoin(3, "export HOMEBREW_API_DOMAIN=\"", xy_2strjoin(source.url, "homebrew-bottles/api"), "\"");
char* bottle_domain = xy_strjoin(3, "export HOMEBREW_API_DOMAIN=\"", xy_2strjoin(source.url, "homebrew-bottles"), "\"");
char* brew_git_remote = xy_strjoin(3, "export HOMEBREW_API_DOMAIN=\"", xy_2strjoin(source.url, "git/homebrew/brew.git"), "\"");
char* core_git_remote = xy_strjoin(3, "export HOMEBREW_API_DOMAIN=\"", xy_2strjoin(source.url, "git/homebrew/homebrew-core.git"), "\"");
chsrc_runcmd(xy_strjoin(3,"echo ", api_domain, " >> ~/.bashrc >> ~/.zshrc"));
chsrc_runcmd(xy_strjoin(3,"echo ", bottle_domain, " >> ~/.bashrc >> ~/.zshrc"));
chsrc_runcmd(xy_strjoin(3,"echo ", brew_git_remote, " >> ~/.bashrc >> ~/.zshrc"));
chsrc_runcmd(xy_strjoin(3,"echo ", core_git_remote, " >> ~/.bashrc >> ~/.zshrc"));
chsrc_say_thanks (&source);
}
/************************************** Begin Target Matrix ****************************************/ /************************************** Begin Target Matrix ****************************************/
def_target_info(pl_ruby); def_target_info(pl_ruby);
@ -1696,11 +1734,11 @@ static const char
def_target_info(wr_tex); def_target_info(wr_tex);
def_target_info(wr_brew);
target_info target_info
wr_anaconda_target = {NULL, NULL, NULL, 0}, wr_anaconda_target = {NULL, NULL, NULL, 0},
wr_emacs_target = {wr_emacs_setsrc, NULL, wr_emacs_sources, wr_emacs_sources_n}, wr_emacs_target = {wr_emacs_setsrc, NULL, wr_emacs_sources, wr_emacs_sources_n};
wr_brew_target = {NULL, NULL, NULL, 0};
static const char static const char
*wr_anaconda[] = {"conda", "anaconda", NULL, targetinfo(&wr_anaconda_target)}, *wr_anaconda[] = {"conda", "anaconda", NULL, targetinfo(&wr_anaconda_target)},

14
chsrc.h
View File

@ -546,6 +546,18 @@ wr_emacs_sources[] = {
{&Ustc, "https://mirrors.ustc.edu.cn/help/elpa.html"}, {&Ustc, "https://mirrors.ustc.edu.cn/help/elpa.html"},
{&Zju, "https://mirrors.zju.edu.cn/docs/elpa/"}, {&Zju, "https://mirrors.zju.edu.cn/docs/elpa/"},
{&EmacsChina, "https://elpamirror.emacs-china.org/"} {&EmacsChina, "https://elpamirror.emacs-china.org/"}
},
/**
* 2023-09-10
*/
wr_brew_sources[] = {
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/"},
{&Bfsu, "https://mirrors.bfsu.edu.cn/git/homebrew/"},
{&Sustech, "https://mirrors.sustech.edu.cn/homebrew/"},
{&Zju, "https://mirrors.zju.edu.cn/git/homebrew"}
}; };
@ -610,7 +622,7 @@ def_target_sources_n(os_kali); def_target_sources_n(os_openbsd); def_
def_target_sources_n(os_arch); def_target_sources_n(os_gentoo); def_target_sources_n(os_netbsd); def_target_sources_n(os_arch); def_target_sources_n(os_gentoo); def_target_sources_n(os_netbsd);
def_target_sources_n(os_deepin); def_target_sources_n(os_openeuler); def_target_sources_n(os_openkylin); def_target_sources_n(os_deepin); def_target_sources_n(os_openeuler); def_target_sources_n(os_openkylin);
def_target_sources_n(wr_tex); def_target_sources_n(wr_emacs); def_target_sources_n(wr_tex); def_target_sources_n(wr_emacs); def_target_sources_n(wr_brew);
/* Target Info */ /* Target Info */
typedef struct { typedef struct {