Rename inner function

This commit is contained in:
Aoran Zeng 2024-08-18 09:27:22 +08:00
parent 15d9ba817e
commit eba633b6e4
No known key found for this signature in database
GPG Key ID: 8F8BA8488E10ED98
55 changed files with 123 additions and 231 deletions

View File

@ -531,6 +531,7 @@ source_has_empty_url (SourceInfo *source)
* @dependency source
*/
#define chsrc_yield_source(for_what) \
SourceInfo source; \
if (is_url (option)) \
{ \
SourceInfo __tmp = { &UserDefine, option }; \
@ -554,8 +555,9 @@ source_has_empty_url (SourceInfo *source)
*
* @translation Done
*/
#define chsrc_confirm_source confirm_source(&source)
void
chsrc_confirm_source (SourceInfo *source)
confirm_source (SourceInfo *source)
{
// 由于实现问题,我们把本应该独立出去的默认上游源,也放在了可以换源的数组中,而且放在第一个
// chsrc 已经规避用户使用未实现的 `chsrc reset`
@ -583,6 +585,8 @@ chsrc_confirm_source (SourceInfo *source)
split_between_source_changing_process;
}
#define chsrc_yield_source_and_confirm(for_what) chsrc_yield_source(for_what);chsrc_confirm_source
#define ChsrcTypeAuto "auto"
#define ChsrcTypeReset "reset"
@ -617,7 +621,7 @@ chsrc_confirm_source (SourceInfo *source)
* @translation Done
*/
void
chsrc_say_lastly (SourceInfo *source, const char *last_word)
chsrc_conclude (SourceInfo *source, const char *last_word)
{
split_between_source_changing_process;

View File

@ -23,13 +23,11 @@ def_sources_n(pl_clojure);
void
pl_clojure_setsrc (char *option)
{
SourceInfo source;
chsrc_yield_source (pl_clojure);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (pl_clojure);
chsrc_note2 ("抱歉Clojure换源较复杂您可手动查阅并换源:");
puts (source.url);
chsrc_say_lastly (&source, ChsrcTypeManual);
chsrc_conclude (&source, ChsrcTypeManual);
}
def_target_s (pl_clojure);

View File

@ -48,9 +48,7 @@ pl_dart_getsrc (char *option)
void
pl_dart_setsrc (char *option)
{
SourceInfo source;
chsrc_yield_source (pl_dart);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (pl_dart);
char *towrite = NULL;
@ -85,7 +83,7 @@ pl_dart_setsrc (char *option)
towrite = xy_strjoin (3, "export FLUTTER_STORAGE_BASE_URL=\"", flutter, "\"");
chsrc_append_to_file (towrite, "~/.bashrc >> ~/.zshrc");
}
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target(pl_dart);

View File

@ -59,16 +59,14 @@ pl_go_setsrc (char *option)
{
pl_go_check_cmd ();
SourceInfo source;
chsrc_yield_source (pl_go);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (pl_go);
char *cmd = "go env -w GO111MODULE=on";
chsrc_run (cmd, RunOpt_Default);
cmd = xy_strjoin (3, "go env -w GOPROXY=", source.url, ",direct");
chsrc_run (cmd, RunOpt_Default);
chsrc_say_lastly (&source, ChsrcTypeAuto);
chsrc_conclude (&source, ChsrcTypeAuto);
}
def_target(pl_go);

View File

@ -24,9 +24,7 @@ def_sources_n(pl_haskell);
void
pl_haskell_setsrc (char *option)
{
SourceInfo source;
chsrc_yield_source (pl_haskell);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (pl_haskell);
char *file = xy_strjoin (3, "repository mirror\n"
" url: ", source.url,
@ -64,7 +62,7 @@ pl_haskell_setsrc (char *option)
chsrc_note2 (xy_strjoin (3, "请向 ", config, " 中手动添加:"));
puts (file);
chsrc_say_lastly (&source, ChsrcTypeManual);
chsrc_conclude (&source, ChsrcTypeManual);
}
def_target_s (pl_haskell);

View File

@ -63,9 +63,7 @@ pl_java_setsrc (char *option)
bool maven_exist, gradle_exist;
pl_java_check_cmd (&maven_exist, &gradle_exist);
SourceInfo source;
chsrc_yield_source (pl_java);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (pl_java);
if (maven_exist)
{
@ -97,7 +95,7 @@ pl_java_setsrc (char *option)
chsrc_note2 ("请在您的 build.gradle 中添加:");
puts (file);
}
chsrc_say_lastly (&source, ChsrcTypeManual);
chsrc_conclude (&source, ChsrcTypeManual);
}
def_target(pl_java);

View File

@ -42,14 +42,12 @@ pl_julia_getsrc (char *option)
void
pl_julia_setsrc (char *option)
{
SourceInfo source;
chsrc_yield_source (pl_julia);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (pl_julia);
const char *towrite = xy_strjoin (3, "ENV[\"JULIA_PKG_SERVER\"] = \"", source.url, "\"");
chsrc_append_to_file (towrite, "~/.julia/config/startup.jl");
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target(pl_julia);

View File

@ -36,9 +36,7 @@ pl_lua_getsrc (char *option)
void
pl_lua_setsrc (char *option)
{
SourceInfo source;
chsrc_yield_source (pl_lua);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (pl_lua);
char *config = xy_strjoin (3, "rocks_servers = {\n"
" \"", source.url, "\"\n"
@ -53,7 +51,7 @@ pl_lua_setsrc (char *option)
chsrc_note2 ("请手动修改 ~/.luarocks/upload_config.lua 文件 (用于上传):");
puts (upload_config);
chsrc_say_lastly (&source, ChsrcTypeManual);
chsrc_conclude (&source, ChsrcTypeManual);
}
def_target(pl_lua);

View File

@ -79,9 +79,7 @@ pl_nodejs_setsrc (char *option)
bool npm_exist, yarn_exist, pnpm_exist;
pl_nodejs_check_cmd (&npm_exist, &yarn_exist, &pnpm_exist);
SourceInfo source;
chsrc_yield_source (pl_nodejs);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (pl_nodejs);
char *cmd = NULL;
@ -110,7 +108,7 @@ pl_nodejs_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
}
chsrc_say_lastly (&source, ChsrcTypeAuto);
chsrc_conclude (&source, ChsrcTypeAuto);
}

View File

@ -39,9 +39,7 @@ pl_ocaml_setsrc(char *option)
{
pl_ocaml_check_cmd ();
SourceInfo source;
chsrc_yield_source (pl_ocaml);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (pl_ocaml);
char *cmd = xy_strjoin (3, "opam repo set-url default ",
source.url,
@ -52,7 +50,7 @@ pl_ocaml_setsrc(char *option)
chsrc_note2 ("如果是首次使用 opam ,请使用以下命令进行初始化");
puts (xy_2strjoin ("opam init default ", source.url));
chsrc_say_lastly (&source, ChsrcTypeSemiAuto);
chsrc_conclude (&source, ChsrcTypeSemiAuto);
}
def_target(pl_ocaml);

View File

@ -45,9 +45,7 @@ pl_php_setsrc (char *option)
{
pl_php_check_cmd ();
SourceInfo source;
chsrc_yield_source (pl_php);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (pl_php);
char *where = " -g ";
if (CliOpt_Locally==true)
@ -58,7 +56,7 @@ pl_php_setsrc (char *option)
char *cmd = xy_strjoin (4, "composer config", where, "repo.packagist composer ", source.url);
chsrc_run (cmd, RunOpt_Default);
chsrc_say_lastly (&source, ChsrcTypeSemiAuto);
chsrc_conclude (&source, ChsrcTypeSemiAuto);
}

View File

@ -47,9 +47,7 @@ pl_perl_getsrc (char *option)
void
pl_perl_setsrc (char *option)
{
SourceInfo source;
chsrc_yield_source (pl_perl);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (pl_perl);
char *cmd = xy_strjoin (3,
"perl -MCPAN -e \"CPAN::HandleConfig->load(); CPAN::HandleConfig->edit('urllist', 'unshift', '", source.url, "'); CPAN::HandleConfig->commit()\"");
@ -57,7 +55,7 @@ pl_perl_setsrc (char *option)
chsrc_note2 ("请您使用 perl -v 以及 cpan -v若 Perl >= v5.36 或 CPAN >= 2.29,请额外手动调用下面的命令");
puts ("perl -MCPAN -e \"CPAN::HandleConfig->load(); CPAN::HandleConfig->edit('pushy_https', 0);; CPAN::HandleConfig->commit()\"");
chsrc_say_lastly (&source, ChsrcTypeSemiAuto);
chsrc_conclude (&source, ChsrcTypeSemiAuto);
}
def_target(pl_perl);

View File

@ -107,9 +107,7 @@ pl_python_setsrc (char *option)
pl_python_check_cmd (&prog, &poetry_exist, &pdm_exist);
SourceInfo source;
chsrc_yield_source (pl_python);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (pl_python);
// 这里用的是 config --user会写入用户目录而不是项目目录
// GitHub#39
@ -133,7 +131,7 @@ pl_python_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
}
chsrc_say_lastly (&source, chsrc_type);
chsrc_conclude (&source, chsrc_type);
}
void

View File

@ -52,9 +52,7 @@ pl_r_getsrc (char *option)
void
pl_r_setsrc (char *option)
{
SourceInfo source;
chsrc_yield_source (pl_r);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (pl_r);
char *bioconductor_url = xy_str_delete_suffix (xy_str_delete_suffix (source.url, "cran/"), "CRAN/");
bioconductor_url = xy_2strjoin(bioconductor_url, "bioconductor");
@ -73,7 +71,7 @@ pl_r_setsrc (char *option)
chsrc_append_to_file (towrite1, "~/.Rprofile");
chsrc_append_to_file (towrite2, "~/.Rprofile");
}
chsrc_say_lastly (&source, ChsrcTypeAuto);
chsrc_conclude (&source, ChsrcTypeAuto);
}
def_target(pl_r);

