Only append once

[GitHub #76]
This commit is contained in:
Aoran Zeng 2024-11-22 01:42:01 +08:00
parent 505b14895e
commit c1c495cf6d
No known key found for this signature in database
GPG Key ID: 8F8BA8488E10ED98
10 changed files with 48 additions and 57 deletions

View File

@ -6,7 +6,7 @@
* |
* Created On : <2023-09-10>
* Major Revision : 2
* Last Modified : <2024-10-31>
* Last Modified : <2024-11-22>
*
* 2024-09-14: Dart和Flutter拆分为两个Target
* 3 Dart Flutter URL模式都不一样

View File

@ -45,10 +45,9 @@ pl_julia_setsrc (char *option)
{
chsrc_yield_source_and_confirm (pl_julia);
const char *towrite = xy_strjoin (3, "ENV[\"JULIA_PKG_SERVER\"] = \"", source.url, "\"");
char *w = xy_strjoin (3, "ENV[\"JULIA_PKG_SERVER\"] = \"", source.url, "\"");
chsrc_append_to_file (towrite, PL_Julia_Config);
chsrc_log_write (PL_Julia_Config);
chsrc_append_to_file (w, PL_Julia_Config);
chsrc_conclude (&source, SetsrcType_Untested);
}

View File

@ -32,15 +32,15 @@ pl_nodejs_nvm_setsrc (char *option)
{
chsrc_yield_source_and_confirm (pl_nodejs_binary_release);
char *env = xy_2strjoin ("export NVM_NODEJS_ORG_MIRROR=", source.url);
char *w = xy_2strjoin ("export NVM_NODEJS_ORG_MIRROR=", source.url);
char *zshrc = "~/.zshrc";
char *bashrc = "~/.bashrc";
chsrc_append_to_file (env, bashrc);
chsrc_append_to_file (w, bashrc);
if (xy_file_exist (zshrc))
chsrc_append_to_file (env, zshrc);
chsrc_append_to_file (w, zshrc);
chsrc_conclude (&source, SetsrcType_Auto);
}

View File

@ -60,16 +60,16 @@ pl_r_setsrc (char *option)
char *bioconductor_url = xy_str_delete_suffix (xy_str_delete_suffix (source.url, "cran/"), "CRAN/");
bioconductor_url = xy_2strjoin(bioconductor_url, "bioconductor");
const char *towrite1 = xy_strjoin (3, "options(\"repos\" = c(CRAN=\"", source.url, "\"))" );
const char *towrite2 = xy_strjoin (3, "options(BioC_mirror=\"", bioconductor_url, "\")" );
const char *w1 = xy_strjoin (3, "options(\"repos\" = c(CRAN=\"", source.url, "\"))" );
const char *w2 = xy_strjoin (3, "options(BioC_mirror=\"", bioconductor_url, "\")" );
char *w = xy_2strjoin (w1, w2);
// 或者我们调用 r.exe --slave -e 上面的内容
char *config = xy_on_windows ? PL_R_Config_Windows : PL_R_Config_POSIX;
chsrc_append_to_file (towrite1, config);
chsrc_append_to_file (towrite2, config);
chsrc_log_write (config);
chsrc_append_to_file (w, config);
chsrc_conclude (&source, SetsrcType_Auto);
}

View File

