diff --git a/src/recipe/lang/Dart/Flutter.c b/src/recipe/lang/Dart/Flutter.c index e41796a..82c95b4 100644 --- a/src/recipe/lang/Dart/Flutter.c +++ b/src/recipe/lang/Dart/Flutter.c @@ -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模式都不一样 diff --git a/src/recipe/lang/Julia.c b/src/recipe/lang/Julia.c index 96eaee5..755ee8d 100644 --- a/src/recipe/lang/Julia.c +++ b/src/recipe/lang/Julia.c @@ -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); } diff --git a/src/recipe/lang/Node.js/nvm.c b/src/recipe/lang/Node.js/nvm.c index aa662bb..1763f0e 100644 --- a/src/recipe/lang/Node.js/nvm.c +++ b/src/recipe/lang/Node.js/nvm.c @@ -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); } diff --git a/src/recipe/lang/R.c b/src/recipe/lang/R.c index fadc11a..48405ae 100644 --- a/src/recipe/lang/R.c +++ b/src/recipe/lang/R.c @@ -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); } diff --git a/src/recipe/lang/Rust/rustup.c b/src/recipe/lang/Rust/rustup.c index 5ad9777..330b4de 100644 --- a/src/recipe/lang/Rust/rustup.c +++ b/src/recipe/lang/Rust/rustup.c @@ -3,8 +3,9 @@ * ------------------------------------------------------------- * File Authors : Aoran Zeng * Contributors : Yangmoooo + * | * 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环境变量生效"); } diff --git a/src/recipe/os/BSD/FreeBSD.c b/src/recipe/os/BSD/FreeBSD.c index edf9783..1cb72f9 100644 --- a/src/recipe/os/BSD/FreeBSD.c +++ b/src/recipe/os/BSD/FreeBSD.c @@ -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"); diff --git a/src/recipe/os/Gentoo-Linux.c b/src/recipe/os/Gentoo-Linux.c index 233c6f6..a5c78b7 100644 --- a/src/recipe/os/Gentoo-Linux.c +++ b/src/recipe/os/Gentoo-Linux.c @@ -4,7 +4,7 @@ * File Authors : Heng Guo <2085471348@qq.com> * Contributors : Aoran Zeng * 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); } diff --git a/src/recipe/ware/Docker-Hub.c b/src/recipe/ware/Docker-Hub.c index 79d5421..3089cef 100644 --- a/src/recipe/ware/Docker-Hub.c +++ b/src/recipe/ware/Docker-Hub.c @@ -6,7 +6,7 @@ * Contributors : Nil Null * | * Created On : <2024-06-08> - * Last Modified : <2024-11-21> + * Last Modified : <2024-11-22> * ------------------------------------------------------------*/ static MirrorSite diff --git a/src/recipe/ware/Homebrew.c b/src/recipe/ware/Homebrew.c index 1ae82fd..4bd5b98 100644 --- a/src/recipe/ware/Homebrew.c +++ b/src/recipe/ware/Homebrew.c @@ -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); diff --git a/src/recipe/ware/Nix.c b/src/recipe/ware/Nix.c index 9e752b6..73196a0 100644 --- a/src/recipe/ware/Nix.c +++ b/src/recipe/ware/Nix.c @@ -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,请确认您的系统版本(如22.11),并手动运行:"); cmd = xy_strjoin (3, "nix-channel --add ", source.url, "nixpkgs- 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); }