View File

@ -68,9 +68,7 @@ pl_ruby_setsrc (char *option)
chsrc_ensure_program ("gem");
SourceInfo source;
chsrc_yield_source (pl_ruby);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (pl_ruby);
char *cmd = NULL;
@ -91,7 +89,7 @@ pl_ruby_setsrc (char *option)
cmd = xy_strjoin (4, "bundle config", where, "'mirror.https://rubygems.org' ", source.url);
chsrc_run (cmd, RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, chsrc_type);
chsrc_conclude (&source, chsrc_type);
// chsrc_note2 ("Ruby的镜像源目前仅有 腾讯软件源RubyChina 实现正确");
// chsrc_note2 ("而其它如Tuna,Bfsu,Ali目前都实现的有问题请勿使用");

View File

@ -35,9 +35,7 @@ pl_rust_getsrc (char *option)
void
pl_rust_setsrc (char *option)
{
SourceInfo source;
chsrc_yield_source (pl_rust);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (pl_rust);
const char* file = xy_strjoin (3,
"[source.crates-io]\n"
@ -48,7 +46,7 @@ pl_rust_setsrc (char *option)
chsrc_note2 (xy_strjoin (3, "请您手动写入以下内容到 ", xy_uniform_path ("~/.cargo/config.toml"), " 文件中:"));
puts (file);
chsrc_say_lastly (&source, ChsrcTypeManual);
chsrc_conclude (&source, ChsrcTypeManual);
}
def_target(pl_rust);

View File

@ -43,9 +43,7 @@ os_armbian_setsrc (char *option)
{
chsrc_ensure_root ();
SourceInfo source;
chsrc_yield_source (os_armbian);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_armbian);
chsrc_backup (OS_Armbian_SourceList);
@ -54,7 +52,7 @@ os_armbian_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeAuto);
chsrc_conclude (&source, ChsrcTypeAuto);
}
#undef OS_Armbian_SourceList

