Split homebrew out

This commit is contained in:
Aoran Zeng 2024-08-16 04:07:54 +08:00
parent cb2fc02ad7
commit 66b2d36c39
No known key found for this signature in database
GPG Key ID: 8F8BA8488E10ED98
4 changed files with 85 additions and 74 deletions

View File

@ -164,21 +164,6 @@ wr_winget_sources[] = {
},
/**
* @time 2023-09-10
* @note {
* 1. setsrc函数中补充完整
* 2. Sustech
* }
*/
wr_brew_sources[] = {
{&Upstream, NULL},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/"},
{&Bfsu, "https://mirrors.bfsu.edu.cn/"},
{&Zju, "https://mirrors.zju.edu.cn/"},
{&Sustech, "https://mirrors.sustech.edu.cn/"}
},
/**
* @time 2024-06-08
@ -265,7 +250,7 @@ def_sources_n(pl_dotnet);
def_sources_n(wr_winget);
def_sources_n(wr_brew); def_sources_n(wr_cocoapods);
def_sources_n(wr_cocoapods);
def_sources_n(wr_flathub);
def_sources_n(wr_nix); def_sources_n(wr_guix);

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/

View File

@ -93,7 +93,6 @@ static const char
def_target_full(wr_winget);
def_target(wr_brew);
def_target_noget (wr_cocoapods);
def_target_noget (wr_flathub);
def_target_noget (wr_nix);
@ -103,7 +102,7 @@ def_target(wr_tex);
static const char
*wr_winget [] = {"winget", NULL, t(&wr_winget_target)},
*wr_brew [] = {"brew", "homebrew", NULL, t(&wr_brew_target)},
*wr_homebrew[] = {"brew", "homebrew", NULL, t(&wr_homebrew_target)},
*wr_cocoapods[] = {"cocoa", "cocoapods","pod", "cocoapod", NULL, t(&wr_cocoapods_target)},
*wr_dockerhub [] ={"dockerhub", "docker", NULL, t(&wr_dockerhub_target)},
*wr_flathub [] = {"flathub", NULL, t(&wr_flathub_target)},
@ -114,7 +113,7 @@ static const char
*wr_anaconda[] = {"conda", "anaconda", NULL, t(&wr_anaconda_target)},
**wr_softwares[] =
{
wr_winget, wr_brew, wr_cocoapods, wr_dockerhub, wr_flathub, wr_nix, wr_guix, wr_emacs, wr_tex, wr_anaconda
wr_winget, wr_homebrew, wr_cocoapods, wr_dockerhub, wr_flathub, wr_nix, wr_guix, wr_emacs, wr_tex, wr_anaconda
};
#undef t

View File

@ -0,0 +1,81 @@
/** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nil Null <nil@null.org>
* Created On : <2023-09-10>
* Last Modified : <2024-08-15>
* ------------------------------------------------------------*/
/**
* @time 2023-09-10
* @note {
* 1. setsrc函数中补充完整
* 2. Sustech
* }
*/
static SourceInfo
wr_homebrew_sources[] = {
{&Upstream, NULL},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/"},
{&Bfsu, "https://mirrors.bfsu.edu.cn/"},
{&Zju, "https://mirrors.zju.edu.cn/"},
{&Sustech, "https://mirrors.sustech.edu.cn/"}
};
def_sources_n(wr_homebrew);
void
wr_homebrew_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_homebrew_setsrc (char *option)
{
SourceInfo source;
chsrc_yield_source (wr_homebrew);
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环境变量生效");
}
def_target(wr_homebrew);