Add support for bioconductor

This commit is contained in:
Aoran Zeng 2023-09-04 21:42:05 +08:00
parent e92509d0e0
commit b7fb8326b6
3 changed files with 27 additions and 9 deletions

View File

@ -41,7 +41,7 @@ set <target> <mirror> # 换源,指定使用某镜像站
- [ ] `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`
## 操作系统

21
chsrc.c
View File

@ -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

13
chsrc.h
View File

@ -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/"},
},