View File

@ -48,9 +48,7 @@ os_debian_getsrc (char *option)
void
os_debian_setsrc_for_deb822 (char *option)
{
SourceInfo source;
chsrc_yield_source (os_debian);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_debian);
chsrc_note2 ("如果遇到无法拉取 HTTPS 源的情况,我们会使用 HTTP 源并需要您运行:");
puts ("apt install apt-transport-https ca-certificates");
@ -65,7 +63,7 @@ os_debian_setsrc_for_deb822 (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeAuto);
chsrc_conclude (&source, ChsrcTypeAuto);
}
@ -89,9 +87,7 @@ os_debian_setsrc (char *option)
// Docker环境下Debian镜像可能不存在该文件
bool sourcelist_exist = ensure_apt_sourcelist (OS_Is_Debian_Literally);
SourceInfo source;
chsrc_yield_source (os_debian);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_debian);
chsrc_note2 ("如果遇到无法拉取 HTTPS 源的情况,我们会使用 HTTP 源并需要您运行:");
puts ("apt install apt-transport-https ca-certificates");
@ -106,7 +102,7 @@ os_debian_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeAuto);
chsrc_conclude (&source, ChsrcTypeAuto);
}
def_target(os_debian);

View File

@ -41,9 +41,7 @@ os_kali_setsrc (char *option)
{
chsrc_ensure_root ();
SourceInfo source;
chsrc_yield_source (os_kali);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_kali);
chsrc_backup (OS_Apt_SourceList);
@ -53,7 +51,7 @@ os_kali_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target(os_kali);

