Compare commits

..

No commits in common. "main" and "v0.2.3" have entirely different histories.
main ... v0.2.3

100 changed files with 453 additions and 821 deletions

4
.github/READIT.md vendored
View File

@ -3,8 +3,8 @@
! ------------------------------------------------------------- ! -------------------------------------------------------------
! Doc Type : Markdown ! Doc Type : Markdown
! Doc Name : (Overview .github) READIT.md ! Doc Name : (Overview .github) READIT.md
! Doc Authors : 曾奥然 <ccmywish@qq.com> ! Doc Authors : Aoran Zeng <ccmywish@qq.com>
! Contributors : Nul None <nul@none.org> ! Contributors : Nul None <nul@none.org>
! | ! |
! Created On : <2025-06-20> ! Created On : <2025-06-20>
! Last Modified : <2025-06-20> ! Last Modified : <2025-06-20>

View File

@ -49,10 +49,10 @@ jobs:
echo "Event 名: ${{ github.event_name }}" echo "Event 名: ${{ github.event_name }}"
# 2025-10-06 移除点赞的步骤 # 2025-10-06 移除点赞的步骤
# 因原 peter-evans/create-or-update-comment@v5 已不再支持空body而如果使用 Github Token 之类又过于大材小用因此移除 # 因原 peter-evans/create-or-update-comment@v4 已不再支持空body而如果使用 Github Token 之类又过于大材小用因此移除
- name: 添加评论欢迎 PRer - name: 添加评论欢迎 PRer
uses: peter-evans/create-or-update-comment@v5 uses: peter-evans/create-or-update-comment@v4
with: with:
issue-number: ${{ github.event.pull_request.number }} issue-number: ${{ github.event.pull_request.number }}
body: | body: |

View File

@ -34,7 +34,7 @@ jobs:
steps: steps:
- name: 检出代码 - name: 检出代码
uses: actions/checkout@v6 uses: actions/checkout@v5
- name: 测试构建情况 - name: 测试构建情况
run: | run: |
@ -51,7 +51,7 @@ jobs:
steps: steps:
- name: 检出代码 - name: 检出代码
uses: actions/checkout@v6 uses: actions/checkout@v5
- name: 创建测试文件 - name: 创建测试文件
shell: powershell shell: powershell

View File

@ -20,7 +20,7 @@ jobs:
steps: steps:
- name: 检出代码 - name: 检出代码
uses: actions/checkout@v6 uses: actions/checkout@v5
- name: 构建 - name: 构建
run: | run: |

View File

@ -24,7 +24,7 @@ jobs:
steps: steps:
- name: 检出代码 - name: 检出代码
uses: actions/checkout@v6 uses: actions/checkout@v5
- name: 安装 GCC - name: 安装 GCC
uses: msys2/setup-msys2@v2 uses: msys2/setup-msys2@v2

View File

@ -4,7 +4,7 @@
# Contributors : Nul None <nul@none.org> # Contributors : Nul None <nul@none.org>
# | # |
# Created On : <2023-09-15> # Created On : <2023-09-15>
# Last Modified : <2025-12-18> # Last Modified : <2025-09-12>
# #
# Build chsrc on macOS and upload it to GitHub: the 'pre' release # Build chsrc on macOS and upload it to GitHub: the 'pre' release
# --------------------------------------------------------------- # ---------------------------------------------------------------
@ -20,7 +20,7 @@ jobs:
steps: steps:
- name: 检出代码 - name: 检出代码
uses: actions/checkout@v6 uses: actions/checkout@v5
- name: 检查编译器版本 - name: 检查编译器版本
run: | run: |
@ -48,13 +48,11 @@ jobs:
on-x64: on-x64:
# macos-13 是 x64macos-14 是 AArch64(ARMv8-A) runs-on: macos-13 # macos-14 is AArch64(ARMv8-A)
# 但是 macos-13 已经于 2025-12-04 下线
runs-on: macos-15-intel
steps: steps:
- name: 检出代码 - name: 检出代码
uses: actions/checkout@v6 uses: actions/checkout@v5
- name: 检查编译器版本 - name: 检查编译器版本
run: | run: |

View File

@ -4,7 +4,7 @@
# Contributors : 曾奥然 <ccmywish@qq.com> # Contributors : 曾奥然 <ccmywish@qq.com>
# | # |
# Created On : <2025-06-10> # Created On : <2025-06-10>
# Last Modified : <2025-10-29> # Last Modified : <2025-06-16>
# #
# Build and publish deb packages # Build and publish deb packages
# --------------------------------------------------------------- # ---------------------------------------------------------------
@ -30,7 +30,7 @@ jobs:
steps: steps:
- name: 检出代码 - name: 检出代码
uses: actions/checkout@v6 uses: actions/checkout@v5
with: with:
ref: gh-build ref: gh-build
@ -44,7 +44,7 @@ jobs:
elif [ "${{ github.event_name }}" = "push" ];then elif [ "${{ github.event_name }}" = "push" ];then
# 从源代码中提取版本号 # 从源代码中提取版本号
version=$(sed -E -n 's/^#define Chsrc_Version +"([0-9]+\.[0-9]+\.[0-9]+).*"/\1/p' ./src/framework/version.h) version=$(sed -E -n 's/^#define Chsrc_Version +"([0-9]+\.[0-9]+\.[0-9]+).*"/\1/p' ./src/chsrc-main.c)
else else
version="${{ github.event.inputs.version }}" version="${{ github.event.inputs.version }}"
@ -73,7 +73,7 @@ jobs:
* Release version $version * Release version $version
-- 曾奥然 <ccmywish@qq.com> $(date -R) -- Aoran Zeng <ccmywish@qq.com> $(date -R)
EOF EOF
@ -121,7 +121,7 @@ jobs:
bash pkg/deb/deb-installation-test.sh bash pkg/deb/deb-installation-test.sh
- name: 上传deb包到artifacts - name: 上传deb包到artifacts
uses: actions/upload-artifact@v6 uses: actions/upload-artifact@v4
with: with:
name: chsrc-deb-files name: chsrc-deb-files
path: dist/chsrc_*.deb path: dist/chsrc_*.deb
@ -154,7 +154,7 @@ jobs:
steps: steps:
- name: Download all artifacts - name: Download all artifacts
uses: actions/download-artifact@v7 uses: actions/download-artifact@v5
with: with:
pattern: chsrc-deb-files pattern: chsrc-deb-files
merge-multiple: true merge-multiple: true
@ -172,7 +172,7 @@ jobs:
dpkg-scanpackages . /dev/null > Packages dpkg-scanpackages . /dev/null > Packages
- name: Upload repository metadata - name: Upload repository metadata
uses: actions/upload-artifact@v6 uses: actions/upload-artifact@v4
with: with:
name: debian-repository-metadata name: debian-repository-metadata
path: debs/Packages* path: debs/Packages*

2
.gitignore vendored
View File

@ -22,7 +22,7 @@
*.dll *.dll
*.out *.out
*.exe *.exe
*.res
############################## ##############################

4
.vscode/README.md vendored
View File

@ -3,8 +3,8 @@
! ------------------------------------------------------------- ! -------------------------------------------------------------
! Doc Type : Markdown ! Doc Type : Markdown
! Doc Name : (for VS Code users) README.md ! Doc Name : (for VS Code users) README.md
! Doc Authors : 曾奥然 <ccmywish@qq.com> ! Doc Authors : Aoran Zeng <ccmywish@qq.com>
! Contributors : Nul None <nul@none.org> ! Contributors : Nul None <nul@none.org>
! | ! |
! Created On : <2025-06-18> ! Created On : <2025-06-18>
! Last Modified : <2025-06-20> ! Last Modified : <2025-06-20>

View File

@ -2,13 +2,13 @@
# -------------------------------------------------------------- # --------------------------------------------------------------
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
# -------------------------------------------------------------- # --------------------------------------------------------------
# Build File : Makefile # Build File : Makefile
# File Authors : 曾奥然 <ccmywish@qq.com> # File Authors : Aoran Zeng <ccmywish@qq.com>
# Contributors : Yangmoooo <yangmoooo@outlook.com> # Contributors : Yangmoooo <yangmoooo@outlook.com>
# | sanchuanhehe <wyihe5520@gmail.com> # | sanchuanhehe <wyihe5520@gmail.com>
# | # |
# Created On : <2023-08-28> # Created On : <2023-08-28>
# Last Modified : <2025-10-15> # Last Modified : <2025-07-22>
# #
# 请阅读 ./doc/01-开发与构建.md 来使用 # 请阅读 ./doc/01-开发与构建.md 来使用
# -------------------------------------------------------------- # --------------------------------------------------------------
@ -26,12 +26,10 @@ ifeq ($(shell uname), Darwin)
On-macOS = 1 On-macOS = 1
endif endif
# 只有 MSYS2 会定义 $(OS) 变量 # 只有Windows会定义$(OS)变量
ifeq ($(OS), Windows_NT) ifeq ($(OS), Windows_NT)
On-Windows = 1 On-Windows = 1
endif endif
# 注意, 原生 Windows 会定义 $(ComSpec) 变量,且区分大小写
# 但是 MSYS2 并不会定义
#===================================== #=====================================
@ -198,7 +196,6 @@ test-cli: $(DevMode-Target-Name)
clean: clean:
-@rm *.exe 2>/dev/null -@rm *.exe 2>/dev/null
-@rm *.res 2>/dev/null
-@rm xy 2>/dev/null -@rm xy 2>/dev/null
-@rm fw 2>/dev/null -@rm fw 2>/dev/null
-@rm README.md.bak* 2>/dev/null -@rm README.md.bak* 2>/dev/null

View File

@ -3,8 +3,8 @@
! ------------------------------------------------------------- ! -------------------------------------------------------------
! Doc Type : Markdown ! Doc Type : Markdown
! Doc Name : (chsrc-bootstrap Introduction.md) ! Doc Name : (chsrc-bootstrap Introduction.md)
! Doc Authors : 曾奥然 <ccmywish@qq.com> ! Doc Authors : Aoran Zeng <ccmywish@qq.com>
! Contributors : Nul None <nul@none.org> ! Contributors : Nul None <nul@none.org>
! | ! |
! Created On : <2025-07-12> ! Created On : <2025-07-12>
! Last Modified : <2025-07-22> ! Last Modified : <2025-07-22>

View File

@ -3,11 +3,11 @@
! ------------------------------------------------------------- ! -------------------------------------------------------------
! Doc Type : Markdown ! Doc Type : Markdown
! Doc Name : 01-开发与构建.md ! Doc Name : 01-开发与构建.md
! Doc Authors : 曾奥然 <ccmywish@qq.com> ! Doc Authors : 曾奥然 <ccmywish@qq.com>
! Contributors : Mikachu2333 <mikachu.23333@zohomail.com> ! Contributors : Nul None <nul@none.org>
! | ! |
! Created On : <2024-12-27> ! Created On : <2024-12-27>
! Last Modified : <2025-10-11> ! Last Modified : <2025-08-22>
! ---------------------------------------------------------- --> ! ---------------------------------------------------------- -->
# 开发 chsrc # 开发 chsrc

View File

@ -7,7 +7,7 @@
! Contributors : Nul None <nul@none.org> ! Contributors : Nul None <nul@none.org>
! | ! |
! Created On : <2024-08-19> ! Created On : <2024-08-19>
! Last Modified : <2025-10-28> ! Last Modified : <2025-08-22>
! ---------------------------------------------------------- --> ! ---------------------------------------------------------- -->
# Write A Recipe Even If You Don't Know C # Write A Recipe Even If You Don't Know C
@ -89,8 +89,7 @@
1. `framework/core.c` 中以 `chsrc_` 开头的所有函数或宏 1. `framework/core.c` 中以 `chsrc_` 开头的所有函数或宏
2. `xy.h` 中以 `xy_` 开头的所有函数或宏 2. `xy.h` 中以 `xy_` 开头的所有函数或宏
3. `chec.c` 中以 `chef_` 开头的所有函数或宏 3. `chec.c` `chef-helper.c` 中以 `chef_` 开头的所有函数或宏
4. `helper.c` 中以 `hp_` 开头的所有函数或宏
一个简单的方法是,在 VS Code 中按快捷键 `Ctrl-T` 搜索上述三种前缀 一个简单的方法是,在 VS Code 中按快捷键 `Ctrl-T` 搜索上述三种前缀

View File

@ -2,14 +2,14 @@
.\" SPDX-License-Identifier: GFDL-1.3-or-later .\" SPDX-License-Identifier: GFDL-1.3-or-later
.\" -------------------------------------------------------------- .\" --------------------------------------------------------------
.\" Doc Type : Man Page .\" Doc Type : Man Page
.\" Doc Authors : 曾奥然 <ccmywish@qq.com> .\" Doc Authors : Aoran Zeng <ccmywish@qq.com>
.\" Contributors : Nul None <nul@none.org> .\" Contributors : Nul None <nul@none.org>
.\" | .\" |
.\" Created On : <2024-08-21> .\" Created On : <2024-08-21>
.\" Last Modified : <2025-10-29> .\" Last Modified : <2025-08-11>
.\" ---------------------------------------------------------------- .\" --------------------------------------------------------------
.TH chsrc 1 "2025-10-29" "v0.2.3.1" "RubyMetric chsrc" .TH chsrc 1 "2025-08-11" "v0.2.2.3" "RubyMetric chsrc"
.SH NAME .SH NAME
chsrc - Change Source for every software on every platform from the command line chsrc - Change Source for every software on every platform from the command line

View File