@ -3,8 +3,9 @@
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Yangmoooo <yangmoooo@outlook.com>
* |
* Created On : <2024-10-02>
* Last Modified : <2024-10-02>
* Last Modified : <2024-11-22>
* ------------------------------------------------------------*/
/**
@ -48,37 +49,37 @@ pl_rust_rustup_setsrc (char *option)
chsrc_yield_source_and_confirm (pl_rust_rustup);
char *dist_server = xy_strjoin (3, "export RUSTUP_DIST_SERVER=\"", source.url, "\"");
char *update_root = xy_strjoin (3, "export RUSTUP_UPDATE_ROOT=\"", source.url, "/rustup\"");
char *w1 = xy_strjoin (3, "export RUSTUP_DIST_SERVER=\"", source.url, "\"\n");
char *w2 = xy_strjoin (3, "export RUSTUP_UPDATE_ROOT=\"", source.url, "/rustup\"\n");
char *w = xy_2strjoin (w1, w2)
char *bashrc = "~/.bashrc";
if (xy_file_exist (bashrc))
{
chsrc_backup (bashrc);
chsrc_append_to_file (dist_server, bashrc);
chsrc_append_to_file (update_root, bashrc);
chsrc_append_to_file (w, bashrc);
}
char *zshrc = "~/.zshrc";
if (xy_file_exist (zshrc))
{
chsrc_backup (zshrc);
chsrc_append_to_file (dist_server, zshrc);
chsrc_append_to_file (update_root, zshrc);
chsrc_append_to_file (w, zshrc);
}
char *fishrc = "~/.config/fish/config.fish";
if (xy_file_exist (fishrc))
{
char *dist_server = xy_2strjoin ("set -x RUSTUP_DIST_SERVER ", source.url);
char *update_root = xy_2strjoin ("set -x RUSTUP_UPDATE_ROOT ", xy_2strjoin (source.url, "/rustup"));
char *w1 = xy_strjoin (3, "set -x RUSTUP_DIST_SERVER ", source.url, "\n");
char *w2 = xy_strjoin (3, "set -x RUSTUP_UPDATE_ROOT ", source.url, "/rustup\n");
char *w = xy_2strjoin (w1, w2)
chsrc_backup (fishrc);
chsrc_append_to_file (dist_server, fishrc);
chsrc_append_to_file (update_root, fishrc);
chsrc_append_to_file (w, fishrc);
}
chsrc_conclude (&source, setsrc_type);
chsrc_note2 ("请您重启终端使rustup环境变量生效");
}

View File

@ -95,7 +95,7 @@ os_freebsd_setsrc (char *option)
// https://help.mirrors.cernet.edu.cn/FreeBSD-ports/
chsrc_backup ("/etc/make.conf");
char *ports = xy_strjoin (3, "MASTER_SITE_OVERRIDE?=http://", source.url, "/freebsd-ports/distfiles/${DIST_SUBDIR}/");
char *ports = xy_strjoin (3, "MASTER_SITE_OVERRIDE?=http://", source.url, "/freebsd-ports/distfiles/${DIST_SUBDIR}/\n");
chsrc_append_to_file (ports, "/etc/make.conf");

View File

@ -4,7 +4,7 @@
* File Authors : Heng Guo <2085471348@qq.com>
* Contributors : Aoran Zeng <ccmywish@qq.com>
* Created On : <2023-09-05>
* Last Modified : <2024-09-14>
* Last Modified : <2024-11-22>
* ------------------------------------------------------------*/
/**
@ -42,9 +42,9 @@ os_gentoo_setsrc (char *option)
"gentoo-portage#g");
chsrc_run (cmd, RunOpt_Default);
char *towrite = xy_strjoin (3, "GENTOO_MIRRORS=\"https://", source.url, "gentoo\"");
char *w = xy_strjoin (3, "GENTOO_MIRRORS=\"https://", source.url, "gentoo\"\n");
chsrc_append_to_file (towrite, "/etc/portage/make.conf");
chsrc_append_to_file (w, "/etc/portage/make.conf");
chsrc_conclude (&source, SetsrcType_Untested);
}

View File

@ -6,7 +6,7 @@
* Contributors : Nil Null <nil@null.org>
* |
* Created On : <2024-06-08>
* Last Modified : <2024-11-21>
* Last Modified : <2024-11-22>
* ------------------------------------------------------------*/
static MirrorSite

View File

