diff --git a/src/chsrc-main.c b/src/chsrc-main.c index a3386b6..e5eb9bf 100644 --- a/src/chsrc-main.c +++ b/src/chsrc-main.c @@ -37,8 +37,8 @@ * chsrc: Change Source —— 全平台通用命令行换源工具 * ------------------------------------------------------------*/ -#define Chsrc_Version "0.2.2.2" -#define Chsrc_Release_Date "2025/08/09" +#define Chsrc_Version "0.2.2.3" +#define Chsrc_Release_Date "2025/08/10" #define Chsrc_Maintain_URL "https://github.com/RubyMetric/chsrc" #define Chsrc_Maintain_URL2 "https://gitee.com/RubyMetric/chsrc" @@ -86,6 +86,7 @@ #include "recipe/lang/NuGet.c" #include "recipe/lang/Clojure.c" + #include "recipe/os/rawstr4c.h" #include "recipe/os/APT/common.h" // Debian-based @@ -127,6 +128,21 @@ #include "recipe/os/BSD/NetBSD.c" #include "recipe/os/BSD/OpenBSD.c" + +#include "recipe/ware/TeX-Live.c" +#include "recipe/ware/Emacs.c" +#include "recipe/ware/WinGet.c" +#include "recipe/ware/Homebrew/Homebrew.c" +#include "recipe/ware/CocoaPods.c" +#include "recipe/ware/Nix.c" +#include "recipe/ware/Guix.c" +#include "recipe/ware/Flathub.c" +#include "recipe/ware/Docker-Hub/Docker-Hub.c" +#include "recipe/ware/Anaconda/Anaconda.c" + + +#include "recipe/menu.c" + #include "rawstr4c.h" diff --git a/src/recipe/lang/PHP.c b/src/recipe/lang/PHP.c index 1eb99e9..c0969c3 100644 --- a/src/recipe/lang/PHP.c +++ b/src/recipe/lang/PHP.c @@ -8,7 +8,7 @@ void pl_php_prelude () { use_this(pl_php); - chef_allow_gsr(pl_php); + chef_allow_gs(pl_php); chef_set_created_on (this, "2023-08-30"); chef_set_last_updated (this, "2025-08-10"); diff --git a/src/recipe/lang/Perl.c b/src/recipe/lang/Perl.c index 7558301..722d9f6 100644 --- a/src/recipe/lang/Perl.c +++ b/src/recipe/lang/Perl.c @@ -8,7 +8,7 @@ void pl_perl_prelude () { use_this(pl_perl); - chef_allow_gsr(pl_perl); + chef_allow_gs(pl_perl); chef_set_created_on (this, "2023-09-31"); chef_set_last_updated (this, "2025-08-10"); diff --git a/src/recipe/menu.c b/src/recipe/menu.c index b87d6ad..676d2d9 100644 --- a/src/recipe/menu.c +++ b/src/recipe/menu.c @@ -5,41 +5,43 @@ * Contributors : Mikachu2333 * | * Created On : <2023-09-01> - * Major Revision : 2 - * Last Modified : <2025-08-09> + * Major Revision : 3 + * Last Modified : <2025-08-10> * ------------------------------------------------------------*/ +#define t(o) &o##_target, &o##_prelude + TargetRegisterInfo_t chsrc_pl_menu[] = { - {&pl_ruby_target, NULL, "gem ruby rb rubygem rubygems bundler"}, - {&pl_python_group_target, NULL, "python pypi py"}, - {&pl_python_pip_target, NULL, "pip"}, - {&pl_python_poetry_target, NULL, "poetry"}, - {&pl_python_pdm_target, NULL, "pdm"}, - {&pl_python_rye_target, NULL, "rye"}, - {&pl_python_uv_target, NULL, "uv"}, - {&pl_js_group_target, NULL, "node nodejs"}, - {&pl_js_bun_target, NULL, "bun"}, - {&pl_js_npm_target, NULL, "npm"}, - {&pl_js_yarn_target, NULL, "yarn"}, - {&pl_js_pnpm_target, NULL, "pnpm"}, - {&pl_js_nvm_target, NULL, "nvm"}, - {&pl_perl_target, NULL, "perl cpan"}, - {&pl_php_target, NULL, "php composer"}, - {&pl_lua_target, NULL, "lua luarocks"}, - {&pl_go_target, NULL, "go golang goproxy"}, - {&pl_rust_cargo_target, NULL, "rust cargo crate crates"}, - {&pl_rust_rustup_target, NULL, "rustup"}, - {&pl_java_target, NULL, "java maven mvn gradle"}, - {&pl_clojure_target, NULL, "clojure clojars cloj lein"}, - {&pl_dart_target, NULL, "dart pub"}, - {&pl_dart_flutter_target, NULL, "flutter"}, - {&pl_nuget_target, NULL, "nuget net .net dotnet"}, - {&pl_haskell_target, NULL, "haskell cabal stack hackage"}, - {&pl_ocaml_target, NULL, "ocaml opam"}, - {&pl_r_target, NULL, "cran r"}, - {&pl_julia_target, NULL, "julia"}, + {t(pl_ruby), "gem ruby rb rubygem rubygems bundler"}, + {t(pl_python_group), "python pypi py"}, + {t(pl_python_pip), "pip"}, + {t(pl_python_poetry), "poetry"}, + {t(pl_python_pdm), "pdm"}, + {t(pl_python_rye), "rye"}, + {t(pl_python_uv), "uv"}, + {t(pl_js_group), "node nodejs"}, + {t(pl_js_bun), "bun"}, + {t(pl_js_npm), "npm"}, + {t(pl_js_yarn), "yarn"}, + {t(pl_js_pnpm), "pnpm"}, + {t(pl_js_nvm), "nvm"}, + {t(pl_perl), "perl cpan"}, + {t(pl_php), "php composer"}, + {t(pl_lua), "lua luarocks"}, + {t(pl_go), "go golang goproxy"}, + {t(pl_rust_cargo), "rust cargo crate crates"}, + {t(pl_rust_rustup), "rustup"}, + {t(pl_java), "java maven mvn gradle"}, + {t(pl_clojure), "clojure clojars cloj lein"}, + {t(pl_dart), "dart pub"}, + {t(pl_dart_flutter), "flutter"}, + {t(pl_nuget), "nuget net .net dotnet"}, + {t(pl_haskell), "haskell cabal stack hackage"}, + {t(pl_ocaml), "ocaml opam"}, + {t(pl_r), "cran r"}, + {t(pl_julia), "julia"}, }; @@ -48,53 +50,54 @@ TargetRegisterInfo_t chsrc_os_menu[] = { /* Zorin OS 完全使用 Ubuntu 的换源方法,二者兼容 */ - {&os_ubuntu_target, NULL, "ubuntu zorinos"}, - {&os_linuxmint_target, NULL, "linuxmint"}, - {&os_debian_target, NULL, "debian"}, - {&os_fedora_target, NULL, "fedora"}, - {&os_opensuse_target, NULL, "opensuse opensuse-leap opensuse-tumbleweed"}, - {&os_kali_target, NULL, "kali"}, - {&os_msys2_target, NULL, "msys2 msys"}, - {&os_arch_target, NULL, "arch archlinux"}, - {&os_archlinuxcn_target, NULL, "archlinuxcn archcn"}, - {&os_manjaro_target, NULL, "manjaro"}, - {&os_gentoo_target, NULL, "gentoo"}, - {&os_rockylinux_target, NULL, "rocky rockylinux"}, - {&os_almalinux_target, NULL, "alma almalinux"}, - {&os_alpine_target, NULL, "alpine"}, - {&os_voidlinux_target, NULL, "voidlinux"}, - {&os_solus_target, NULL, "solus"}, - {&os_trisquel_target, NULL, "trisquel"}, - {&os_linuxlite_target, NULL, "linuxlite"}, - {&os_ros_target, NULL, "ros ros2"}, - {&os_raspberrypi_target, NULL, "raspi raspberrypi"}, - {&os_armbian_target, NULL, "armbian"}, - {&os_openwrt_target, NULL, "openwrt opkg LEDE"}, - {&os_termux_target, NULL, "termux"}, - {&os_openkylin_target, NULL, "openkylin"}, - {&os_openeuler_target, NULL, "openeuler"}, - {&os_anolis_target, NULL, "openanolis anolis"}, - {&os_deepin_target, NULL, "deepin"}, - {&os_freebsd_target, NULL, "freebsd"}, - {&os_netbsd_target, NULL, "netbsd"}, - {&os_openbsd_target, NULL, "openbsd"}, + {t(os_ubuntu), "ubuntu zorinos"}, + {t(os_linuxmint), "linuxmint"}, + {t(os_debian), "debian"}, + {t(os_fedora), "fedora"}, + {t(os_opensuse), "opensuse opensuse-leap opensuse-tumbleweed"}, + {t(os_kali), "kali"}, + {t(os_msys2), "msys2 msys"}, + {t(os_arch), "arch archlinux"}, + {t(os_archlinuxcn),"archlinuxcn archcn"}, + {t(os_manjaro), "manjaro"}, + {t(os_gentoo), "gentoo"}, + {t(os_rockylinux), "rocky rockylinux"}, + {t(os_almalinux), "alma almalinux"}, + {t(os_alpine), "alpine"}, + {t(os_voidlinux), "voidlinux"}, + {t(os_solus), "solus"}, + {t(os_trisquel), "trisquel"}, + {t(os_linuxlite), "linuxlite"}, + {t(os_ros), "ros ros2"}, + {t(os_raspberrypi),"raspi raspberrypi"}, + {t(os_armbian), "armbian"}, + {t(os_openwrt), "openwrt opkg LEDE"}, + {t(os_termux), "termux"}, + {t(os_openkylin), "openkylin"}, + {t(os_openeuler), "openeuler"}, + {t(os_anolis), "openanolis anolis"}, + {t(os_deepin), "deepin"}, + {t(os_freebsd), "freebsd"}, + {t(os_netbsd), "netbsd"}, + {t(os_openbsd), "openbsd"}, }; TargetRegisterInfo_t chsrc_wr_menu[] = { - {&wr_winget_target, NULL, "winget"}, - {&wr_homebrew_target, NULL, "brew homebrew"}, - {&wr_cocoapods_target, NULL, "cocoa cocoapods cocoapod"}, - {&wr_dockerhub_target, NULL, "dockerhub docker"}, - {&wr_flathub_target, wr_flathub_prelude, "flathub flatpak"}, - {&wr_nix_target, NULL, "nix"}, - {&wr_guix_target, NULL, "guix"}, - {&wr_emacs_target, NULL, "emacs elpa"}, - {&wr_tex_target, NULL, "latex ctan tex texlive miktex tlmgr mpm"}, - {&wr_anaconda_target, NULL, "conda anaconda"}, + {t(wr_winget), "winget"}, + {t(wr_homebrew), "brew homebrew"}, + {t(wr_cocoapods), "cocoa cocoapods cocoapod"}, + {t(wr_dockerhub), "dockerhub docker"}, + {t(wr_flathub), "flathub flatpak"}, + {t(wr_nix), "nix"}, + {t(wr_guix), "guix"}, + {t(wr_emacs), "emacs elpa"}, + {t(wr_tex), "latex ctan tex texlive miktex tlmgr mpm"}, + {t(wr_anaconda), "conda anaconda"}, }; +#undef t @@ -112,8 +115,6 @@ chsrc_available_mirrors[] = { &Cqupt, &Cqu, &Neosoft, - - /* ------------------------ 商业公司(通用镜像站) ------------------------ */ &Ali, // &Ali_ECS_VPC, &Ali_ECS_classic, &Tencent, // &Tencent_Intra, @@ -125,16 +126,11 @@ chsrc_available_mirrors[] = { &Api7, &Fit2Cloud, &DaoCloud, - - /* ------------------------ 专用镜像站 ------------------------ */ &RubyChina, &EmacsChina, &NpmMirror, &GoProxyIO, &GoProxyCN, &RsProxyCN, &FlutterCN, /* 暂不支持 &NugetOrg */ - - /* ------------------------ chsrc 内部实现 ------------------------ */ /* 不要列出 &UpstreamProvider 和 &UserDefinedProvider */ - }; diff --git a/src/recipe/os/APT/Linux-Mint.c b/src/recipe/os/APT/Linux-Mint.c index 9cfb803..d59bd43 100644 --- a/src/recipe/os/APT/Linux-Mint.c +++ b/src/recipe/os/APT/Linux-Mint.c @@ -8,7 +8,7 @@ void os_linuxmint_prelude () { use_this(os_linuxmint); - chef_allow_gsr(os_linuxmint); + chef_allow_gs(os_linuxmint); chef_set_created_on (this, "2023-09-29"); chef_set_last_updated (this, "2025-08-10"); diff --git a/src/recipe/os/APT/ROS.c b/src/recipe/os/APT/ROS.c index 8e6bfb0..7ca4b97 100644 --- a/src/recipe/os/APT/ROS.c +++ b/src/recipe/os/APT/ROS.c @@ -8,7 +8,7 @@ void os_ros_prelude () { use_this(os_ros); - chef_allow_gsr(os_ros); + chef_allow_gs(os_ros); chef_set_created_on (this, "2023-09-03"); chef_set_last_updated (this, "2025-08-10"); diff --git a/src/recipe/ware/Anaconda/Anaconda.c b/src/recipe/ware/Anaconda/Anaconda.c index 25b6b68..58c8d55 100644 --- a/src/recipe/ware/Anaconda/Anaconda.c +++ b/src/recipe/ware/Anaconda/Anaconda.c @@ -56,8 +56,7 @@ wr_anaconda_getsrc (char *option) void wr_anaconda_setsrc (char *option) { - use_this(wr_anaconda); - Source_t source = chsrc_yield_source_and_confirm (this, option); + use_this_source(wr_anaconda); char *w = xy_str_gsub (RAWSTR_wr_anaconda_condarc, "@1@", source.url); diff --git a/src/recipe/ware/CocoaPods.c b/src/recipe/ware/CocoaPods.c index 25a5cc9..66e5a0f 100644 --- a/src/recipe/ware/CocoaPods.c +++ b/src/recipe/ware/CocoaPods.c @@ -40,8 +40,7 @@ wr_cocoapods_prelude () void wr_cocoapods_setsrc (char *option) { - use_this(wr_cocoapods); - Source_t source = chsrc_yield_source_and_confirm (this, option); + use_this_source(wr_cocoapods); chsrc_note2 ("请手动执行以下命令:"); p("cd ~/.cocoapods/repos"); diff --git a/src/recipe/ware/Docker-Hub/Docker-Hub.c b/src/recipe/ware/Docker-Hub/Docker-Hub.c index 32dc495..1a2a97d 100644 --- a/src/recipe/ware/Docker-Hub/Docker-Hub.c +++ b/src/recipe/ware/Docker-Hub/Docker-Hub.c @@ -74,8 +74,8 @@ void wr_dockerhub_setsrc (char *option) { chsrc_ensure_root (); - use_this(wr_dockerhub); - Source_t source = chsrc_yield_source_and_confirm (this, option); + + use_this_source(wr_dockerhub); if (xy_on_linux || xy_on_bsd) { diff --git a/src/recipe/ware/Emacs.c b/src/recipe/ware/Emacs.c index 3e0c103..ef0ee84 100644 --- a/src/recipe/ware/Emacs.c +++ b/src/recipe/ware/Emacs.c @@ -49,8 +49,7 @@ wr_emacs_prelude () void wr_emacs_setsrc (char *option) { - use_this(wr_emacs); - Source_t source = chsrc_yield_source_and_confirm (this, option); + use_this_source(wr_emacs); chsrc_note2 ("Emacs换源涉及Elisp, 需要手动查阅并换源:"); p (source.url); diff --git a/src/recipe/ware/Flathub.c b/src/recipe/ware/Flathub.c index bae035f..b811e9c 100644 --- a/src/recipe/ware/Flathub.c +++ b/src/recipe/ware/Flathub.c @@ -66,8 +66,7 @@ wr_flathub_getsrc (char *option) void wr_flathub_setsrc (char *option) { - use_this(wr_flathub); - Source_t source = chsrc_yield_source_and_confirm (this, option); + use_this_source(wr_flathub); chsrc_alert2 ("若出现问题,可先调用以下命令:"); char *note = xy_strjoin (3, diff --git a/src/recipe/ware/Guix.c b/src/recipe/ware/Guix.c index b36e945..a54b293 100644 --- a/src/recipe/ware/Guix.c +++ b/src/recipe/ware/Guix.c @@ -39,8 +39,7 @@ wr_guix_prelude () void wr_guix_setsrc (char *option) { - use_this(wr_guix); - Source_t source = chsrc_yield_source_and_confirm (this, option); + use_this_source(wr_guix); char *file = xy_strjoin (3, "(list (channel\n" " (inherit (car %default-channels))\n" diff --git a/src/recipe/ware/Homebrew/Homebrew.c b/src/recipe/ware/Homebrew/Homebrew.c index 8314eb8..99b6197 100644 --- a/src/recipe/ware/Homebrew/Homebrew.c +++ b/src/recipe/ware/Homebrew/Homebrew.c @@ -56,8 +56,7 @@ wr_homebrew_getsrc (char *option) void wr_homebrew_setsrc (char *option) { - use_this(wr_homebrew); - Source_t source = chsrc_yield_source_and_confirm (this, option); + use_this_source(wr_homebrew); char *w = xy_str_gsub (RAWSTR_wr_homebrew_config_in_bash, "@1@", source.url); diff --git a/src/recipe/ware/Nix.c b/src/recipe/ware/Nix.c index bfe2ae2..9b483aa 100644 --- a/src/recipe/ware/Nix.c +++ b/src/recipe/ware/Nix.c @@ -52,8 +52,7 @@ wr_nix_setsrc (char *option) { wr_nix_check_cmd (); - use_this(wr_nix); - Source_t source = chsrc_yield_source_and_confirm (this, option); + use_this_source(wr_nix); char *cmd = xy_strjoin (3, "nix-channel --add ", source.url, "nixpkgs-unstable nixpkgs"); chsrc_run (cmd, RunOpt_Default); diff --git a/src/recipe/ware/TeX-Live.c b/src/recipe/ware/TeX-Live.c index 01ed508..453af56 100644 --- a/src/recipe/ware/TeX-Live.c +++ b/src/recipe/ware/TeX-Live.c @@ -85,8 +85,7 @@ wr_tex_setsrc (char *option) bool tlmgr_exist, mpm_exist; wr_tex_check_cmd (&tlmgr_exist, &mpm_exist); - use_this(wr_tex); - Source_t source = chsrc_yield_source_and_confirm (this, option); + use_this_source(wr_tex); char *cmd = NULL; diff --git a/src/recipe/ware/WinGet.c b/src/recipe/ware/WinGet.c index 70f1f4e..bd8df16 100644 --- a/src/recipe/ware/WinGet.c +++ b/src/recipe/ware/WinGet.c @@ -46,8 +46,7 @@ wr_winget_getsrc (char *option) void wr_winget_setsrc (char *option) { - use_this(wr_winget); - Source_t source = chsrc_yield_source_and_confirm (this, option); + use_this_source(wr_winget); chsrc_run ("winget source remove winget", RunOpt_Default); chsrc_run (xy_strjoin (3, "winget source add winget ", source.url, " --trust-level trusted"), RunOpt_Default);