diff --git a/.gitignore b/.gitignore index 66c4a28..8586f5b 100644 --- a/.gitignore +++ b/.gitignore @@ -22,7 +22,7 @@ *.dll *.out *.exe - +*.res ############################## diff --git a/Makefile b/Makefile index 5f8ab71..1345d17 100755 --- a/Makefile +++ b/Makefile @@ -2,13 +2,13 @@ # -------------------------------------------------------------- # SPDX-License-Identifier: GPL-3.0-or-later # -------------------------------------------------------------- -# Build File : Makefile -# File Authors : Aoran Zeng -# Contributors : Yangmoooo +# Build File : Makefile +# File Authors : 曾奥然 +# Contributors : Yangmoooo # | sanchuanhehe # | # Created On : <2023-08-28> -# Last Modified : <2025-07-22> +# Last Modified : <2025-10-15> # # 请阅读 ./doc/01-开发与构建.md 来使用 # -------------------------------------------------------------- @@ -26,10 +26,12 @@ ifeq ($(shell uname), Darwin) On-macOS = 1 endif -# 只有Windows会定义$(OS)变量 +# 只有 MSYS2 会定义 $(OS) 变量 ifeq ($(OS), Windows_NT) On-Windows = 1 endif +# 注意, 原生 Windows 会定义 $(ComSpec) 变量,且区分大小写 +# 但是 MSYS2 并不会定义 #===================================== @@ -196,6 +198,7 @@ test-cli: $(DevMode-Target-Name) clean: -@rm *.exe 2>/dev/null + -@rm *.res 2>/dev/null -@rm xy 2>/dev/null -@rm fw 2>/dev/null -@rm README.md.bak* 2>/dev/null diff --git a/doc/01-开发与构建.md b/doc/01-开发与构建.md index 27a1422..a2d3b1e 100644 --- a/doc/01-开发与构建.md +++ b/doc/01-开发与构建.md @@ -3,11 +3,11 @@ ! ------------------------------------------------------------- ! Doc Type : Markdown ! Doc Name : 01-开发与构建.md - ! Doc Authors : 曾奥然 - ! Contributors : Nul None + ! Doc Authors : 曾奥然 + ! Contributors : Mikachu2333 ! | ! Created On : <2024-12-27> - ! Last Modified : <2025-08-22> + ! Last Modified : <2025-10-11> ! ---------------------------------------------------------- --> # 开发 chsrc diff --git a/doc/image/chsrc.svg b/doc/image/chsrc.svg new file mode 100644 index 0000000..fc00ba6 --- /dev/null +++ b/doc/image/chsrc.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/justfile b/justfile index 2bacf86..016986d 100644 --- a/justfile +++ b/justfile @@ -2,12 +2,12 @@ # -------------------------------------------------------------- # SPDX-License-Identifier: GPL-3.0-or-later # -------------------------------------------------------------- -# Build File : justfile -# File Authors : Aoran Zeng -# Contributors : Nul None -# | +# Build File : justfile +# File Authors : 曾奥然 +# Contributors : Mikachu2333 +# | # Created On : <2025-06-18> -# Last Modified : <2025-07-21> +# Last Modified : <2025-10-15> # # 该文件主要用于在原生Windows上执行项目的基本任务,而不借助于 # GNU make 以及相应的 MSYS2、Cygwin 环境 @@ -104,9 +104,9 @@ alias c := clean default: build-in-dev-mode build-in-dev-mode: - @echo Starting: Build in DEV mode: '{{CC}}' {{CFLAGS_dev_mode_prompt}} -o {{DevMode-Target-Name}} - @{{CC}} src/chsrc-main.c {{CFLAGS_dev_mode}} -o {{DevMode-Target-Name}} - @echo Finished: Build in DEV mode + @echo Starting: Build in DEV mode: '{{CC}}' {{CFLAGS_dev_mode_prompt}} -o {{DevMode-Target-Name}} + @{{CC}} src/chsrc-main.c {{CFLAGS_dev_mode}} -o {{DevMode-Target-Name}} + @echo Finished: Build in DEV mode build-in-debug-mode: @echo Starting: Build in DEBUG mode: '{{CC}}' {{CFLAGS_debug_mode_prompt}} -o {{DebugMode-Target-Name}} @@ -114,9 +114,17 @@ build-in-debug-mode: @echo Finished: Build in DEBUG mode build-in-release-mode: - @echo Starting: Build in RELEASE mode: '{{CC}}' {{CFLAGS_release_mode_prompt}} -o {{ReleaseMode-Target-Name}} - @{{CC}} src/chsrc-main.c {{CFLAGS_release_mode}} -o {{ReleaseMode-Target-Name}} - @echo Finished: Build in RELEASE mode + @echo Starting: Build in RELEASE mode: '{{CC}}' {{CFLAGS_release_mode_prompt}} -o {{ReleaseMode-Target-Name}} + @{{ if os() == 'windows' { \ + '(if exist chsrc.res del chsrc.res)' + \ + ' & windres src/resource/chsrc.rc -O coff -o chsrc.res' \ + } else { '' } }} + @{{ if os() == 'windows' { \ + CC + ' src/chsrc-main.c chsrc.res ' + CFLAGS_release_mode + ' -o ' + ReleaseMode-Target-Name \ + } else { \ + CC + ' src/chsrc-main.c ' + CFLAGS_release_mode + ' -o ' + ReleaseMode-Target-Name \ + } }} + @echo Finished: Build in RELEASE mode debug: build-in-debug-mode @{{DEBUGGER}} {{DebugMode-Target-Name}} @@ -140,6 +148,7 @@ test-cli: clean: -@{{BIN_rm}} *.exe + -@{{BIN_rm}} *.res -@{{BIN_rm}} xy -@{{BIN_rm}} fw -@{{BIN_rm}} chsrc diff --git a/lib/xy.h b/lib/xy.h index e0289a4..efcaa56 100644 --- a/lib/xy.h +++ b/lib/xy.h @@ -9,7 +9,7 @@ * | BingChunMoLi * | * Created On : <2023-08-28> - * Last Modified : <2025-10-07> + * Last Modified : <2025-10-15> * * * xy: 襄阳、咸阳 @@ -122,15 +122,24 @@ xy = #define assert_str(a, b) assert (xy_streql ((a), (b))) -#define xy_panic(reason) assert(!reason) +#define xy_throw(reason) assert(!reason) -// @flavor Perl, PHP, Raku -#define die xy_panic +/** + * @depreacated 避免消极用语 + * + * @flavor Perl, PHP, Raku + */ +// #define die xy_throw -#define xy_unsupported() xy_panic("Unsuppoted") -#define xy_unimplemented() xy_panic("Unimplemented temporarily") -#define xy_unreached() xy_panic("This code shouldn't be reached") -#define xy_cant_be_null(p) if(!p) xy_panic("This pointer can't be null") +/** + * @depreacated 避免消极用语 + */ +// #define xy_panic xy_throw + +#define xy_unsupported() xy_throw("Unsuppoted") +#define xy_unimplemented() xy_throw("Unimplemented temporarily") +#define xy_unreached() xy_throw("This code shouldn't be reached") +#define xy_cant_be_null(p) if(!p) xy_throw("This pointer can't be null") @@ -164,7 +173,7 @@ static void _xy_println_const_str (const char *str) {printf ("%s\n", str);} bool: _xy_print_bool, \ char *: _xy_print_str, \ const char *: _xy_print_const_str, \ - default: xy_panic("Unsupported type for print()!") \ + default: xy_throw("Unsupported type for print()!") \ )(x) /** @@ -179,7 +188,7 @@ static void _xy_println_const_str (const char *str) {printf ("%s\n", str);} bool: _xy_println_bool, \ char *: _xy_println_str, \ const char *: _xy_println_const_str, \ - default: xy_panic("Unsupported type for println()/say()!") \ + default: xy_throw("Unsupported type for println()/say()!") \ )(x) /* @flavor Raku, Perl */ #define say println @@ -1332,18 +1341,21 @@ xy_detect_os () char buf[256] = {0}; fread (buf, 1, sizeof (buf) - 1, fp); fclose (fp); - if (strstr (buf, "Android")) - { - xy.on_android = true; - return; - } - else if (strstr (buf, "Linux")) + if (strstr (buf, "Linux")) { xy.on_linux = true; return; } } + // @consult https://android.googlesource.com/platform/system/core/+/refs/heads/main/rootdir/init.environ.rc.in + char *android_env = getenv ("ANDROID_ROOT"); + if (xy_str_find (android_env, "/system").found) + { + xy.on_android = true; + return; + } + /* 判断 macOS */ DIR *d = opendir ("/System/Applications"); if (d) @@ -1354,6 +1366,7 @@ xy_detect_os () { xy.on_macos = true; closedir (d); + return; } } @@ -1376,10 +1389,11 @@ xy_detect_os () pclose (fp); if (strstr (buf, "BSD") != NULL) xy.on_bsd = true; + return; } if (!(xy.on_windows || xy.on_linux || xy.on_android || xy.on_macos || xy.on_bsd)) - xy_panic ("Unknown operating system"); + xy_throw ("Unknown operating system"); } @@ -1488,7 +1502,7 @@ xy_seq_at (XySeq_t *seq, int n) { xy_cant_be_null (seq); - if (0 == n) xy_panic ("The index must begin from 1, not 0"); + if (0 == n) xy_throw ("The index must begin from 1, not 0"); if (1 == n) return seq->first_item ? seq->first_item->data : NULL; diff --git a/src/chsrc-main.c b/src/chsrc-main.c index 98318a7..895adeb 100644 --- a/src/chsrc-main.c +++ b/src/chsrc-main.c @@ -30,11 +30,10 @@ * 然的加入,逐渐成长为互相支持的伙伴。 * ------------------------------------------------------------*/ -#define Chsrc_Version "0.2.3" -#define Chsrc_Release_Date "2025/10/06" #define Chsrc_Maintain_URL "https://github.com/RubyMetric/chsrc" #define Chsrc_Maintain_URL2 "https://gitee.com/RubyMetric/chsrc" +#include "framework/version.h" #include "framework/core.c" #include "framework/chef.c" diff --git a/src/framework/chef.c b/src/framework/chef.c index 886fef3..9291ad5 100644 --- a/src/framework/chef.c +++ b/src/framework/chef.c @@ -5,7 +5,7 @@ * File Authors : 曾奥然 * Contributors : BingChunMoLi * Created On : <2025-08-09> - * Last Modified : <2025-08-27> + * Last Modified : <2025-10-27> * * chef DSL: for chefs (recipe makers) to define a target * ------------------------------------------------------------*/ @@ -186,7 +186,7 @@ chef_allow_english (Target_t *target) } void -chef_forbid_english (Target_t *target) +chef_deny_english (Target_t *target) { xy_cant_be_null (target); target->can_english = false; @@ -226,7 +226,7 @@ chef_allow_user_define (Target_t *target) } void -chef_forbid_user_define (Target_t *target) +chef_deny_user_define (Target_t *target) { xy_cant_be_null (target); diff --git a/src/framework/version.h b/src/framework/version.h new file mode 100644 index 0000000..e8f65dc --- /dev/null +++ b/src/framework/version.h @@ -0,0 +1,23 @@ +/** ------------------------------------------------------------ + * SPDX-License-Identifier: GPL-3.0-or-later + * ------------------------------------------------------------- + * File Name : version.h + * File Authors : 曾奥然 + * | Mikachu2333 + * Contributors : Nil Null + * | + * Created On : <2025-10-10> + * Last Modified : + * + * 发布新版本前请修改此文件 + * ------------------------------------------------------------*/ + +#define Chsrc_Version "0.2.3.1-dev1" + +// 以下四个宏仅用于 resource/chsrc.rc +#define Chsrc_Version_Major 0 +#define Chsrc_Version_Minor 2 +#define Chsrc_Version_Patch 3 +#define Chsrc_Version_Pre 1 + +#define Chsrc_Release_Date "2025/10/15" diff --git a/src/recipe/lang/Clojure.c b/src/recipe/lang/Clojure.c index e052f81..aa345c6 100644 --- a/src/recipe/lang/Clojure.c +++ b/src/recipe/lang/Clojure.c @@ -18,7 +18,7 @@ pl_clojure_prelude () chef_set_sauciers (this, 1, "@hezonglun"); chef_allow_local_mode (this, FullyCan, NULL, NULL); - chef_forbid_english(this); + chef_deny_english(this); chef_allow_user_define(this); def_sources_begin() diff --git a/src/recipe/lang/Go.c b/src/recipe/lang/Go.c index 92990ec..e0f93e3 100644 --- a/src/recipe/lang/Go.c +++ b/src/recipe/lang/Go.c @@ -32,7 +32,7 @@ pl_go_prelude () chef_set_sauciers (this, 2, "@czyt", "@techoc"); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); + chef_deny_english(this); chef_allow_user_define(this); diff --git a/src/recipe/lang/Haskell.c b/src/recipe/lang/Haskell.c index 7d742da..38c688e 100644 --- a/src/recipe/lang/Haskell.c +++ b/src/recipe/lang/Haskell.c @@ -18,7 +18,7 @@ pl_haskell_prelude () chef_set_sauciers (this, 1, "@hezonglun"); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); + chef_deny_english(this); chef_allow_user_define(this); def_sources_begin() diff --git a/src/recipe/lang/Java.c b/src/recipe/lang/Java.c index 1bf4a81..29cae8f 100644 --- a/src/recipe/lang/Java.c +++ b/src/recipe/lang/Java.c @@ -18,7 +18,7 @@ pl_java_prelude () chef_set_sauciers (this, 0); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); + chef_deny_english(this); chef_allow_user_define(this); // 阿里巴巴开源镜像站需要修改为此才能测速 diff --git a/src/recipe/lang/Lua.c b/src/recipe/lang/Lua.c index 52b81f3..6abc620 100644 --- a/src/recipe/lang/Lua.c +++ b/src/recipe/lang/Lua.c @@ -25,7 +25,7 @@ pl_lua_prelude () chef_set_sauciers (this, 1, "@hezonglun"); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); + chef_deny_english(this); chef_allow_user_define(this); def_sources_begin() diff --git a/src/recipe/lang/NuGet.c b/src/recipe/lang/NuGet.c index 19b0bea..401fe1e 100644 --- a/src/recipe/lang/NuGet.c +++ b/src/recipe/lang/NuGet.c @@ -18,8 +18,8 @@ pl_nuget_prelude () chef_set_sauciers (this, 0); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); - chef_forbid_user_define(this); + chef_deny_english(this); + chef_deny_user_define(this); def_sources_begin() {&UpstreamProvider, "https://www.nuget.org/api/v3/", DelegateToUpstream}, diff --git a/src/recipe/lang/OCaml.c b/src/recipe/lang/OCaml.c index 7571548..44da4ab 100644 --- a/src/recipe/lang/OCaml.c +++ b/src/recipe/lang/OCaml.c @@ -18,7 +18,7 @@ pl_ocaml_prelude () chef_set_sauciers (this, 1, "@hezonglun"); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); + chef_deny_english(this); chef_allow_user_define(this); def_sources_begin() diff --git a/src/recipe/lang/PHP.c b/src/recipe/lang/PHP.c index 1fdb212..4cdfade 100644 --- a/src/recipe/lang/PHP.c +++ b/src/recipe/lang/PHP.c @@ -18,7 +18,7 @@ pl_php_prelude () chef_set_sauciers (this, 1, "@hezonglun"); chef_allow_local_mode (this, FullyCan, NULL, NULL); - chef_forbid_english(this); + chef_deny_english(this); chef_allow_user_define(this); def_sources_begin() diff --git a/src/recipe/lang/Perl.c b/src/recipe/lang/Perl.c index c5ccff1..691942f 100644 --- a/src/recipe/lang/Perl.c +++ b/src/recipe/lang/Perl.c @@ -18,7 +18,7 @@ pl_perl_prelude () chef_set_sauciers (this, 2, "@hezonglun", "@Mikachu2333"); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english (this); + chef_deny_english (this); chef_allow_user_define (this); def_sources_begin() diff --git a/src/recipe/lang/R.c b/src/recipe/lang/R.c index 6dac62d..9a0a045 100644 --- a/src/recipe/lang/R.c +++ b/src/recipe/lang/R.c @@ -18,7 +18,7 @@ pl_r_prelude () chef_set_sauciers (this, 1, "@hezonglun"); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); + chef_deny_english(this); chef_allow_user_define(this); // 以下注释的,是不含有bioconductor的镜像站,我们在换cran的同时,也直接帮助用户换bioconductor diff --git a/src/recipe/lang/Rust/Cargo.c b/src/recipe/lang/Rust/Cargo.c index 776a702..d4dbbb1 100644 --- a/src/recipe/lang/Rust/Cargo.c +++ b/src/recipe/lang/Rust/Cargo.c @@ -18,7 +18,7 @@ pl_rust_cargo_prelude (void) chef_set_sauciers (this, 1, "@happy-game"); chef_allow_local_mode (this, FullyCan, NULL, NULL); - chef_forbid_english (this); + chef_deny_english (this); chef_allow_user_define (this); @@ -75,7 +75,6 @@ pl_rust_cargo_getsrc (char *option) char *raw_content = xy_file_read (cargo_config_file); char *formatted_content = xy_str_gsub (raw_content, " ", ""); formatted_content = xy_str_gsub (formatted_content, "'", "\""); - free (raw_content); XyStrFindResult_t result_has_mirror = xy_str_find (formatted_content, "replace-with"); if (result_has_mirror.found) @@ -112,7 +111,6 @@ pl_write_rust_config (const char *path, const char *url) char *content = RAWSTR_pl_rust_cargo_config; content = xy_str_gsub (content, "@url@", url); chsrc_overwrite_file (content, path); - free (content); } /** @@ -172,7 +170,6 @@ pl_rust_cargo_setsrc (char *option) char *final_content = xy_str_gsub (raw_content, mirror_url, xy_2strcat ("sparse+", source.url)); chsrc_overwrite_file (final_content, cargo_config_file); - free (final_content); goto finish; } diff --git a/src/recipe/lang/Rust/rustup.c b/src/recipe/lang/Rust/rustup.c index e152d86..d79c73b 100644 --- a/src/recipe/lang/Rust/rustup.c +++ b/src/recipe/lang/Rust/rustup.c @@ -21,7 +21,7 @@ pl_rust_rustup_prelude (void) chef_set_sauciers (this, 2, "@Yangmoooo", "@Mikachu2333"); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english (this); + chef_deny_english (this); chef_allow_user_define(this); def_sources_begin() diff --git a/src/recipe/os/APT/Armbian.c b/src/recipe/os/APT/Armbian.c index ce8e1d2..8fe2194 100644 --- a/src/recipe/os/APT/Armbian.c +++ b/src/recipe/os/APT/Armbian.c @@ -18,8 +18,8 @@ os_armbian_prelude () chef_set_sauciers (this, 2, "@ccmywish", "@Yangmoooo"); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); - chef_forbid_user_define(this); + chef_deny_english(this); + chef_deny_user_define(this); chef_set_note(this, NULL, NULL); diff --git a/src/recipe/os/APT/Debian.c b/src/recipe/os/APT/Debian.c index 44cd22c..f56ebb5 100644 --- a/src/recipe/os/APT/Debian.c +++ b/src/recipe/os/APT/Debian.c @@ -18,8 +18,8 @@ os_debian_prelude () chef_set_sauciers (this, 1, "@Yangmoooo"); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); - chef_forbid_user_define(this); + chef_deny_english(this); + chef_deny_user_define(this); chef_set_note(this, NULL, NULL); diff --git a/src/recipe/os/APT/Kali-Linux.c b/src/recipe/os/APT/Kali-Linux.c index 7b85209..6ac6749 100644 --- a/src/recipe/os/APT/Kali-Linux.c +++ b/src/recipe/os/APT/Kali-Linux.c @@ -18,8 +18,8 @@ os_kali_prelude () chef_set_sauciers (this, 2, "@Yangmoooo", "@happy-game"); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); - chef_forbid_user_define(this); + chef_deny_english(this); + chef_deny_user_define(this); chef_set_note(this, NULL, NULL); diff --git a/src/recipe/os/APT/Linux-Lite.c b/src/recipe/os/APT/Linux-Lite.c index 5b951a6..23ccc0f 100644 --- a/src/recipe/os/APT/Linux-Lite.c +++ b/src/recipe/os/APT/Linux-Lite.c @@ -18,8 +18,8 @@ os_linuxlite_prelude () chef_set_sauciers (this, 1, "@Yangmoooo"); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); - chef_forbid_user_define(this); + chef_deny_english(this); + chef_deny_user_define(this); chef_set_note(this, NULL, NULL); diff --git a/src/recipe/os/APT/Linux-Mint.c b/src/recipe/os/APT/Linux-Mint.c index 36371cf..794a7c4 100644 --- a/src/recipe/os/APT/Linux-Mint.c +++ b/src/recipe/os/APT/Linux-Mint.c @@ -18,8 +18,8 @@ os_linuxmint_prelude () chef_set_sauciers (this, 1, "@happy-game"); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); - chef_forbid_user_define(this); + chef_deny_english(this); + chef_deny_user_define(this); /* @note 实际上镜像站里的内容和Ubuntu的不太一样 */ diff --git a/src/recipe/os/APT/ROS.c b/src/recipe/os/APT/ROS.c index fa38c24..0ccb50d 100644 --- a/src/recipe/os/APT/ROS.c +++ b/src/recipe/os/APT/ROS.c @@ -18,8 +18,8 @@ os_ros_prelude () chef_set_sauciers (this, 2, "@ccmywish", "@zouri"); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); - chef_forbid_user_define(this); + chef_deny_english(this); + chef_deny_user_define(this); chef_set_note(this, "该换源方案中,URL存在拼凑,因此不能手动使用某URL来换源", "In this switching method, URLs are constructed, so manual URL specification is not supported"); diff --git a/src/recipe/os/APT/Raspberry-Pi-OS.c b/src/recipe/os/APT/Raspberry-Pi-OS.c index 182c51a..7b2162f 100644 --- a/src/recipe/os/APT/Raspberry-Pi-OS.c +++ b/src/recipe/os/APT/Raspberry-Pi-OS.c @@ -20,8 +20,8 @@ os_raspberrypi_prelude () chef_set_sauciers (this, 1, "@Yangmoooo"); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); - chef_forbid_user_define(this); + chef_deny_english(this); + chef_deny_user_define(this); chef_set_note(this, NULL, NULL); diff --git a/src/recipe/os/APT/Termux.c b/src/recipe/os/APT/Termux.c index a0b0eee..e696379 100644 --- a/src/recipe/os/APT/Termux.c +++ b/src/recipe/os/APT/Termux.c @@ -18,8 +18,8 @@ os_termux_prelude () chef_set_sauciers (this, 0); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); - chef_forbid_user_define(this); + chef_deny_english(this); + chef_deny_user_define(this); chef_set_note(this, "该 recipe 存在对应的 bootstrapper", "This recipe has a corresponding bootstrapper"); diff --git a/src/recipe/os/APT/Trisquel.c b/src/recipe/os/APT/Trisquel.c index 3ac2e79..7502f57 100644 --- a/src/recipe/os/APT/Trisquel.c +++ b/src/recipe/os/APT/Trisquel.c @@ -20,8 +20,8 @@ os_trisquel_prelude () chef_set_sauciers (this, 0); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); - chef_forbid_user_define(this); + chef_deny_english(this); + chef_deny_user_define(this); chef_set_note(this, NULL, NULL); diff --git a/src/recipe/os/APT/Ubuntu.c b/src/recipe/os/APT/Ubuntu.c index 9c4f8a5..7a5dff5 100644 --- a/src/recipe/os/APT/Ubuntu.c +++ b/src/recipe/os/APT/Ubuntu.c @@ -19,8 +19,8 @@ os_ubuntu_prelude () chef_set_sauciers (this, 1, "@XUANJI233"); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); - chef_forbid_user_define(this); + chef_deny_english(this); + chef_deny_user_define(this); chef_set_note(this, NULL, NULL); diff --git a/src/recipe/os/APT/deepin.c b/src/recipe/os/APT/deepin.c index 8f01ed1..304d100 100644 --- a/src/recipe/os/APT/deepin.c +++ b/src/recipe/os/APT/deepin.c @@ -18,8 +18,8 @@ os_deepin_prelude () chef_set_sauciers (this, 1, "@Yangmoooo"); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); - chef_forbid_user_define(this); + chef_deny_english(this); + chef_deny_user_define(this); chef_set_note(this, NULL, NULL); diff --git a/src/recipe/os/APT/openKylin.c b/src/recipe/os/APT/openKylin.c index 8d6ddd4..39157bb 100644 --- a/src/recipe/os/APT/openKylin.c +++ b/src/recipe/os/APT/openKylin.c @@ -21,8 +21,8 @@ os_openkylin_prelude () chef_set_sauciers (this, 1, "@ccmywish"); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); - chef_forbid_user_define(this); + chef_deny_english(this); + chef_deny_user_define(this); chef_set_note(this, NULL, NULL); diff --git a/src/recipe/os/Alpine-Linux.c b/src/recipe/os/Alpine-Linux.c index f7e98bd..f1d03c3 100644 --- a/src/recipe/os/Alpine-Linux.c +++ b/src/recipe/os/Alpine-Linux.c @@ -19,7 +19,7 @@ os_alpine_prelude () chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_english(this); - chef_forbid_user_define(this); + chef_deny_user_define(this); chef_set_note(this, NULL, NULL); diff --git a/src/recipe/os/BSD/FreeBSD.c b/src/recipe/os/BSD/FreeBSD.c index 05a30e7..6c853e1 100644 --- a/src/recipe/os/BSD/FreeBSD.c +++ b/src/recipe/os/BSD/FreeBSD.c @@ -18,8 +18,8 @@ os_freebsd_prelude () chef_set_sauciers (this, 1, "@hezonglun"); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); - chef_forbid_user_define(this); + chef_deny_english(this); + chef_deny_user_define(this); // 2023-09-24: 以下三个USTC, NJU, Netease 均维护了 freebsd-pkg freebsd-ports diff --git a/src/recipe/os/BSD/NetBSD.c b/src/recipe/os/BSD/NetBSD.c index 9551288..6c4d03d 100644 --- a/src/recipe/os/BSD/NetBSD.c +++ b/src/recipe/os/BSD/NetBSD.c @@ -19,8 +19,8 @@ os_netbsd_prelude () chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); - chef_forbid_user_define(this); + chef_deny_english(this); + chef_deny_user_define(this); def_sources_begin() {&UpstreamProvider, "http://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/", DelegateToUpstream}, diff --git a/src/recipe/os/BSD/OpenBSD.c b/src/recipe/os/BSD/OpenBSD.c index 62acaae..dfc2996 100644 --- a/src/recipe/os/BSD/OpenBSD.c +++ b/src/recipe/os/BSD/OpenBSD.c @@ -18,8 +18,8 @@ os_openbsd_prelude () chef_set_sauciers (this, 1, "@hezonglun"); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); - chef_forbid_user_define(this); + chef_deny_english(this); + chef_deny_user_define(this); def_sources_begin() {&UpstreamProvider, "https://cdn.openbsd.org/pub/OpenBSD/", DelegateToUpstream}, diff --git a/src/recipe/os/Gentoo-Linux.c b/src/recipe/os/Gentoo-Linux.c index 4e25fdb..b13c09f 100644 --- a/src/recipe/os/Gentoo-Linux.c +++ b/src/recipe/os/Gentoo-Linux.c @@ -19,7 +19,7 @@ os_gentoo_prelude () chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_english(this); - chef_forbid_user_define(this); + chef_deny_user_define(this); chef_set_note(this, NULL, NULL); diff --git a/src/recipe/os/Solus.c b/src/recipe/os/Solus.c index 989da7b..feaabc1 100644 --- a/src/recipe/os/Solus.c +++ b/src/recipe/os/Solus.c @@ -19,7 +19,7 @@ os_solus_prelude () chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); + chef_deny_english(this); chef_allow_user_define(this); chef_set_note(this, NULL, NULL); diff --git a/src/recipe/os/Void-Linux.c b/src/recipe/os/Void-Linux.c index ace7dd6..2254df1 100644 --- a/src/recipe/os/Void-Linux.c +++ b/src/recipe/os/Void-Linux.c @@ -18,7 +18,7 @@ os_voidlinux_prelude () chef_set_sauciers (this, 1, "@Yangmoooo"); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); + chef_deny_english(this); chef_set_note(this, NULL, NULL); diff --git a/src/recipe/os/YUM/AlmaLinux.c b/src/recipe/os/YUM/AlmaLinux.c index 2112c3a..0b1d7f5 100644 --- a/src/recipe/os/YUM/AlmaLinux.c +++ b/src/recipe/os/YUM/AlmaLinux.c @@ -18,8 +18,8 @@ os_almalinux_prelude () chef_set_sauciers (this, 1, "@Yangmoooo"); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); - chef_forbid_user_define(this); + chef_deny_english(this); + chef_deny_user_define(this); chef_set_note(this, NULL, NULL); diff --git a/src/recipe/os/YUM/Anolis-OS.c b/src/recipe/os/YUM/Anolis-OS.c index 6761ef7..e56f696 100644 --- a/src/recipe/os/YUM/Anolis-OS.c +++ b/src/recipe/os/YUM/Anolis-OS.c @@ -18,8 +18,8 @@ os_anolis_prelude () chef_set_sauciers (this, 0); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); - chef_forbid_user_define(this); + chef_deny_english(this); + chef_deny_user_define(this); chef_set_note(this, NULL, NULL); diff --git a/src/recipe/os/YUM/Fedora-Linux.c b/src/recipe/os/YUM/Fedora-Linux.c index 9abbed9..e1c7777 100644 --- a/src/recipe/os/YUM/Fedora-Linux.c +++ b/src/recipe/os/YUM/Fedora-Linux.c @@ -18,8 +18,8 @@ os_fedora_prelude () chef_set_sauciers (this, 1, "@ccmywish"); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); - chef_forbid_user_define(this); + chef_deny_english(this); + chef_deny_user_define(this); chef_set_note(this, NULL, NULL); diff --git a/src/recipe/os/YUM/Rocky-Linux.c b/src/recipe/os/YUM/Rocky-Linux.c index db748d7..7bd28be 100644 --- a/src/recipe/os/YUM/Rocky-Linux.c +++ b/src/recipe/os/YUM/Rocky-Linux.c @@ -18,8 +18,8 @@ os_rockylinux_prelude () chef_set_sauciers (this, 1, "@happy-game"); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); - chef_forbid_user_define(this); + chef_deny_english(this); + chef_deny_user_define(this); def_sources_begin() {&UpstreamProvider, "https://dl.rockylinux.org", DelegateToUpstream}, diff --git a/src/recipe/os/YUM/openEuler.c b/src/recipe/os/YUM/openEuler.c index f7a2517..0263d66 100644 --- a/src/recipe/os/YUM/openEuler.c +++ b/src/recipe/os/YUM/openEuler.c @@ -18,8 +18,8 @@ os_openeuler_prelude () chef_set_sauciers (this, 3, "@ccmywish", "@Yangmoooo", "@happy-game"); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); - chef_forbid_user_define(this); + chef_deny_english(this); + chef_deny_user_define(this); chef_set_note(this, NULL, NULL); diff --git a/src/recipe/os/openSUSE.c b/src/recipe/os/openSUSE.c index bb5052f..e26448c 100644 --- a/src/recipe/os/openSUSE.c +++ b/src/recipe/os/openSUSE.c @@ -18,8 +18,8 @@ os_opensuse_prelude () chef_set_sauciers (this, 0); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); - chef_forbid_user_define(this); + chef_deny_english(this); + chef_deny_user_define(this); chef_set_note(this, NULL, NULL); diff --git a/src/recipe/os/pacman/Arch-Linux.c b/src/recipe/os/pacman/Arch-Linux.c index e77760c..cd92a76 100644 --- a/src/recipe/os/pacman/Arch-Linux.c +++ b/src/recipe/os/pacman/Arch-Linux.c @@ -21,8 +21,8 @@ os_arch_prelude () chef_set_sauciers (this, 2, "@happy-game", "@Young-Lord"); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); - chef_forbid_user_define(this); + chef_deny_english(this); + chef_deny_user_define(this); chef_set_note (this, "可额外使用 chsrc set archlinuxcn 来更换 Arch Linux CN Repository 源", @@ -124,8 +124,8 @@ os_archlinuxcn_prelude () chef_set_sauciers (this, 2, "@happy-game", "@Young-Lord"); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); - chef_forbid_user_define(this); + chef_deny_english(this); + chef_deny_user_define(this); chef_set_note (this, "可额外使用 chsrc set arch 来更换 Arch Linux 源", diff --git a/src/recipe/os/pacman/MSYS2.c b/src/recipe/os/pacman/MSYS2.c index e281d5e..6e031d5 100644 --- a/src/recipe/os/pacman/MSYS2.c +++ b/src/recipe/os/pacman/MSYS2.c @@ -18,8 +18,8 @@ os_msys2_prelude () chef_set_sauciers (this, 2, "@ccmywish", "@hezonglun"); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); - chef_forbid_user_define(this); + chef_deny_english(this); + chef_deny_user_define(this); def_sources_begin() {&UpstreamProvider, "https://mirror.msys2.org/", DelegateToUpstream}, diff --git a/src/recipe/os/pacman/Manjaro-Linux.c b/src/recipe/os/pacman/Manjaro-Linux.c index 1859897..620847b 100644 --- a/src/recipe/os/pacman/Manjaro-Linux.c +++ b/src/recipe/os/pacman/Manjaro-Linux.c @@ -17,8 +17,8 @@ os_manjaro_prelude () chef_set_sauciers (this, 0); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); - chef_forbid_user_define(this); + chef_deny_english(this); + chef_deny_user_define(this); def_sources_begin() {&UpstreamProvider, NULL, DelegateToUpstream} diff --git a/src/recipe/recipe-template.c b/src/recipe/recipe-template.c index 8f75e26..442e030 100644 --- a/src/recipe/recipe-template.c +++ b/src/recipe/recipe-template.c @@ -73,10 +73,10 @@ void chef_allow_local_mode (this, PartiallyCan, "具体说明是否支持项目级换源...", "Tell users the local mode support"); // chef_allow_english(this); // 项目是否支持英文 - chef_forbid_english(this); + chef_deny_english(this); // chef_allow_user_define(this); // 是否支持用户自定义镜像源 - chef_forbid_user_define(this); + chef_deny_user_define(this); chef_set_note ("中文备注说明...", "English note..."); diff --git a/src/recipe/ware/Anaconda/Anaconda.c b/src/recipe/ware/Anaconda/Anaconda.c index d265ff1..36a15d1 100644 --- a/src/recipe/ware/Anaconda/Anaconda.c +++ b/src/recipe/ware/Anaconda/Anaconda.c @@ -20,8 +20,8 @@ wr_anaconda_prelude () chef_set_sauciers (this, 2, "@Yangmoooo", "@xyx1926885268"); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); - chef_forbid_user_define(this); + chef_deny_english(this); + chef_deny_user_define(this); def_sources_begin() {&UpstreamProvider, "https://repo.anaconda.com", DelegateToUpstream}, diff --git a/src/recipe/ware/CocoaPods.c b/src/recipe/ware/CocoaPods.c index 88f4f78..58573ab 100644 --- a/src/recipe/ware/CocoaPods.c +++ b/src/recipe/ware/CocoaPods.c @@ -19,7 +19,7 @@ wr_cocoapods_prelude () chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); + chef_deny_english(this); chef_allow_user_define(this); def_sources_begin() diff --git a/src/recipe/ware/Docker/Docker.c b/src/recipe/ware/Docker/Docker.c index 09bba30..dc6784d 100644 --- a/src/recipe/ware/Docker/Docker.c +++ b/src/recipe/ware/Docker/Docker.c @@ -35,7 +35,7 @@ wr_docker_prelude () chef_set_sauciers (this, 0); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); + chef_deny_english(this); chef_allow_user_define(this); def_sources_begin() diff --git a/src/recipe/ware/Emacs.c b/src/recipe/ware/Emacs.c index d0b7e84..9e9ca5b 100644 --- a/src/recipe/ware/Emacs.c +++ b/src/recipe/ware/Emacs.c @@ -25,8 +25,8 @@ wr_emacs_prelude () chef_set_sauciers (this, 0); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); - chef_forbid_user_define(this); + chef_deny_english(this); + chef_deny_user_define(this); chef_set_note (this, "Emacs用户往往只需要一次性换源,只会极少次调用 chsrc,我们只给用户提供文档", "Emacs users typically only need to switch sources once and rarely call chsrc, so we only provide documentation to users"); diff --git a/src/recipe/ware/Flatpak.c b/src/recipe/ware/Flatpak.c index 0163298..902a66f 100644 --- a/src/recipe/ware/Flatpak.c +++ b/src/recipe/ware/Flatpak.c @@ -18,7 +18,7 @@ wr_flatpak_prelude () chef_set_sauciers (this, 1, "@jialinlvcn"); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); + chef_deny_english(this); chef_allow_user_define(this); chef_set_note (this, "对Flathub目标进行测速的文件非常小,测速效果严重失真,若你知道可供测速的URL,欢迎参与贡献: chsrc issue", diff --git a/src/recipe/ware/Guix.c b/src/recipe/ware/Guix.c index a31483a..2546530 100644 --- a/src/recipe/ware/Guix.c +++ b/src/recipe/ware/Guix.c @@ -18,8 +18,8 @@ wr_guix_prelude () chef_set_sauciers (this, 0); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); - chef_forbid_user_define(this); + chef_deny_english(this); + chef_deny_user_define(this); chef_set_note (this, "目前只有一个源, guixcn 的源不知道是否可用", "Currently only one source available, guixcn source availability unknown"); diff --git a/src/recipe/ware/Homebrew/Homebrew.c b/src/recipe/ware/Homebrew/Homebrew.c index 286fdb5..99bcc4d 100644 --- a/src/recipe/ware/Homebrew/Homebrew.c +++ b/src/recipe/ware/Homebrew/Homebrew.c @@ -21,7 +21,7 @@ wr_homebrew_prelude () chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_english(this); - chef_forbid_user_define(this); + chef_deny_user_define(this); chef_set_note (this, "该换源通过写入环境变量实现,若多次换源,请手动清理profile文件", "This source switching is implemented by writing environment variables. If switching sources multiple times, please manually clean the profile file"); diff --git a/src/recipe/ware/Nix.c b/src/recipe/ware/Nix.c index b39379c..8656f5d 100644 --- a/src/recipe/ware/Nix.c +++ b/src/recipe/ware/Nix.c @@ -18,8 +18,8 @@ wr_nix_prelude () chef_set_sauciers (this, 0); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); - chef_forbid_user_define(this); + chef_deny_english(this); + chef_deny_user_define(this); def_sources_begin() {&UpstreamProvider, "https://channels.nixos.org/", DelegateToUpstream}, diff --git a/src/recipe/ware/TeX-Live.c b/src/recipe/ware/TeX-Live.c index b267159..c590b6b 100644 --- a/src/recipe/ware/TeX-Live.c +++ b/src/recipe/ware/TeX-Live.c @@ -20,7 +20,7 @@ wr_tex_prelude () chef_set_sauciers (this, 1, "@Mikachu2333"); chef_allow_local_mode (this, CanNot, NULL, NULL); - chef_forbid_english(this); + chef_deny_english(this); chef_allow_user_define(this); def_sources_begin() diff --git a/src/recipe/ware/WinGet.c b/src/recipe/ware/WinGet.c index a05f2a8..a843b0c 100644 --- a/src/recipe/ware/WinGet.c +++ b/src/recipe/ware/WinGet.c @@ -17,7 +17,7 @@ wr_winget_prelude () chef_set_cooks (this, 1, "@ccmywish"); chef_set_sauciers (this, 1, "@Mikachu2333"); - chef_forbid_english(this); + chef_deny_english(this); chef_allow_user_define(this); def_sources_begin() diff --git a/src/resource/chsrc.rc b/src/resource/chsrc.rc new file mode 100644 index 0000000..9deb8ac --- /dev/null +++ b/src/resource/chsrc.rc @@ -0,0 +1,48 @@ +// chsrc.rc - Windows Resource Script +// SPDX-License-Identifier: GPL-3.0-or-later + +#include +#include "../framework/version.h" + +// 图标资源 +IDI_ICON1 ICON DISCARDABLE "logo.ico" + +// 版本信息 +VS_VERSION_INFO VERSIONINFO + FILEVERSION Chsrc_Version_Major,Chsrc_Version_Minor,Chsrc_Version_Patch,Chsrc_Version_Pre + // 经实验,该值会被下面的 ProductVersion 替换 + // PRODUCTVERSION Chsrc_Version_Major,Chsrc_Version_Minor,Chsrc_Version_Patch,Chsrc_Version_Pre + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE VFT2_UNKNOWN +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "RubyMetric" + VALUE "FileDescription", "Change Source everywhere for every software" + + // 经实验,该值会被上面的 FILEVERSION 替换 + // VALUE "FileVersion", Chsrc_Version + + VALUE "InternalName", "chsrc" + VALUE "LegalCopyright", "Copyright (c) 2023-2025 RubyMetric" + VALUE "OriginalFilename", "chsrc.exe" + VALUE "ProductName", "chsrc" + VALUE "ProductVersion", Chsrc_Version + VALUE "Comments", "Released on " Chsrc_Release_Date " (GPLv3+)" + VALUE "LegalTrademarks", "RubyMetric" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0804, 1200, 0x0409, 1200 // 简体中文和英语 + END +END diff --git a/src/resource/logo.ico b/src/resource/logo.ico new file mode 100644 index 0000000..44c0dc6 Binary files /dev/null and b/src/resource/logo.ico differ