Adjust chsrc_conclude()

This commit is contained in:
Aoran Zeng 2024-11-22 09:08:32 +08:00
parent 6a59ec51e1
commit 722de55ecb
No known key found for this signature in database
GPG Key ID: 8F8BA8488E10ED98
65 changed files with 234 additions and 124 deletions

View File

@ -30,6 +30,17 @@ int ProgMode_Leader_Selected_Index = -1;
/* 此时 chsrc_run() 不再是recipe中指定要运行的一个外部命令而是作为一个功能实现的支撑 */
bool ProgMode_Run_as_a_Service = false;
enum ChgType_t
{
ChgType_Auto,
ChgType_Reset,
ChgType_SemiAuto,
ChgType_Manual,
ChgType_Untested
};
enum ChgType_t ProgMode_ChgType = ChgType_Auto;
/* 命令行选项 */
bool CliOpt_IPv6 = false;
@ -769,7 +780,7 @@ source_has_empty_url (Source_t *source)
* 1. Mirror Code
* 2. NULL: ()
* 3. URL
* 4. SetsrcType_Reset
* 4. ChgType_Reset
* Leader target
* 5. ProgMode_Leader_Selected_Index
*
@ -846,11 +857,6 @@ confirm_source (Source_t *source)
#define chsrc_yield_source_and_confirm(for_what) chsrc_yield_source(for_what);chsrc_confirm_source
#define SetsrcType_Auto "auto"
#define SetsrcType_Reset "reset"
#define SetsrcType_SemiAuto "semiauto"
#define SetsrcType_Manual "manual"
#define SetsrcType_Untested "untested"
#define MSG_EN_PUBLIC_URL "If the URL you specify is a public service, you are invited to contribute: chsrc issue"
#define MSG_CN_PUBLIC_URL "若您指定的URL为公有服务邀您参与贡献: chsrc issue"
@ -876,22 +882,24 @@ confirm_source (Source_t *source)
#define thank_mirror(msg) chsrc_log(xy_2strjoin(msg,purple(CliOpt_InEnglish?source->mirror->abbr:source->mirror->name)))
/**
* @param source NULL
* @param last_word 5SetsrcType_Auto | SetsrcType_Reset | SetsrcType_SemiAuto | SetsrcType_Manual | SetsrcType_Untested
* @translation Done
* @param source NULL
*
* @param[g] ProgMode_ChgType
*/
void
chsrc_conclude (Source_t *source, const char *last_word)
chsrc_conclude (Source_t *source)
{
split_between_source_changing_process;
if ((ProgMode_CMD_Reset == true) || xy_streql (SetsrcType_Reset, last_word))
// fprintf (stderr, "chsrc: now change type: %d\n", ProgMode_ChgType);
if (ProgMode_CMD_Reset || ChgType_Reset == ProgMode_ChgType)
{
// source_is_upstream (source)
char *msg = CliOpt_InEnglish ? "Has been reset to the upstream default source" : "已重置为上游默认源";
chsrc_log (purple (msg));
}
else if (xy_streql (SetsrcType_Auto, last_word))
else if (ChgType_Auto == ProgMode_ChgType)
{
if (source)
{
@ -914,7 +922,7 @@ chsrc_conclude (Source_t *source, const char *last_word)
chsrc_log (msg);
}
}
else if (xy_streql (SetsrcType_SemiAuto, last_word))
else if (ChgType_SemiAuto == ProgMode_ChgType)
{
if (source)
{
@ -941,7 +949,7 @@ chsrc_conclude (Source_t *source, const char *last_word)
char *msg = CliOpt_InEnglish ? MSG_EN_BETTER : MSG_CN_BETTER;
chsrc_warn (msg);
}
else if (xy_streql (SetsrcType_Manual, last_word))
else if (ChgType_Manual == ProgMode_ChgType)
{
if (source)
{
@ -966,7 +974,7 @@ chsrc_conclude (Source_t *source, const char *last_word)
char *msg = CliOpt_InEnglish ? MSG_EN_BETTER : MSG_CN_BETTER;
chsrc_warn (msg);
}
else if (xy_streql (SetsrcType_Untested, last_word))
else if (ChgType_Untested == ProgMode_ChgType)
{
if (source)
{
@ -992,7 +1000,8 @@ chsrc_conclude (Source_t *source, const char *last_word)
}
else
{
say (last_word);
fprintf (stderr, "chsrc: Wrong change type: %d\n", ProgMode_ChgType);
xy_unreach;
}
}

View File

@ -26,8 +26,9 @@ pl_clojure_setsrc (char *option)
chsrc_yield_source_and_confirm (pl_clojure);
chsrc_note2 ("抱歉Clojure换源较复杂您可手动查阅并换源:");
puts (source.url);
chsrc_conclude (&source, SetsrcType_Manual);
say (source.url);
ProgMode_ChgType = ChgType_Manual;
chsrc_conclude (&source);
}
def_target_s (pl_clojure);

View File

@ -83,14 +83,16 @@ pl_dart_flutter_setsrc (char *option)
chsrc_append_to_file (w, bashrc);
}
}
chsrc_conclude (&source, SetsrcType_Auto);
ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto;
chsrc_conclude (&source);
}
void
pl_dart_flutter_resetsrc (char *option)
{
pl_dart_flutter_setsrc (SetsrcType_Reset);
pl_dart_flutter_setsrc (option);
}