View File

@ -32,16 +32,14 @@ os_linuxlite_setsrc (char *option)
{
chsrc_ensure_root ();
SourceInfo source;
chsrc_yield_source (os_linuxlite);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_linuxlite);
chsrc_backup (OS_Apt_SourceList);
char *cmd = xy_strjoin (3, "sed -E -i 's@https?://.*/.*/?@", source.url, "@g' " OS_Apt_SourceList);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeAuto);
chsrc_conclude (&source, ChsrcTypeAuto);
}
def_target(os_linuxlite);

View File

@ -35,9 +35,7 @@ os_linuxmint_setsrc (char *option)
{
chsrc_ensure_root ();
SourceInfo source;
chsrc_yield_source (os_linuxmint);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_linuxmint);
chsrc_backup (OS_LinuxMint_SourceList);
@ -46,7 +44,7 @@ os_linuxmint_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeAuto);
chsrc_conclude (&source, ChsrcTypeAuto);
chsrc_warn2 ("完成后请不要再使用 mintsources自带的图形化软件源设置工具进行任何操作因为在操作后无论是否有按“确定”mintsources 均会覆写我们刚才换源的内容");
}

View File

@ -34,9 +34,7 @@ os_ros_setsrc (char *option)
{
chsrc_ensure_root (OS_ROS_SourceList);
SourceInfo source;
chsrc_yield_source (os_ros);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_ros);
chsrc_backup (OS_ROS_SourceList);
@ -48,7 +46,7 @@ os_ros_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target_s(os_ros);

View File

@ -35,9 +35,7 @@ os_raspberrypi_setsrc (char *option)
{
chsrc_ensure_root(); // HELP: 不确定是否需要
SourceInfo source;
chsrc_yield_source (os_raspberrypi);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_raspberrypi);
chsrc_backup (OS_RaspberryPi_SourceList);
@ -46,7 +44,7 @@ os_raspberrypi_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target(os_raspberrypi);

View File

@ -37,9 +37,7 @@ os_trisquel_setsrc (char *option)
{
chsrc_ensure_root ();
SourceInfo source;
chsrc_yield_source (os_trisquel);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_trisquel);
chsrc_backup (OS_Apt_SourceList);
@ -47,7 +45,7 @@ os_trisquel_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target(os_trisquel);

View File

@ -53,9 +53,7 @@ os_ubuntu_getsrc (char *option)
void
os_ubuntu_setsrc_for_deb822 (char *option)
{
SourceInfo source;
chsrc_yield_source (os_ubuntu);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_ubuntu);
chsrc_backup (OS_Ubuntu_SourceList_DEB822);
@ -72,7 +70,7 @@ os_ubuntu_setsrc_for_deb822 (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeAuto);
chsrc_conclude (&source, ChsrcTypeAuto);
}
/**
@ -92,9 +90,7 @@ os_ubuntu_setsrc (char *option)
bool sourcelist_exist = ensure_apt_sourcelist (OS_Is_Ubuntu);
SourceInfo source;
chsrc_yield_source (os_ubuntu);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_ubuntu);
// 不存在的时候,用的是我们生成的无效文件,不要备份
if (sourcelist_exist)
@ -115,7 +111,7 @@ os_ubuntu_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeAuto);
chsrc_conclude (&source, ChsrcTypeAuto);
}
def_target(os_ubuntu);

View File

@ -41,9 +41,7 @@ os_deepin_setsrc (char *option)
{
chsrc_ensure_root();
SourceInfo source;
chsrc_yield_source (os_deepin);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_deepin);
chsrc_backup (OS_Apt_SourceList);
@ -53,7 +51,7 @@ os_deepin_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target(os_deepin);

View File

@ -32,16 +32,14 @@ os_openkylin_setsrc (char *option)
{
chsrc_ensure_root();
SourceInfo source;
chsrc_yield_source (os_openkylin);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_openkylin);
chsrc_backup (OS_Apt_SourceList);
char *cmd = xy_strjoin (3, "sed -E -i 's@https?://.*/openkylin/?@", source.url, "@g'" OS_Apt_SourceList);
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target(os_openkylin);