@ -2,29 +2,29 @@
@c SPDX-License-Identifier: GFDL-1.3-or-later @c SPDX-License-Identifier: GFDL-1.3-or-later
@c -------------------------------------------------------------- @c --------------------------------------------------------------
@c Doc Type : Texinfo @c Doc Type : Texinfo
@c Doc Authors : 曾奥然 <ccmywish@qq.com> @c Doc Authors : Aoran Zeng <ccmywish@qq.com>
@c Contributors : Nul None <nul@none.org> @c Contributors : Nul None <nul@none.org>
@c | @c |
@c Created On : <2024-08-22> @c Created On : <2024-08-22>
@c Last Modified : <2025-10-29> @c Last Modified : <2025-08-11>
@c -------------------------------------------------------------- @c --------------------------------------------------------------
\input texinfo \input texinfo
@setfilename chsrc.info @setfilename chsrc.info
@settitle chsrc @settitle chsrc
@set Chsrc_Version v0.2.3.1 @set Chsrc_Version v0.2.2.3
@set Doc_Publish_Date 2025-10-29 @set Doc_Publish_Date 2025-08-11
@copying @copying
@comment 这是软件copyright不是文档copyright因此不放在titlepage @comment 这是软件copyright不是文档copyright因此不放在titlepage
Copyright @copyright{} 2025 曾奥然, 郭恒 Copyright @copyright{} 2025 Aoran Zeng, Heng Guo
@end copying @end copying
@titlepage @titlepage
@title chsrc printed manual @title chsrc printed manual
@subtitle Change Source everywhere for every software! @subtitle Change Source everywhere for every software!
@author 曾奥然 @author Aoran Zeng
@c @insertcopying @c @insertcopying
For chsrc @value{Chsrc_Version} For chsrc @value{Chsrc_Version}
@page @page

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 500 500" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<g>
<path d="M13.392,207.176L130.909,79.868L369.203,79.868L486.608,207.055L486.608,210.821L255.801,459.814L244.311,459.814L13.392,210.7L13.392,207.176ZM250.056,118.434C186.007,118.434 134.008,170.433 134.008,234.482C134.008,298.53 186.007,350.53 250.056,350.53C314.104,350.53 366.104,298.53 366.104,234.482C366.104,170.433 314.104,118.434 250.056,118.434Z" style="fill:#a52019;"/>
<path d="M189.09,222.379C183.346,222.379 178.683,217.716 178.683,211.972C178.683,209.1 179.849,206.498 181.733,204.614L204.205,182.142C204.253,182.092 204.302,182.042 204.351,181.993C208.413,177.931 215.007,177.931 219.069,181.993C223.131,186.055 223.131,192.649 219.069,196.711C219.02,196.76 218.97,196.808 218.921,196.856L214.212,201.565L312.183,201.565C317.927,201.565 322.59,206.228 322.59,211.972C322.59,217.716 317.927,222.379 312.183,222.379L189.09,222.379Z" style="fill:#a52019;"/>
<path d="M311.547,245.378C317.29,245.378 321.954,250.042 321.954,255.785C321.954,258.657 320.788,261.259 318.904,263.143L296.431,285.616C296.383,285.665 296.335,285.715 296.286,285.764C292.224,289.826 285.629,289.826 281.568,285.764C277.506,281.703 277.506,275.108 281.568,271.046C281.617,270.997 281.666,270.949 281.716,270.901L286.424,266.193L188.453,266.193C182.71,266.193 178.046,261.529 178.046,255.785C178.046,250.042 182.71,245.378 188.453,245.378L311.547,245.378Z" style="fill:#a52019;"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -2,12 +2,12 @@
# -------------------------------------------------------------- # --------------------------------------------------------------
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
# -------------------------------------------------------------- # --------------------------------------------------------------
# Build File : justfile # Build File : justfile
# File Authors : 曾奥然 <ccmywish@qq.com> # File Authors : Aoran Zeng <ccmywish@qq.com>
# Contributors : Mikachu2333 <mikachu.23333@zohomail.com> # Contributors : Nul None <nul@none.org>
# | # |
# Created On : <2025-06-18> # Created On : <2025-06-18>
# Last Modified : <2025-10-15> # Last Modified : <2025-07-21>
# #
# 该文件主要用于在原生Windows上执行项目的基本任务而不借助于 # 该文件主要用于在原生Windows上执行项目的基本任务而不借助于
# GNU make 以及相应的 MSYS2、Cygwin 环境 # GNU make 以及相应的 MSYS2、Cygwin 环境
@ -104,9 +104,9 @@ alias c := clean
default: build-in-dev-mode default: build-in-dev-mode
build-in-dev-mode: build-in-dev-mode:
@echo Starting: Build in DEV mode: '{{CC}}' {{CFLAGS_dev_mode_prompt}} -o {{DevMode-Target-Name}} @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}} @{{CC}} src/chsrc-main.c {{CFLAGS_dev_mode}} -o {{DevMode-Target-Name}}
@echo Finished: Build in DEV mode @echo Finished: Build in DEV mode
build-in-debug-mode: build-in-debug-mode:
@echo Starting: Build in DEBUG mode: '{{CC}}' {{CFLAGS_debug_mode_prompt}} -o {{DebugMode-Target-Name}} @echo Starting: Build in DEBUG mode: '{{CC}}' {{CFLAGS_debug_mode_prompt}} -o {{DebugMode-Target-Name}}
@ -114,17 +114,9 @@ build-in-debug-mode:
@echo Finished: Build in DEBUG mode @echo Finished: Build in DEBUG mode
build-in-release-mode: build-in-release-mode:
@echo Starting: Build in RELEASE mode: '{{CC}}' {{CFLAGS_release_mode_prompt}} -o {{ReleaseMode-Target-Name}} @echo Starting: Build in RELEASE mode: '{{CC}}' {{CFLAGS_release_mode_prompt}} -o {{ReleaseMode-Target-Name}}
@{{ if os() == 'windows' { \ @{{CC}} src/chsrc-main.c {{CFLAGS_release_mode}} -o {{ReleaseMode-Target-Name}}
'(if exist chsrc.res del chsrc.res)' + \ @echo Finished: Build in RELEASE mode
' & 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 debug: build-in-debug-mode
@{{DEBUGGER}} {{DebugMode-Target-Name}} @{{DEBUGGER}} {{DebugMode-Target-Name}}
@ -148,7 +140,6 @@ test-cli:
clean: clean:
-@{{BIN_rm}} *.exe -@{{BIN_rm}} *.exe
-@{{BIN_rm}} *.res
-@{{BIN_rm}} xy -@{{BIN_rm}} xy
-@{{BIN_rm}} fw -@{{BIN_rm}} fw
-@{{BIN_rm}} chsrc -@{{BIN_rm}} chsrc

View File

@ -1,53 +0,0 @@
# ---------------------------------------------------------------
# Lefthook File : lefthook.yml
# File Authors : 曾奥然 <ccmywish@qq.com>
# Contributors : Nul None <nul@none.org>
# |
# Created On : <2025-10-28>
# Last Modified : <2025-10-30>
# ---------------------------------------------------------------
min_version: 2.0.1
pre-commit:
only:
- ref: dev
parallel: false
jobs:
- name: 试运行 DEBUG mode
# 触发所有 _prelude() 函数检查
run: |
just build-in-debug-mode
./chsrc-debug get pip
glob: "*.{c,h}"
exclude: test/*
- name: 测试 xy.h
run: just test-xy
glob:
- lib/xy.h
- test/xy.c
- name: 测试 framework
run: just test-fw
glob:
- "src/framework/*.{c,h}"
- src/chsrc-main.c
- test/fw.c
post-merge:
only:
- ref: main
jobs:
- name: 测试编译 DEV mode
run: just build-in-dev-mode
pre-push:
only:
- ref: gh-build
jobs:
- name: 测试编译 RELEASE mode
run: just build-in-release-mode
- name: 测试运行
run: just test-cli

279
lib/xy.h
View File

@ -9,7 +9,7 @@
* | BingChunMoLi <bingchunmoli@bingchunmoli.com> * | BingChunMoLi <bingchunmoli@bingchunmoli.com>
* | * |
* Created On : <2023-08-28> * Created On : <2023-08-28>
* Last Modified : <2025-12-31> * Last Modified : <2025-10-06>
* *
* *
* xy: * xy:
@ -23,7 +23,7 @@
#ifndef XY_H #ifndef XY_H
#define XY_H #define XY_H
#define _XY_Version "v0.2.2.0-2025/10/28" #define _XY_Version "v0.2.1.0-2025/10/06"
#define _XY_Maintain_URL "https://github.com/RubyMetric/chsrc/blob/dev/lib/xy.h" #define _XY_Maintain_URL "https://github.com/RubyMetric/chsrc/blob/dev/lib/xy.h"
#define _XY_Maintain_URL2 "https://gitee.com/RubyMetric/chsrc/blob/dev/lib/xy.h" #define _XY_Maintain_URL2 "https://gitee.com/RubyMetric/chsrc/blob/dev/lib/xy.h"
@ -72,8 +72,6 @@ struct
bool on_bsd; bool on_bsd;
bool on_android; bool on_android;
/* @flavor 同 just 中的 os_family(),只区分 windows, unix */
char *os_family;
char *os_devnull; char *os_devnull;
} }
xy = xy =
@ -90,7 +88,6 @@ xy =
.on_bsd = false, .on_bsd = false,
.on_android = false, .on_android = false,
.os_family = NULL,
.os_devnull = NULL .os_devnull = NULL
}; };
@ -125,31 +122,17 @@ xy =
#define assert_str(a, b) assert (xy_streql ((a), (b))) #define assert_str(a, b) assert (xy_streql ((a), (b)))
#define xy_throw(reason) assert(!reason) #define xy_panic(reason) assert(!reason)
/** // @flavor Perl, PHP, Raku
* @depreacated #define die xy_panic
*
* @flavor Perl, PHP, Raku
*/
// #define die xy_throw
/** #define xy_unsupported() xy_panic("Unsuppoted")
* @depreacated #define xy_unimplemented() xy_panic("Unimplemented temporarily")
*/ #define xy_unreached() xy_panic("This code shouldn't be reached")
// #define xy_panic xy_throw #define xy_cant_be_null(p) if(!p) xy_panic("This pointer can't be null")
#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")
static inline void
_xy_internal_warn (char *str)
{
fprintf (stderr, "[xy.h] %s\n", str);
}
static void _xy_print_int (int n) {printf ("%d", n);} static void _xy_print_int (int n) {printf ("%d", n);}
static void _xy_print_long (long n) {printf ("%ld", n);} static void _xy_print_long (long n) {printf ("%ld", n);}
@ -181,7 +164,7 @@ static void _xy_println_const_str (const char *str) {printf ("%s\n", str);}
bool: _xy_print_bool, \ bool: _xy_print_bool, \
char *: _xy_print_str, \ char *: _xy_print_str, \
const char *: _xy_print_const_str, \ const char *: _xy_print_const_str, \
default: xy_throw("Unsupported type for print()!") \ default: xy_panic("Unsupported type for print()!") \
)(x) )(x)
/** /**
@ -196,7 +179,7 @@ static void _xy_println_const_str (const char *str) {printf ("%s\n", str);}
bool: _xy_println_bool, \ bool: _xy_println_bool, \
char *: _xy_println_str, \ char *: _xy_println_str, \
const char *: _xy_println_const_str, \ const char *: _xy_println_const_str, \
default: xy_throw("Unsupported type for println()/say()!") \ default: xy_panic("Unsupported type for println()/say()!") \
)(x) )(x)
/* @flavor Raku, Perl */ /* @flavor Raku, Perl */
#define say println #define say println
@ -221,31 +204,12 @@ xy_malloc0 (size_t size)
} }
/**
* @brief
*
* @param pptr
* *pptr NULL
* @param new_mem
*/
static inline void
xy_ptr_replace (char **pptr, char *new_mem)
{
xy_cant_be_null (pptr);
if (*pptr)
free (*pptr);
*pptr = new_mem;
}
/****************************************************** /******************************************************
* String * String
******************************************************/ ******************************************************/
/** /**
* @brief str pat replace * @brief str pat replace
* *
* @flavor Ruby: String#gsub * @flavor Ruby: String#gsub
* *
@ -380,7 +344,7 @@ xy_strcat (unsigned int count, ...)
} }
if (NULL == ret) if (NULL == ret)
{ {
_xy_internal_warn ("xy_strcat(): No availble memory to allocate!"); fprintf (stderr, "xy.h: No availble memory!");
return NULL; return NULL;
} }
strcpy (cur, str); strcpy (cur, str);
@ -406,7 +370,7 @@ xy_strdup (const char *str)
{ {
if (!str) if (!str)
{ {
_xy_internal_warn ("xy_strdup(): called with NULL!"); fprintf (stderr, "xy.h: xy_strdup() called with NULL!\n");
return NULL; return NULL;
} }
@ -506,15 +470,15 @@ xy_streql (const char *str1, const char *str2)
} }
static bool static bool
xy_streql_ic (const char *str1, const char *str2) xy_streql_ic(const char *str1, const char *str2)
{ {
if (NULL == str1 || NULL == str2) if (NULL == str1 || NULL == str2)
{ {
return false; return false;
} }
size_t len1 = strlen (str1); size_t len1 = strlen(str1);
size_t len2 = strlen (str2); size_t len2 = strlen(str2);
if (len1 != len2) if (len1 != len2)
{ {
return false; return false;
@ -522,7 +486,7 @@ xy_streql_ic (const char *str1, const char *str2)
for (size_t i = 0; i < len1; i++) for (size_t i = 0; i < len1; i++)
{ {
if (tolower (str1[i]) != tolower (str2[i])) if (tolower(str1[i]) != tolower(str2[i]))
{ {
return false; return false;
} }
@ -596,16 +560,14 @@ xy_str_start_with (const char *str, const char *prefix)
static char * static char *
xy_str_delete_prefix (const char *str, const char *prefix) xy_str_delete_prefix (const char *str, const char *prefix)
{ {
char *new = xy_strdup (str);
bool yes = xy_str_start_with (str, prefix); bool yes = xy_str_start_with (str, prefix);
if (!yes) if (!yes)
{ return new;
return xy_strdup (str);
} size_t len = strlen (prefix);
else char *cur = new + len;
{ return cur;
size_t len = strlen (prefix);
return xy_strdup (str + len);
}
} }
/** /**
@ -632,24 +594,23 @@ xy_str_delete_suffix (const char *str, const char *suffix)
static char * static char *
xy_str_strip (const char *str) xy_str_strip (const char *str)
{ {
xy_cant_be_null (str); char *new = xy_strdup (str);
const char *start = str; while (strchr ("\n\r\v\t\f ", new[0]))
while (*start && strchr ("\n\r\v\t\f ", *start)) {
start++; new += 1;
}
if ('\0' == *start) size_t len = strlen (new);
return xy_strdup ("");
const char *end = start + strlen (start) - 1; char *last = new + len - 1;
while (end >= start && strchr ("\n\r\v\t\f ", *end))
end--;
size_t len = (size_t) (end - start + 1); while (strchr ("\n\r\v\t\f ", *last))
char *ret = xy_malloc0 (len + 1); {
memcpy (ret, start, len); *last = '\0';
ret[len] = '\0'; last -= 1;
return ret; }
return new;
} }
typedef struct typedef struct
@ -763,7 +724,7 @@ xy_file_read (const char *path)
buf[read_bytes] = '\0'; buf[read_bytes] = '\0';
char *formatted_str = xy_str_gsub (buf, "\r\n", "\n"); char *formatted_str = xy_str_gsub (buf, "\r\n", "\n");
xy_ptr_replace (&formatted_str, xy_str_gsub (formatted_str, "\r", "\n")); formatted_str = xy_str_gsub (formatted_str, "\r", "\n");
free (buf); free (buf);
@ -943,10 +904,10 @@ xy_quiet_cmd (const char *cmd)
/** /**
* @brief `cmd` stdout `n` `func` * @brief `cmd` `func`
* *
* @param cmd * @param cmd
* @param n stdout 0 n (n>0) n行 * @param n 0 n (n>0) n行
* @param func true * @param func true
* *
* @return * @return
@ -968,7 +929,7 @@ xy_run_iter_lines (const char *cmd, unsigned long n, bool (*func) (const char
FILE *stream = popen (cmd, "r"); FILE *stream = popen (cmd, "r");
if (stream == NULL) if (stream == NULL)
{ {
_xy_internal_warn ("xy_run_iter_lines(): popen() failed"); fprintf (stderr, "xy: 命令执行失败\n");
return NULL; return NULL;
} }
@ -995,11 +956,6 @@ xy_run_iter_lines (const char *cmd, unsigned long n, bool (*func) (const char
return ret; return ret;
} }
/**
* @brief `cmd` `n` stdout
*
* @return `n` stdout
*/
static char * static char *
xy_run (const char *cmd, unsigned long n) xy_run (const char *cmd, unsigned long n)
{ {
@ -1008,9 +964,7 @@ xy_run (const char *cmd, unsigned long n)
/** /**
* @brief `cmd` Exit Codestdout stderr * @brief
*
* @return `cmd` Exit Code
*/ */
int int
xy_run_get_status (char *cmd) xy_run_get_status (char *cmd)
@ -1023,7 +977,7 @@ xy_run_get_status (char *cmd)
/** /**
* @brief `cmd` stdout stderr * @brief
* *
* @param[in] cmd * @param[in] cmd
* @param[out] output * @param[out] output
@ -1040,7 +994,7 @@ xy_run_get_stdout (const char *cmd, char **output)
FILE *stream = popen (cmd, "r"); FILE *stream = popen (cmd, "r");
if (stream == NULL) if (stream == NULL)
{ {
_xy_internal_warn ("xy_run_get_stdout(): popen() failed"); fprintf (stderr, "xy: 命令执行失败\n");
return -1; return -1;
} }
@ -1066,6 +1020,21 @@ xy_run_get_stdout (const char *cmd, char **output)
} }
/**
* @flavor just os_family() windows, unix
*
* @return "windows" "unix"
*/
#define xy_os_family _xy_os_family ()
static char *
_xy_os_family ()
{
if (xy.on_windows)
return "windows";
else
return "unix";
}
/** /**
* @brief os family * @brief os family
@ -1174,19 +1143,13 @@ _xy_win_powershellv5_profile ()
static bool static bool
xy_file_exist (const char *path) xy_file_exist (const char *path)
{ {
char *expanded_path = NULL; const char *new_path = path;
const char *check_path = path;
if (xy_str_start_with (path, "~")) if (xy_str_start_with (path, "~"))
{ {
expanded_path = xy_2strcat (xy_os_home, path + 1); new_path = xy_2strcat (xy_os_home, path + 1);
check_path = expanded_path;
} }
// 0 即 F_OK // 0 即 F_OK
bool result = (0 == access (check_path, 0)) ? true : false; return (0==access (new_path, 0)) ? true : false;
if (expanded_path) free (expanded_path);
return result;
} }
/** /**
@ -1196,14 +1159,12 @@ xy_file_exist (const char *path)
static bool static bool
xy_dir_exist (const char *path) xy_dir_exist (const char *path)
{ {
char *allocated_dir = NULL;
const char *dir = path; const char *dir = path;
if (xy.on_windows) if (xy.on_windows)
{ {
if (xy_str_start_with (path, "~")) if (xy_str_start_with (path, "~"))
{ {
allocated_dir = xy_2strcat (xy_os_home, path + 1); dir = xy_2strcat (xy_os_home, path + 1);
dir = allocated_dir;
} }
} }
@ -1213,32 +1174,29 @@ xy_dir_exist (const char *path)
// 也可以用 opendir() #include <dirent.h> // 也可以用 opendir() #include <dirent.h>
DWORD attr = GetFileAttributesA (dir); DWORD attr = GetFileAttributesA (dir);
bool result = false;
if (attr == INVALID_FILE_ATTRIBUTES) if (attr == INVALID_FILE_ATTRIBUTES)
{ {
// Q: 我们应该报错吗? // Q: 我们应该报错吗?
result = false; return false;
} }
else if (attr & FILE_ATTRIBUTE_DIRECTORY) else if (attr & FILE_ATTRIBUTE_DIRECTORY)
{ {
result = true; return true;
} }
else else
{ {
result = false; return false;
} }
if (allocated_dir) free (allocated_dir);
return result;
#endif #endif
} }
else else
{ {
char *tmp_cmd = xy_2strcat ("test -d ", dir); int status = system (xy_2strcat ("test -d ", dir));
int status = system (tmp_cmd);
free (tmp_cmd); if (0==status)
bool result = (0==status); return true;
if (allocated_dir) free (allocated_dir); else
return result; return false;
} }
return false; return false;
@ -1261,17 +1219,13 @@ xy_normalize_path (const char *path)
if (xy_str_start_with (new, "~")) if (xy_str_start_with (new, "~"))
{ {
char *tmp = xy_str_delete_prefix (new, "~"); new = xy_2strcat (xy_os_home, xy_str_delete_prefix (new, "~"));
char *joined = xy_2strcat (xy_os_home, tmp);
free (tmp);
xy_ptr_replace (&new, joined);
} }
if (xy.on_windows) if (xy.on_windows)
{ return xy_str_gsub (new, "/", "\\");
xy_ptr_replace (&new, xy_str_gsub (new, "/", "\\")); else
} return new;
return new;
} }
@ -1288,10 +1242,10 @@ xy_parent_dir (const char *path)
char *dir = xy_normalize_path (path); char *dir = xy_normalize_path (path);
/* 不管是否为Windows全部统一使用 / 作为路径分隔符,方便后续处理 */ /* 不管是否为Windows全部统一使用 / 作为路径分隔符,方便后续处理 */
xy_ptr_replace (&dir, xy_str_gsub (dir, "\\", "/")); dir = xy_str_gsub (dir, "\\", "/");
if (xy_str_end_with (dir, "/")) if (xy_str_end_with (dir, "/"))
xy_ptr_replace (&dir, xy_str_delete_suffix (dir, "/")); dir = xy_str_delete_suffix (dir, "/");
char *last = NULL; char *last = NULL;
@ -1305,24 +1259,17 @@ xy_parent_dir (const char *path)
/* Windows上重新使用 \ 作为路径分隔符 */ /* Windows上重新使用 \ 作为路径分隔符 */
if (xy.on_windows) if (xy.on_windows)
{ return xy_str_gsub (dir, "/", "\\");
xy_ptr_replace (&dir, xy_str_gsub (dir, "/", "\\")); else
} return dir;
return dir;
} }
/**
* @internal xy_init ()
*/
void void
_xy_detect_os () xy_detect_os ()
{ {
/** // C:
* Windows
*
* SystemDrive C:
*/
char *drive = getenv ("SystemDrive"); char *drive = getenv ("SystemDrive");
if (drive) if (drive)
{ {
@ -1332,39 +1279,25 @@ _xy_detect_os ()
if (d) if (d)
{ {
xy.on_windows = true; xy.on_windows = true;
xy.os_family = "windows";
closedir (d); closedir (d);
return; return;
} }
} }
/* 判断 Linux */
FILE *fp = fopen ("/proc/version", "r"); FILE *fp = fopen ("/proc/version", "r");
if (fp) if (fp)
{ {
char buf[256] = {0}; char buf[256] = {0};
fread (buf, 1, sizeof (buf) - 1, fp); fread (buf, 1, sizeof(buf) - 1, fp);
fclose (fp); fclose (fp);
if (strstr (buf, "Linux")) if (strstr (buf, "Android"))
{
xy.on_linux = true;
xy.os_family = "unix";
return;
}
}
/**
* Android
*
* @consult https://android.googlesource.com/platform/system/core/+/refs/heads/main/rootdir/init.environ.rc.in
*/
char *android_env = getenv ("ANDROID_ROOT");
if (android_env)
{
if (xy_str_find (android_env, "/system").found)
{ {
xy.on_android = true; xy.on_android = true;
xy.os_family = "unix"; return;
}
else if (strstr (buf, "Linux"))
{
xy.on_linux = true;
return; return;
} }
} }
@ -1378,40 +1311,32 @@ _xy_detect_os ()
if (d) if (d)
{ {
xy.on_macos = true; xy.on_macos = true;
xy.os_family = "unix";
closedir (d); closedir (d);
return;
} }
} }
/* 最后判断 BSD */ /* 最后判断 BSD */
fp = popen ("uname -s", "r"); fp = popen ("uname -s", "r");
if (fp) if (!fp)
{ {
char buf[256]; if (opendir ("/etc/rc.d"))
fgets (buf, sizeof (buf), fp);
pclose (fp);
if (strstr (buf, "BSD") != NULL)
{ {
closedir (d);
xy.on_bsd = true; xy.on_bsd = true;
xy.os_family = "unix";
return; return;
} }
} }
else else
{ {
DIR *bsd_dir = opendir ("/etc/rc.d"); char buf[256];
if (bsd_dir) fgets (buf, sizeof (buf), fp);
{ pclose (fp);
closedir (bsd_dir); if (strstr (buf, "BSD") != NULL)
xy.on_bsd = true; xy.on_bsd = true;
xy.os_family = "unix";
return;
}
} }
if (!(xy.on_windows || xy.on_linux || xy.on_android || xy.on_macos || xy.on_bsd)) if (!(xy.on_windows || xy.on_linux || xy.on_android || xy.on_macos || xy.on_bsd))
xy_throw ("Unknown operating system"); xy_panic ("Unknown operating system");
} }
@ -1430,7 +1355,7 @@ xy_use_utf8 ()
void void
xy_init () xy_init ()
{ {
_xy_detect_os (); xy_detect_os ();
if (xy.on_windows) if (xy.on_windows)
xy.os_devnull = "nul"; xy.os_devnull = "nul";
@ -1520,7 +1445,7 @@ xy_seq_at (XySeq_t *seq, int n)
{ {
xy_cant_be_null (seq); xy_cant_be_null (seq);
if (0 == n) xy_throw ("The index must begin from 1, not 0"); if (0 == n) xy_panic ("The index must begin from 1, not 0");
if (1 == n) return seq->first_item ? seq->first_item->data : NULL; if (1 == n) return seq->first_item ? seq->first_item->data : NULL;

View File

@ -3,8 +3,8 @@
! ------------------------------------------------------------- ! -------------------------------------------------------------
! Doc Type : Markdown ! Doc Type : Markdown
! Doc Name : README.md ! Doc Name : README.md
! Doc Authors : 曾奥然 <ccmywish@qq.com> ! Doc Authors : Aoran Zeng <ccmywish@qq.com>
! Contributors : Nil Null <nil@null.org> ! Contributors : Nil Null <nil@null.org>
! | ! |
! Created On : <2025-06-15> ! Created On : <2025-06-15>
! Last Modified : <2025-06-16> ! Last Modified : <2025-06-16>

View File

@ -4,7 +4,7 @@
! Doc Type : Markdown ! Doc Type : Markdown
! Doc Name : BUILD.md ! Doc Name : BUILD.md
! Doc Authors : sanchuanhehe <wyihe5520@gmail.com> ! Doc Authors : sanchuanhehe <wyihe5520@gmail.com>
! Contributors : 曾奥然 <ccmywish@qq.com> ! Contributors : Aoran Zeng <ccmywish@qq.com>
! | ! |
! Created On : <2025-06-14> ! Created On : <2025-06-14>
! Last Modified : <2025-06-16> ! Last Modified : <2025-06-16>

View File

@ -4,7 +4,7 @@
! Doc Type : Markdown ! Doc Type : Markdown
! Doc Name : CI.md ! Doc Name : CI.md
! Doc Authors : sanchuanhehe <wyihe5520@gmail.com> ! Doc Authors : sanchuanhehe <wyihe5520@gmail.com>
! Contributors : 曾奥然 <ccmywish@qq.com> ! Contributors : Aoran Zeng <ccmywish@qq.com>
! | ! |
! Created On : <2025-06-14> ! Created On : <2025-06-14>
! Last Modified : <2025-06-16> ! Last Modified : <2025-06-16>

View File

@ -4,7 +4,7 @@
# -------------------------------------------------------------- # --------------------------------------------------------------
# Build File : Makefile # Build File : Makefile
# File Authors : sanchuanhehe <wyihe5520@gmail.com> # File Authors : sanchuanhehe <wyihe5520@gmail.com>
# Contributors : 曾奥然 <ccmywish@qq.com> # Contributors : Aoran Zeng <ccmywish@qq.com>
# | # |
# Created On : <2025-06-14> # Created On : <2025-06-14>
# Last Modified : <2025-06-16> # Last Modified : <2025-06-16>

View File

@ -4,8 +4,8 @@
! Doc Type : Markdown ! Doc Type : Markdown
! Doc Name : README.md ! Doc Name : README.md
! Doc Authors : sanchuanhehe <wyihe5520@gmail.com> ! Doc Authors : sanchuanhehe <wyihe5520@gmail.com>
! | 曾奥然 <ccmywish@qq.com> ! | Aoran Zeng <ccmywish@qq.com>
! Contributors : Nil Null <nil@null.org> ! Contributors : Nil Null <nil@null.org>
! | ! |
! Created On : <2025-06-14> ! Created On : <2025-06-14>
! Last Modified : <2025-06-16> ! Last Modified : <2025-06-16>

View File

@ -4,7 +4,7 @@
# -------------------------------------------------------------- # --------------------------------------------------------------
# Test File : deb-installation-test.sh # Test File : deb-installation-test.sh
# File Authors : sanchuanhehe <wyihe5520@gmail.com> # File Authors : sanchuanhehe <wyihe5520@gmail.com>
# Contributors : 曾奥然 <ccmywish@qq.com> # Contributors : Aoran Zeng <ccmywish@qq.com>
# | # |
# Created On : <2025-06-14> # Created On : <2025-06-14>
# Last Modified : <2025-06-16> # Last Modified : <2025-06-16>

View File

@ -1,15 +1,8 @@
chsrc (0.2.3-1) unstable; urgency=medium
* v0.2.3 已发布
-- 曾奥然 <ccmywish@qq.com> Wed, 29 Oct 2025 11:29:05 +0800
chsrc (0.1.9-1) unstable; urgency=medium chsrc (0.1.9-1) unstable; urgency=medium
* v0.1.9 已发布 * v0.1.9 已发布
-- 曾奥然 <ccmywish@qq.com> Sun, 15 Jun 2025 13:32:50 +0800 -- Aoran Zeng <ccmywish@qq.com> Sun, 15 Jun 2025 13:32:50 +0800
chsrc (0.0.1-1) unstable; urgency=medium chsrc (0.0.1-1) unstable; urgency=medium

View File

@ -1,17 +1,17 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: chsrc Upstream-Name: chsrc
Upstream-Contact: 曾奥然 <ccmywish@qq.com> Upstream-Contact: Aoran Zeng <ccmywish@qq.com>
Source: https://github.com/RubyMetric/chsrc Source: https://github.com/RubyMetric/chsrc
Files: * Files: *
Copyright: 2023-2025 曾奥然 <ccmywish@qq.com> Copyright: 2023-2025 Aoran Zeng <ccmywish@qq.com>
2023-2025 郭恒 <2085471348@qq.com> 2023-2025 Heng Guo <2085471348@qq.com>
License: GPL-3+ License: GPL-3+
Comment: The authors' names are indicated in each source code file's header. Comment: The authors' names are indicated in each source code file's header.
Files: lib/xy.h Files: lib/xy.h
Copyright: 2023-2025 曾奥然 <ccmywish@qq.com> Copyright: 2023-2025 Aoran Zeng <ccmywish@qq.com>
2023-2025 郭恒 <2085471348@qq.com> 2023-2025 Heng Guo <2085471348@qq.com>
License: MIT License: MIT
Files: pkg/deb/debian/* Files: pkg/deb/debian/*

View File

@ -5,7 +5,7 @@
# deb File : postinst # deb File : postinst
# File Authors : sanchuanhehe <wyihe5520@gmail.com> # File Authors : sanchuanhehe <wyihe5520@gmail.com>
# Contributors : Nil Null <nil@null.org> # Contributors : Nil Null <nil@null.org>
# | # |
# Created On : <2025-06-14> # Created On : <2025-06-14>
# Last Modified : <2025-06-16> # Last Modified : <2025-06-16>
# #

View File

@ -5,7 +5,7 @@
# deb File : prerm # deb File : prerm
# File Authors : sanchuanhehe <wyihe5520@gmail.com> # File Authors : sanchuanhehe <wyihe5520@gmail.com>
# Contributors : Nil Null <nil@null.org> # Contributors : Nil Null <nil@null.org>
# | # |
# Created On : <2025-06-14> # Created On : <2025-06-14>
# Last Modified : <2025-06-16> # Last Modified : <2025-06-16>
# #

View File

@ -4,8 +4,8 @@
# -------------------------------------------------------------- # --------------------------------------------------------------
# Build File : rules # Build File : rules
# File Authors : sanchuanhehe <wyihe5520@gmail.com> # File Authors : sanchuanhehe <wyihe5520@gmail.com>
# | 曾奥然 <ccmywish@qq.com> # | Aoran Zeng <ccmywish@qq.com>
# Contributors : Nil Null <nil@null.org> # Contributors : Nil Null <nil@null.org>
# | # |
# Created On : <2025-06-14> # Created On : <2025-06-14>
# Last Modified : <2025-06-20> # Last Modified : <2025-06-20>

View File

@ -30,10 +30,11 @@
* *
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
#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_URL "https://github.com/RubyMetric/chsrc"
#define Chsrc_Maintain_URL2 "https://gitee.com/RubyMetric/chsrc" #define Chsrc_Maintain_URL2 "https://gitee.com/RubyMetric/chsrc"
#include "framework/version.h"
#include "framework/core.c" #include "framework/core.c"
#include "framework/chef.c" #include "framework/chef.c"
@ -75,7 +76,6 @@ chsrc_register_contributors ()
// 该 ID 为 Gitee ID // 该 ID 为 Gitee ID
chef_register_contributor ("@hezonglun", "HeZongLun", "hezonglun123456@outlook.com", NULL); chef_register_contributor ("@hezonglun", "HeZongLun", "hezonglun123456@outlook.com", NULL);
chef_register_contributor ("@Young-Lord", "LY", "ly-niko@qq.com", NULL); chef_register_contributor ("@Young-Lord", "LY", "ly-niko@qq.com", NULL);
chef_register_contributor ("@MingriLingran", "MingriLingran", "i@linran.moe", NULL);
/** /**
* AI贡献者 * AI贡献者
@ -456,8 +456,7 @@ cli_print_version ()
{ {
char *version_string = "v" Chsrc_Version " (" Chsrc_Release_Date ")"; char *version_string = "v" Chsrc_Version " (" Chsrc_Release_Date ")";
char *str = xy_str_gsub (CHINESE ? RAWSTR_chsrc_for_v_CHINESE : RAWSTR_chsrc_for_v_ENGLISH, char *str = xy_str_gsub (RAWSTR_chsrc_for_v, "@ver@", version_string);
"@ver@", version_string);
println (str); println (str);
} }

View File

@ -1,18 +1,18 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* ------------------------------------------------------------- * -------------------------------------------------------------
* File Name : helper.c * File Name : chef-helper.c
* File Authors : <ccmywish@qq.com> * File Authors : <ccmywish@qq.com>
* Contributors : Nul None <nul@none.org> * Contributors : Nul None <nul@none.org>
* Created On : <2025-07-14> * Created On : <2025-07-14>
* Last Modified : <2025-10-28> * Last Modified : <2025-08-20>
* *
* For chefs (recipe makers) and sometimes framewoker * For chefs (recipe makers) and sometimes framewoker
* to do some work not releated to OS operations * to do some work not releated to OS operations
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
bool bool
hp_is_url (const char *str) chef_is_url (const char *str)
{ {
return (xy_str_start_with (str, "http://") || xy_str_start_with (str, "https://")); return (xy_str_start_with (str, "http://") || xy_str_start_with (str, "https://"));
} }
@ -21,7 +21,7 @@ hp_is_url (const char *str)
* @return * @return
*/ */
char * char *
hp_remove_trailing_slash (char *str) chef_remove_trailing_slash (char *str)
{ {
char *newstr = xy_strdup (str); char *newstr = xy_strdup (str);
size_t len = strlen (newstr); size_t len = strlen (newstr);
@ -34,7 +34,7 @@ hp_remove_trailing_slash (char *str)
* @return * @return
*/ */
char * char *
hp_ensure_trailing_slash (char *str) chef_ensure_trailing_slash (char *str)
{ {
size_t len = strlen (str); size_t len = strlen (str);
if (len == 0 || str[len - 1] == '/') if (len == 0 || str[len - 1] == '/')

View File

@ -5,7 +5,7 @@
* File Authors : <ccmywish@qq.com> * File Authors : <ccmywish@qq.com>
* Contributors : BingChunMoLi <bingchunmoli@bingchunmoli.com> * Contributors : BingChunMoLi <bingchunmoli@bingchunmoli.com>
* Created On : <2025-08-09> * Created On : <2025-08-09>
* Last Modified : <2025-10-27> * Last Modified : <2025-08-27>
* *
* chef DSL: for chefs (recipe makers) to define a target * chef DSL: for chefs (recipe makers) to define a target
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
@ -137,7 +137,7 @@ chef_set_sources_speed_measure_url_with_func (
if (src->url) if (src->url)
{ {
/* 为空时才修改 或者里面是脏数据 */ /* 为空时才修改 或者里面是脏数据 */
if (NULL==src->speed_measure_url || !hp_is_url (src->speed_measure_url)) if (NULL==src->speed_measure_url || !chef_is_url (src->speed_measure_url))
{ {
src->speed_measure_url = func (src->url, user_data); src->speed_measure_url = func (src->url, user_data);
} }
@ -186,7 +186,7 @@ chef_allow_english (Target_t *target)
} }
void void
chef_deny_english (Target_t *target) chef_forbid_english (Target_t *target)
{ {
xy_cant_be_null (target); xy_cant_be_null (target);
target->can_english = false; target->can_english = false;
@ -226,7 +226,7 @@ chef_allow_user_define (Target_t *target)
} }
void void
chef_deny_user_define (Target_t *target) chef_forbid_user_define (Target_t *target)
{ {
xy_cant_be_null (target); xy_cant_be_null (target);

View File

@ -2,16 +2,16 @@
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* ------------------------------------------------------------- * -------------------------------------------------------------
* File Name : core.c * File Name : core.c
* File Authors : @ccmywish * File Authors : <ccmywish@qq.com>
* | @G_I_Y * | <2085471348@qq.com>
* Contributors : @Gn3po4g * Contributors : Peng Gao <gn3po4g@outlook.com>
* | @happy-game * | Happy Game <happygame10124@gmail.com>
* | @Yangmoooo * | Yangmoooo <yangmoooo@outlook.com>
* | @BingChunMoLi * | BingChunMoLi <bingchunmoli@bingchunmoli.com>
* | @Mikachu2333 * | Mikachu2333 <mikachu.23333@zohomail.com>
* | * |
* Created On : <2023-08-29> * Created On : <2023-08-29>
* Last Modified : <2025-12-29> * Last Modified : <2025-09-29>
* *
* chsrc framework * chsrc framework
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
@ -27,7 +27,7 @@
#include "xy.h" #include "xy.h"
#include "struct.h" #include "struct.h"
#include "mirror.c" #include "mirror.c"
#include "helper.c" #include "chef-helper.c"
#define App_Name "chsrc" #define App_Name "chsrc"
@ -511,7 +511,7 @@ chsrc_check_file (char *path)
int int
query_mirror_exist (Source_t *sources, size_t size, char *target_name, char *input) query_mirror_exist (Source_t *sources, size_t size, char *target_name, char *input)
{ {
if (hp_is_url (input)) if (chef_is_url (input))
{ {
char *msg = ENGLISH ? "Using user-defined sources for this software is not supported at this time, please contact the developers to ask why or request support" : "暂不支持对该软件使用用户自定义源,请联系开发者询问原因或请求支持"; char *msg = ENGLISH ? "Using user-defined sources for this software is not supported at this time, please contact the developers to ask why or request support" : "暂不支持对该软件使用用户自定义源,请联系开发者询问原因或请求支持";
chsrc_error (msg); chsrc_error (msg);
@ -764,7 +764,7 @@ measure_speed_for_every_source (Source_t sources[], int size, double speed_recor
} }
else if (!provider_skip && provider_speed_url) else if (!provider_skip && provider_speed_url)
{ {
if (hp_is_url (provider_speed_url)) if (chef_is_url (provider_speed_url))
{ {
url = xy_strdup (provider_speed_url); url = xy_strdup (provider_speed_url);
chsrc_debug ("m", xy_2strcat ("使用镜像站整体测速链接: ", url)); chsrc_debug ("m", xy_2strcat ("使用镜像站整体测速链接: ", url));
@ -777,7 +777,7 @@ measure_speed_for_every_source (Source_t sources[], int size, double speed_recor
if (dedicated_speed_url) if (dedicated_speed_url)
{ {
if (hp_is_url (dedicated_speed_url)) if (chef_is_url (dedicated_speed_url))
{ {
url = xy_strdup (dedicated_speed_url); url = xy_strdup (dedicated_speed_url);
has_dedicated_speed_url = true; has_dedicated_speed_url = true;
@ -863,9 +863,6 @@ measure_speed_for_every_source (Source_t sources[], int size, double speed_recor
char *curl_result = measure_speed_for_url (url); char *curl_result = measure_speed_for_url (url);
double speed = parse_and_say_curl_result (curl_result); double speed = parse_and_say_curl_result (curl_result);
speed_records[i] = speed; speed_records[i] = speed;
/* 释放 url 内存 */
if (url) free (url);
} }
else else
{ {
@ -1055,7 +1052,7 @@ chsrc_yield_source (Target_t *t, char *option)
{ {
source = t->sources[ProgStatus.leader_selected_index]; source = t->sources[ProgStatus.leader_selected_index];
} }
else if (hp_is_url (option)) else if (chef_is_url (option))
{ {
Source_t tmp = { &UserDefinedProvider, option }; Source_t tmp = { &UserDefinedProvider, option };
source = tmp; source = tmp;
@ -1522,7 +1519,6 @@ chsrc_run_as_bash_file (const char *script_content)
char *cmd = xy_2strcat ("bash ", tmpfile); char *cmd = xy_2strcat ("bash ", tmpfile);
chsrc_run (cmd, RunOpt_Dont_Abort_On_Failure); chsrc_run (cmd, RunOpt_Dont_Abort_On_Failure);
remove (tmpfile); remove (tmpfile);
free (tmpfile); /* 释放 tmpfile 路径内存 */
} }
@ -1543,7 +1539,6 @@ chsrc_run_as_sh_file (const char *script_content)
char *cmd = xy_2strcat ("sh ", tmpfile); char *cmd = xy_2strcat ("sh ", tmpfile);
chsrc_run (cmd, RunOpt_Dont_Abort_On_Failure); chsrc_run (cmd, RunOpt_Dont_Abort_On_Failure);
remove (tmpfile); remove (tmpfile);
free (tmpfile);
} }
@ -1557,54 +1552,12 @@ chsrc_run_as_pwsh_file (const char *script_content)
FILE *f = chsrc_make_tmpfile ("pwsh_script", ".ps1", false, &tmpfile); FILE *f = chsrc_make_tmpfile ("pwsh_script", ".ps1", false, &tmpfile);
fwrite (script_content, strlen (script_content), 1, f); fwrite (script_content, strlen (script_content), 1, f);
fclose (f); fclose (f);
char *msg = CHINESE ? "即将执行 PowerShell (v7以上) 脚本内容:" : "The PowerShell script content will be executed:"; char *msg = CHINESE ? "即将执行 PowerShell 脚本内容:" : "The PowerShell script content will be executed:";
chsrc_note2 (msg); chsrc_note2 (msg);
println (faint(script_content)); println (faint(script_content));
char *cmd = xy_2strcat ("pwsh ", tmpfile); char *cmd = xy_2strcat ("pwsh ", tmpfile);
chsrc_run (cmd, RunOpt_Dont_Abort_On_Failure); chsrc_run (cmd, RunOpt_Dont_Abort_On_Failure);
remove (tmpfile); remove (tmpfile);
free (tmpfile);
}
/**
* powershell file.ps1
*/
void
chsrc_run_as_powershellv5_file (const char *script_content)
{
char *tmpfile = NULL;
FILE *f = chsrc_make_tmpfile ("psv5_script", ".ps1", false, &tmpfile);
fwrite (script_content, strlen (script_content), 1, f);
fclose (f);
char *msg = CHINESE ? "即将执行 PowerShell v5 脚本内容:" : "The PowerShell v5 script content will be executed:";
chsrc_note2 (msg);
println (faint(script_content));
// -ExecutionPolicy Bypass
char *cmd = xy_2strcat ("powershell -File ", tmpfile);
chsrc_run (cmd, RunOpt_Dont_Abort_On_Failure);
remove (tmpfile);
free (tmpfile);
}
/**
* 使 pwsh powershell (v5) 使 pwsh
*/
void
chsrc_run_as_powershell_file (const char *script_content)
{
// if (chsrc_check_program_quietly_when_exist ("pwsh"))
if (chsrc_check_program_quietly ("pwsh"))
{
chsrc_run_as_pwsh_file (script_content);
}
else
{
chsrc_alert2 (CHINESE ? "未检测到 PowerShell 7 及以上版本,默认使用 PowerShell v5"
: "PowerShell 7 or above not detected, switch to PowerShell v5");
chsrc_run_as_powershellv5_file (script_content);
}
} }
@ -1648,30 +1601,27 @@ chsrc_view_env (const char *var1, ...)
bool first = true; bool first = true;
while (var) while (var)
{ {
if (xy.on_windows) #ifdef XY_Build_On_Windows
if (first)
{ {
if (first) cmd = xy_strcat (3, "set ", var, " ");
{ first = false;
cmd = xy_strcat (3, "set ", var, " ");
first = false;
}
else
{
cmd = xy_strcat (4, cmd, "& set ", var, " ");
}
} }
else else
{ {
if (first) cmd = xy_strcat (4, cmd, "& set ", var, " ");
{
cmd = xy_strcat (5, "echo ", var, "=$", var, " ");
first = false;
}
else
{
cmd = xy_strcat (6, cmd, "; echo ", var, "=$", var, " ");
}
} }
#else
if (first)
{
cmd = xy_strcat (5, "echo ", var, "=$", var, " ");
first = false;
}
else
{
cmd = xy_strcat (6, cmd, "; echo ", var, "=$", var, " ");
}
#endif
var = va_arg (vars, const char *); var = va_arg (vars, const char *);
} }
@ -1795,7 +1745,7 @@ log_anyway:
} }
/** /**
* @note `str` `str` * @note `str`
*/ */
static void static void
chsrc_prepend_to_file (const char *str, const char *filename) chsrc_prepend_to_file (const char *str, const char *filename)
@ -1806,21 +1756,67 @@ chsrc_prepend_to_file (const char *str, const char *filename)
} }
char *file = xy_normalize_path (filename); char *file = xy_normalize_path (filename);
char *dir = xy_parent_dir (file);
chsrc_ensure_dir (dir);
char *file_content = xy_file_read (file); char *tmpfile_path = NULL;
char *content = xy_2strcat (str, file_content); FILE *output = chsrc_make_tmpfile ("prepend", ".txt", false, &tmpfile_path);
FILE *f = fopen (file, "w"); if (!output)
if (f)
{ {
fwrite (content, 1, strlen (content), f); char *msg = ENGLISH ? xy_2strcat ("Create temp file before Write prepend failed ", file)
fclose (f); : xy_2strcat ("尝试在文件开头写入时创建临时文件失败:", file);
chsrc_error2 (msg);
exit (Exit_ExternalError);
} }
else
/* 先写入要插入的内容 */
fprintf (output, "%s", str);
/* 如果原文件存在,复制其内容到临时文件 */
FILE *input = fopen (file, "r");
if (input)
{ {
chsrc_error2 ("文件打开失败"); fseek (input, 0, SEEK_END);
exit (Exit_UserCause); long file_size = ftell (input);
fseek (input, 0, SEEK_SET);
if (file_size > 0)
{
char *buffer = malloc (file_size);
if (buffer == NULL)
{
fclose (input);
fclose (output);
remove (tmpfile_path);
char *msg = ENGLISH ? "Memory allocation failed" : "内存分配失败";
chsrc_error2 (msg);
exit (Exit_ExternalError);
}
size_t bytes = fread (buffer, 1, file_size, input);
if (bytes > 0)
{
fwrite (buffer, 1, bytes, output);
}
free (buffer);
}
fclose (input);
}
fclose (output);
/* 删除原文件(如果存在) */
remove (file);
/* 将临时文件重命名为目标文件 */
if (rename (tmpfile_path, file) != 0)
{
unlink (tmpfile_path);
char *msg = ENGLISH ? xy_2strcat ("Write prepend failed to ", file)
: xy_2strcat ("在文件开头写入失败: ", file);
chsrc_error2 (msg);
exit (Exit_ExternalError);
} }
log_anyway: log_anyway:
@ -1853,7 +1849,6 @@ chsrc_overwrite_file (const char *str, const char *filename)
size_t ret = fwrite (str, len, 1, f); size_t ret = fwrite (str, len, 1, f);
if (ret != 1) if (ret != 1)
{ {
fclose (f);
char *msg = ENGLISH ? xy_2strcat ("Write failed to ", file) char *msg = ENGLISH ? xy_2strcat ("Write failed to ", file)
: xy_2strcat ("写入文件失败: ", file); : xy_2strcat ("写入文件失败: ", file);
chsrc_error2 (msg); chsrc_error2 (msg);

View File

@ -10,7 +10,7 @@
* | BingChunMoLi <bingchunmoli@bingchunmoli.com> * | BingChunMoLi <bingchunmoli@bingchunmoli.com>
* | * |
* Created On : <2023-08-29> * Created On : <2023-08-29>
* Last Modified : <2025-10-07> * Last Modified : <2025-08-27>
* *
* *
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/

View File

@ -1,23 +0,0 @@
/** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Name : version.h
* File Authors : <ccmywish@qq.com>
* | Mikachu2333 <mikachu.23333@zohomail.com>
* Contributors : Nil Null <nil@null.org>
* |
* Created On : <2025-10-10>
* Last Modified : <See 'Chsrc_Release_Date'>
*
*
* ------------------------------------------------------------*/
#define Chsrc_Version "0.2.4"
// 以下四个宏仅用于 resource/chsrc.rc
#define Chsrc_Version_Major 0
#define Chsrc_Version_Minor 2
#define Chsrc_Version_Patch 4
#define Chsrc_Version_Pre 0
#define Chsrc_Release_Date "2025/12/31"

File diff suppressed because one or more lines are too long

View File

@ -5,7 +5,7 @@
! Config Authors: 曾奥然 <ccmywish@qq.com> ! Config Authors: 曾奥然 <ccmywish@qq.com>
! Contributors : Nil Null <nil@null.org> ! Contributors : Nil Null <nil@null.org>
! Created On : <2025-07-22> ! Created On : <2025-07-22>
! Last Modified : <2025-10-29> ! Last Modified : <2025-08-22>
! ---------------------------------------------------------- --> ! ---------------------------------------------------------- -->
# [rawstr4c] input for chsrc # [rawstr4c] input for chsrc
@ -132,36 +132,16 @@ MAINTAIN:
## for `chsrc -v` ## for `chsrc -v`
- name = `for__v_CHINESE` - name = `for__v`
``` ```
chsrc @ver@ chsrc @ver@
Copyright (C) 2025 Aoran Zeng, Heng Guo
Copyright (C) 2023-2025 曾奥然, 郭恒
许可证 GPLv3+GNU GPL 第 3 版或更高版本 <https://gnu.org/licenses/gpl.html>
这是自由软件:您可以自由修改和分发它。
在法律允许的最大范围内,本软件按'原样'提供,不作任何明示或暗示的保证。
由作者曾奥然、郭恒协作者Mikachu2333、Happy Game 以及各位贡献者开发。(详见 chsrc-main.c, 或 `chsrc ls <target>`)
```
<br>
## for `chsrc -v -en`
- name = `for__v_ENGLISH`
```
chsrc @ver@
Copyright (C) 2023-2025 Aoran Zeng, Heng Guo
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html> License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it. This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. There is NO WARRANTY, to the extent permitted by law.
Written by authors: Aoran Zeng, Heng Guo, collaborators: Mikachu2333, Happy Game, and contributors. (See chsrc-main.c, or `chsrc ls <target>`) Written by Aoran Zeng, Heng Guo and contributors. (See chsrc-main.c)
``` ```
<br> <br>

View File

@ -18,7 +18,7 @@ pl_clojure_prelude ()
chef_set_sauciers (this, 1, "@hezonglun"); chef_set_sauciers (this, 1, "@hezonglun");
chef_allow_local_mode (this, FullyCan, NULL, NULL); chef_allow_local_mode (this, FullyCan, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_allow_user_define(this); chef_allow_user_define(this);
def_sources_begin() def_sources_begin()

View File

@ -32,7 +32,7 @@ pl_go_prelude ()
chef_set_sauciers (this, 2, "@czyt", "@techoc"); chef_set_sauciers (this, 2, "@czyt", "@techoc");
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_allow_user_define(this); chef_allow_user_define(this);

View File

@ -18,7 +18,7 @@ pl_haskell_prelude ()
chef_set_sauciers (this, 1, "@hezonglun"); chef_set_sauciers (this, 1, "@hezonglun");
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_allow_user_define(this); chef_allow_user_define(this);
def_sources_begin() def_sources_begin()

View File

@ -18,7 +18,7 @@ pl_java_prelude ()
chef_set_sauciers (this, 0); chef_set_sauciers (this, 0);
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_allow_user_define(this); chef_allow_user_define(this);
// 阿里巴巴开源镜像站需要修改为此才能测速 // 阿里巴巴开源镜像站需要修改为此才能测速

View File

@ -25,7 +25,7 @@ pl_lua_prelude ()
chef_set_sauciers (this, 1, "@hezonglun"); chef_set_sauciers (this, 1, "@hezonglun");
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_allow_user_define(this); chef_allow_user_define(this);
def_sources_begin() def_sources_begin()

View File

@ -18,8 +18,8 @@ pl_nuget_prelude ()
chef_set_sauciers (this, 0); chef_set_sauciers (this, 0);
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
def_sources_begin() def_sources_begin()
{&UpstreamProvider, "https://www.nuget.org/api/v3/", DelegateToUpstream}, {&UpstreamProvider, "https://www.nuget.org/api/v3/", DelegateToUpstream},

View File

@ -18,7 +18,7 @@ pl_ocaml_prelude ()
chef_set_sauciers (this, 1, "@hezonglun"); chef_set_sauciers (this, 1, "@hezonglun");
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_allow_user_define(this); chef_allow_user_define(this);
def_sources_begin() def_sources_begin()

View File

@ -18,7 +18,7 @@ pl_php_prelude ()
chef_set_sauciers (this, 1, "@hezonglun"); chef_set_sauciers (this, 1, "@hezonglun");
chef_allow_local_mode (this, FullyCan, NULL, NULL); chef_allow_local_mode (this, FullyCan, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_allow_user_define(this); chef_allow_user_define(this);
def_sources_begin() def_sources_begin()

View File

@ -10,36 +10,26 @@ pl_perl_prelude ()
chef_prep_this (pl_perl, gs); chef_prep_this (pl_perl, gs);
chef_set_created_on (this, "2023-09-31"); chef_set_created_on (this, "2023-09-31");
chef_set_last_updated (this, "2025-10-07"); chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2025-10-07"); chef_set_sources_last_updated (this, "2025-08-21");
chef_set_chef (this, NULL); chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish"); chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 2, "@hezonglun", "@Mikachu2333"); chef_set_sauciers (this, 1, "@hezonglun");
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english (this); chef_forbid_english(this);
chef_allow_user_define (this); chef_allow_user_define(this);
def_sources_begin() def_sources_begin()
{&UpstreamProvider, "https://www.cpan.org/", FeedByPrelude}, {&UpstreamProvider, "https://www.cpan.org/", DelegateToUpstream},
{&MirrorZ, "https://mirrors.cernet.edu.cn/CPAN/", FeedByPrelude}, {&Bfsu, "https://mirrors.bfsu.edu.cn/CPAN/", DelegateToMirror},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/CPAN/", FeedByPrelude}, {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/CPAN/", DelegateToMirror},
{&Bfsu, "https://mirrors.bfsu.edu.cn/CPAN/", FeedByPrelude}, {&Bjtu, "https://mirror.bjtu.edu.cn/cpan/", DelegateToMirror},
{&Cqu, "https://mirrors.cqu.edu.cn/CPAN/", FeedByPrelude}, {&Hust, "https://mirrors.hust.edu.cn/CPAN/", DelegateToMirror},
{&Bjtu, "https://mirror.bjtu.edu.cn/cpan/", FeedByPrelude}, {&Ali, "https://mirrors.aliyun.com/CPAN/", DelegateToMirror},
{&Nju, "https://mirrors.nju.edu.cn/CPAN/", FeedByPrelude}, {&Lzuoss, "https://mirror.lzu.edu.cn/CPAN/", DelegateToMirror}
{&Nyist, "https://mirror.nyist.edu.cn/CPAN/", FeedByPrelude},
{&Ustc, "https://mirrors.ustc.edu.cn/CPAN/", FeedByPrelude},
{&Sjtug_Siyuan, "https://mirror.sjtu.edu.cn/cpan/", FeedByPrelude},
{&Iscas, "https://mirror.iscas.ac.cn/CPAN/", FeedByPrelude},
{&Zju, "https://mirrors.zju.edu.cn/CPAN/", FeedByPrelude},
{&Lzuoss, "https://mirrors.lzu.edu.cn/CPAN/", FeedByPrelude},
{&Hust, "https://mirrors.hust.edu.cn/CPAN/", FeedByPrelude},
{&Ali, "https://mirrors.aliyun.com/CPAN/", FeedByPrelude}
def_sources_end() def_sources_end()
chef_set_sources_speed_measure_url_with_postfix (this, "authors/id/D/DB/DBAURAIN/Bio-MUST-Apps-FortyTwo-0.213470.tar.gz");
} }

View File

@ -1,11 +1,11 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* ------------------------------------------------------------- * -------------------------------------------------------------
* File Authors : @ccmywish * File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : @happy-game * Contributors : happy game <happygame1024@gmail.com>
* | * |
* Created On : <2023-09-03> * Created On : <2023-09-03>
* Last Modified : <2025-12-31> * Last Modified : <2025-07-14>
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
void void

View File

@ -9,8 +9,7 @@ def_target(pl_python_group, "python/pypi/py");
/** /**
* @note ${host}/pipi/web/pacakges/56/e4.... * @note ${host}/pipi/web/pacakges/56/e4....
* packages * packages
* * @note 2025-09-29 pkg 40M
* @note 2025-09-29 pkg 40M
* *
* @warning 2025-09-29 Sjtug * @warning 2025-09-29 Sjtug
*/ */
@ -33,7 +32,7 @@ pl_python_group_prelude (void)
chef_prep_this (pl_python_group, gsr); chef_prep_this (pl_python_group, gsr);
chef_set_created_on (this, "2023-09-03"); chef_set_created_on (this, "2023-09-03");
chef_set_last_updated (this, "2025-12-31"); chef_set_last_updated (this, "2025-09-30");
chef_set_sources_last_updated (this, "2025-09-30"); chef_set_sources_last_updated (this, "2025-09-30");
chef_set_chef (this, "@happy-game"); chef_set_chef (this, "@happy-game");
@ -100,33 +99,11 @@ pl_python_get_py_program_name (char **prog_name)
*/ */
py_exist = chsrc_check_program ("python3"); py_exist = chsrc_check_program ("python3");
if (py_exist) if (py_exist) *prog_name = "python3";
{
*prog_name = "python3";
// https://github.com/RubyMetric/chsrc/issues/327
if (xy.on_windows)
{
int status = xy_run_get_status ("python3 --version");
if (status == 9009)
{
chsrc_error2 (CHINESE ? "用户环境中的 `python3` 命令,是微软商店的占位符,并非真正可用的 Python。请安装真正的 Python 后重试!"
: "`python3` in your environment is a placeholder of Microsoft Store, not the real Python which can be used, please install the real Python and try again!");
exit (Exit_UserCause);
}
}
}
else else
{ {
/** /* 不要调用 python 自己,而是使用 python --version或者其他方式
* : python 使Windows弹出Microsoft Store */
*
* $ python
*
* `python` 使 `python --version`
* `python` 使 Windows Microsoft Store
*/
py_exist = chsrc_check_program ("python"); py_exist = chsrc_check_program ("python");
if (py_exist) *prog_name = "python"; if (py_exist) *prog_name = "python";

View File

@ -1,22 +1,16 @@
#pragma once #pragma once
/** /**
* Generated by rawstr4c v1.1.0-2025/09/27 * Generated by rawstr4c v1.0.0-2025/08/09
*/ */
char RAWSTR_pl_python_uv_config_source_content[] = "\x5b\x5b\x69\x6e\x64\x65\x78\x5d\x5d\x0a\x75\x72\x6c\x20\x3d\x20\x22\x40\x75\x72\x6c\x40\x22\x0a\x64\x65\x66\x61\x75\x6c\x74\x20\x3d\x20\x74\x72\x75\x65\x0a"; char RAWSTR_pl_python_uv_config_source_content[] = "\x5b\x5b\x69\x6e\x64\x65\x78\x5d\x5d\x0a\x75\x72\x6c\x20\x3d\x20\x22\x40\x75\x72\x6c\x40\x22\x0a\x64\x65\x66\x61\x75\x6c\x74\x20\x3d\x20\x74\x72\x75\x65\x0a";
char RAWSTR_pl_python_get_uv_config[] = "\x67\x72\x65\x70\x20\x2d\x41\x20\x32\x20\x27\x69\x6e\x64\x65\x78\x27\x20\x40\x66\x40\x20\x7c\x20\x73\x65\x64\x20\x2d\x6e\x20\x27\x73\x2f\x5e\x75\x72\x6c\x20\x3d\x20\x22\x5c\x28\x2e\x2a\x5c\x29\x22\x2f\x5c\x31\x2f\x70\x27"; char RAWSTR_pl_python_get_uv_config[] = "\x67\x72\x65\x70\x20\x2d\x41\x20\x32\x20\x27\x69\x6e\x64\x65\x78\x27\x20\x40\x66\x40\x20\x7c\x20\x73\x65\x64\x20\x2d\x6e\x20\x27\x73\x2f\x5e\x75\x72\x6c\x20\x3d\x20\x22\x5c\x28\x2e\x2a\x5c\x29\x22\x2f\x5c\x31\x2f\x70\x27";
char RAWSTR_pl_python_get_uv_config_on_windows[] = "\x24\x6c\x69\x6e\x65\x73\x20\x3d\x20\x47\x65\x74\x2d\x43\x6f\x6e\x74\x65\x6e\x74\x20\x40\x66\x40\x3b\x0a\x0a\x66\x6f\x72\x28\x24\x69\x6e\x64\x65\x78\x3d\x30\x3b\x20\x24\x69\x6e\x64\x65\x78\x20\x2d\x6c\x74\x20\x24\x6c\x69\x6e\x65\x73\x2e\x43\x6f\x75\x6e\x74\x3b\x20\x24\x69\x6e\x64\x65\x78\x2b\x2b\x29\x20\x7b\x0a\x20\x20\x69\x66\x28\x24\x6c\x69\x6e\x65\x73\x5b\x24\x69\x6e\x64\x65\x78\x5d\x20\x2d\x6d\x61\x74\x63\x68\x20\x27\x5e\x5c\x5b\x5c\x5b\x69\x6e\x64\x65\x78\x5c\x5d\x5c\x5d\x24\x27\x29\x20\x7b\x0a\x20\x20\x20\x20\x24\x6c\x69\x6e\x65\x73\x5b\x24\x69\x6e\x64\x65\x78\x2e\x2e\x28\x24\x69\x6e\x64\x65\x78\x2b\x33\x29\x5d\x0a\x20\x20\x7d\x0a\x7d"; char RAWSTR_pl_python_set_uv_config[] = "\x40\x73\x65\x64\x40\x20\x27\x2f\x5e\x5c\x5b\x5c\x5b\x69\x6e\x64\x65\x78\x5c\x5d\x5c\x5d\x24\x2f\x2c\x2f\x5e\x64\x65\x66\x61\x75\x6c\x74\x20\x3d\x20\x74\x72\x75\x65\x24\x2f\x7b\x73\x7c\x5e\x75\x72\x6c\x20\x3d\x20\x22\x2e\x2a\x22\x24\x7c\x75\x72\x6c\x20\x3d\x20\x22\x40\x75\x72\x6c\x40\x22\x7c\x7d\x27\x20\x40\x66\x40";
char RAWSTR_pl_python_set_uv_config[] = "\x40\x73\x65\x64\x40\x20\x27\x2f\x5e\x5c\x5b\x5c\x5b\x69\x6e\x64\x65\x78\x5c\x5d\x5c\x5d\x24\x2f\x2c\x2f\x5e\x64\x65\x66\x61\x75\x6c\x74\x20\x3d\x20\x74\x72\x75\x65\x24\x2f\x7b\x73\x7c\x5e\x75\x72\x6c\x20\x3d\x20\x22\x2e\x2a\x22\x24\x7c\x75\x72\x6c\x20\x3d\x20\x22\x40\x75\x72\x6c\x40\x22\x7c\x3b\x7d\x27\x20\x40\x66\x40";
char RAWSTR_pl_python_set_uv_config_on_windows[] = "\x70\x6f\x77\x65\x72\x73\x68\x65\x6c\x6c\x20\x2d\x43\x6f\x6d\x6d\x61\x6e\x64\x20\x22\x24\x63\x6f\x6e\x74\x65\x6e\x74\x20\x3d\x20\x47\x65\x74\x2d\x43\x6f\x6e\x74\x65\x6e\x74\x20\x27\x40\x66\x40\x27\x3b\x20\x24\x63\x6f\x6e\x74\x65\x6e\x74\x20\x3d\x20\x24\x63\x6f\x6e\x74\x65\x6e\x74\x20\x2d\x72\x65\x70\x6c\x61\x63\x65\x20\x27\x5e\x75\x72\x6c\x20\x3d\x20\x5c\x22\x2e\x2a\x5c\x22\x24\x27\x2c\x20\x27\x75\x72\x6c\x20\x3d\x20\x5c\x22\x40\x75\x72\x6c\x40\x5c\x22\x27\x3b\x20\x24\x63\x6f\x6e\x74\x65\x6e\x74\x20\x7c\x20\x53\x65\x74\x2d\x43\x6f\x6e\x74\x65\x6e\x74\x20\x27\x40\x66\x40\x27\x22";
char RAWSTR_pl_python_test_uv_if_set_source[] = "\x67\x72\x65\x70\x20\x2d\x71\x20\x27\x5e\x5c\x5b\x5c\x5b\x69\x6e\x64\x65\x78\x5d\x5d\x24\x27\x20\x40\x66\x40"; char RAWSTR_pl_python_test_uv_if_set_source[] = "\x67\x72\x65\x70\x20\x2d\x71\x20\x27\x5e\x5c\x5b\x5c\x5b\x69\x6e\x64\x65\x78\x5d\x5d\x24\x27\x20\x40\x66\x40";
char RAWSTR_pl_python_test_uv_if_set_source_on_windows[] = "\x70\x6f\x77\x65\x72\x73\x68\x65\x6c\x6c\x20\x2d\x43\x6f\x6d\x6d\x61\x6e\x64\x20\x22\x69\x66\x20\x28\x47\x65\x74\x2d\x43\x6f\x6e\x74\x65\x6e\x74\x20\x40\x66\x40\x20\x7c\x20\x53\x65\x6c\x65\x63\x74\x2d\x53\x74\x72\x69\x6e\x67\x20\x27\x5e\x5c\x5b\x5c\x5b\x69\x6e\x64\x65\x78\x5c\x5d\x5c\x5d\x24\x27\x29\x20\x7b\x20\x65\x78\x69\x74\x20\x30\x20\x7d\x20\x65\x6c\x73\x65\x20\x7b\x20\x65\x78\x69\x74\x20\x31\x20\x7d\x22";
char RAWSTR_pl_python_rye_config[] = "\x5b\x5b\x73\x6f\x75\x72\x63\x65\x73\x5d\x5d\x0a\x6e\x61\x6d\x65\x20\x3d\x20\x22\x40\x31\x40\x22\x0a\x75\x72\x6c\x20\x20\x3d\x20\x22\x40\x32\x40\x22"; char RAWSTR_pl_python_rye_config[] = "\x5b\x5b\x73\x6f\x75\x72\x63\x65\x73\x5d\x5d\x0a\x6e\x61\x6d\x65\x20\x3d\x20\x22\x40\x31\x40\x22\x0a\x75\x72\x6c\x20\x20\x3d\x20\x22\x40\x32\x40\x22";

View File

@ -2,12 +2,11 @@
! SPDX-License-Identifier: GPL-3.0-or-later ! SPDX-License-Identifier: GPL-3.0-or-later
! ------------------------------------------------------------- ! -------------------------------------------------------------
! Config Type : rawstr4c (Markdown) ! Config Type : rawstr4c (Markdown)
! Config Authors: @ccmywish ! Config Authors: Aoran Zeng <ccmywish@qq.com>
! | @happy-game ! | happy game <happygame1024@gmail.com>
! | @MingriLingran ! Contributors : Nil Null <nil@null.org>
! Contributors : Nil Null <nil@null.org>
! Created On : <2025-07-14> ! Created On : <2025-07-14>
! Last Modified : <2025-12-29> ! Last Modified : <2025-08-09>
! ---------------------------------------------------------- --> ! ---------------------------------------------------------- -->
# rawstr4c input for Python # rawstr4c input for Python
@ -40,35 +39,10 @@ grep -A 2 'index' @f@ | sed -n 's/^url = "\(.*\)"/\1/p'
``` ```
### Get uv config on Windows
为什么不用 `Select-String`,原因见: <https://github.com/RubyMetric/chsrc/pull/328#issuecomment-3695577870>
还有另外一个好处:如果 `[[index]]` 配置被写入了多次,可以这样检查出来
我们倾向于使用脚本而非命令,因为内容较长,便于用户检查到底执行了什么内容。
```powershell
$lines = Get-Content @f@;
for($index=0; $index -lt $lines.Count; $index++) {
if($lines[$index] -match '^\[\[index\]\]$') {
$lines[$index..($index+3)]
}
}
```
### Set uv config ### Set uv config
```sh ```sh
@sed@ '/^\[\[index\]\]$/,/^default = true$/{s|^url = ".*"$|url = "@url@"|;}' @f@ @sed@ '/^\[\[index\]\]$/,/^default = true$/{s|^url = ".*"$|url = "@url@"|}' @f@
```
### Set uv config on Windows
```powershell
powershell -Command "$content = Get-Content '@f@'; $content = $content -replace '^url = \".*\"$', 'url = \"@url@\"'; $content | Set-Content '@f@'"
``` ```
@ -78,12 +52,6 @@ powershell -Command "$content = Get-Content '@f@'; $content = $content -replace
grep -q '^\[\[index]]$' @f@ grep -q '^\[\[index]]$' @f@
``` ```
### Test uv if set source on Windows
```powershell
powershell -Command "if (Get-Content @f@ | Select-String '^\[\[index\]\]$') { exit 0 } else { exit 1 }"
```
<br> <br>

View File

@ -10,11 +10,11 @@ pl_python_uv_prelude (void)
chef_prep_this (pl_python_uv, gsr); chef_prep_this (pl_python_uv, gsr);
chef_set_created_on (this, "2024-12-11"); chef_set_created_on (this, "2024-12-11");
chef_set_last_updated (this, "2025-12-29"); chef_set_last_updated (this, "2025-08-09");
chef_set_sources_last_updated (this, "2025-08-09"); chef_set_sources_last_updated (this, "2025-08-09");
chef_set_chef (this, NULL); chef_set_chef (this, NULL);
chef_set_cooks (this, 2, "@happy-game", "@MingriLingran"); chef_set_cooks (this, 1, "@happy-game");
chef_set_sauciers (this, 2, "@Kattos", "@ccmywish"); chef_set_sauciers (this, 2, "@Kattos", "@ccmywish");
chef_allow_local_mode (this, FullyCan, NULL, NULL); chef_allow_local_mode (this, FullyCan, NULL, NULL);
@ -91,18 +91,8 @@ pl_python_uv_getsrc (char *option)
} }
/* 获取 [[index]] 配置项的 url */ /* 获取 [[index]] 配置项的 url */
if (xy.on_windows) char *cmd = xy_str_gsub (RAWSTR_pl_python_get_uv_config, "@f@", uv_config);
{ chsrc_run (cmd, RunOpt_Default);
/* 在 Windows 上使用 PowerShell 替代 grep */
char *script = xy_str_gsub (RAWSTR_pl_python_get_uv_config_on_windows, "@f@", uv_config);
chsrc_run_as_powershell_file (script);
}
else
{
/* 在类 Unix 系统上使用 grep */
char *cmd = xy_str_gsub (RAWSTR_pl_python_get_uv_config, "@f@", uv_config);
chsrc_run (cmd, RunOpt_Default);
}
} }
@ -129,6 +119,19 @@ pl_python_uv_setsrc (char *option)
const char *source_content = xy_str_gsub (RAWSTR_pl_python_uv_config_source_content, "@url@", source.url); const char *source_content = xy_str_gsub (RAWSTR_pl_python_uv_config_source_content, "@url@", source.url);
#if defined(XY_Build_On_macOS) || defined(XY_Build_On_BSD)
char *sed_cmd = "sed -i '' ";
#else
char *sed_cmd = "sed -i ";
#endif
/**
* [[index]] default = true url = ".*" url = "source.url"
*/
char *update_config_cmd = xy_str_gsub (RAWSTR_pl_python_set_uv_config, "@sed@", sed_cmd);
update_config_cmd = xy_str_gsub (update_config_cmd, "@f@", uv_config);
update_config_cmd = xy_str_gsub (update_config_cmd, "@url@", source.url);
if (!xy_file_exist (uv_config)) if (!xy_file_exist (uv_config))
{ {
/* 当 uv_config 不存在,直接写入文件 */ /* 当 uv_config 不存在,直接写入文件 */
@ -137,41 +140,12 @@ pl_python_uv_setsrc (char *option)
else else
{ {
/* 当 uv_config 存在,如果存在 [[index]] 则更新,否则追加到文件末尾 */ /* 当 uv_config 存在,如果存在 [[index]] 则更新,否则追加到文件末尾 */
char *cmd = NULL; char *cmd = xy_str_gsub (RAWSTR_pl_python_test_uv_if_set_source, "@f@", uv_config);
if (xy.on_windows) chsrc_ensure_program ("grep");
{
/* 在 Windows 上使用 PowerShell 替代 grep */
cmd = xy_str_gsub (RAWSTR_pl_python_test_uv_if_set_source_on_windows, "@f@", uv_config);
}
else
{
cmd = xy_str_gsub (RAWSTR_pl_python_test_uv_if_set_source, "@f@", uv_config);
}
int status = xy_run_get_status (cmd); int status = xy_run_get_status (cmd);
if (0==status) if (0==status)
{ {
if (xy.on_windows) chsrc_run (update_config_cmd, RunOpt_Default);
{
/* 在 Windows 上使用 PowerShell 替代 sed */
char *powershell_cmd_with_file = xy_str_gsub(RAWSTR_pl_python_set_uv_config_on_windows, "@f@", uv_config);
char *powershell_cmd = xy_str_gsub(powershell_cmd_with_file, "@url@", source.url);
chsrc_run (powershell_cmd, RunOpt_Default);
}
else
{
/* 非 Windows 系统使用 sed */
char *sed_cmd = NULL;
#if defined(XY_Build_On_macOS) || defined(XY_Build_On_BSD)
sed_cmd = "sed -i '' ";
#else
sed_cmd = "sed -i ";
#endif
char *update_config_cmd = xy_str_gsub (RAWSTR_pl_python_set_uv_config, "@sed@", sed_cmd);
update_config_cmd = xy_str_gsub (update_config_cmd, "@f@", uv_config);
update_config_cmd = xy_str_gsub (update_config_cmd, "@url@", source.url);
chsrc_run (update_config_cmd, RunOpt_Default);
}
} }
else else
{ {

View File

@ -18,7 +18,7 @@ pl_r_prelude ()
chef_set_sauciers (this, 1, "@hezonglun"); chef_set_sauciers (this, 1, "@hezonglun");
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_allow_user_define(this); chef_allow_user_define(this);
// 以下注释的是不含有bioconductor的镜像站我们在换cran的同时也直接帮助用户换bioconductor // 以下注释的是不含有bioconductor的镜像站我们在换cran的同时也直接帮助用户换bioconductor

View File

@ -54,7 +54,7 @@ bool
pl_ruby_remove_gem_source (const char *source) pl_ruby_remove_gem_source (const char *source)
{ {
char *cmd = NULL; char *cmd = NULL;
if (hp_is_url (source)) if (chef_is_url (source))
{ {
cmd = xy_2strcat ("gem sources -r ", source); cmd = xy_2strcat ("gem sources -r ", source);
chsrc_run (cmd, RunOpt_Default); chsrc_run (cmd, RunOpt_Default);

View File

@ -2,9 +2,6 @@
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
#define PL_Rust_cargo_default_download_url "https://static.crates.io/crates/windows/windows-0.62.2.crate"
#define PL_Rust_cargo_custom_download_url "api/v1/crates/windows/0.62.2/download"
def_target(pl_rust_cargo, "rust/cargo/crate/crates"); def_target(pl_rust_cargo, "rust/cargo/crate/crates");
void void
@ -13,45 +10,41 @@ pl_rust_cargo_prelude (void)
chef_prep_this (pl_rust_cargo, gsr); chef_prep_this (pl_rust_cargo, gsr);
chef_set_created_on (this, "2023-08-30"); chef_set_created_on (this, "2023-08-30");
chef_set_last_updated (this, "2025-12-31"); chef_set_last_updated (this, "2025-10-06");
chef_set_sources_last_updated (this, "2025-12-31"); chef_set_sources_last_updated (this, "2025-06-18");
chef_set_chef (this, NULL); chef_set_chef (this, NULL);
chef_set_cooks (this, 2, "@Mikachu2333", "@ccmywish"); chef_set_cooks (this, 2, "@Mikachu2333", "@ccmywish");
chef_set_sauciers (this, 1, "@happy-game"); chef_set_sauciers (this, 1, "@happy-game");
chef_allow_local_mode (this, FullyCan, NULL, NULL); chef_allow_local_mode (this, FullyCan, NULL, NULL);
chef_deny_english (this); chef_forbid_english (this);
chef_allow_user_define (this); chef_allow_user_define (this);
// 以下都支持稀疏索引,我们换源时都将默认添加 `sparse+`。链接末尾的 `/` 不能缺少 // 以下都支持稀疏索引,我们换源时都将默认添加 `sparse+`。链接末尾的 `/` 不能缺少
/**
* @warning 2025-12-29:
* dl static.crates.io static.crates.ioAPI失效
* : https://github.com/RubyMetric/chsrc/pull/330
*/
def_sources_begin() def_sources_begin()
{&UpstreamProvider, "https://crates.io/", PL_Rust_cargo_default_download_url}, {&UpstreamProvider, "https://crates.io/", FeedByPrelude},
{&MirrorZ, "https://mirrors.cernet.edu.cn/crates.io-index/", PL_Rust_cargo_default_download_url}, {&MirrorZ, "https://mirrors.cernet.edu.cn/crates.io-index/", FeedByPrelude},
{&RsProxyCN, "https://rsproxy.cn/index/", "https://rsproxy.cn/" PL_Rust_cargo_custom_download_url}, {&RsProxyCN, "https://rsproxy.cn/index/", FeedByPrelude},
{&Ali, "https://mirrors.aliyun.com/crates.io-index/", "https://mirrors.aliyun.com/crates/" PL_Rust_cargo_custom_download_url}, {&Ali, "https://mirrors.aliyun.com/crates.io-index/", FeedByPrelude},
{&Zju, "https://mirrors.zju.edu.cn/crates.io-index/", PL_Rust_cargo_default_download_url}, {&Zju, "https://mirrors.zju.edu.cn/crates.io-index/", FeedByPrelude},
/* 注释原因: (2025-06-17) 镜像同步失败,多数包都不可用 */ /* 注释原因: (2025-06-17) 镜像同步失败,多数包都不可用 */
// {&Nju, "https://mirror.nju.edu.cn/git/crates.io-index.git/", FeedByPrelude}, // {&Nju, "https://mirror.nju.edu.cn/git/crates.io-index.git/", FeedByPrelude},
{&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/crates.io-index/", "https://mirror.sjtu.edu.cn/crates.io/crates/windows/windows-0.58.0.crate"}, {&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/crates.io-index/", FeedByPrelude},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/crates.io-index/",PL_Rust_cargo_default_download_url}, {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/crates.io-index/",FeedByPrelude},
{&Bfsu, "https://mirrors.bfsu.edu.cn/crates.io-index/", PL_Rust_cargo_default_download_url}, {&Bfsu, "https://mirrors.bfsu.edu.cn/crates.io-index/", FeedByPrelude},
{&Ustc, "https://mirrors.ustc.edu.cn/crates.io-index/", "https://crates-io.proxy.ustclug.org/" PL_Rust_cargo_custom_download_url}, {&Ustc, "https://mirrors.ustc.edu.cn/crates.io-index/", FeedByPrelude},
/* 注释原因: (2025-06-17) 镜像同步失败,多数包都不可用 */ /* 注释原因: (2025-06-17) 镜像同步失败,多数包都不可用 */
// {&Hust, "https://mirrors.hust.edu.cn/crates.io-index/", FeedByPrelude}, // {&Hust, "https://mirrors.hust.edu.cn/crates.io-index/", FeedByPrelude},
{&Cqu, "https://mirrors.cqu.edu.cn/crates.io-index/", PL_Rust_cargo_default_download_url} {&Cqu, "https://mirrors.cqu.edu.cn/crates.io-index/", FeedByPrelude}
def_sources_end() def_sources_end()
chef_set_sources_speed_measure_url_with_postfix (this, "api/v1/crates/windows/0.58.0/download");
} }
@ -82,6 +75,7 @@ pl_rust_cargo_getsrc (char *option)
char *raw_content = xy_file_read (cargo_config_file); char *raw_content = xy_file_read (cargo_config_file);
char *formatted_content = xy_str_gsub (raw_content, " ", ""); char *formatted_content = xy_str_gsub (raw_content, " ", "");
formatted_content = xy_str_gsub (formatted_content, "'", "\""); formatted_content = xy_str_gsub (formatted_content, "'", "\"");
free (raw_content);
XyStrFindResult_t result_has_mirror = xy_str_find (formatted_content, "replace-with"); XyStrFindResult_t result_has_mirror = xy_str_find (formatted_content, "replace-with");
if (result_has_mirror.found) if (result_has_mirror.found)
@ -118,6 +112,7 @@ pl_write_rust_config (const char *path, const char *url)
char *content = RAWSTR_pl_rust_cargo_config; char *content = RAWSTR_pl_rust_cargo_config;
content = xy_str_gsub (content, "@url@", url); content = xy_str_gsub (content, "@url@", url);
chsrc_overwrite_file (content, path); chsrc_overwrite_file (content, path);
free (content);
} }
/** /**
@ -177,6 +172,7 @@ pl_rust_cargo_setsrc (char *option)
char *final_content = xy_str_gsub (raw_content, mirror_url, xy_2strcat ("sparse+", source.url)); char *final_content = xy_str_gsub (raw_content, mirror_url, xy_2strcat ("sparse+", source.url));
chsrc_overwrite_file (final_content, cargo_config_file); chsrc_overwrite_file (final_content, cargo_config_file);
free (final_content);
goto finish; goto finish;
} }

View File

@ -21,7 +21,7 @@ pl_rust_rustup_prelude (void)
chef_set_sauciers (this, 2, "@Yangmoooo", "@Mikachu2333"); chef_set_sauciers (this, 2, "@Yangmoooo", "@Mikachu2333");
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english (this); chef_forbid_english (this);
chef_allow_user_define(this); chef_allow_user_define(this);
def_sources_begin() def_sources_begin()

View File

@ -18,8 +18,8 @@ os_armbian_prelude ()
chef_set_sauciers (this, 2, "@ccmywish", "@Yangmoooo"); chef_set_sauciers (this, 2, "@ccmywish", "@Yangmoooo");
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
chef_set_note(this, NULL, NULL); chef_set_note(this, NULL, NULL);

View File

@ -10,7 +10,7 @@ os_debian_prelude ()
chef_prep_this (os_debian, gsr); chef_prep_this (os_debian, gsr);
chef_set_created_on (this, "2023-09-02"); chef_set_created_on (this, "2023-09-02");
chef_set_last_updated (this, "2025-11-09"); chef_set_last_updated (this, "2025-09-12");
chef_set_sources_last_updated (this, "2025-07-11"); chef_set_sources_last_updated (this, "2025-07-11");
chef_set_chef (this, NULL); chef_set_chef (this, NULL);
@ -18,14 +18,14 @@ os_debian_prelude ()
chef_set_sauciers (this, 1, "@Yangmoooo"); chef_set_sauciers (this, 1, "@Yangmoooo");
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
chef_set_note(this, NULL, NULL); chef_set_note(this, NULL, NULL);
def_sources_begin() def_sources_begin()
{&UpstreamProvider, "http://deb.debian.org/debian", FeedByPrelude}, {&UpstreamProvider, "http://deb.debian.org/debian", FeedByPrelude},
{&MirrorZ, "https://mirrors.cernet.edu.cn/debian", FeedByPrelude}, {&MirrorZ, "https://mirrors.cernet.edu.cn/debian/", FeedByPrelude},
{&Ali, "https://mirrors.aliyun.com/debian", FeedByPrelude}, {&Ali, "https://mirrors.aliyun.com/debian", FeedByPrelude},
{&Volcengine, "https://mirrors.volces.com/debian", FeedByPrelude}, {&Volcengine, "https://mirrors.volces.com/debian", FeedByPrelude},
{&Bfsu, "https://mirrors.bfsu.edu.cn/debian", FeedByPrelude}, {&Bfsu, "https://mirrors.bfsu.edu.cn/debian", FeedByPrelude},

View File

@ -18,8 +18,8 @@ os_kali_prelude ()
chef_set_sauciers (this, 2, "@Yangmoooo", "@happy-game"); chef_set_sauciers (this, 2, "@Yangmoooo", "@happy-game");
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
chef_set_note(this, NULL, NULL); chef_set_note(this, NULL, NULL);

View File

@ -18,8 +18,8 @@ os_linuxlite_prelude ()
chef_set_sauciers (this, 1, "@Yangmoooo"); chef_set_sauciers (this, 1, "@Yangmoooo");
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
chef_set_note(this, NULL, NULL); chef_set_note(this, NULL, NULL);

View File

@ -18,8 +18,8 @@ os_linuxmint_prelude ()
chef_set_sauciers (this, 1, "@happy-game"); chef_set_sauciers (this, 1, "@happy-game");
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
/* @note 实际上镜像站里的内容和Ubuntu的不太一样 */ /* @note 实际上镜像站里的内容和Ubuntu的不太一样 */

View File

@ -18,8 +18,8 @@ os_ros_prelude ()
chef_set_sauciers (this, 2, "@ccmywish", "@zouri"); chef_set_sauciers (this, 2, "@ccmywish", "@zouri");
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
chef_set_note(this, "该换源方案中URL存在拼凑因此不能手动使用某URL来换源", "In this switching method, URLs are constructed, so manual URL specification is not supported"); chef_set_note(this, "该换源方案中URL存在拼凑因此不能手动使用某URL来换源", "In this switching method, URLs are constructed, so manual URL specification is not supported");

View File

@ -20,8 +20,8 @@ os_raspberrypi_prelude ()
chef_set_sauciers (this, 1, "@Yangmoooo"); chef_set_sauciers (this, 1, "@Yangmoooo");
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
chef_set_note(this, NULL, NULL); chef_set_note(this, NULL, NULL);

View File

@ -18,8 +18,8 @@ os_termux_prelude ()
chef_set_sauciers (this, 0); chef_set_sauciers (this, 0);
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
chef_set_note(this, "该 recipe 存在对应的 bootstrapper", "This recipe has a corresponding bootstrapper"); chef_set_note(this, "该 recipe 存在对应的 bootstrapper", "This recipe has a corresponding bootstrapper");

View File

@ -20,8 +20,8 @@ os_trisquel_prelude ()
chef_set_sauciers (this, 0); chef_set_sauciers (this, 0);
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
chef_set_note(this, NULL, NULL); chef_set_note(this, NULL, NULL);

View File

@ -19,8 +19,8 @@ os_ubuntu_prelude ()
chef_set_sauciers (this, 1, "@XUANJI233"); chef_set_sauciers (this, 1, "@XUANJI233");
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
chef_set_note(this, NULL, NULL); chef_set_note(this, NULL, NULL);

View File

@ -18,8 +18,8 @@ os_deepin_prelude ()
chef_set_sauciers (this, 1, "@Yangmoooo"); chef_set_sauciers (this, 1, "@Yangmoooo");
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
chef_set_note(this, NULL, NULL); chef_set_note(this, NULL, NULL);

View File

@ -21,8 +21,8 @@ os_openkylin_prelude ()
chef_set_sauciers (this, 1, "@ccmywish"); chef_set_sauciers (this, 1, "@ccmywish");
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
chef_set_note(this, NULL, NULL); chef_set_note(this, NULL, NULL);

View File

@ -19,7 +19,7 @@ os_alpine_prelude ()
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_allow_english(this); chef_allow_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
chef_set_note(this, NULL, NULL); chef_set_note(this, NULL, NULL);

View File

@ -18,8 +18,8 @@ os_freebsd_prelude ()
chef_set_sauciers (this, 1, "@hezonglun"); chef_set_sauciers (this, 1, "@hezonglun");
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
// 2023-09-24: 以下三个USTC, NJU, Netease 均维护了 freebsd-pkg freebsd-ports // 2023-09-24: 以下三个USTC, NJU, Netease 均维护了 freebsd-pkg freebsd-ports

View File

@ -19,8 +19,8 @@ os_netbsd_prelude ()
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
def_sources_begin() def_sources_begin()
{&UpstreamProvider, "http://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/", DelegateToUpstream}, {&UpstreamProvider, "http://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/", DelegateToUpstream},
@ -66,7 +66,7 @@ os_netbsd_setsrc (char *option)
char *vercmd = "cat /etc/os-release | grep \"VERSION=\" | grep -Po \"[8-9].[0-9]+\""; char *vercmd = "cat /etc/os-release | grep \"VERSION=\" | grep -Po \"[8-9].[0-9]+\"";
char *version = xy_run (vercmd, 0); char *version = xy_run (vercmd, 0);
char *url = xy_strcat (5, hp_ensure_trailing_slash (source.url), arch, "/", version, "/All"); char *url = xy_strcat (5, chef_ensure_trailing_slash (source.url), arch, "/", version, "/All");
chsrc_overwrite_file (url, "/usr/pkg/etc/pkgin/repositories.conf"); chsrc_overwrite_file (url, "/usr/pkg/etc/pkgin/repositories.conf");
chsrc_conclude (&source); chsrc_conclude (&source);

View File

@ -18,8 +18,8 @@ os_openbsd_prelude ()
chef_set_sauciers (this, 1, "@hezonglun"); chef_set_sauciers (this, 1, "@hezonglun");
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
def_sources_begin() def_sources_begin()
{&UpstreamProvider, "https://cdn.openbsd.org/pub/OpenBSD/", DelegateToUpstream}, {&UpstreamProvider, "https://cdn.openbsd.org/pub/OpenBSD/", DelegateToUpstream},

View File

@ -19,7 +19,7 @@ os_gentoo_prelude ()
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_allow_english(this); chef_allow_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
chef_set_note(this, NULL, NULL); chef_set_note(this, NULL, NULL);

View File

@ -19,7 +19,7 @@ os_solus_prelude ()
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_allow_user_define(this); chef_allow_user_define(this);
chef_set_note(this, NULL, NULL); chef_set_note(this, NULL, NULL);

View File

@ -18,7 +18,7 @@ os_voidlinux_prelude ()
chef_set_sauciers (this, 1, "@Yangmoooo"); chef_set_sauciers (this, 1, "@Yangmoooo");
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_set_note(this, NULL, NULL); chef_set_note(this, NULL, NULL);

View File

@ -18,8 +18,8 @@ os_almalinux_prelude ()
chef_set_sauciers (this, 1, "@Yangmoooo"); chef_set_sauciers (this, 1, "@Yangmoooo");
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
chef_set_note(this, NULL, NULL); chef_set_note(this, NULL, NULL);

View File

@ -18,8 +18,8 @@ os_anolis_prelude ()
chef_set_sauciers (this, 0); chef_set_sauciers (this, 0);
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
chef_set_note(this, NULL, NULL); chef_set_note(this, NULL, NULL);

View File

@ -18,8 +18,8 @@ os_fedora_prelude ()
chef_set_sauciers (this, 1, "@ccmywish"); chef_set_sauciers (this, 1, "@ccmywish");
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
chef_set_note(this, NULL, NULL); chef_set_note(this, NULL, NULL);

View File

@ -18,8 +18,8 @@ os_rockylinux_prelude ()
chef_set_sauciers (this, 1, "@happy-game"); chef_set_sauciers (this, 1, "@happy-game");
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
def_sources_begin() def_sources_begin()
{&UpstreamProvider, "https://dl.rockylinux.org", DelegateToUpstream}, {&UpstreamProvider, "https://dl.rockylinux.org", DelegateToUpstream},

View File

@ -18,8 +18,8 @@ os_openeuler_prelude ()
chef_set_sauciers (this, 3, "@ccmywish", "@Yangmoooo", "@happy-game"); chef_set_sauciers (this, 3, "@ccmywish", "@Yangmoooo", "@happy-game");
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
chef_set_note(this, NULL, NULL); chef_set_note(this, NULL, NULL);

View File

@ -18,8 +18,8 @@ os_opensuse_prelude ()
chef_set_sauciers (this, 0); chef_set_sauciers (this, 0);
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
chef_set_note(this, NULL, NULL); chef_set_note(this, NULL, NULL);

View File

@ -13,7 +13,7 @@ os_arch_prelude ()
chef_prep_this (os_arch, gs); chef_prep_this (os_arch, gs);
chef_set_created_on (this, "2023-09-05"); chef_set_created_on (this, "2023-09-05");
chef_set_last_updated (this, "2025-10-30"); chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2025-06-20"); chef_set_sources_last_updated (this, "2025-06-20");
chef_set_chef (this, "@happy-game"); chef_set_chef (this, "@happy-game");
@ -21,8 +21,8 @@ os_arch_prelude ()
chef_set_sauciers (this, 2, "@happy-game", "@Young-Lord"); chef_set_sauciers (this, 2, "@happy-game", "@Young-Lord");
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
chef_set_note (this, chef_set_note (this,
"可额外使用 chsrc set archlinuxcn 来更换 Arch Linux CN Repository 源", "可额外使用 chsrc set archlinuxcn 来更换 Arch Linux CN Repository 源",
@ -78,12 +78,12 @@ os_arch_setsrc (char *option)
if (strncmp(arch, "x86_64", 6)==0) if (strncmp(arch, "x86_64", 6)==0)
{ {
is_x86 = true; is_x86 = true;
to_write = xy_strcat (3, "Server = ", source.url, "/$repo/os/$arch\n"); to_write = xy_strcat (3, "Server = ", source.url, "/$repo/os/$arch");
} }
else else
{ {
is_x86 = false; is_x86 = false;
to_write = xy_strcat (3, "Server = ", source.url, "arm/$arch/$repo\n"); to_write = xy_strcat (3, "Server = ", source.url, "arm/$arch/$repo");
} }
/* 配置文件中,越前面的优先级越高 */ /* 配置文件中,越前面的优先级越高 */
@ -124,8 +124,8 @@ os_archlinuxcn_prelude ()
chef_set_sauciers (this, 2, "@happy-game", "@Young-Lord"); chef_set_sauciers (this, 2, "@happy-game", "@Young-Lord");
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
chef_set_note (this, chef_set_note (this,
"可额外使用 chsrc set arch 来更换 Arch Linux 源", "可额外使用 chsrc set arch 来更换 Arch Linux 源",

View File

@ -18,8 +18,8 @@ os_msys2_prelude ()
chef_set_sauciers (this, 2, "@ccmywish", "@hezonglun"); chef_set_sauciers (this, 2, "@ccmywish", "@hezonglun");
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
def_sources_begin() def_sources_begin()
{&UpstreamProvider, "https://mirror.msys2.org/", DelegateToUpstream}, {&UpstreamProvider, "https://mirror.msys2.org/", DelegateToUpstream},

View File

@ -17,8 +17,8 @@ os_manjaro_prelude ()
chef_set_sauciers (this, 0); chef_set_sauciers (this, 0);
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
def_sources_begin() def_sources_begin()
{&UpstreamProvider, NULL, DelegateToUpstream} {&UpstreamProvider, NULL, DelegateToUpstream}

View File

@ -73,10 +73,10 @@ void
chef_allow_local_mode (this, PartiallyCan, "具体说明是否支持项目级换源...", "Tell users the local mode support"); chef_allow_local_mode (this, PartiallyCan, "具体说明是否支持项目级换源...", "Tell users the local mode support");
// chef_allow_english(this); // 项目是否支持英文 // chef_allow_english(this); // 项目是否支持英文
chef_deny_english(this); chef_forbid_english(this);
// chef_allow_user_define(this); // 是否支持用户自定义镜像源 // chef_allow_user_define(this); // 是否支持用户自定义镜像源
chef_deny_user_define(this); chef_forbid_user_define(this);
chef_set_note ("中文备注说明...", "English note..."); chef_set_note ("中文备注说明...", "English note...");

View File

@ -20,8 +20,8 @@ wr_anaconda_prelude ()
chef_set_sauciers (this, 2, "@Yangmoooo", "@xyx1926885268"); chef_set_sauciers (this, 2, "@Yangmoooo", "@xyx1926885268");
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
def_sources_begin() def_sources_begin()
{&UpstreamProvider, "https://repo.anaconda.com", DelegateToUpstream}, {&UpstreamProvider, "https://repo.anaconda.com", DelegateToUpstream},

View File

@ -19,7 +19,7 @@ wr_cocoapods_prelude ()
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_allow_user_define(this); chef_allow_user_define(this);
def_sources_begin() def_sources_begin()

View File

@ -35,7 +35,7 @@ wr_docker_prelude ()
chef_set_sauciers (this, 0); chef_set_sauciers (this, 0);
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_allow_user_define(this); chef_allow_user_define(this);
def_sources_begin() def_sources_begin()

View File

@ -25,8 +25,8 @@ wr_emacs_prelude ()
chef_set_sauciers (this, 0); chef_set_sauciers (this, 0);
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
chef_set_note (this, "Emacs用户往往只需要一次性换源只会极少次调用 chsrc我们只给用户提供文档", 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"); "Emacs users typically only need to switch sources once and rarely call chsrc, so we only provide documentation to users");

View File

@ -18,7 +18,7 @@ wr_flatpak_prelude ()
chef_set_sauciers (this, 1, "@jialinlvcn"); chef_set_sauciers (this, 1, "@jialinlvcn");
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_allow_user_define(this); chef_allow_user_define(this);
chef_set_note (this, "对Flathub目标进行测速的文件非常小测速效果严重失真若你知道可供测速的URL欢迎参与贡献: chsrc issue", chef_set_note (this, "对Flathub目标进行测速的文件非常小测速效果严重失真若你知道可供测速的URL欢迎参与贡献: chsrc issue",

View File

@ -18,8 +18,8 @@ wr_guix_prelude ()
chef_set_sauciers (this, 0); chef_set_sauciers (this, 0);
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
chef_set_note (this, "目前只有一个源, guixcn 的源不知道是否可用", chef_set_note (this, "目前只有一个源, guixcn 的源不知道是否可用",
"Currently only one source available, guixcn source availability unknown"); "Currently only one source available, guixcn source availability unknown");

View File

@ -21,7 +21,7 @@ wr_homebrew_prelude ()
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_allow_english(this); chef_allow_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
chef_set_note (this, "该换源通过写入环境变量实现若多次换源请手动清理profile文件", 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"); "This source switching is implemented by writing environment variables. If switching sources multiple times, please manually clean the profile file");

View File

@ -18,8 +18,8 @@ wr_nix_prelude ()
chef_set_sauciers (this, 0); chef_set_sauciers (this, 0);
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_deny_user_define(this); chef_forbid_user_define(this);
def_sources_begin() def_sources_begin()
{&UpstreamProvider, "https://channels.nixos.org/", DelegateToUpstream}, {&UpstreamProvider, "https://channels.nixos.org/", DelegateToUpstream},

View File

@ -20,7 +20,7 @@ wr_tex_prelude ()
chef_set_sauciers (this, 1, "@Mikachu2333"); chef_set_sauciers (this, 1, "@Mikachu2333");
chef_allow_local_mode (this, CanNot, NULL, NULL); chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this); chef_forbid_english(this);
chef_allow_user_define(this); chef_allow_user_define(this);
def_sources_begin() def_sources_begin()

View File

@ -17,7 +17,7 @@ wr_winget_prelude ()
chef_set_cooks (this, 1, "@ccmywish"); chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 1, "@Mikachu2333"); chef_set_sauciers (this, 1, "@Mikachu2333");
chef_deny_english(this); chef_forbid_english(this);
chef_allow_user_define(this); chef_allow_user_define(this);
def_sources_begin() def_sources_begin()

View File

@ -1,48 +0,0 @@
// chsrc.rc - Windows Resource Script
// SPDX-License-Identifier: GPL-3.0-or-later
#include <windows.h>
#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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

View File

@ -2,11 +2,11 @@
# --------------------------------------------------------------- # ---------------------------------------------------------------
# Test File : cli.pl # Test File : cli.pl
# Test Authors : 曾奥然 <ccmywish@qq.com> # Test Authors : 曾奥然 <ccmywish@qq.com>
# Contributors : Nil Null <nil@null.org> # Contributors : Nil Null <nil@null.org>
# Created On : <2024-06-05> # Created On : <2024-06-05>
# Last Modified : <2025-10-29> # Last Modified : <2025-09-27>
# #
# 测试 chsrc 可执行文件 # 测试 chsrc 可执行文件
# --------------------------------------------------------------- # ---------------------------------------------------------------
=encoding utf8 =encoding utf8
@ -62,16 +62,11 @@ use open qw(:std :encoding(UTF-8));
my $CHSRC = ($^O eq 'MSWin32') ? '.\chsrc' : './chsrc'; my $CHSRC = ($^O eq 'MSWin32') ? '.\chsrc' : './chsrc';
my $version_str_cn = qr|chsrc .*\n\nCopyright .*\n许可证 GPLv3\+GNU GPL 第 3 版或更高版本|;
like `$CHSRC -v`, $version_str_cn, 'chsrc -v';
like `$CHSRC --version`, $version_str_cn, 'chsrc --version';
like `$CHSRC version`, $version_str_cn, 'chsrc version';
my $version_str_en = qr|chsrc .*\n\nCopyright .*\nLicense GPLv3\+: GNU GPL version 3 or later|; my $version_str = qr|chsrc .*\nCopyright .*\nLicense GPLv3\+: GNU GPL version 3 or later|;
like `$CHSRC -v -en`, $version_str_en, 'chsrc -v -en'; like `$CHSRC -v`, $version_str, 'chsrc -v';
like `$CHSRC -en -v`, $version_str_en, 'chsrc -en -v'; like `$CHSRC --version`, $version_str, 'chsrc --version';
like `$CHSRC --version -en`, $version_str_en, 'chsrc --version -en'; like `$CHSRC version`, $version_str, 'chsrc version';
like `$CHSRC version -en`, $version_str_en, 'chsrc version -en';
my $help_str = qr/^ (help|list|get|set|reset)/m; my $help_str = qr/^ (help|list|get|set|reset)/m;
like `$CHSRC -h`, $help_str, 'chsrc -h'; like `$CHSRC -h`, $help_str, 'chsrc -h';

View File

@ -1,10 +1,10 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* ------------------------------------------------------------- * -------------------------------------------------------------
* File Authors : @ccmywish * File Authors : <ccmywish@qq.com>
* Contributors : @Mikachu2333 * Contributors : Mikachu2333 <mikachu.23333@zohomail.com>
* Created On : <2024-12-14> * Created On : <2024-12-14>
* Last Modified : <2025-12-29> * Last Modified : <2025-10-06>
* *
* DEBUG mode * DEBUG mode
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
@ -85,14 +85,10 @@ main (int argc, char const *argv[])
if (xy.on_windows) if (xy.on_windows)
{ {
chsrc_view_env ("OS", "windir", NULL); chsrc_run_as_pwsh_file ("Write-Host \"Hello from PowerShell file\"");
chsrc_run_as_pwsh_file ("Write-Host \"Hello from PowerShell (v7) file\"");
chsrc_run_as_powershellv5_file ("Write-Host \"Hello from PowerShell v5 file\"");
chsrc_run_as_powershell_file ("Write-Host \"Hello from PowerShell file\"");
} }
else else
{ {
chsrc_view_env ("PWD", NULL);
chsrc_run_as_sh_file ("echo Hello from sh file"); chsrc_run_as_sh_file ("echo Hello from sh file");
chsrc_run_as_bash_file ("echo Hello from Bash file"); chsrc_run_as_bash_file ("echo Hello from Bash file");
} }

View File

@ -3,9 +3,9 @@
! ------------------------------------------------------------- ! -------------------------------------------------------------
! Doc Type : Markdown ! Doc Type : Markdown
! Doc Name : (Tools Introduction).md ! Doc Name : (Tools Introduction).md
! Doc Authors : 曾奥然 <ccmywish@qq.com> ! Doc Authors : Aoran Zeng <ccmywish@qq.com>
! | xuan <wick.dynex@qq.com> ! | xuan <wick.dynex@qq.com>
! Contributors : ChatGPT <https://chatgpt.com> ! Contributors : ChatGPT <https://chatgpt.com>
! | ! |
! Created On : <2024-10-25> ! Created On : <2024-10-25>
! Last Modified : <2025-07-21> ! Last Modified : <2025-07-21>