View File

@ -79,14 +79,16 @@ pl_dart_setsrc (char *option)
chsrc_append_to_file (w, bashrc);
}
}
chsrc_conclude (&source, SetsrcType_Auto);
ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto;
chsrc_conclude (&source);
}
void
pl_dart_resetsrc (char *option)
{
pl_dart_setsrc (SetsrcType_Reset);
pl_dart_setsrc (option);
}

View File

@ -76,7 +76,8 @@ pl_go_setsrc (char *option)
cmd = xy_strjoin (3, "go env -w GOPROXY=", source.url, ",direct");
chsrc_run (cmd, RunOpt_Default);
chsrc_conclude (&source, SetsrcType_Auto);
ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto;
chsrc_conclude (&source);
}
/**

View File

@ -61,8 +61,9 @@ pl_haskell_setsrc (char *option)
" ignore-expiry: no");
chsrc_note2 (xy_strjoin (3, "请向 ", config, " 中手动添加:"));
puts (file);
chsrc_conclude (&source, SetsrcType_Manual);
say (file);
ProgMode_ChgType = ChgType_Manual;
chsrc_conclude (&source);
}
def_target_s (pl_haskell);

View File

@ -93,9 +93,10 @@ pl_java_setsrc (char *option)
"}");
chsrc_note2 ("请在您的 build.gradle 中添加:");
puts (file);
say (file);
}
chsrc_conclude (&source, SetsrcType_Manual);
ProgMode_ChgType = ChgType_Manual;
chsrc_conclude (&source);
}
def_target(pl_java);

View File

@ -49,7 +49,8 @@ pl_julia_setsrc (char *option)
chsrc_append_to_file (w, PL_Julia_Config);
chsrc_conclude (&source, SetsrcType_Untested);
ProgMode_ChgType = ChgType_Untested;
chsrc_conclude (&source);
}

View File

@ -52,9 +52,10 @@ pl_lua_setsrc (char *option)
"server = \"", source.url, "\"");
chsrc_note2 ("请手动修改 ~/.luarocks/upload_config.lua 文件 (用于上传):");
puts (upload_config);
say (upload_config);
chsrc_conclude (&source, SetsrcType_Manual);
ProgMode_ChgType = ChgType_Manual;
chsrc_conclude (&source);
}
def_target(pl_lua);

View File

@ -27,8 +27,6 @@ pl_nodejs_bun_getsrc (char *option)
void
pl_nodejs_bun_setsrc (char *option)
{
char *setsrc_type = xy_streql (option, SetsrcType_Reset) ? SetsrcType_Reset : SetsrcType_Manual;
// 用的是 npm Registry 的源
chsrc_yield_source (pl_nodejs);
@ -44,8 +42,9 @@ pl_nodejs_bun_setsrc (char *option)
chsrc_note2 (xy_strjoin (3, "请您手动写入以下内容到 ", xy_normalize_path ("~/.bunfig.toml"), " 文件中"));
}
puts (file);
chsrc_conclude (&source, setsrc_type);
say (file);
ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto;
chsrc_conclude (&source);
}
@ -55,7 +54,7 @@ pl_nodejs_bun_setsrc (char *option)
void
pl_nodejs_bun_resetsrc (char *option)
{
pl_nodejs_bun_setsrc (SetsrcType_Reset);
pl_nodejs_bun_setsrc (option);
}

View File

@ -94,7 +94,8 @@ pl_nodejs_setsrc (char *option)
pl_nodejs_pnpm_setsrc (option);
}
chsrc_conclude (&source, SetsrcType_Auto);
ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto;
chsrc_conclude (&source);
}
@ -104,7 +105,7 @@ pl_nodejs_setsrc (char *option)
void
pl_nodejs_resetsrc (char *option)
{
pl_nodejs_setsrc (SetsrcType_Reset);
pl_nodejs_setsrc (option);
}

View File

@ -72,7 +72,10 @@ pl_nodejs_yarn_setsrc (char *option)
}
if (ProgMode_Target_Group!=true)
chsrc_conclude (&source, SetsrcType_Auto);
{
ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto;
chsrc_conclude (&source);
}
}
@ -82,7 +85,7 @@ pl_nodejs_yarn_setsrc (char *option)
void
pl_nodejs_yarn_resetsrc (char *option)
{
pl_nodejs_yarn_setsrc (SetsrcType_Reset);
pl_nodejs_yarn_setsrc (option);
}

View File

@ -41,7 +41,10 @@ pl_nodejs_npm_setsrc (char *option)
chsrc_run (cmd, RunOpt_No_Last_New_Line);
if (ProgMode_Target_Group!=true)
chsrc_conclude (&source, SetsrcType_Auto);
{
ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto;
chsrc_conclude (&source);
}
}
@ -51,7 +54,7 @@ pl_nodejs_npm_setsrc (char *option)
void
pl_nodejs_npm_resetsrc (char *option)
{
pl_nodejs_npm_setsrc (SetsrcType_Reset);
pl_nodejs_npm_setsrc (option);
}

View File

@ -42,7 +42,8 @@ pl_nodejs_nvm_setsrc (char *option)
if (xy_file_exist (zshrc))
chsrc_append_to_file (w, zshrc);
chsrc_conclude (&source, SetsrcType_Auto);
ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto;
chsrc_conclude (&source);
}
@ -52,7 +53,7 @@ pl_nodejs_nvm_setsrc (char *option)
void
pl_nodejs_nvm_resetsrc (char *option)
{
// pl_nodejs_nvm_setsrc (SetsrcType_Reset);
// pl_nodejs_nvm_setsrc (ChgType_Reset);
chsrc_error ("暂不支持对 nvm 重置");
exit (Exit_Unsupported);
}

View File

@ -42,7 +42,10 @@ pl_nodejs_pnpm_setsrc (char *option)
chsrc_run (cmd, RunOpt_No_Last_New_Line);
if (ProgMode_Target_Group!=true)
chsrc_conclude (&source, SetsrcType_Auto);
{
ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto;
chsrc_conclude (&source);
}
}
@ -52,7 +55,7 @@ pl_nodejs_pnpm_setsrc (char *option)
void
pl_nodejs_pnpm_resetsrc (char *option)
{
pl_nodejs_pnpm_setsrc (SetsrcType_Reset);
pl_nodejs_pnpm_setsrc (option);
}

View File

@ -48,9 +48,10 @@ pl_ocaml_setsrc(char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_note2 ("如果是首次使用 opam ,请使用以下命令进行初始化");
puts (xy_2strjoin ("opam init default ", source.url));
say (xy_2strjoin ("opam init default ", source.url));
chsrc_conclude (&source, SetsrcType_SemiAuto);
ProgMode_ChgType = ChgType_SemiAuto;
chsrc_conclude (&source);
}
def_target(pl_ocaml);

View File

@ -4,7 +4,7 @@
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nil Null <nil@null.org>
* Created On : <2023-08-30>
* Last Modified : <2024-09-14>
* Last Modified : <2024-11-22>
* ------------------------------------------------------------*/
/**
@ -39,7 +39,7 @@ pl_php_getsrc (char *option)
}
/**
* PHP https://developer.aliyun.com/composer
* @consult https://developer.aliyun.com/composer
*/
void
pl_php_setsrc (char *option)
@ -57,7 +57,8 @@ pl_php_setsrc (char *option)
char *cmd = xy_strjoin (4, "composer config", where, "repo.packagist composer ", source.url);
chsrc_run (cmd, RunOpt_Default);
chsrc_conclude (&source, SetsrcType_SemiAuto);
ProgMode_ChgType = ChgType_Auto;
chsrc_conclude (&source);
}

