diff --git a/README.md b/README.md index d8c2234..4e9d899 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ set # 换源,指定使用某镜像站 - [ ] `chsrc set rust` 或 `chsrc set cargo` 或 `chsrc crate` - [ ] `chsrc set java` 或 `chsrc set maven` 或 `chsrc set mvn` 或 `chsrc gradle` -- [x] `chsrc set r` 或 `chsrc set cran` +- [x] `chsrc set r` 或 `chsrc set cran` (同时会为 `bioconductor` 换源) - [ ] `chsrc set julia` ## 操作系统 diff --git a/chsrc.c b/chsrc.c index bc8fcf3..48e2b79 100644 --- a/chsrc.c +++ b/chsrc.c @@ -631,6 +631,11 @@ pl_java_setsrc (char* option) void pl_r_getsrc (char* option) { + // 或参考:https://zhuanlan.zhihu.com/p/585036231 + // + // options()$repos + // options()$BioC_mirror + // char* cmd = NULL; if(xy_on_windows) { cmd = "type %USERPROFILE%\\Documents\\.Rprofile"; @@ -643,7 +648,6 @@ pl_r_getsrc (char* option) /** * R 换源,参考:https://help.mirrors.cernet.edu.cn/CRAN/ - * TODO: bioconductor 换源 */ void pl_r_setsrc (char* option) @@ -659,9 +663,24 @@ pl_r_setsrc (char* option) source_info source = pl_r_sources[index]; chsrc_say_selection(&source); + char* bioconductor_url = xy_str_delete_suffix(xy_str_delete_suffix(source.url, "cran/"), "CRAN/"); + bioconductor_url = xy_2strjoin(bioconductor_url, "bioconductor"); + const char* file = xy_strjoin (3, "options(\"repos\" = c(CRAN=\"", source.url, "\"))" ); char* cmd = NULL; + // 或者我们调用 r.exe --slave -e 上面的内容 + if (xy_on_windows) + cmd = xy_strjoin(3, "echo ", file, " >> %USERPROFILE%/Documents/.Rprofile"); + else + cmd = xy_strjoin(3, "echo ", file, " >> ~/.Rprofile"); + + chsrc_logcmd(cmd); + system(cmd); + + + file = xy_strjoin (3, "options(BioC_mirror=\"", bioconductor_url, "\")" ); + // 或者我们调用 r.exe --slave -e 上面的内容 if (xy_on_windows) cmd = xy_strjoin(3, "echo ", file, " >> %USERPROFILE%/Documents/.Rprofile"); else diff --git a/chsrc.h b/chsrc.h index 362d59b..221b651 100644 --- a/chsrc.h +++ b/chsrc.h @@ -175,8 +175,6 @@ pl_nodejs_sources[] = { * * 参考:https://help.mirrors.cernet.edu.cn/CPAN/ * - * Jlu 吉林大学没有该源 - * * TODO: 速度未经测试,请Perl用户协助 */ pl_perl_sources[] = { @@ -191,15 +189,16 @@ pl_perl_sources[] = { /** * 2023-09-04 更新 * - * TODO: 速度未经测试,请R用户协助 + * @note 以下注释的,是不含有bioconductor的镜像站, + * 我们在换cran的同时,也直接帮助用户换bioconductor */ pl_r_sources[] = { {&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/cran/"}, - {&Ali, "https://mirrors.aliyun.com/CRAN/"}, + // {&Ali, "https://mirrors.aliyun.com/CRAN/"}, {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/CRAN/"}, - {&Sustech, "https://mirrors.sustech.edu.cn/CRAN"}, - {&Bfsu, "https://mirrors.bfsu.edu.cn/CRAN/"}, - {&Bjtu, "https://mirror.bjtu.edu.cn/cran/"}, + // {&Sustech, "https://mirrors.sustech.edu.cn/CRAN"}, + // {&Bfsu, "https://mirrors.bfsu.edu.cn/CRAN/"}, + // {&Bjtu, "https://mirror.bjtu.edu.cn/cran/"}, },