diff --git a/chsrc.c b/chsrc.c index 902d7e7..eb54746 100644 --- a/chsrc.c +++ b/chsrc.c @@ -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 ****************************************/ def_target_info(pl_ruby); @@ -1696,11 +1734,11 @@ static const char def_target_info(wr_tex); +def_target_info(wr_brew); target_info wr_anaconda_target = {NULL, NULL, NULL, 0}, - wr_emacs_target = {wr_emacs_setsrc, NULL, wr_emacs_sources, wr_emacs_sources_n}, - wr_brew_target = {NULL, NULL, NULL, 0}; + wr_emacs_target = {wr_emacs_setsrc, NULL, wr_emacs_sources, wr_emacs_sources_n}; static const char *wr_anaconda[] = {"conda", "anaconda", NULL, targetinfo(&wr_anaconda_target)}, diff --git a/chsrc.h b/chsrc.h index e496132..8e9ba03 100644 --- a/chsrc.h +++ b/chsrc.h @@ -546,6 +546,18 @@ wr_emacs_sources[] = { {&Ustc, "https://mirrors.ustc.edu.cn/help/elpa.html"}, {&Zju, "https://mirrors.zju.edu.cn/docs/elpa/"}, {&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_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 */ typedef struct {