View File

@ -54,8 +54,10 @@ pl_perl_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
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_conclude (&source, SetsrcType_SemiAuto);
say ("perl -MCPAN -e \"CPAN::HandleConfig->load(); CPAN::HandleConfig->edit('pushy_https', 0);; CPAN::HandleConfig->commit()\"");
ProgMode_ChgType = ChgType_SemiAuto;
chsrc_conclude (&source);
}
def_target(pl_perl);

View File

@ -43,7 +43,10 @@ pl_python_pdm_setsrc (char *option)
chsrc_run (cmd, RunOpt_No_Last_New_Line);
if (ProgMode_Target_Group!=true)
chsrc_conclude (&source, SetsrcType_Auto);
{
ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto;
chsrc_conclude (&source);
}
}
@ -53,7 +56,7 @@ pl_python_pdm_setsrc (char *option)
void
pl_python_pdm_resetsrc (char *option)
{
pl_python_pdm_setsrc (SetsrcType_Reset);
pl_python_pdm_setsrc (option);
}

View File

@ -41,7 +41,10 @@ pl_python_poetry_setsrc (char *option)
chsrc_run (cmd, RunOpt_No_Last_New_Line);
if (ProgMode_Target_Group!=true)
chsrc_conclude (&source, SetsrcType_Auto);
{
ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto;
chsrc_conclude (&source);
}
}
@ -51,7 +54,7 @@ pl_python_poetry_setsrc (char *option)
void
pl_python_poetry_resetsrc (char *option)
{
pl_python_poetry_setsrc (SetsrcType_Reset);
pl_python_poetry_setsrc (option);
}

