From 2d75a48c19c5053076f8a09ba495f6e05900b01c Mon Sep 17 00:00:00 2001 From: Aoran Zeng Date: Thu, 6 Mar 2025 12:36:16 +0800 Subject: [PATCH] Use `chsrc_determine_chgtype()` --- src/framework/core.c | 16 ++++++++++++++-- src/recipe/lang/Clojure.c | 3 ++- src/recipe/lang/Dart/Flutter.c | 2 +- src/recipe/lang/Dart/Pub.c | 2 +- src/recipe/lang/Go.c | 3 ++- src/recipe/lang/Haskell.c | 3 ++- src/recipe/lang/Java.c | 3 ++- src/recipe/lang/Julia.c | 2 +- src/recipe/lang/Lua.c | 4 ++-- src/recipe/lang/Node.js/Bun.c | 3 ++- src/recipe/lang/Node.js/Node.js.c | 2 +- src/recipe/lang/Node.js/Yarn.c | 2 +- src/recipe/lang/Node.js/npm.c | 2 +- src/recipe/lang/Node.js/nvm.c | 2 +- src/recipe/lang/Node.js/pnpm.c | 2 +- src/recipe/lang/OCaml.c | 10 ++++++---- src/recipe/lang/PHP.c | 2 +- src/recipe/lang/Perl.c | 2 +- src/recipe/lang/Python/PDM.c | 2 +- src/recipe/lang/Python/Poetry.c | 2 +- src/recipe/lang/Python/Python.c | 2 +- src/recipe/lang/Python/Rye.c | 2 +- src/recipe/lang/Python/pip.c | 2 +- src/recipe/lang/Python/uv.c | 19 +++++++++++-------- src/recipe/lang/R.c | 2 +- src/recipe/lang/Ruby.c | 2 +- src/recipe/lang/Rust/Cargo.c | 3 ++- src/recipe/lang/Rust/rustup.c | 2 +- src/recipe/os/APT/Armbian.c | 2 +- src/recipe/os/APT/Debian.c | 4 ++-- src/recipe/os/APT/Kali-Linux.c | 2 +- src/recipe/os/APT/Linux-Lite.c | 4 ++-- src/recipe/os/APT/Linux-Mint.c | 6 +++--- src/recipe/os/APT/ROS.c | 2 +- src/recipe/os/APT/Raspberry-Pi-OS.c | 4 +++- src/recipe/os/APT/Termux.c | 2 +- src/recipe/os/APT/Trisquel.c | 2 +- src/recipe/os/APT/Ubuntu.c | 4 ++-- src/recipe/os/APT/deepin.c | 2 +- src/recipe/os/APT/openKylin.c | 2 +- src/recipe/os/Alpine-Linux.c | 2 +- src/recipe/os/BSD/FreeBSD.c | 2 +- src/recipe/os/BSD/NetBSD.c | 2 +- src/recipe/os/BSD/OpenBSD.c | 2 +- src/recipe/os/Gentoo-Linux.c | 2 +- src/recipe/os/OpenWrt.c | 2 +- src/recipe/os/Solus.c | 2 +- src/recipe/os/Void-Linux.c | 3 ++- src/recipe/os/YUM/AlmaLinux.c | 2 +- src/recipe/os/YUM/Anolis-OS.c | 2 +- src/recipe/os/YUM/Fedora-Linux.c | 2 +- src/recipe/os/YUM/Rocky-Linux.c | 2 +- src/recipe/os/YUM/openEuler.c | 2 +- src/recipe/os/openSUSE.c | 2 +- src/recipe/os/pacman/Arch-Linux.c | 3 ++- src/recipe/os/pacman/MSYS2.c | 2 +- src/recipe/os/pacman/Manjaro-Linux.c | 3 ++- src/recipe/ware/Anaconda.c | 2 +- src/recipe/ware/CocoaPods.c | 2 +- src/recipe/ware/Docker-Hub.c | 2 +- src/recipe/ware/Emacs.c | 2 +- src/recipe/ware/Flathub.c | 2 +- src/recipe/ware/Guix.c | 2 +- src/recipe/ware/Homebrew.c | 2 +- src/recipe/ware/Nix.c | 2 +- src/recipe/ware/TeX-Live.c | 2 +- src/recipe/ware/WinGet.c | 4 ++-- 67 files changed, 113 insertions(+), 85 deletions(-) diff --git a/src/framework/core.c b/src/framework/core.c index 0c52cce..12f1fba 100644 --- a/src/framework/core.c +++ b/src/framework/core.c @@ -9,7 +9,7 @@ * | Yangmoooo * | * Created On : <2023-08-29> - * Last Modified : <2024-12-14> + * Last Modified : <2025-03-06> * * chsrc framework * ------------------------------------------------------------*/ @@ -783,6 +783,11 @@ source_has_empty_url (Source_t *source) return source->url == NULL; } +bool +is_reset_mode () +{ + return ProgMode_CMD_Reset; +} /** @@ -868,6 +873,13 @@ confirm_source (Source_t *source) #define chsrc_yield_source_and_confirm(for_what) chsrc_yield_source(for_what);chsrc_confirm_source +void +chsrc_determine_chgtype (enum ChgType_t type) +{ + ProgMode_ChgType = is_reset_mode() ? ChgType_Reset : type; +} + + #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" @@ -895,7 +907,7 @@ confirm_source (Source_t *source) /** * @param source 可为NULL * - * @param[g] ProgMode_ChgType + * @param [g]ProgMode_ChgType */ void chsrc_conclude (Source_t *source) diff --git a/src/recipe/lang/Clojure.c b/src/recipe/lang/Clojure.c index 14770c0..25c49de 100644 --- a/src/recipe/lang/Clojure.c +++ b/src/recipe/lang/Clojure.c @@ -27,7 +27,8 @@ pl_clojure_setsrc (char *option) chsrc_note2 ("抱歉,Clojure换源较复杂,您可手动查阅并换源:"); p(source.url); - ProgMode_ChgType = ChgType_Manual; + + chsrc_determine_chgtype (ChgType_Manual); chsrc_conclude (&source); } diff --git a/src/recipe/lang/Dart/Flutter.c b/src/recipe/lang/Dart/Flutter.c index 90a1324..84c34b3 100644 --- a/src/recipe/lang/Dart/Flutter.c +++ b/src/recipe/lang/Dart/Flutter.c @@ -84,7 +84,7 @@ pl_dart_flutter_setsrc (char *option) } } - ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto; + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } diff --git a/src/recipe/lang/Dart/Pub.c b/src/recipe/lang/Dart/Pub.c index e82e51d..f12f708 100644 --- a/src/recipe/lang/Dart/Pub.c +++ b/src/recipe/lang/Dart/Pub.c @@ -80,7 +80,7 @@ pl_dart_setsrc (char *option) } } - ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto; + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } diff --git a/src/recipe/lang/Go.c b/src/recipe/lang/Go.c index 67f9f75..79e05a6 100644 --- a/src/recipe/lang/Go.c +++ b/src/recipe/lang/Go.c @@ -83,7 +83,8 @@ pl_go_setsrc (char *option) cmd = xy_strjoin (3, "go env -w GOPROXY=", source.url, ",direct"); chsrc_run (cmd, RunOpt_Default); - ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto; + + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } diff --git a/src/recipe/lang/Haskell.c b/src/recipe/lang/Haskell.c index cf2f927..dbc43a2 100644 --- a/src/recipe/lang/Haskell.c +++ b/src/recipe/lang/Haskell.c @@ -62,7 +62,8 @@ pl_haskell_setsrc (char *option) chsrc_note2 (xy_strjoin (3, "请向 ", config, " 中手动添加:")); p(file); - ProgMode_ChgType = ChgType_Manual; + + chsrc_determine_chgtype (ChgType_Manual); chsrc_conclude (&source); } diff --git a/src/recipe/lang/Java.c b/src/recipe/lang/Java.c index 5a01884..35853d0 100644 --- a/src/recipe/lang/Java.c +++ b/src/recipe/lang/Java.c @@ -101,7 +101,8 @@ pl_java_setsrc (char *option) chsrc_note2 ("请在您的 build.gradle 中添加:"); p(file); } - ProgMode_ChgType = ChgType_Manual; + + chsrc_determine_chgtype (ChgType_Manual); chsrc_conclude (&source); } diff --git a/src/recipe/lang/Julia.c b/src/recipe/lang/Julia.c index d5e5d65..ff135da 100644 --- a/src/recipe/lang/Julia.c +++ b/src/recipe/lang/Julia.c @@ -49,7 +49,7 @@ pl_julia_setsrc (char *option) chsrc_append_to_file (w, PL_Julia_Config); - ProgMode_ChgType = ChgType_Untested; + chsrc_determine_chgtype (ChgType_Untested); chsrc_conclude (&source); } diff --git a/src/recipe/lang/Lua.c b/src/recipe/lang/Lua.c index f9396bc..1b883e9 100644 --- a/src/recipe/lang/Lua.c +++ b/src/recipe/lang/Lua.c @@ -34,7 +34,7 @@ pl_lua_getsrc (char *option) } /** - * Lua 换源,参考:https://luarocks.cn/ + * @consult https://luarocks.cn/ */ void pl_lua_setsrc (char *option) @@ -54,7 +54,7 @@ pl_lua_setsrc (char *option) chsrc_note2 ("请手动修改 ~/.luarocks/upload_config.lua 文件 (用于上传):"); p(upload_config); - ProgMode_ChgType = ChgType_Manual; + chsrc_determine_chgtype (ChgType_Manual); chsrc_conclude (&source); } diff --git a/src/recipe/lang/Node.js/Bun.c b/src/recipe/lang/Node.js/Bun.c index 937cf6f..456645c 100644 --- a/src/recipe/lang/Node.js/Bun.c +++ b/src/recipe/lang/Node.js/Bun.c @@ -43,7 +43,8 @@ pl_nodejs_bun_setsrc (char *option) } p(file); - ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto; + + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } diff --git a/src/recipe/lang/Node.js/Node.js.c b/src/recipe/lang/Node.js/Node.js.c index 1eefc4f..d9338d8 100644 --- a/src/recipe/lang/Node.js/Node.js.c +++ b/src/recipe/lang/Node.js/Node.js.c @@ -94,7 +94,7 @@ pl_nodejs_setsrc (char *option) pl_nodejs_pnpm_setsrc (option); } - ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto; + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } diff --git a/src/recipe/lang/Node.js/Yarn.c b/src/recipe/lang/Node.js/Yarn.c index ae2d2fe..061d4bc 100644 --- a/src/recipe/lang/Node.js/Yarn.c +++ b/src/recipe/lang/Node.js/Yarn.c @@ -73,7 +73,7 @@ pl_nodejs_yarn_setsrc (char *option) if (ProgMode_Target_Group!=true) { - ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto; + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } } diff --git a/src/recipe/lang/Node.js/npm.c b/src/recipe/lang/Node.js/npm.c index d0dc5d0..92554f0 100644 --- a/src/recipe/lang/Node.js/npm.c +++ b/src/recipe/lang/Node.js/npm.c @@ -42,7 +42,7 @@ pl_nodejs_npm_setsrc (char *option) if (ProgMode_Target_Group!=true) { - ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto; + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } } diff --git a/src/recipe/lang/Node.js/nvm.c b/src/recipe/lang/Node.js/nvm.c index fb05409..62f380b 100644 --- a/src/recipe/lang/Node.js/nvm.c +++ b/src/recipe/lang/Node.js/nvm.c @@ -42,7 +42,7 @@ pl_nodejs_nvm_setsrc (char *option) if (xy_file_exist (zshrc)) chsrc_append_to_file (w, zshrc); - ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto; + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } diff --git a/src/recipe/lang/Node.js/pnpm.c b/src/recipe/lang/Node.js/pnpm.c index 90b0341..6f8e420 100644 --- a/src/recipe/lang/Node.js/pnpm.c +++ b/src/recipe/lang/Node.js/pnpm.c @@ -43,7 +43,7 @@ pl_nodejs_pnpm_setsrc (char *option) if (ProgMode_Target_Group!=true) { - ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto; + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } } diff --git a/src/recipe/lang/OCaml.c b/src/recipe/lang/OCaml.c index ab74986..80d7bb4 100644 --- a/src/recipe/lang/OCaml.c +++ b/src/recipe/lang/OCaml.c @@ -24,18 +24,20 @@ pl_ocaml_check_cmd () chsrc_ensure_program ("opam"); } + void -pl_ocaml_getsrc(char *option) +pl_ocaml_getsrc (char *option) { pl_ocaml_check_cmd (); chsrc_run ("opam repo get-url default", RunOpt_Default); } + /** - * 参考: https://mirrors.sjtug.sjtu.edu.cn/docs/git/opam-repository.git + * @consult https://mirrors.sjtug.sjtu.edu.cn/docs/git/opam-repository.git */ void -pl_ocaml_setsrc(char *option) +pl_ocaml_setsrc (char *option) { pl_ocaml_check_cmd (); @@ -50,7 +52,7 @@ pl_ocaml_setsrc(char *option) chsrc_note2 ("如果是首次使用 opam ,请使用以下命令进行初始化"); p(xy_2strjoin ("opam init default ", source.url)); - ProgMode_ChgType = ChgType_SemiAuto; + chsrc_determine_chgtype (ChgType_SemiAuto); chsrc_conclude (&source); } diff --git a/src/recipe/lang/PHP.c b/src/recipe/lang/PHP.c index f9b1f5b..5b442b4 100644 --- a/src/recipe/lang/PHP.c +++ b/src/recipe/lang/PHP.c @@ -57,7 +57,7 @@ pl_php_setsrc (char *option) char *cmd = xy_strjoin (4, "composer config", where, "repo.packagist composer ", source.url); chsrc_run (cmd, RunOpt_Default); - ProgMode_ChgType = ChgType_Auto; + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } diff --git a/src/recipe/lang/Perl.c b/src/recipe/lang/Perl.c index 4731745..616739e 100644 --- a/src/recipe/lang/Perl.c +++ b/src/recipe/lang/Perl.c @@ -63,7 +63,7 @@ pl_perl_setsrc (char *option) chsrc_note2 ("请您使用 perl -v 以及 cpan -v,若 Perl >= v5.36 或 CPAN >= 2.29,请额外手动调用下面的命令"); p("perl -MCPAN -e \"CPAN::HandleConfig->load(); CPAN::HandleConfig->edit('pushy_https', 0);; CPAN::HandleConfig->commit()\""); - ProgMode_ChgType = ChgType_SemiAuto; + chsrc_determine_chgtype (ChgType_SemiAuto); chsrc_conclude (&source); } diff --git a/src/recipe/lang/Python/PDM.c b/src/recipe/lang/Python/PDM.c index e2e0b0d..03def58 100644 --- a/src/recipe/lang/Python/PDM.c +++ b/src/recipe/lang/Python/PDM.c @@ -44,7 +44,7 @@ pl_python_pdm_setsrc (char *option) if (ProgMode_Target_Group!=true) { - ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto; + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } } diff --git a/src/recipe/lang/Python/Poetry.c b/src/recipe/lang/Python/Poetry.c index 7e5f4a9..e5fe417 100644 --- a/src/recipe/lang/Python/Poetry.c +++ b/src/recipe/lang/Python/Poetry.c @@ -42,7 +42,7 @@ pl_python_poetry_setsrc (char *option) if (ProgMode_Target_Group!=true) { - ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto; + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } } diff --git a/src/recipe/lang/Python/Python.c b/src/recipe/lang/Python/Python.c index 28bcba5..afec8e8 100644 --- a/src/recipe/lang/Python/Python.c +++ b/src/recipe/lang/Python/Python.c @@ -81,7 +81,7 @@ pl_python_setsrc (char *option) pl_python_uv_setsrc (option); } - ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto; + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } diff --git a/src/recipe/lang/Python/Rye.c b/src/recipe/lang/Python/Rye.c index 9957570..4efc007 100644 --- a/src/recipe/lang/Python/Rye.c +++ b/src/recipe/lang/Python/Rye.c @@ -49,7 +49,7 @@ pl_python_rye_setsrc (char *option) chsrc_note2 (xy_strjoin (3, "请在您的 Rye 配置文件 ", rye_config, " 中添加:")); puts (file); - ProgMode_ChgType = ChgType_Manual; + chsrc_determine_chgtype (ChgType_Manual); chsrc_conclude (&source); } diff --git a/src/recipe/lang/Python/pip.c b/src/recipe/lang/Python/pip.c index 4e88753..c197dae 100644 --- a/src/recipe/lang/Python/pip.c +++ b/src/recipe/lang/Python/pip.c @@ -54,7 +54,7 @@ pl_python_pip_setsrc (char *option) if (ProgMode_Target_Group!=true) { - ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto; + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } } diff --git a/src/recipe/lang/Python/uv.c b/src/recipe/lang/Python/uv.c index 2034ba9..d337e01 100644 --- a/src/recipe/lang/Python/uv.c +++ b/src/recipe/lang/Python/uv.c @@ -67,28 +67,28 @@ void pl_python_uv_setsrc (char *option) { chsrc_ensure_program("uv"); - + Source_t source; chsrc_yield_for_the_source (pl_python); - + char *uv_config = pl_python_find_uv_config (true); chsrc_backup (uv_config); - + const char *source_content = xy_strjoin (5, "[[index]]\n", "url = \"", source.url, "\"\n", "default = true\n"); - + // sed -i '/^\[\[index\]\]$/,/^default = true$/{s|^url = ".*"$|url = " source.url "|}' uv_config // 将 [[index]] 到 default = true 之间的 url = ".*" 替换为 url = "source.url" char *update_source_cmd = xy_strjoin (5, "sed -i ", "'/^\\[\\[index\\]\\]$/,/^default = true$/{s|^url = \".*\"$|url = \"", - source.url, + source.url, "\"|}' ", uv_config); - + char *append_source_cmd = xy_strjoin (4, "echo -e '", source_content, "' >> ", uv_config); - + // grep -q '^[[index]]$' uv_config && update_source_cmd || append_source_cmd // 如果 uv_config 中存在 [[index]] 则更新, 否则追加到文件末尾 // 文件不存在也是追加到新文件末尾 @@ -98,8 +98,11 @@ pl_python_uv_setsrc (char *option) update_source_cmd, " || ", append_source_cmd); - + chsrc_run (cmd, RunOpt_Default); + + chsrc_determine_chgtype (ChgType_Auto); + chsrc_conclude (&source); } diff --git a/src/recipe/lang/R.c b/src/recipe/lang/R.c index aef3545..a7243b8 100644 --- a/src/recipe/lang/R.c +++ b/src/recipe/lang/R.c @@ -71,7 +71,7 @@ pl_r_setsrc (char *option) chsrc_append_to_file (w, config); - ProgMode_ChgType = ChgType_Auto; + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } diff --git a/src/recipe/lang/Ruby.c b/src/recipe/lang/Ruby.c index 6f70401..e1ec0fe 100644 --- a/src/recipe/lang/Ruby.c +++ b/src/recipe/lang/Ruby.c @@ -91,7 +91,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); - ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto; + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } diff --git a/src/recipe/lang/Rust/Cargo.c b/src/recipe/lang/Rust/Cargo.c index 3d07beb..ea87e72 100644 --- a/src/recipe/lang/Rust/Cargo.c +++ b/src/recipe/lang/Rust/Cargo.c @@ -63,7 +63,8 @@ pl_rust_cargo_setsrc (char *option) chsrc_note2 (xy_strjoin (3, "请您手动写入以下内容到 ", xy_normalize_path ("~/.cargo/config.toml"), " 文件中:")); p(file); - ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto; + + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } diff --git a/src/recipe/lang/Rust/rustup.c b/src/recipe/lang/Rust/rustup.c index 1b2b49f..e61f436 100644 --- a/src/recipe/lang/Rust/rustup.c +++ b/src/recipe/lang/Rust/rustup.c @@ -84,7 +84,7 @@ pl_rust_rustup_setsrc (char *option) chsrc_append_to_file (w, fishrc); } - ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto; + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); chsrc_note2 ("请您重启终端使rustup环境变量生效"); } diff --git a/src/recipe/os/APT/Armbian.c b/src/recipe/os/APT/Armbian.c index 9fcfbc3..07fcb0f 100644 --- a/src/recipe/os/APT/Armbian.c +++ b/src/recipe/os/APT/Armbian.c @@ -58,7 +58,7 @@ os_armbian_setsrc (char *option) chsrc_run (cmd, RunOpt_Default); chsrc_run ("apt update", RunOpt_No_Last_New_Line); - ProgMode_ChgType = ChgType_Auto; + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } diff --git a/src/recipe/os/APT/Debian.c b/src/recipe/os/APT/Debian.c index 33e0fe0..def94cf 100644 --- a/src/recipe/os/APT/Debian.c +++ b/src/recipe/os/APT/Debian.c @@ -74,7 +74,7 @@ os_debian_setsrc_for_deb822 (char *option) chsrc_run ("apt update", RunOpt_No_Last_New_Line); - ProgMode_ChgType = ChgType_Auto; + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } @@ -115,7 +115,7 @@ os_debian_setsrc (char *option) chsrc_run (cmd, RunOpt_Default); chsrc_run ("apt update", RunOpt_No_Last_New_Line); - ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto; + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } diff --git a/src/recipe/os/APT/Kali-Linux.c b/src/recipe/os/APT/Kali-Linux.c index ca026ec..b7e9cd2 100644 --- a/src/recipe/os/APT/Kali-Linux.c +++ b/src/recipe/os/APT/Kali-Linux.c @@ -60,7 +60,7 @@ os_kali_setsrc (char *option) chsrc_run (cmd, RunOpt_Default); chsrc_run ("apt update", RunOpt_No_Last_New_Line); - ProgMode_ChgType = ChgType_Untested; + chsrc_determine_chgtype (ChgType_Untested); chsrc_conclude (&source); } diff --git a/src/recipe/os/APT/Linux-Lite.c b/src/recipe/os/APT/Linux-Lite.c index 55cd1d7..25855e8 100644 --- a/src/recipe/os/APT/Linux-Lite.c +++ b/src/recipe/os/APT/Linux-Lite.c @@ -34,7 +34,7 @@ os_linuxlite_getsrc (char *option) } /** - * 参考: https://help.mirrors.cernet.edu.cn/linuxliteos/ + * @consult https://help.mirrors.cernet.edu.cn/linuxliteos/ */ void os_linuxlite_setsrc (char *option) @@ -49,7 +49,7 @@ os_linuxlite_setsrc (char *option) chsrc_run ("apt update", RunOpt_No_Last_New_Line); - ProgMode_ChgType = ChgType_Auto; + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } diff --git a/src/recipe/os/APT/Linux-Mint.c b/src/recipe/os/APT/Linux-Mint.c index 355437e..252cab0 100644 --- a/src/recipe/os/APT/Linux-Mint.c +++ b/src/recipe/os/APT/Linux-Mint.c @@ -39,7 +39,7 @@ os_linuxmint_getsrc (char *option) } /** - * 参考: https://help.mirrors.cernet.edu.cn/linuxmint/ + * @consult https://help.mirrors.cernet.edu.cn/linuxmint/ */ void os_linuxmint_setsrc (char *option) @@ -55,13 +55,13 @@ os_linuxmint_setsrc (char *option) char *version_codename = xy_run ("sed -nr 's/^VERSION_CODENAME=([^\"]+)/\1/p' " ETC_OS_RELEASE, 0); // sed -i '// s|http[^ ]*||g' OS_LinuxMint_SourceList char* cmd = xy_strjoin (5, "sed -i '/", - version_codename, "/ s|http[^ ]*|", + version_codename, "/ s|http[^ ]*|", source.url, "|g' " OS_LinuxMint_SourceList); chsrc_run (cmd, RunOpt_Default); chsrc_run ("apt update", RunOpt_No_Last_New_Line); - ProgMode_ChgType = ChgType_Auto; + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); chsrc_warn2 ("完成后请不要再使用 mintsources(自带的图形化软件源设置工具)进行任何操作,因为在操作后,无论是否有按“确定”,mintsources 均会覆写我们刚才换源的内容"); chsrc_warn2 ("已自动更换mint主要源, 但mint也使用基于debian或ubuntu的基础源, 可参考对应的debian或ubuntu换源方法进行手动换源"); diff --git a/src/recipe/os/APT/ROS.c b/src/recipe/os/APT/ROS.c index 7885c28..c0ae86e 100644 --- a/src/recipe/os/APT/ROS.c +++ b/src/recipe/os/APT/ROS.c @@ -56,7 +56,7 @@ os_ros_setsrc (char *option) chsrc_run ("apt update", RunOpt_No_Last_New_Line); - ProgMode_ChgType = ChgType_Untested; + chsrc_determine_chgtype (ChgType_Untested); chsrc_conclude (&source); } diff --git a/src/recipe/os/APT/Raspberry-Pi-OS.c b/src/recipe/os/APT/Raspberry-Pi-OS.c index 11fea4a..11b4682 100644 --- a/src/recipe/os/APT/Raspberry-Pi-OS.c +++ b/src/recipe/os/APT/Raspberry-Pi-OS.c @@ -24,12 +24,14 @@ static Source_t os_raspberrypi_sources[] = }; def_sources_n(os_raspberrypi); + void os_raspberrypi_getsrc (char *option) { chsrc_view_file (OS_RaspberryPi_SourceList); } + void os_raspberrypi_setsrc (char *option) { @@ -45,7 +47,7 @@ os_raspberrypi_setsrc (char *option) chsrc_run (cmd, RunOpt_Default); chsrc_run ("apt update", RunOpt_No_Last_New_Line); - ProgMode_ChgType = ChgType_Untested; + chsrc_determine_chgtype (ChgType_Untested); chsrc_conclude (&source); } diff --git a/src/recipe/os/APT/Termux.c b/src/recipe/os/APT/Termux.c index cfe1b29..f3985d6 100644 --- a/src/recipe/os/APT/Termux.c +++ b/src/recipe/os/APT/Termux.c @@ -61,7 +61,7 @@ os_termux_setsrc (char *option) chsrc_run ("apt update", RunOpt_Default); chsrc_run ("apt upgrade", RunOpt_Default); - ProgMode_ChgType = ChgType_Auto; + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } diff --git a/src/recipe/os/APT/Trisquel.c b/src/recipe/os/APT/Trisquel.c index 5214e33..97e7e16 100644 --- a/src/recipe/os/APT/Trisquel.c +++ b/src/recipe/os/APT/Trisquel.c @@ -48,7 +48,7 @@ os_trisquel_setsrc (char *option) chsrc_run (cmd, RunOpt_Default); chsrc_run ("apt update", RunOpt_No_Last_New_Line); - ProgMode_ChgType = ChgType_Untested; + chsrc_determine_chgtype (ChgType_Untested); chsrc_conclude (&source); } diff --git a/src/recipe/os/APT/Ubuntu.c b/src/recipe/os/APT/Ubuntu.c index f876bb7..7937cd3 100644 --- a/src/recipe/os/APT/Ubuntu.c +++ b/src/recipe/os/APT/Ubuntu.c @@ -83,7 +83,7 @@ os_ubuntu_setsrc_for_deb822 (char *option) chsrc_run (cmd, RunOpt_Default); chsrc_run ("apt update", RunOpt_No_Last_New_Line); - ProgMode_ChgType = ChgType_Auto; + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } @@ -128,7 +128,7 @@ os_ubuntu_setsrc (char *option) chsrc_run (cmd, RunOpt_Default); chsrc_run ("apt update", RunOpt_No_Last_New_Line); - ProgMode_ChgType = ChgType_Auto; + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } diff --git a/src/recipe/os/APT/deepin.c b/src/recipe/os/APT/deepin.c index cfacd67..a6b237b 100644 --- a/src/recipe/os/APT/deepin.c +++ b/src/recipe/os/APT/deepin.c @@ -52,7 +52,7 @@ os_deepin_setsrc (char *option) chsrc_run (cmd, RunOpt_Default); chsrc_run ("apt update", RunOpt_No_Last_New_Line); - ProgMode_ChgType = ChgType_Untested; + chsrc_determine_chgtype (ChgType_Untested); chsrc_conclude (&source); } diff --git a/src/recipe/os/APT/openKylin.c b/src/recipe/os/APT/openKylin.c index b2a6b8f..276f9bd 100644 --- a/src/recipe/os/APT/openKylin.c +++ b/src/recipe/os/APT/openKylin.c @@ -40,7 +40,7 @@ os_openkylin_setsrc (char *option) chsrc_run (cmd, RunOpt_Default); chsrc_run ("apt update", RunOpt_No_Last_New_Line); - ProgMode_ChgType = ChgType_Untested; + chsrc_determine_chgtype (ChgType_Untested); chsrc_conclude (&source); } diff --git a/src/recipe/os/Alpine-Linux.c b/src/recipe/os/Alpine-Linux.c index c576588..7e78c8e 100644 --- a/src/recipe/os/Alpine-Linux.c +++ b/src/recipe/os/Alpine-Linux.c @@ -57,7 +57,7 @@ os_alpine_setsrc (char *option) chsrc_run ("apk update", RunOpt_No_Last_New_Line); - ProgMode_ChgType = ChgType_Untested; + chsrc_determine_chgtype (ChgType_Untested); chsrc_conclude (&source); } diff --git a/src/recipe/os/BSD/FreeBSD.c b/src/recipe/os/BSD/FreeBSD.c index 0c3b6a9..c154859 100644 --- a/src/recipe/os/BSD/FreeBSD.c +++ b/src/recipe/os/BSD/FreeBSD.c @@ -128,7 +128,7 @@ os_freebsd_setsrc (char *option) chsrc_overwrite_file (update, "/etc/freebsd-update.conf"); */ - ProgMode_ChgType = ChgType_SemiAuto; + chsrc_determine_chgtype (ChgType_SemiAuto); chsrc_conclude (&source); } diff --git a/src/recipe/os/BSD/NetBSD.c b/src/recipe/os/BSD/NetBSD.c index 84e45e4..d464f6b 100644 --- a/src/recipe/os/BSD/NetBSD.c +++ b/src/recipe/os/BSD/NetBSD.c @@ -58,7 +58,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"); - ProgMode_ChgType = ChgType_Untested; + chsrc_determine_chgtype (ChgType_Untested); chsrc_conclude (&source); } diff --git a/src/recipe/os/BSD/OpenBSD.c b/src/recipe/os/BSD/OpenBSD.c index 79faeb5..b05c3b3 100644 --- a/src/recipe/os/BSD/OpenBSD.c +++ b/src/recipe/os/BSD/OpenBSD.c @@ -47,7 +47,7 @@ os_openbsd_setsrc (char *option) chsrc_backup ("/etc/installurl"); chsrc_overwrite_file (source.url, "/etc/installurl"); - ProgMode_ChgType = ChgType_Untested; + chsrc_determine_chgtype (ChgType_Untested); chsrc_conclude (&source); } diff --git a/src/recipe/os/Gentoo-Linux.c b/src/recipe/os/Gentoo-Linux.c index 7c6abef..5ae22e5 100644 --- a/src/recipe/os/Gentoo-Linux.c +++ b/src/recipe/os/Gentoo-Linux.c @@ -46,7 +46,7 @@ os_gentoo_setsrc (char *option) chsrc_append_to_file (w, "/etc/portage/make.conf"); - ProgMode_ChgType = ChgType_Untested; + chsrc_determine_chgtype (ChgType_Untested); chsrc_conclude (&source); } diff --git a/src/recipe/os/OpenWrt.c b/src/recipe/os/OpenWrt.c index f853b4a..ac6e893 100644 --- a/src/recipe/os/OpenWrt.c +++ b/src/recipe/os/OpenWrt.c @@ -62,7 +62,7 @@ os_openwrt_setsrc (char *option) chsrc_run (cmd, RunOpt_No_Last_New_Line); chsrc_run ("opkg update", RunOpt_No_Last_New_Line); - ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto; + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } diff --git a/src/recipe/os/Solus.c b/src/recipe/os/Solus.c index d1aec14..f10de36 100644 --- a/src/recipe/os/Solus.c +++ b/src/recipe/os/Solus.c @@ -33,7 +33,7 @@ os_solus_setsrc (char *option) char *cmd = xy_2strjoin ("eopkg add-repo Solus ", source.url); chsrc_run (cmd, RunOpt_Default); - ProgMode_ChgType = ChgType_Auto; + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } diff --git a/src/recipe/os/Void-Linux.c b/src/recipe/os/Void-Linux.c index cdcdfa4..1482942 100644 --- a/src/recipe/os/Void-Linux.c +++ b/src/recipe/os/Void-Linux.c @@ -59,7 +59,8 @@ os_voidlinux_setsrc (char *option) chsrc_note2 ("若报错可尝试使用以下命令:"); p(cmd); - ProgMode_ChgType = ChgType_Untested; + + chsrc_determine_chgtype (ChgType_Untested); chsrc_conclude (&source); } diff --git a/src/recipe/os/YUM/AlmaLinux.c b/src/recipe/os/YUM/AlmaLinux.c index c6148ed..37d49b0 100644 --- a/src/recipe/os/YUM/AlmaLinux.c +++ b/src/recipe/os/YUM/AlmaLinux.c @@ -44,7 +44,7 @@ os_almalinux_setsrc (char *option) chsrc_run (cmd, RunOpt_Default); chsrc_run ("dnf makecache", RunOpt_No_Last_New_Line); - ProgMode_ChgType = ChgType_Auto; + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } diff --git a/src/recipe/os/YUM/Anolis-OS.c b/src/recipe/os/YUM/Anolis-OS.c index 0c12b62..bed51ed 100644 --- a/src/recipe/os/YUM/Anolis-OS.c +++ b/src/recipe/os/YUM/Anolis-OS.c @@ -37,7 +37,7 @@ os_anolis_setsrc (char *option) chsrc_run ("dnf makecache", RunOpt_Default); chsrc_run ("dnf update", RunOpt_No_Last_New_Line); - ProgMode_ChgType = ChgType_Untested; + chsrc_determine_chgtype (ChgType_Untested); chsrc_conclude (&source); } diff --git a/src/recipe/os/YUM/Fedora-Linux.c b/src/recipe/os/YUM/Fedora-Linux.c index 5a9c9eb..c93459c 100644 --- a/src/recipe/os/YUM/Fedora-Linux.c +++ b/src/recipe/os/YUM/Fedora-Linux.c @@ -72,7 +72,7 @@ os_fedora_setsrc (char *option) chsrc_run ("dnf makecache", RunOpt_No_Last_New_Line); - ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto; + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } diff --git a/src/recipe/os/YUM/Rocky-Linux.c b/src/recipe/os/YUM/Rocky-Linux.c index 8ca433c..57b879f 100644 --- a/src/recipe/os/YUM/Rocky-Linux.c +++ b/src/recipe/os/YUM/Rocky-Linux.c @@ -67,7 +67,7 @@ os_rockylinux_setsrc (char *option) chsrc_run (cmd, RunOpt_Default); chsrc_run ("dnf makecache", RunOpt_No_Last_New_Line); - ProgMode_ChgType = ChgType_Auto; + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } diff --git a/src/recipe/os/YUM/openEuler.c b/src/recipe/os/YUM/openEuler.c index 72c8e1b..03c2e14 100644 --- a/src/recipe/os/YUM/openEuler.c +++ b/src/recipe/os/YUM/openEuler.c @@ -70,7 +70,7 @@ os_openeuler_setsrc (char *option) chsrc_run ("dnf makecache", RunOpt_No_Last_New_Line); - ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto; + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } diff --git a/src/recipe/os/openSUSE.c b/src/recipe/os/openSUSE.c index 8c2cc2b..d97c955 100644 --- a/src/recipe/os/openSUSE.c +++ b/src/recipe/os/openSUSE.c @@ -76,7 +76,7 @@ os_opensuse_setsrc (char *option) chsrc_run (cmd5, RunOpt_Default); chsrc_run (cmd6, RunOpt_Default); - ProgMode_ChgType = ChgType_Untested; + chsrc_determine_chgtype (ChgType_Untested); chsrc_conclude (&source); } diff --git a/src/recipe/os/pacman/Arch-Linux.c b/src/recipe/os/pacman/Arch-Linux.c index 5200ed6..e533053 100644 --- a/src/recipe/os/pacman/Arch-Linux.c +++ b/src/recipe/os/pacman/Arch-Linux.c @@ -92,7 +92,8 @@ os_arch_setsrc (char *option) { chsrc_run ("pacman -Syy", RunOpt_No_Last_New_Line); } - ProgMode_ChgType = ChgType_Auto; + + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } diff --git a/src/recipe/os/pacman/MSYS2.c b/src/recipe/os/pacman/MSYS2.c index 419ec5d..bba2a4a 100644 --- a/src/recipe/os/pacman/MSYS2.c +++ b/src/recipe/os/pacman/MSYS2.c @@ -48,7 +48,7 @@ os_msys2_setsrc (char *option) chsrc_run (cmd, RunOpt_Default); - ProgMode_ChgType = ChgType_Untested; + chsrc_determine_chgtype (ChgType_Untested); chsrc_conclude (&source); } diff --git a/src/recipe/os/pacman/Manjaro-Linux.c b/src/recipe/os/pacman/Manjaro-Linux.c index ea1e2e8..4d42cf8 100644 --- a/src/recipe/os/pacman/Manjaro-Linux.c +++ b/src/recipe/os/pacman/Manjaro-Linux.c @@ -20,7 +20,8 @@ os_manjaro_setsrc (char *option) chsrc_run (cmd, RunOpt_Default); chsrc_run ("pacman -Syy", RunOpt_No_Last_New_Line); - ProgMode_ChgType = ChgType_Auto; + + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (NULL); } diff --git a/src/recipe/ware/Anaconda.c b/src/recipe/ware/Anaconda.c index 440e15f..6eeb43a 100644 --- a/src/recipe/ware/Anaconda.c +++ b/src/recipe/ware/Anaconda.c @@ -74,7 +74,7 @@ wr_anaconda_setsrc (char *option) chsrc_note2 ("然后运行 conda clean -i 清除索引缓存,保证用的是镜像站提供的索引"); - ProgMode_ChgType = ChgType_SemiAuto; + chsrc_determine_chgtype (ChgType_SemiAuto); chsrc_conclude (&source); } diff --git a/src/recipe/ware/CocoaPods.c b/src/recipe/ware/CocoaPods.c index 93fce2c..1ff9ddb 100644 --- a/src/recipe/ware/CocoaPods.c +++ b/src/recipe/ware/CocoaPods.c @@ -38,7 +38,7 @@ wr_cocoapods_setsrc (char *option) char *source_str = xy_strjoin (3, "source '", source.url, "'"); p(source_str); - ProgMode_ChgType = ChgType_Manual; + chsrc_determine_chgtype (ChgType_Manual); chsrc_conclude (&source); } diff --git a/src/recipe/ware/Docker-Hub.c b/src/recipe/ware/Docker-Hub.c index c6781ed..38e5b22 100644 --- a/src/recipe/ware/Docker-Hub.c +++ b/src/recipe/ware/Docker-Hub.c @@ -154,7 +154,7 @@ wr_dockerhub_setsrc (char *option) puts (source.url); } - ProgMode_ChgType = ChgType_Manual; + chsrc_determine_chgtype (ChgType_SemiAuto); chsrc_conclude (&source); } diff --git a/src/recipe/ware/Emacs.c b/src/recipe/ware/Emacs.c index 47de3e3..883b6f5 100644 --- a/src/recipe/ware/Emacs.c +++ b/src/recipe/ware/Emacs.c @@ -38,7 +38,7 @@ wr_emacs_setsrc (char *option) chsrc_note2 ("Emacs换源涉及Elisp,需要手动查阅并换源:"); p(source.url); - ProgMode_ChgType = ChgType_Manual; + chsrc_determine_chgtype (ChgType_Manual); chsrc_conclude (&source); } diff --git a/src/recipe/ware/Flathub.c b/src/recipe/ware/Flathub.c index 1c954aa..3815171 100644 --- a/src/recipe/ware/Flathub.c +++ b/src/recipe/ware/Flathub.c @@ -37,7 +37,7 @@ wr_flathub_setsrc (char *option) char *cmd = xy_2strjoin ("flatpak remote-modify flathub --url=", source.url); chsrc_run (cmd, RunOpt_Default); - ProgMode_ChgType = ChgType_Auto; + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } diff --git a/src/recipe/ware/Guix.c b/src/recipe/ware/Guix.c index 15b92a6..c456a7e 100644 --- a/src/recipe/ware/Guix.c +++ b/src/recipe/ware/Guix.c @@ -34,7 +34,7 @@ wr_guix_setsrc (char *option) chsrc_note2 ("为防止扰乱配置文件,请您手动写入以下内容到 ~/.config/guix/channels.scm 文件中"); p(file); - ProgMode_ChgType = ChgType_Manual; + chsrc_determine_chgtype (ChgType_Manual); chsrc_conclude (&source); } diff --git a/src/recipe/ware/Homebrew.c b/src/recipe/ware/Homebrew.c index 908d421..1864909 100644 --- a/src/recipe/ware/Homebrew.c +++ b/src/recipe/ware/Homebrew.c @@ -81,7 +81,7 @@ wr_homebrew_setsrc (char *option) chsrc_append_to_file (w, fishrc); } - ProgMode_ChgType = ChgType_Auto; + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); chsrc_note2 ("请您重启终端使Homebrew环境变量生效"); } diff --git a/src/recipe/ware/Nix.c b/src/recipe/ware/Nix.c index d666e1f..4afa694 100644 --- a/src/recipe/ware/Nix.c +++ b/src/recipe/ware/Nix.c @@ -56,7 +56,7 @@ wr_nix_setsrc (char *option) chsrc_note2 ("若您使用的是NixOS,请额外添加下述内容至 configuration.nix 中"); p(cmd); - ProgMode_ChgType = ChgType_SemiAuto; + chsrc_determine_chgtype (ChgType_SemiAuto); chsrc_conclude (&source); } diff --git a/src/recipe/ware/TeX-Live.c b/src/recipe/ware/TeX-Live.c index 6112082..8461506 100644 --- a/src/recipe/ware/TeX-Live.c +++ b/src/recipe/ware/TeX-Live.c @@ -78,7 +78,7 @@ wr_tex_setsrc (char *option) chsrc_run (cmd, RunOpt_Default); } - ProgMode_ChgType = ChgType_Untested; + chsrc_determine_chgtype (ChgType_Untested); chsrc_conclude (&source); } diff --git a/src/recipe/ware/WinGet.c b/src/recipe/ware/WinGet.c index e9402b4..18a77b4 100644 --- a/src/recipe/ware/WinGet.c +++ b/src/recipe/ware/WinGet.c @@ -37,7 +37,7 @@ 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); - ProgMode_ChgType = ChgType_Auto; + chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); } @@ -47,7 +47,7 @@ wr_winget_resetsrc (char *option) { chsrc_run ("winget source reset winget", RunOpt_Default); - ProgMode_ChgType = ChgType_Auto; + chsrc_determine_chgtype (ChgType_Reset); chsrc_conclude (NULL); }