Split homebrew out

This commit is contained in:
Aoran Zeng
2024-08-16 04:07:54 +08:00
parent cb2fc02ad7
commit 66b2d36c39
4 changed files with 85 additions and 74 deletions

View File

@@ -207,61 +207,7 @@ wr_winget_resetsrc (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);
}
/**
* 参考自: https://mirrors.tuna.tsinghua.edu.cn/help/homebrew/
*
* 自brew 4.0.0 (2023 年 2 月 16日) 起,
* HOMEBREW_INSTALL_FROM_API 会成为默认行为,无需设置。大部分用户无需再克隆 homebrew-core 仓库,故无需设置 HOMEBREW_CORE_GIT_REMOTE 环境变量;
* 但是为了以防万一,我们还是为用户设置该环境变量
*/
void
wr_brew_setsrc (char *option)
{
SourceInfo source;
chsrc_yield_source (wr_brew);
chsrc_confirm_source (&source);
char *splitter = "\n\n# Generated by chsrc " Chsrc_Version;
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_BOTTLE_DOMAIN=\"", xy_2strjoin (source.url, "homebrew-bottles"), "\"");
char *brew_git_remote = xy_strjoin (3, "export HOMEBREW_BREW_GIT_REMOTE=\"", xy_2strjoin (source.url, "git/homebrew/brew.git"), "\"");
char *core_git_remote = xy_strjoin (3, "export HOMEBREW_CORE_GIT_REMOTE=\"", xy_2strjoin (source.url, "git/homebrew/homebrew-core.git"), "\"");
char *zshrc = "~/.zshrc";
chsrc_backup (zshrc);
chsrc_append_to_file (splitter, zshrc);
chsrc_append_to_file (api_domain, zshrc);
chsrc_append_to_file (bottle_domain, zshrc);
chsrc_append_to_file (brew_git_remote, zshrc);
chsrc_append_to_file (core_git_remote, zshrc);
char *bashrc = "~/.bashrc";
if (xy_file_exist (bashrc))
{
chsrc_backup ("~/.bashrc");
chsrc_append_to_file (splitter, bashrc);
chsrc_append_to_file (api_domain, bashrc);
chsrc_append_to_file (bottle_domain, bashrc);
chsrc_append_to_file (brew_git_remote, bashrc);
chsrc_append_to_file (core_git_remote, bashrc);
}
chsrc_say_lastly (&source, ChsrcTypeAuto);
chsrc_note2 ("请您重启终端使Homebrew环境变量生效");
}
#include "recipe/ware/Homebrew.c"
/**
* 参考https://mirrors.tuna.tsinghua.edu.cn/help/CocoaPods/