View File

@ -45,8 +45,6 @@ pl_python_setsrc (char *option)
chsrc_note2 (msg);
}
char *setsrc_type = xy_streql (option, SetsrcType_Reset) ? SetsrcType_Reset : SetsrcType_Auto;
bool pdm_exist = false,
poetry_exist = false;
@ -71,13 +69,14 @@ pl_python_setsrc (char *option)
pl_python_pdm_setsrc (option);
}
chsrc_conclude (&source, setsrc_type);
ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto;
chsrc_conclude (&source);
}
void
pl_python_resetsrc (char *option)
{
pl_python_setsrc (SetsrcType_Reset);
pl_python_setsrc (option);
}

View File

@ -53,7 +53,10 @@ pl_python_pip_setsrc (char *option)
chsrc_run (cmd, RunOpt_No_Last_New_Line);
if (ProgMode_Target_Group!=true)
chsrc_conclude (&source, SetsrcType_Auto);
{
ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto;
chsrc_conclude (&source);
}
}
@ -63,7 +66,7 @@ pl_python_pip_setsrc (char *option)
void
pl_python_pip_resetsrc (char *option)
{
pl_python_pip_setsrc (SetsrcType_Reset);
pl_python_pip_setsrc (option);
}

View File

@ -71,7 +71,8 @@ pl_r_setsrc (char *option)
chsrc_append_to_file (w, config);
chsrc_conclude (&source, SetsrcType_Auto);
ProgMode_ChgType = ChgType_Auto;
chsrc_conclude (&source);
}
def_target(pl_r);

View File