@ -48,45 +48,36 @@ wr_homebrew_setsrc (char *option)
{
chsrc_yield_source_and_confirm (wr_homebrew);
char *splitter = "\n\n# Generated by chsrc " Chsrc_Banner_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 *splitter = "\n\n# Generated by chsrc " Chsrc_Banner_Version;
char *w1 = xy_strjoin (3, "export HOMEBREW_API_DOMAIN=\"", source.url, "homebrew-bottles/api", "\"\n");
char *w2 = xy_strjoin (3, "export HOMEBREW_BOTTLE_DOMAIN=\"", source.url, "homebrew-bottles", "\"\n");
char *w3 = xy_strjoin (3, "export HOMEBREW_BREW_GIT_REMOTE=\"", source.url, "git/homebrew/brew.git", "\"\n");
char *w4 = xy_strjoin (3, "export HOMEBREW_CORE_GIT_REMOTE=\"", source.url, "git/homebrew/homebrew-core.git", "\"\n");
char *w = xy_strjoin (5, splitter, w1, w2, w3, w4);
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);
chsrc_append_to_file (w, 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_append_to_file (w, bashrc);
}
char *fishrc = "~/.config/fish/config.fish";
if (xy_file_exist (fishrc))
{
char *api_domain_fish = xy_strjoin(3, "set -x HOMEBREW_API_DOMAIN \"", xy_2strjoin(source.url, "homebrew-bottles/api"), "\"");
char *bottle_domain_fish = xy_strjoin(3, "set -x HOMEBREW_BOTTLE_DOMAIN \"", xy_2strjoin(source.url, "homebrew-bottles"), "\"");
char *brew_git_remote_fish = xy_strjoin(3, "set -x HOMEBREW_BREW_GIT_REMOTE \"", xy_2strjoin(source.url, "git/homebrew/brew.git"), "\"");
char *core_git_remote_fish = xy_strjoin(3, "set -x HOMEBREW_CORE_GIT_REMOTE \"", xy_2strjoin(source.url, "git/homebrew/homebrew-core.git"), "\"");
char *w1 = xy_strjoin(3, "set -x HOMEBREW_API_DOMAIN \"", source.url, "homebrew-bottles/api", "\"\n");
char *w2 = xy_strjoin(3, "set -x HOMEBREW_BOTTLE_DOMAIN \"", source.url, "homebrew-bottles", "\"\n");
char *w3 = xy_strjoin(3, "set -x HOMEBREW_BREW_GIT_REMOTE \"",source.url, "git/homebrew/brew.git", "\"\n");
char *w4 = xy_strjoin(3, "set -x HOMEBREW_CORE_GIT_REMOTE \"",source.url, "git/homebrew/homebrew-core.git", "\"\n");
char *w = xy_strjoin (5, splitter, w1, w2, w3, w4);
chsrc_backup (fishrc);
chsrc_append_to_file (splitter, fishrc);
chsrc_append_to_file (api_domain_fish, fishrc);
chsrc_append_to_file (bottle_domain_fish, fishrc);
chsrc_append_to_file (brew_git_remote_fish, fishrc);
chsrc_append_to_file (core_git_remote_fish, fishrc);
chsrc_append_to_file (w, fishrc);
}
chsrc_conclude(&source, SetsrcType_Auto);

View File

@ -43,18 +43,18 @@ wr_nix_setsrc (char *option)
char *cmd = xy_strjoin (3, "nix-channel --add ", source.url, "nixpkgs-unstable nixpkgs");
chsrc_run (cmd, RunOpt_Default);
char *towrite = xy_strjoin (3, "substituters = ", source.url, "store https://cache.nixos.org/");
chsrc_append_to_file (towrite , "~/.config/nix/nix.conf");
char *w = xy_strjoin (3, "substituters = ", source.url, "store https://cache.nixos.org/");
chsrc_append_to_file (w, "~/.config/nix/nix.conf");
chsrc_run ("nix-channel --update", RunOpt_Default);
chsrc_note2 ("若您使用的是NixOS请确认您的系统版本<version>如22.11),并手动运行:");
cmd = xy_strjoin (3, "nix-channel --add ", source.url, "nixpkgs-<version> nixpkgs");
puts (cmd);
say (cmd);
cmd = xy_strjoin (3, "nix.settings.substituters = [ \"", source.url, "store\" ];");
chsrc_note2 ("若您使用的是NixOS请额外添加下述内容至 configuration.nix 中");
puts (cmd);
say (cmd);
chsrc_conclude (&source, SetsrcType_SemiAuto);
}