View File

@ -39,9 +39,7 @@ os_alpine_setsrc (char *option)
{
// chsrc_ensure_root(); // HELP: 不确定是否需要root
SourceInfo source;
chsrc_yield_source (os_alpine);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_alpine);
char* cmd = xy_strjoin (3,
"sed -i 's#https\\?://dl-cdn.alpinelinux.org/alpine#", source.url, "#g' /etc/apk/repositories"
@ -49,7 +47,7 @@ os_alpine_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apk update", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target(os_alpine);

View File

@ -42,7 +42,7 @@ os_freebsd_setsrc (char *option)
int index = use_specific_mirror_or_auto_select (option, os_freebsd);
SourceInfo source = os_freebsd_sources[index];
chsrc_confirm_source (&source);
chsrc_confirm_source;
chsrc_log2 ("1. 添加 freebsd-pkg 源 (二进制安装包)");
chsrc_ensure_dir ("/usr/local/etc/pkg/repos");
@ -128,7 +128,7 @@ os_freebsd_setsrc (char *option)
chsrc_overwrite_file (update, "/etc/freebsd-update.conf");
*/
chsrc_say_lastly (&source, ChsrcTypeSemiAuto);
chsrc_conclude (&source, ChsrcTypeSemiAuto);
}
def_target_s(os_freebsd);

View File

@ -46,9 +46,7 @@ os_netbsd_setsrc (char *option)
{
chsrc_ensure_root (); // HELP: 不知道是否需要确保root权限
SourceInfo source;
chsrc_yield_source (os_netbsd);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_netbsd);
chsrc_backup ("/usr/pkg/etc/pkgin/repositories.conf");
@ -59,7 +57,7 @@ os_netbsd_setsrc (char *option)
char *url = xy_strjoin (5, source.url, arch, "/", version, "/All");
chsrc_overwrite_file (url, "/usr/pkg/etc/pkgin/repositories.conf");
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target(os_netbsd);

View File

@ -41,14 +41,12 @@ os_openbsd_setsrc (char *option)
{
chsrc_ensure_root ();
SourceInfo source;
chsrc_yield_source (os_openbsd);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_openbsd);
chsrc_backup ("/etc/installurl");
chsrc_overwrite_file (source.url, "/etc/installurl");
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target(os_openbsd);

View File

@ -33,9 +33,7 @@ os_gentoo_setsrc (char *option)
{
chsrc_ensure_root ();
SourceInfo source;
chsrc_yield_source (os_gentoo);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_gentoo);
chsrc_backup ("/etc/portage/repos.conf/gentoo.conf");
@ -47,7 +45,7 @@ os_gentoo_setsrc (char *option)
char *towrite = xy_strjoin (3, "GENTOO_MIRRORS=\"https://", source.url, "gentoo\"");
chsrc_append_to_file (towrite, "/etc/portage/make.conf");
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target_s(os_gentoo);

View File

@ -42,16 +42,14 @@ os_openwrt_setsrc (char *option)
{
chsrc_ensure_root ();
SourceInfo source;
chsrc_yield_source (os_openwrt);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_openwrt);
chsrc_backup (OS_OpenWRT_SourceConfig);
char *cmd = xy_strjoin (3, "sed -E -i 's@https?://.*downloads.openwrt.org@", source.url, "@g' " OS_OpenWRT_SourceConfig);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeAuto);
chsrc_conclude (&source, ChsrcTypeAuto);
}

View File

@ -28,13 +28,11 @@ os_solus_setsrc (char *option)
{
chsrc_ensure_root ();
SourceInfo source;
chsrc_yield_source (os_solus);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_solus);
char *cmd = xy_2strjoin ("eopkg add-repo Solus ", source.url);
chsrc_run (cmd, RunOpt_Default);
chsrc_say_lastly (&source, ChsrcTypeAuto);
chsrc_conclude (&source, ChsrcTypeAuto);
}
def_target_s(os_solus);

View File