@ -62,8 +62,6 @@ pl_ruby_remove_gem_source (const char *source)
void
pl_ruby_setsrc (char *option)
{
char *setsrc_type = xy_streql (option, SetsrcType_Reset) ? SetsrcType_Reset : SetsrcType_Auto;
chsrc_ensure_program ("gem");
chsrc_yield_source_and_confirm (pl_ruby);
@ -87,13 +85,14 @@ 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_conclude (&source, setsrc_type);
ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto;
chsrc_conclude (&source);
}
void
pl_ruby_resetsrc (char *option)
{
pl_ruby_setsrc (SetsrcType_Reset);
pl_ruby_setsrc (option);
}

View File

@ -55,8 +55,9 @@ pl_rust_cargo_setsrc (char *option)
"registry = \"sparse+", source.url, "\"");
chsrc_note2 (xy_strjoin (3, "请您手动写入以下内容到 ", xy_normalize_path ("~/.cargo/config.toml"), " 文件中:"));
puts (file);
chsrc_conclude (&source, SetsrcType_Manual);
say (file);
ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto;
chsrc_conclude (&source);
}
@ -66,7 +67,7 @@ pl_rust_cargo_setsrc (char *option)
void
pl_rust_cargo_resetsrc (char *option)
{
pl_rust_cargo_setsrc (SetsrcType_Reset);
pl_rust_cargo_setsrc (option);
}

View File

@ -45,8 +45,6 @@ pl_rust_rustup_getsrc (char *option)
void
pl_rust_rustup_setsrc (char *option)
{
char *setsrc_type = xy_streql (option, SetsrcType_Reset) ? SetsrcType_Reset : SetsrcType_Auto;
chsrc_yield_source_and_confirm (pl_rust_rustup);
char *w1 = xy_strjoin (3, "export RUSTUP_DIST_SERVER=\"", source.url, "\"\n");
@ -80,7 +78,8 @@ pl_rust_rustup_setsrc (char *option)
chsrc_append_to_file (w, fishrc);
}
chsrc_conclude (&source, setsrc_type);
ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto;
chsrc_conclude (&source);
chsrc_note2 ("请您重启终端使rustup环境变量生效");
}
@ -91,7 +90,7 @@ pl_rust_rustup_setsrc (char *option)
void
pl_rust_rustup_resetsrc (char *option)
{
pl_rust_rustup_setsrc (SetsrcType_Reset);
pl_rust_rustup_setsrc (option);
}

View File

@ -57,7 +57,9 @@ os_armbian_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_conclude (&source, SetsrcType_Auto);
ProgMode_ChgType = ChgType_Auto;
chsrc_conclude (&source);
}

View File

@ -66,7 +66,9 @@ os_debian_setsrc_for_deb822 (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_conclude (&source, SetsrcType_Auto);
ProgMode_ChgType = ChgType_Auto;
chsrc_conclude (&source);
}
@ -105,7 +107,9 @@ os_debian_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_conclude (&source, SetsrcType_Auto);
ProgMode_ChgType = ChgType_Auto;
chsrc_conclude (&source);
}

View File

@ -53,7 +53,9 @@ os_kali_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_conclude (&source, SetsrcType_Untested);
ProgMode_ChgType = ChgType_Untested;
chsrc_conclude (&source);
}
def_target(os_kali);

View File

@ -42,7 +42,9 @@ os_linuxlite_setsrc (char *option)
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_conclude (&source, SetsrcType_Auto);
ProgMode_ChgType = ChgType_Auto;
chsrc_conclude (&source);
}
def_target(os_linuxlite);

View File

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

View File

@ -46,7 +46,9 @@ os_ros_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_conclude (&source, SetsrcType_Untested);
ProgMode_ChgType = ChgType_Untested;
chsrc_conclude (&source);
}
def_target_s(os_ros);

View File

@ -44,7 +44,9 @@ os_raspberrypi_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_conclude (&source, SetsrcType_Untested);
ProgMode_ChgType = ChgType_Untested;
chsrc_conclude (&source);
}
def_target(os_raspberrypi);

View File

@ -46,7 +46,9 @@ os_trisquel_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_conclude (&source, SetsrcType_Untested);
ProgMode_ChgType = ChgType_Untested;
chsrc_conclude (&source);
}
def_target(os_trisquel);

View File

