Split anaconda out

This commit is contained in:
Aoran Zeng 2024-08-16 04:28:50 +08:00
parent a92b30c57b
commit 019b0b060b
No known key found for this signature in database
GPG Key ID: 8F8BA8488E10ED98
5 changed files with 124 additions and 113 deletions

View File

@ -153,38 +153,10 @@ pl_dotnet_sources[] = {
/**
* @time 2023-09-11
* @note
* @time 2023-09-10
*/
static SourceInfo
wr_flathub_sources[] = {
{&Upstream, NULL},
{&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/flathub"},
},
/**
* @time 2023-09-10
* @note setsrc函数中补充完整
*/
wr_anaconda_sources[] = {
{&Upstream, NULL},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/anaconda/"},
{&Bfsu, "https://mirrors.bfsu.edu.cn/anaconda/"},
{&Zju, "https://mirrors.zju.edu.cn/anaconda/"},
{&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/anaconda"}
},
/**
* @time 2023-09-10
*/
wr_tex_sources[] = {
{&Upstream, NULL},
{&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/ctan/systems/texlive/tlnet"},
@ -203,6 +175,5 @@ wr_tex_sources[] = {
def_sources_n(pl_clojure);
def_sources_n(pl_dotnet);
def_sources_n(wr_flathub);
def_sources_n(wr_tex);
def_sources_n(wr_anaconda);

View File

@ -182,86 +182,9 @@ wr_tex_setsrc (char *option)
#include "recipe/ware/CocoaPods.c"
#include "recipe/ware/Nix.c"
#include "recipe/ware/Guix.c"
#include "recipe/ware/Flathub.c"
#include "recipe/ware/docker.c"
/**
* : https://mirrors.sjtug.sjtu.edu.cn/docs/flathub
*/
void
wr_flathub_setsrc (char *option)
{
SourceInfo source;
chsrc_yield_source (wr_flathub);
chsrc_confirm_source (&source);
chsrc_note2 ("若出现问题,可先调用以下命令:");
char *note = xy_strjoin (3,
"wget ", source.url, "/flathub.gpg\n"
"flatpak remote-modify --gpg-import=flathub.gpg flathub"
);
puts (note);
char *cmd = xy_2strjoin ("flatpak remote-modify flathub --url=", source.url);
chsrc_run (cmd, RunOpt_Default);
chsrc_say_lastly (&source, ChsrcTypeAuto);
}
void
wr_anaconda_setsrc (char *option)
{
SourceInfo source;
chsrc_yield_source (wr_anaconda);
chsrc_confirm_source (&source);
char *main = xy_2strjoin (source.url, "pkgs/main");
char *r = xy_2strjoin (source.url, "pkgs/r");
char *msys2 = xy_2strjoin (source.url, "pkgs/msys2");
char *cloud = xy_2strjoin (source.url, "cloud");
char *file = xy_strjoin (22,
"channels:\n - defaults\n"
"show_channel_urls: true\ndefault_channels:"
"\n - ", main,
"\n - ", r,
"\n - ", msys2,
"\ncustom_channels:\n"
" conda-forge: ", cloud,
"\n msys2: ", cloud,
"\n bioconda: ", cloud,
"\n menpo: ", cloud,
"\n pytorch: ", cloud,
"\n pytorch-lts: ", cloud,
"\n simpleitk: ", cloud,
"\n deepmodeling: ", cloud);
// TODO: 待确认 windows 上也是这里吗?
char *config = xy_2strjoin (xy_os_home, "/.condarc");
if (xy_on_windows)
{
bool exist = chsrc_check_program ("conda");
if (!exist)
{
chsrc_error ("未找到 conda 命令,请检查是否存在");
exit (Exit_UserCause);
}
chsrc_run ("conda config --set show_channel_urls yes", RunOpt_Default);
}
chsrc_note2 (xy_strjoin (3, "请向 ", config, " 中手动添加:"));
puts (file);
chsrc_note2 ("然后运行 conda clean -i 清除索引缓存,保证用的是镜像站提供的索引");
chsrc_say_lastly (&source, ChsrcTypeSemiAuto);
}
#include "recipe/ware/Anaconda.c"
#include "recipe/catalog.c"

View File

@ -91,9 +91,6 @@ static const char
os_freebsd, os_netbsd, os_openbsd,
};
def_target_noget (wr_flathub);
def_target_noget (wr_anaconda);
def_target(wr_tex);
static const char

View File

@ -0,0 +1,75 @@
/** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nil Null <nil@null.org>
* Created On : <2023-09-10>
* Last Modified : <2024-08-15>
* ------------------------------------------------------------*/
/**
* @time 2023-09-10
* @note setsrc函数中补充完整
*/
static SourceInfo
wr_anaconda_sources[] = {
{&Upstream, NULL},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/anaconda/"},
{&Bfsu, "https://mirrors.bfsu.edu.cn/anaconda/"},
{&Zju, "https://mirrors.zju.edu.cn/anaconda/"},
{&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/anaconda"}
};
def_sources_n(wr_anaconda);
void
wr_anaconda_setsrc (char *option)
{
SourceInfo source;
chsrc_yield_source (wr_anaconda);
chsrc_confirm_source (&source);
char *main = xy_2strjoin (source.url, "pkgs/main");
char *r = xy_2strjoin (source.url, "pkgs/r");
char *msys2 = xy_2strjoin (source.url, "pkgs/msys2");
char *cloud = xy_2strjoin (source.url, "cloud");
char *file = xy_strjoin (22,
"channels:\n - defaults\n"
"show_channel_urls: true\ndefault_channels:"
"\n - ", main,
"\n - ", r,
"\n - ", msys2,
"\ncustom_channels:\n"
" conda-forge: ", cloud,
"\n msys2: ", cloud,
"\n bioconda: ", cloud,
"\n menpo: ", cloud,
"\n pytorch: ", cloud,
"\n pytorch-lts: ", cloud,
"\n simpleitk: ", cloud,
"\n deepmodeling: ", cloud);
// TODO: 待确认 windows 上也是这里吗?
char *config = xy_2strjoin (xy_os_home, "/.condarc");
if (xy_on_windows)
{
bool exist = chsrc_check_program ("conda");
if (!exist)
{
chsrc_error ("未找到 conda 命令,请检查是否存在");
exit (Exit_UserCause);
}
chsrc_run ("conda config --set show_channel_urls yes", RunOpt_Default);
}
chsrc_note2 (xy_strjoin (3, "请向 ", config, " 中手动添加:"));
puts (file);
chsrc_note2 ("然后运行 conda clean -i 清除索引缓存,保证用的是镜像站提供的索引");
chsrc_say_lastly (&source, ChsrcTypeSemiAuto);
}
def_target_noget (wr_anaconda);

45
src/recipe/ware/Flathub.c Normal file
View File

@ -0,0 +1,45 @@
/** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nil Null <nil@null.org>
* Created On : <2023-09-11>
* Last Modified : <2024-08-15>
* ------------------------------------------------------------*/
/**
* @time 2023-09-11
* @note
*/
static SourceInfo
wr_flathub_sources[] = {
{&Upstream, NULL},
{&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/flathub"},
};
def_sources_n(wr_flathub);
/**
* : https://mirrors.sjtug.sjtu.edu.cn/docs/flathub
*/
void
wr_flathub_setsrc (char *option)
{
SourceInfo source;
chsrc_yield_source (wr_flathub);
chsrc_confirm_source (&source);
chsrc_note2 ("若出现问题,可先调用以下命令:");
char *note = xy_strjoin (3,
"wget ", source.url, "/flathub.gpg\n"
"flatpak remote-modify --gpg-import=flathub.gpg flathub"
);
puts (note);
char *cmd = xy_2strjoin ("flatpak remote-modify flathub --url=", source.url);
chsrc_run (cmd, RunOpt_Default);
chsrc_say_lastly (&source, ChsrcTypeAuto);
}
def_target_noget (wr_flathub);