@ -33,11 +33,9 @@ os_void_getsrc (char *option)
void
os_void_setsrc (char *option)
{
// chsrc_ensure_root(); // HELP: 不确定是否需要root
chsrc_ensure_root (); // HELP: 不确定是否需要root
SourceInfo source;
chsrc_yield_source (os_void);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_void);
chsrc_ensure_dir ("/etc/xbps.d");
char *cmd = "cp /usr/share/xbps.d/*-repository-*.conf /etc/xbps.d/";
@ -53,8 +51,8 @@ os_void_setsrc (char *option)
);
chsrc_note2 ("若报错可尝试使用以下命令:");
puts (cmd);
chsrc_say_lastly (&source, ChsrcTypeUntested);
say (cmd);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target(os_void);

View File

@ -29,16 +29,14 @@ os_almalinux_setsrc (char *option)
{
chsrc_ensure_root ();
SourceInfo source;
chsrc_yield_source (os_almalinux);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_almalinux);
char *cmd = xy_strjoin (3,
"sed -e 's|^mirrorlist=|#mirrorlist=|g' -e 's|^#\\s*baseurl=https://repo.almalinux.org/almalinux|baseurl=", source.url, "|g' -i.bak /etc/yum.repos.d/almalinux*.repo");
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("dnf makecache", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeAuto);
chsrc_conclude (&source, ChsrcTypeAuto);
}
def_target_s(os_almalinux);

View File

@ -29,16 +29,14 @@ os_anolis_setsrc (char *option)
{
chsrc_ensure_root ();
SourceInfo source;
chsrc_yield_source (os_anolis);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_anolis);
char *cmd = xy_strjoin (3, "sed -i.bak -E 's|https?://(mirrors\\.openanolis\\.cn/anolis)|", source.url, "|g' /etc/yum.repos.d/*.repo");
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("dnf makecache", RunOpt_Default);
chsrc_run ("dnf update", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target_s(os_anolis);

View File

@ -35,9 +35,7 @@ os_fedora_setsrc (char *option)
{
chsrc_ensure_root ();
SourceInfo source;
chsrc_yield_source (os_fedora);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_fedora);
chsrc_note2 ("Fedora 29 及以下版本暂不支持");
@ -62,7 +60,7 @@ os_fedora_setsrc (char *option)
chsrc_log2 ("已新增文件 /etc/yum.repos.d/fedora-updates-modular.repo");
chsrc_run ("dnf makecache", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeAuto);
chsrc_conclude (&source, ChsrcTypeAuto);
}
def_target_s(os_fedora);

View File

@ -33,9 +33,7 @@ os_rockylinux_setsrc (char *option)
{
chsrc_ensure_root ();
SourceInfo source;
chsrc_yield_source (os_rockylinux);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_rockylinux);
char *cmd = xy_strjoin (3,
"sed -e 's|^mirrorlist=|#mirrorlist=|g' "
@ -44,7 +42,7 @@ os_rockylinux_setsrc (char *option)
);
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("dnf makecache", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target_s(os_rockylinux);

View File

@ -32,9 +32,7 @@ os_openeuler_setsrc (char *option)
{
chsrc_ensure_root ();
SourceInfo source;
chsrc_yield_source (os_openeuler);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_openeuler);
chsrc_backup (OS_openEuler_SourceList);
@ -45,7 +43,7 @@ os_openeuler_setsrc (char *option)
chsrc_overwrite_file (towrite, OS_openEuler_SourceList);
chsrc_run ("dnf makecache", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeAuto);
chsrc_conclude (&source, ChsrcTypeAuto);
}
def_target_s(os_openeuler);

View File

@ -33,9 +33,7 @@ os_opensuse_setsrc (char *option)
{
chsrc_ensure_root (); // HELP: 不知道是否需要确保root权限
SourceInfo source;
chsrc_yield_source (os_opensuse);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_opensuse);
char *source_nselect = "zypper mr -da";
chsrc_run (source_nselect, RunOpt_Default);
@ -76,7 +74,7 @@ os_opensuse_setsrc (char *option)
chsrc_run (cmd5, RunOpt_Default);
chsrc_run (cmd6, RunOpt_Default);
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target_s(os_opensuse);

View File