@ -75,7 +75,9 @@ os_ubuntu_setsrc_for_deb822 (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_conclude (&source, SetsrcType_Auto);
ProgMode_ChgType = ChgType_Auto;
chsrc_conclude (&source);
}
/**
@ -118,7 +120,9 @@ os_ubuntu_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_conclude (&source, SetsrcType_Auto);
ProgMode_ChgType = ChgType_Auto;
chsrc_conclude (&source);
}

View File

@ -51,7 +51,9 @@ os_deepin_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_conclude (&source, SetsrcType_Untested);
ProgMode_ChgType = ChgType_Untested;
chsrc_conclude (&source);
}
def_target(os_deepin);

View File

@ -39,7 +39,9 @@ os_openkylin_setsrc (char *option)
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_conclude (&source, SetsrcType_Untested);
ProgMode_ChgType = ChgType_Untested;
chsrc_conclude (&source);
}
def_target(os_openkylin);

View File

@ -48,7 +48,9 @@ os_alpine_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apk update", RunOpt_No_Last_New_Line);
chsrc_conclude (&source, SetsrcType_Untested);
ProgMode_ChgType = ChgType_Untested;
chsrc_conclude (&source);
}
def_target(os_alpine);

View File

@ -128,7 +128,8 @@ os_freebsd_setsrc (char *option)
chsrc_overwrite_file (update, "/etc/freebsd-update.conf");
*/
chsrc_conclude (&source, SetsrcType_SemiAuto);
ProgMode_ChgType = ChgType_SemiAuto;
chsrc_conclude (&source);
}
def_target_s(os_freebsd);

View File

@ -58,7 +58,8 @@ 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_conclude (&source, SetsrcType_Untested);
ProgMode_ChgType = ChgType_Untested;
chsrc_conclude (&source);
}
def_target(os_netbsd);

View File

@ -47,7 +47,8 @@ os_openbsd_setsrc (char *option)
chsrc_backup ("/etc/installurl");
chsrc_overwrite_file (source.url, "/etc/installurl");
chsrc_conclude (&source, SetsrcType_Untested);
ProgMode_ChgType = ChgType_Untested;
chsrc_conclude (&source);
}
def_target(os_openbsd);

View File

@ -45,7 +45,9 @@ os_gentoo_setsrc (char *option)
char *w = xy_strjoin (3, "GENTOO_MIRRORS=\"https://", source.url, "gentoo\"\n");
chsrc_append_to_file (w, "/etc/portage/make.conf");
chsrc_conclude (&source, SetsrcType_Untested);
ProgMode_ChgType = ChgType_Untested;
chsrc_conclude (&source);
}
def_target_s(os_gentoo);

View File

@ -50,7 +50,9 @@ os_openwrt_setsrc (char *option)
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_conclude (&source, SetsrcType_Auto);
ProgMode_ChgType = ChgType_Auto;
chsrc_conclude (&source);
}

View File

@ -32,7 +32,9 @@ os_solus_setsrc (char *option)
char *cmd = xy_2strjoin ("eopkg add-repo Solus ", source.url);
chsrc_run (cmd, RunOpt_Default);
chsrc_conclude (&source, SetsrcType_Auto);
ProgMode_ChgType = ChgType_Auto;
chsrc_conclude (&source);
}
def_target_s(os_solus);

View File

@ -52,7 +52,8 @@ os_void_setsrc (char *option)
chsrc_note2 ("若报错可尝试使用以下命令:");
say (cmd);
chsrc_conclude (&source, SetsrcType_Untested);
ProgMode_ChgType = ChgType_Untested;
chsrc_conclude (&source);
}
def_target(os_void);

View File

@ -36,7 +36,9 @@ os_almalinux_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("dnf makecache", RunOpt_No_Last_New_Line);
chsrc_conclude (&source, SetsrcType_Auto);
ProgMode_ChgType = ChgType_Auto;
chsrc_conclude (&source);
}
def_target_s(os_almalinux);

View File

@ -36,7 +36,9 @@ os_anolis_setsrc (char *option)
chsrc_run ("dnf makecache", RunOpt_Default);
chsrc_run ("dnf update", RunOpt_No_Last_New_Line);
chsrc_conclude (&source, SetsrcType_Untested);
ProgMode_ChgType = ChgType_Untested;
chsrc_conclude (&source);
}
def_target_s(os_anolis);

