Only append once

[GitHub #76]
This commit is contained in:
Aoran Zeng
2024-11-22 01:42:01 +08:00
parent 505b14895e
commit c1c495cf6d
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环境变量生效");
}