@ -59,9 +59,7 @@ os_arch_setsrc (char *option)
{
chsrc_ensure_root ();
SourceInfo source;
chsrc_yield_source (os_arch);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_arch);
chsrc_backup (OS_Pacman_MirrorList);
@ -91,7 +89,7 @@ os_arch_setsrc (char *option)
{
chsrc_run ("pacman -Syy", RunOpt_No_Last_New_Line);
}
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
@ -109,9 +107,7 @@ os_archlinuxcn_setsrc (char *option)
{
chsrc_ensure_root ();
SourceInfo source;
chsrc_yield_source (os_archlinuxcn);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_archlinuxcn);
chsrc_backup (OS_Pacman_MirrorList);
@ -126,7 +122,7 @@ os_archlinuxcn_setsrc (char *option)
chsrc_run ("pacman -Sy archlinuxcn-keyring", RunOpt_Default);
chsrc_run ("pacman -Syy", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
#undef OS_Pacman_MirrorList

View File

@ -31,9 +31,7 @@ def_sources_n(os_msys2);
void
os_msys2_setsrc (char *option)
{
SourceInfo source;
chsrc_yield_source (os_msys2);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_msys2);
chsrc_backup ("/etc/pacman.d/mirrorlist.mingw32");
chsrc_backup ("/etc/pacman.d/mirrorlist.mingw64");
@ -49,7 +47,7 @@ os_msys2_setsrc (char *option)
"#g\" /etc/pacman.d/mirrorlist* ");
chsrc_run (cmd, RunOpt_Default);
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target_s(os_msys2);

View File

@ -20,7 +20,7 @@ os_manjaro_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("pacman -Syy", RunOpt_No_Last_New_Line);
chsrc_say_lastly (NULL, ChsrcTypeAuto);
chsrc_conclude (NULL, ChsrcTypeAuto);
}
TargetInfo os_manjaro_target = {NULL, os_manjaro_setsrc, NULL, NULL, 0};

View File

@ -71,17 +71,13 @@ void
{
// chsrc set <target>
// 下面这3行是必须的
SourceInfo source;
chsrc_yield_source (pl_ruby);
chsrc_confirm_source (&source);
// 下面这行是必须的注入source变量
chsrc_yield_source_and_confirm (<category>_<target>);
/* 具体的换源步骤,如调用第三方命令... */
// 最后总结输出
chsrc_say_lastly (&source, chsrc_type);
chsrc_conclude (&source, chsrc_type);
}

View File

@ -25,9 +25,7 @@ def_sources_n(wr_anaconda);
void
wr_anaconda_setsrc (char *option)
{
SourceInfo source;
chsrc_yield_source (wr_anaconda);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (wr_anaconda);
char *main = xy_2strjoin (source.url, "pkgs/main");
char *r = xy_2strjoin (source.url, "pkgs/r");
@ -69,7 +67,7 @@ wr_anaconda_setsrc (char *option)
puts (file);
chsrc_note2 ("然后运行 conda clean -i 清除索引缓存,保证用的是镜像站提供的索引");
chsrc_say_lastly (&source, ChsrcTypeSemiAuto);
chsrc_conclude (&source, ChsrcTypeSemiAuto);
}
def_target_s (wr_anaconda);

View File

@ -24,9 +24,7 @@ def_sources_n(wr_cocoapods);
void
wr_cocoapods_setsrc (char *option)
{
SourceInfo source;
chsrc_yield_source (wr_cocoapods);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (wr_cocoapods);
chsrc_note2 ("请手动执行以下命令:");
@ -40,7 +38,7 @@ wr_cocoapods_setsrc (char *option)
char *source_str = xy_strjoin (3, "source '", source.url, "'");
say (source_str);
chsrc_say_lastly (&source, ChsrcTypeManual);
chsrc_conclude (&source, ChsrcTypeManual);
}
def_target_s (wr_cocoapods);

View File

@ -66,9 +66,7 @@ wr_dockerhub_getsrc (char *option)
void
wr_dockerhub_setsrc (char *option)
{
SourceInfo source;
chsrc_yield_source (wr_dockerhub);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (wr_dockerhub);
if (xy_on_linux || xy_on_bsd)
{
@ -93,7 +91,7 @@ wr_dockerhub_setsrc (char *option)
chsrc_note2 ("选择“Docker Engine”选项卡在该选项卡中找到“registry-mirrors”一栏添加镜像地址:");
puts (source.url);
}
chsrc_say_lastly (&source, ChsrcTypeManual);
chsrc_conclude (&source, ChsrcTypeManual);
}

View File

@ -30,14 +30,12 @@ def_sources_n(wr_emacs);
void
wr_emacs_setsrc (char *option)
{
SourceInfo source;
chsrc_yield_source (wr_emacs);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (wr_emacs);
chsrc_note2 ("Emacs换源涉及Elisp需要手动查阅并换源:");
puts (source.url);
chsrc_say_lastly (&source, ChsrcTypeManual);
chsrc_conclude (&source, ChsrcTypeManual);
}
def_target_s (wr_emacs);