View File

@ -37,8 +37,6 @@ def_sources_n(os_fedora);
void
os_fedora_setsrc (char *option)
{
char *setsrc_type = xy_streql (option, SetsrcType_Reset) ? SetsrcType_Reset : SetsrcType_Auto;
chsrc_ensure_root ();
chsrc_yield_source_and_confirm (os_fedora);
@ -74,14 +72,15 @@ os_fedora_setsrc (char *option)
chsrc_run ("dnf makecache", RunOpt_No_Last_New_Line);
chsrc_conclude (&source, setsrc_type);
ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto;
chsrc_conclude (&source);
}
void
os_fedora_resetsrc (char *option)
{
os_fedora_setsrc (SetsrcType_Reset);
os_fedora_setsrc (option);
}

View File

@ -67,7 +67,9 @@ os_rockylinux_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("dnf makecache", RunOpt_No_Last_New_Line);
chsrc_conclude (&source, SetsrcType_Auto);
ProgMode_ChgType = ChgType_Auto;
chsrc_conclude (&source);
}

View File

@ -44,7 +44,9 @@ os_openeuler_setsrc (char *option)
chsrc_overwrite_file (towrite, OS_openEuler_SourceList);
chsrc_run ("dnf makecache", RunOpt_No_Last_New_Line);
chsrc_conclude (&source, SetsrcType_Auto);
ProgMode_ChgType = ChgType_Auto;
chsrc_conclude (&source);
}
def_target_s(os_openeuler);

View File

@ -75,7 +75,9 @@ os_opensuse_setsrc (char *option)
chsrc_run (cmd5, RunOpt_Default);
chsrc_run (cmd6, RunOpt_Default);
chsrc_conclude (&source, SetsrcType_Untested);
ProgMode_ChgType = ChgType_Untested;
chsrc_conclude (&source);
}
def_target_s(os_opensuse);

View File

@ -91,7 +91,8 @@ os_arch_setsrc (char *option)
{
chsrc_run ("pacman -Syy", RunOpt_No_Last_New_Line);
}
chsrc_conclude (&source, SetsrcType_Auto);
ProgMode_ChgType = ChgType_Auto;
chsrc_conclude (&source);
}
@ -124,7 +125,9 @@ os_archlinuxcn_setsrc (char *option)
chsrc_run ("pacman -Sy archlinuxcn-keyring", RunOpt_Default);
chsrc_run ("pacman -Syy", RunOpt_No_Last_New_Line);
chsrc_conclude (&source, SetsrcType_Untested);
ProgMode_ChgType = ChgType_Untested;
chsrc_conclude (&source);
}
#undef OS_Pacman_MirrorList

View File

@ -47,7 +47,9 @@ os_msys2_setsrc (char *option)
"#g\" /etc/pacman.d/mirrorlist* ");
chsrc_run (cmd, RunOpt_Default);
chsrc_conclude (&source, SetsrcType_Untested);
ProgMode_ChgType = ChgType_Untested;
chsrc_conclude (&source);
}
def_target_s(os_msys2);

View File

@ -20,7 +20,8 @@ os_manjaro_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("pacman -Syy", RunOpt_No_Last_New_Line);
chsrc_conclude (NULL, SetsrcType_Auto);
ProgMode_ChgType = ChgType_Auto;
chsrc_conclude (NULL);
}
Target_t os_manjaro_target = {NULL, os_manjaro_setsrc, NULL, NULL, 0};

View File

@ -77,13 +77,14 @@ void
void
<category>_<target>_setsrc (char *option)
{
// 下面这行是必须的注入source变量
/* 下面这行是必须的注入source变量 */
chsrc_yield_source_and_confirm (<category>_<target>);
/* 具体的换源步骤,如调用第三方命令... */
// 最后总结输出
chsrc_conclude (&source, setsrc_type);
/* 最后总结输出 */
ProgMode_ChgType = ChgType_;
chsrc_conclude (&source);
}

View File

