diff --git a/include/chsrc.h b/include/chsrc.h index ad52942..6b9b35d 100644 --- a/include/chsrc.h +++ b/include/chsrc.h @@ -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; diff --git a/src/recipe/lang/Clojure.c b/src/recipe/lang/Clojure.c index cac9ed8..550d642 100644 --- a/src/recipe/lang/Clojure.c +++ b/src/recipe/lang/Clojure.c @@ -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); diff --git a/src/recipe/lang/Dart.c b/src/recipe/lang/Dart.c index 8062afa..3e55ec4 100644 --- a/src/recipe/lang/Dart.c +++ b/src/recipe/lang/Dart.c @@ -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); diff --git a/src/recipe/lang/Go.c b/src/recipe/lang/Go.c index 92cc6a4..6152187 100644 --- a/src/recipe/lang/Go.c +++ b/src/recipe/lang/Go.c @@ -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); diff --git a/src/recipe/lang/Haskell.c b/src/recipe/lang/Haskell.c index c5b7d82..bb4df8d 100644 --- a/src/recipe/lang/Haskell.c +++ b/src/recipe/lang/Haskell.c @@ -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); diff --git a/src/recipe/lang/Java.c b/src/recipe/lang/Java.c index 4397799..33cbffa 100644 --- a/src/recipe/lang/Java.c +++ b/src/recipe/lang/Java.c @@ -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); diff --git a/src/recipe/lang/Julia.c b/src/recipe/lang/Julia.c index 706437b..de31939 100644 --- a/src/recipe/lang/Julia.c +++ b/src/recipe/lang/Julia.c @@ -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); diff --git a/src/recipe/lang/Lua.c b/src/recipe/lang/Lua.c index 73fefed..7d997c0 100644 --- a/src/recipe/lang/Lua.c +++ b/src/recipe/lang/Lua.c @@ -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); diff --git a/src/recipe/lang/Node.js.c b/src/recipe/lang/Node.js.c index a75a8e8..3d602d8 100644 --- a/src/recipe/lang/Node.js.c +++ b/src/recipe/lang/Node.js.c @@ -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); } diff --git a/src/recipe/lang/OCaml.c b/src/recipe/lang/OCaml.c index 66b58d5..e9c1a51 100644 --- a/src/recipe/lang/OCaml.c +++ b/src/recipe/lang/OCaml.c @@ -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); diff --git a/src/recipe/lang/PHP.c b/src/recipe/lang/PHP.c index 377f663..907116f 100644 --- a/src/recipe/lang/PHP.c +++ b/src/recipe/lang/PHP.c @@ -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); } diff --git a/src/recipe/lang/Perl.c b/src/recipe/lang/Perl.c index bcc29e2..2f51f87 100644 --- a/src/recipe/lang/Perl.c +++ b/src/recipe/lang/Perl.c @@ -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); diff --git a/src/recipe/lang/Python.c b/src/recipe/lang/Python.c index 709faa9..3f2c1c2 100644 --- a/src/recipe/lang/Python.c +++ b/src/recipe/lang/Python.c @@ -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 diff --git a/src/recipe/lang/R.c b/src/recipe/lang/R.c index 93bdde8..fa5f881 100644 --- a/src/recipe/lang/R.c +++ b/src/recipe/lang/R.c @@ -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); diff --git a/src/recipe/lang/Ruby.c b/src/recipe/lang/Ruby.c index 8a9b65f..b931152 100644 --- a/src/recipe/lang/Ruby.c +++ b/src/recipe/lang/Ruby.c @@ -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目前都实现的有问题,请勿使用"); diff --git a/src/recipe/lang/Rust.c b/src/recipe/lang/Rust.c index 5a4f5db..92fe667 100644 --- a/src/recipe/lang/Rust.c +++ b/src/recipe/lang/Rust.c @@ -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); diff --git a/src/recipe/os/APT/Armbian.c b/src/recipe/os/APT/Armbian.c index 7f48f89..4cf8379 100644 --- a/src/recipe/os/APT/Armbian.c +++ b/src/recipe/os/APT/Armbian.c @@ -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 diff --git a/src/recipe/os/APT/Debian.c b/src/recipe/os/APT/Debian.c index 2fdaf60..52c3482 100644 --- a/src/recipe/os/APT/Debian.c +++ b/src/recipe/os/APT/Debian.c @@ -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); diff --git a/src/recipe/os/APT/Kali-Linux.c b/src/recipe/os/APT/Kali-Linux.c index a3b466c..7ca2a66 100644 --- a/src/recipe/os/APT/Kali-Linux.c +++ b/src/recipe/os/APT/Kali-Linux.c @@ -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); diff --git a/src/recipe/os/APT/Linux-Lite.c b/src/recipe/os/APT/Linux-Lite.c index 2ec3510..2b0da05 100644 --- a/src/recipe/os/APT/Linux-Lite.c +++ b/src/recipe/os/APT/Linux-Lite.c @@ -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); diff --git a/src/recipe/os/APT/Linux-Mint.c b/src/recipe/os/APT/Linux-Mint.c index 0a53389..20606c5 100644 --- a/src/recipe/os/APT/Linux-Mint.c +++ b/src/recipe/os/APT/Linux-Mint.c @@ -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 均会覆写我们刚才换源的内容"); } diff --git a/src/recipe/os/APT/ROS.c b/src/recipe/os/APT/ROS.c index d6aa6f5..7491f11 100644 --- a/src/recipe/os/APT/ROS.c +++ b/src/recipe/os/APT/ROS.c @@ -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); diff --git a/src/recipe/os/APT/Raspberry-Pi-OS.c b/src/recipe/os/APT/Raspberry-Pi-OS.c index 83f1fb9..bfb0256 100644 --- a/src/recipe/os/APT/Raspberry-Pi-OS.c +++ b/src/recipe/os/APT/Raspberry-Pi-OS.c @@ -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); diff --git a/src/recipe/os/APT/Trisquel.c b/src/recipe/os/APT/Trisquel.c index 289da7a..ff2ddd0 100644 --- a/src/recipe/os/APT/Trisquel.c +++ b/src/recipe/os/APT/Trisquel.c @@ -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); diff --git a/src/recipe/os/APT/Ubuntu.c b/src/recipe/os/APT/Ubuntu.c index 22bf41b..0fe2189 100644 --- a/src/recipe/os/APT/Ubuntu.c +++ b/src/recipe/os/APT/Ubuntu.c @@ -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); diff --git a/src/recipe/os/APT/deepin.c b/src/recipe/os/APT/deepin.c index f824cae..9eb5b01 100644 --- a/src/recipe/os/APT/deepin.c +++ b/src/recipe/os/APT/deepin.c @@ -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); diff --git a/src/recipe/os/APT/openKylin.c b/src/recipe/os/APT/openKylin.c index 17b3106..c929cb7 100644 --- a/src/recipe/os/APT/openKylin.c +++ b/src/recipe/os/APT/openKylin.c @@ -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); diff --git a/src/recipe/os/Alpine-Linux.c b/src/recipe/os/Alpine-Linux.c index 2135e1b..07b5f5c 100644 --- a/src/recipe/os/Alpine-Linux.c +++ b/src/recipe/os/Alpine-Linux.c @@ -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); diff --git a/src/recipe/os/BSD/FreeBSD.c b/src/recipe/os/BSD/FreeBSD.c index 1eb730d..bb9a739 100644 --- a/src/recipe/os/BSD/FreeBSD.c +++ b/src/recipe/os/BSD/FreeBSD.c @@ -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); diff --git a/src/recipe/os/BSD/NetBSD.c b/src/recipe/os/BSD/NetBSD.c index 7f0a307..a16c6ea 100644 --- a/src/recipe/os/BSD/NetBSD.c +++ b/src/recipe/os/BSD/NetBSD.c @@ -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); diff --git a/src/recipe/os/BSD/OpenBSD.c b/src/recipe/os/BSD/OpenBSD.c index 9dab7eb..0b91c87 100644 --- a/src/recipe/os/BSD/OpenBSD.c +++ b/src/recipe/os/BSD/OpenBSD.c @@ -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); diff --git a/src/recipe/os/Gentoo-Linux.c b/src/recipe/os/Gentoo-Linux.c index f5b2f9b..597736f 100644 --- a/src/recipe/os/Gentoo-Linux.c +++ b/src/recipe/os/Gentoo-Linux.c @@ -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); diff --git a/src/recipe/os/OpenWrt.c b/src/recipe/os/OpenWrt.c index 66966f7..8934555 100644 --- a/src/recipe/os/OpenWrt.c +++ b/src/recipe/os/OpenWrt.c @@ -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); } diff --git a/src/recipe/os/Solus.c b/src/recipe/os/Solus.c index 864ccfc..b08fd56 100644 --- a/src/recipe/os/Solus.c +++ b/src/recipe/os/Solus.c @@ -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); diff --git a/src/recipe/os/Void-Linux.c b/src/recipe/os/Void-Linux.c index f30c2c0..299c4bd 100644 --- a/src/recipe/os/Void-Linux.c +++ b/src/recipe/os/Void-Linux.c @@ -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); diff --git a/src/recipe/os/YUM/AlmaLinux.c b/src/recipe/os/YUM/AlmaLinux.c index 88415b5..99210fc 100644 --- a/src/recipe/os/YUM/AlmaLinux.c +++ b/src/recipe/os/YUM/AlmaLinux.c @@ -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); diff --git a/src/recipe/os/YUM/Anolis-OS.c b/src/recipe/os/YUM/Anolis-OS.c index 1f9b897..301a0db 100644 --- a/src/recipe/os/YUM/Anolis-OS.c +++ b/src/recipe/os/YUM/Anolis-OS.c @@ -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); diff --git a/src/recipe/os/YUM/Fedora-Linux.c b/src/recipe/os/YUM/Fedora-Linux.c index aed6909..9e7c364 100644 --- a/src/recipe/os/YUM/Fedora-Linux.c +++ b/src/recipe/os/YUM/Fedora-Linux.c @@ -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); diff --git a/src/recipe/os/YUM/Rocky-Linux.c b/src/recipe/os/YUM/Rocky-Linux.c index 4b0b3c4..9ddd4c6 100644 --- a/src/recipe/os/YUM/Rocky-Linux.c +++ b/src/recipe/os/YUM/Rocky-Linux.c @@ -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); diff --git a/src/recipe/os/YUM/openEuler.c b/src/recipe/os/YUM/openEuler.c index 78fb913..b145871 100644 --- a/src/recipe/os/YUM/openEuler.c +++ b/src/recipe/os/YUM/openEuler.c @@ -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); diff --git a/src/recipe/os/openSUSE.c b/src/recipe/os/openSUSE.c index 35b535a..86602b2 100644 --- a/src/recipe/os/openSUSE.c +++ b/src/recipe/os/openSUSE.c @@ -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); diff --git a/src/recipe/os/pacman/Arch-Linux.c b/src/recipe/os/pacman/Arch-Linux.c index c1604d5..9af6638 100644 --- a/src/recipe/os/pacman/Arch-Linux.c +++ b/src/recipe/os/pacman/Arch-Linux.c @@ -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 diff --git a/src/recipe/os/pacman/MSYS2.c b/src/recipe/os/pacman/MSYS2.c index a042245..a1afda7 100644 --- a/src/recipe/os/pacman/MSYS2.c +++ b/src/recipe/os/pacman/MSYS2.c @@ -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); diff --git a/src/recipe/os/pacman/Manjaro-Linux.c b/src/recipe/os/pacman/Manjaro-Linux.c index 4228c58..03032ed 100644 --- a/src/recipe/os/pacman/Manjaro-Linux.c +++ b/src/recipe/os/pacman/Manjaro-Linux.c @@ -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}; diff --git a/src/recipe/template.c b/src/recipe/template.c index 688e5cc..2708217 100644 --- a/src/recipe/template.c +++ b/src/recipe/template.c @@ -71,17 +71,13 @@ void { // chsrc set - // 下面这3行是必须的 - SourceInfo source; - chsrc_yield_source (pl_ruby); - chsrc_confirm_source (&source); - + // 下面这行是必须的,注入source变量 + chsrc_yield_source_and_confirm (_); /* 具体的换源步骤,如调用第三方命令... */ - // 最后总结输出 - chsrc_say_lastly (&source, chsrc_type); + chsrc_conclude (&source, chsrc_type); } diff --git a/src/recipe/ware/Anaconda.c b/src/recipe/ware/Anaconda.c index 40804a4..91be079 100644 --- a/src/recipe/ware/Anaconda.c +++ b/src/recipe/ware/Anaconda.c @@ -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); diff --git a/src/recipe/ware/CocoaPods.c b/src/recipe/ware/CocoaPods.c index 00b9319..d35b078 100644 --- a/src/recipe/ware/CocoaPods.c +++ b/src/recipe/ware/CocoaPods.c @@ -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); diff --git a/src/recipe/ware/Docker-Hub.c b/src/recipe/ware/Docker-Hub.c index 151c982..35e6951 100644 --- a/src/recipe/ware/Docker-Hub.c +++ b/src/recipe/ware/Docker-Hub.c @@ -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); } diff --git a/src/recipe/ware/Emacs.c b/src/recipe/ware/Emacs.c index e15e3a9..03cd79d 100644 --- a/src/recipe/ware/Emacs.c +++ b/src/recipe/ware/Emacs.c @@ -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); diff --git a/src/recipe/ware/Flathub.c b/src/recipe/ware/Flathub.c index 6109a4e..ee2d30a 100644 --- a/src/recipe/ware/Flathub.c +++ b/src/recipe/ware/Flathub.c @@ -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); diff --git a/src/recipe/ware/Guix.c b/src/recipe/ware/Guix.c index 04e1427..602b244 100644 --- a/src/recipe/ware/Guix.c +++ b/src/recipe/ware/Guix.c @@ -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); diff --git a/src/recipe/ware/Homebrew.c b/src/recipe/ware/Homebrew.c index bae0886..54e8c25 100644 --- a/src/recipe/ware/Homebrew.c +++ b/src/recipe/ware/Homebrew.c @@ -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环境变量生效"); } diff --git a/src/recipe/ware/Nix.c b/src/recipe/ware/Nix.c index be3c2da..19301f4 100644 --- a/src/recipe/ware/Nix.c +++ b/src/recipe/ware/Nix.c @@ -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); diff --git a/src/recipe/ware/TeX-Live.c b/src/recipe/ware/TeX-Live.c index 2003c67..4443aab 100644 --- a/src/recipe/ware/TeX-Live.c +++ b/src/recipe/ware/TeX-Live.c @@ -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); diff --git a/src/recipe/ware/WinGet.c b/src/recipe/ware/WinGet.c index daa783b..02b484e 100644 --- a/src/recipe/ware/WinGet.c +++ b/src/recipe/ware/WinGet.c @@ -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); }