View File

@ -25,9 +25,7 @@ def_sources_n(wr_flathub);
void
wr_flathub_setsrc (char *option)
{
SourceInfo source;
chsrc_yield_source (wr_flathub);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (wr_flathub);
chsrc_note2 ("若出现问题,可先调用以下命令:");
char *note = xy_strjoin (3,
@ -39,7 +37,7 @@ wr_flathub_setsrc (char *option)
char *cmd = xy_2strjoin ("flatpak remote-modify flathub --url=", source.url);
chsrc_run (cmd, RunOpt_Default);
chsrc_say_lastly (&source, ChsrcTypeAuto);
chsrc_conclude (&source, ChsrcTypeAuto);
}
def_target_s (wr_flathub);

View File

@ -25,9 +25,7 @@ def_sources_n(wr_guix);
void
wr_guix_setsrc (char *option)
{
SourceInfo source;
chsrc_yield_source (wr_guix);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (wr_guix);
char *file = xy_strjoin (3, "(list (channel\n"
" (inherit (car %default-channels))\n"
@ -35,7 +33,7 @@ wr_guix_setsrc (char *option)
chsrc_note2 ("为防止扰乱配置文件,请您手动写入以下内容到 ~/.config/guix/channels.scm 文件中");
puts (file);
chsrc_say_lastly (&source, ChsrcTypeManual);
chsrc_conclude (&source, ChsrcTypeManual);
}
def_target_s (wr_guix);

View File

@ -45,9 +45,7 @@ wr_homebrew_getsrc (char *option)
void
wr_homebrew_setsrc (char *option)
{
SourceInfo source;
chsrc_yield_source (wr_homebrew);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (wr_homebrew);
char *splitter = "\n\n# Generated by chsrc " Chsrc_Version;
char *api_domain = xy_strjoin (3, "export HOMEBREW_API_DOMAIN=\"", xy_2strjoin (source.url, "homebrew-bottles/api"), "\"");
@ -74,7 +72,7 @@ wr_homebrew_setsrc (char *option)
chsrc_append_to_file (core_git_remote, bashrc);
}
chsrc_say_lastly (&source, ChsrcTypeAuto);
chsrc_conclude (&source, ChsrcTypeAuto);
chsrc_note2 ("请您重启终端使Homebrew环境变量生效");
}

View File

@ -38,9 +38,7 @@ wr_nix_setsrc (char *option)
{
wr_nix_check_cmd ();
SourceInfo source;
chsrc_yield_source (wr_nix);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (wr_nix);
char *cmd = xy_strjoin (3, "nix-channel --add ", source.url, "nixpkgs-unstable nixpkgs");
chsrc_run (cmd, RunOpt_Default);
@ -58,7 +56,7 @@ wr_nix_setsrc (char *option)
chsrc_note2 ("若您使用的是NixOS请额外添加下述内容至 configuration.nix 中");
puts (cmd);
chsrc_say_lastly (&source, ChsrcTypeSemiAuto);
chsrc_conclude (&source, ChsrcTypeSemiAuto);
}
def_target_s (wr_nix);

View File

@ -61,9 +61,7 @@ wr_tex_setsrc (char *option)
bool tlmgr_exist, mpm_exist;
wr_tex_check_cmd (&tlmgr_exist, &mpm_exist);
SourceInfo source;
chsrc_yield_source (wr_tex);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (wr_tex);
char *cmd = NULL;
@ -80,7 +78,7 @@ wr_tex_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
}
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target(wr_tex);

View File

@ -29,21 +29,19 @@ wr_winget_getsrc (char *option)
void
wr_winget_setsrc (char *option)
{
SourceInfo source;
chsrc_yield_source (wr_winget);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (wr_winget);
chsrc_run ("winget source remove winget", RunOpt_Default);
chsrc_run (xy_2strjoin ("winget source add winget ", source.url), RunOpt_Default);
chsrc_say_lastly (&source, ChsrcTypeAuto);
chsrc_conclude (&source, ChsrcTypeAuto);
}
void
wr_winget_resetsrc (char *option)
{
chsrc_run ("winget source reset winget", RunOpt_Default);
chsrc_say_lastly (NULL, ChsrcTypeAuto);
chsrc_conclude (NULL, ChsrcTypeAuto);
}