@ -67,7 +67,9 @@ wr_anaconda_setsrc (char *option)
puts (file);
chsrc_note2 ("然后运行 conda clean -i 清除索引缓存,保证用的是镜像站提供的索引");
chsrc_conclude (&source, SetsrcType_SemiAuto);
ProgMode_ChgType = ChgType_SemiAuto;
chsrc_conclude (&source);
}
def_target_s (wr_anaconda);

View File

@ -38,7 +38,8 @@ wr_cocoapods_setsrc (char *option)
char *source_str = xy_strjoin (3, "source '", source.url, "'");
say (source_str);
chsrc_conclude (&source, SetsrcType_Manual);
ProgMode_ChgType = ChgType_Manual;
chsrc_conclude (&source);
}
def_target_s (wr_cocoapods);

View File

@ -151,7 +151,9 @@ wr_dockerhub_setsrc (char *option)
chsrc_note2 ("选择“Docker Engine”选项卡在该选项卡中找到“registry-mirrors”一栏添加镜像地址:");
puts (source.url);
}
chsrc_conclude (&source, SetsrcType_Manual);
ProgMode_ChgType = ChgType_Manual;
chsrc_conclude (&source);
}

View File

@ -36,9 +36,10 @@ wr_emacs_setsrc (char *option)
chsrc_yield_source_and_confirm (wr_emacs);
chsrc_note2 ("Emacs换源涉及Elisp需要手动查阅并换源:");
puts (source.url);
say (source.url);
chsrc_conclude (&source, SetsrcType_Manual);
ProgMode_ChgType = ChgType_Manual;
chsrc_conclude (&source);
}
def_target_s (wr_emacs);

View File

@ -37,7 +37,8 @@ wr_flathub_setsrc (char *option)
char *cmd = xy_2strjoin ("flatpak remote-modify flathub --url=", source.url);
chsrc_run (cmd, RunOpt_Default);
chsrc_conclude (&source, SetsrcType_Auto);
ProgMode_ChgType = ChgType_Auto;
chsrc_conclude (&source);
}
def_target_s (wr_flathub);

View File

@ -32,8 +32,10 @@ wr_guix_setsrc (char *option)
" (url \"", source.url, "\")))");
chsrc_note2 ("为防止扰乱配置文件,请您手动写入以下内容到 ~/.config/guix/channels.scm 文件中");
puts (file);
chsrc_conclude (&source, SetsrcType_Manual);
say (file);
ProgMode_ChgType = ChgType_Manual;
chsrc_conclude (&source);
}
def_target_s (wr_guix);

View File

@ -81,7 +81,8 @@ wr_homebrew_setsrc (char *option)
chsrc_append_to_file (w, fishrc);
}
chsrc_conclude(&source, SetsrcType_Auto);
ProgMode_ChgType = ChgType_Auto;
chsrc_conclude (&source);
chsrc_note2 ("请您重启终端使Homebrew环境变量生效");
}

View File

@ -56,7 +56,8 @@ wr_nix_setsrc (char *option)
chsrc_note2 ("若您使用的是NixOS请额外添加下述内容至 configuration.nix 中");
say (cmd);
chsrc_conclude (&source, SetsrcType_SemiAuto);
ProgMode_ChgType = ChgType_SemiAuto;
chsrc_conclude (&source);
}
def_target_s (wr_nix);

View File

@ -78,7 +78,8 @@ wr_tex_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
}
chsrc_conclude (&source, SetsrcType_Untested);
ProgMode_ChgType = ChgType_Untested;
chsrc_conclude (&source);
}
def_target(wr_tex);

View File

@ -34,14 +34,17 @@ wr_winget_setsrc (char *option)
chsrc_run ("winget source remove winget", RunOpt_Default);
chsrc_run (xy_2strjoin ("winget source add winget ", source.url), RunOpt_Default);
chsrc_conclude (&source, SetsrcType_Auto);
ProgMode_ChgType = ChgType_Auto;
chsrc_conclude (&source);
}
void
wr_winget_resetsrc (char *option)
{
chsrc_run ("winget source reset winget", RunOpt_Default);
chsrc_conclude (NULL, SetsrcType_Auto);
ProgMode_ChgType = ChgType_Auto;
chsrc_conclude (NULL);
}