Compare commits

..

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

156 changed files with 5064 additions and 6491 deletions

View File

@ -1,17 +1,4 @@
# --------------------------------------------------------------
# SPDX-License-Identifier: GPL-3.0-or-later
# --------------------------------------------------------------
# Config Type : EditorConfig
# Config Authors: 曾奥然 <ccmywish@qq.com>
# Contributors : Nil Null <nil@null.org>
# Created On : <2023-09-06>
# Last Modified : <2025-08-27>
#
# 请参考 ./doc/03-为什么拒绝使用代码格式化工具.md
#
# http://editorconfig.org # http://editorconfig.org
# --------------------------------------------------------------
root = true root = true
[*] [*]
@ -19,31 +6,18 @@ indent_style = space
indent_size = 2 indent_size = 2
charset = utf-8 charset = utf-8
trim_trailing_whitespace = true trim_trailing_whitespace = true
insert_final_newline = false
# VS Code 对该配置(为 false)的实现有问题,这是确定的,
# 然而 CLion 似乎对该配置(为 false)的实现是正确的,这导致不同贡献者反而产生了冲突
# 所以我们现在改成 true
insert_final_newline = true
[*.{c,C,cpp,cxx,cc,h,hpp}] [*.{c,C,cpp,cxx,cc,h,hpp}]
indent_style = space indent_style = space
indent_size = 2 indent_size = 2
[*.pl]
indent_size = 4
[*.{raku,rakumod,rakutest}]
indent_size = 2
[*.ps1]
indent_size = 4
[*.{sh,bash}]
indent_size = 2
[Makefile,makefile,*.{mk,make,makefile}] [Makefile,makefile,*.{mk,make,makefile}]
indent_style = tab indent_style = tab
[*.md]
trim_trailing_whitespace = true
# 使用 VS Code 生成文件的默认格式 # 使用 VS Code 生成文件的默认格式
[*.json] [*.json]
indent_size = 4 indent_size = 4

View File

@ -45,7 +45,7 @@ body:
attributes: attributes:
label: chsrc 版本 label: chsrc 版本
# description: 你正在使用 chsrc 哪个版本? # description: 你正在使用 chsrc 哪个版本?
placeholder: 请使用 chsrc -h 或 chsrc -v 查看,并*复制发布日期* placeholder: 请使用 chsrc -h 查看*带有发布日期*的精确版本 (chsrc -v 并不含有日期信息)
validations: validations:
required: true required: true

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

@ -1,32 +0,0 @@
# chsrc Project Rules for AI Assistants
## 项目概述
这是 chsrc 项目,一个用 C 语言编写的跨平台命令行换源工具,帮助用户在不同的镜像之间切换,适用于编程语言、操作系统、其他软件。它的最强大之处在于它是一个框架,能够帮助用户轻松地为不同的目标换源。
## 架构
- **Framework**: 在目录 `src/framework/` 中,包含了核心实现,支持 recipe
- `struct.h` 里定义了各种数据结构和宏,这是整个 chsrc 的核心,也是 chef DSL 的核心
- `chef.c` 里实现了 chef DSL你可以使用它来确定正确的使用方法
- **Recipes**: 在目录 `src/recipe/` 中,包含了针对不同目标的具体实现
- `lang/` - 编程语言 (Ruby, JavaScript 等等)
- `os/` - 操作系统 (Ubuntu, Arch Linux 等等)
- `ware/` - 软件工具和应用 (Docker, Homebrew 等等)
## Coding Guidelines
### C Coding Style:
请阅读 `doc/03-为什么拒绝使用代码格式化工具.md`
### Important Project Concepts:
请阅读 `doc/10-如何编写recipe.md`
## Important: 一定要保持注释,因为它记录了重要的维护信息

View File

@ -1,10 +1,10 @@
# --------------------------------------------------------------- # ---------------------------------------------------------------
# Workflow File : PR-notify.yml # Workflow File : PR-notify.yml
# File Authors : 曾奥然 <ccmywish@qq.com> # File Authors : Aoran Zeng <ccmywish@qq.com>
# Contributors : Nul None <nul@none.org> # Contributors : Nul None <nul@none.org>
# | # |
# Created On : <2025-06-19> # Created On : <2025-06-19>
# Last Modified : <2025-08-07> # Last Modified : <2025-06-28>
# #
# Notify PR # Notify PR
# --------------------------------------------------------------- # ---------------------------------------------------------------
@ -40,23 +40,15 @@ jobs:
welcome: welcome:
name: 欢迎PR者 name: 欢迎PR者
runs-on: ubuntu-latest runs-on: ubuntu-latest
# 仅在 opened 时欢迎,其他情况都不再重复欢迎了 if: github.event.pull_request.base.ref == 'dev'
if: github.event.pull_request.base.ref == 'dev' && github.event.action == 'opened'
steps: steps:
- name: 查看 GitHub Actions 环境 - name: 评论
run: | uses: peter-evans/create-or-update-comment@v4
echo "Event 类型: ${{ github.event.action }}"
echo "Event 名: ${{ github.event_name }}"
# 2025-10-06 移除点赞的步骤
# 因原 peter-evans/create-or-update-comment@v5 已不再支持空body而如果使用 Github Token 之类又过于大材小用因此移除
- name: 添加评论欢迎 PRer
uses: peter-evans/create-or-update-comment@v5
with: with:
issue-number: ${{ github.event.pull_request.number }} issue-number: ${{ github.event.pull_request.number }}
body: | body: |
Hi @${{github.event.pull_request.user.login}} Hi @${{github.event.pull_request.user.login}},
❤️ 感谢你的贡献!我们将在最少半小时,最多5天内阅读此 PR 并回复你 ❤️ 感谢你的贡献我们将在5天内阅读此 PR 并回复你
edit-mode: replace edit-mode: replace
reactions: heart

View File

@ -1,10 +1,10 @@
# --------------------------------------------------------------- # ---------------------------------------------------------------
# Workflow File : PR-test.yml # Workflow File : PR-test.yml
# File Authors : 曾奥然 <ccmywish@qq.com> # File Authors : Aoran Zeng <ccmywish@qq.com>
# Contributors : Mikachu2333 <mikachu2333@zohomail.com> # Contributors : Nul None <nul@none.org>
# | # |
# Created On : <2025-06-19> # Created On : <2025-06-19>
# Last Modified : <2025-08-17> # Last Modified : <2025-06-19>
# #
# Test PR # Test PR
# --------------------------------------------------------------- # ---------------------------------------------------------------
@ -13,15 +13,11 @@ name: 测试PR
on: on:
pull_request: pull_request:
# 仅在开 pr、草稿转正式、手动要求 review、reopen的时候运行测试 types: [opened,
types: [ synchronize, # 后续提交
opened, ready_for_review, # draft PR 转为正式 PR
# 因 synchronize 将导致 pr 的构建过于频繁而禁用 review_requested,
# synchronize, # 在 pr 者 push commit 时每次构建 reopened]
ready_for_review, # draft PR 转为正式 PR
review_requested,
reopened,
]
paths: paths:
- "src/**" - "src/**"
- "lib/**" - "lib/**"
@ -34,7 +30,7 @@ jobs:
steps: steps:
- name: 检出代码 - name: 检出代码
uses: actions/checkout@v6 uses: actions/checkout@v4
- name: 测试构建情况 - name: 测试构建情况
run: | run: |
@ -46,18 +42,12 @@ jobs:
test-on-windows: test-on-windows:
name: 在Windows上测试 name: 在Windows上测试
runs-on: windows-latest runs-on: ubuntu-latest
if: github.event.pull_request.base.ref == 'dev' if: github.event.pull_request.base.ref == 'dev'
steps: steps:
- name: 检出代码 - name: 检出代码
uses: actions/checkout@v6 uses: actions/checkout@v4
- name: 创建测试文件
shell: powershell
run: |
New-Item -Path "$env:USERPROFILE\Documents\Powershell\Microsoft.PowerShell_profile.ps1" -ItemType File -Force
New-Item -Path "$env:USERPROFILE\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1" -ItemType File -Force
- name: 安装依赖 - name: 安装依赖
run: | run: |

View File

@ -1,10 +1,10 @@
# --------------------------------------------------------------- # ---------------------------------------------------------------
# Workflow File : build-on-Linux-AArch64.yml # Workflow File : build-on-Linux-AArch64.yml
# File Authors : 曾奥然 <ccmywish@qq.com> # File Authors : Aoran Zeng <ccmywish@qq.com>
# Contributors : Nul None <nul@none.org> # Contributors : Nul None <nul@none.org>
# | # |
# Created On : <2023-09-14> # Created On : <2023-09-14>
# Last Modified : <2025-09-12> # Last Modified : <2025-06-20>
# #
# Build chsrc on Linux (AArch64) and upload it to GitHub: the 'pre' release # Build chsrc on Linux (AArch64) and upload it to GitHub: the 'pre' release
# --------------------------------------------------------------- # ---------------------------------------------------------------
@ -45,3 +45,4 @@ jobs:
tag_name: pre tag_name: pre
files: | files: |
./artifacts/chsrc-aarch64-linux ./artifacts/chsrc-aarch64-linux
token: ${{ secrets.UPLOAD_TO_GITHUB }}

View File

@ -1,10 +1,10 @@
# --------------------------------------------------------------- # ---------------------------------------------------------------
# Workflow File : build-on-Linux-ARMv7.yml # Workflow File : build-on-Linux-ARMv7.yml
# File Authors : 曾奥然 <ccmywish@qq.com> # File Authors : Aoran Zeng <ccmywish@qq.com>
# Contributors : Nul None <nul@none.org> # Contributors : Nul None <nul@none.org>
# | # |
# Created On : <2023-09-14> # Created On : <2023-09-14>
# Last Modified : <2025-09-12> # Last Modified : <2025-06-20>
# #
# Build chsrc on Linux (ARMv7) and upload it to GitHub: the 'pre' release # Build chsrc on Linux (ARMv7) and upload it to GitHub: the 'pre' release
# --------------------------------------------------------------- # ---------------------------------------------------------------
@ -45,3 +45,5 @@ jobs:
tag_name: pre tag_name: pre
files: | files: |
./artifacts/chsrc-armv7-linux ./artifacts/chsrc-armv7-linux
token: ${{ secrets.UPLOAD_TO_GITHUB }}

View File

@ -1,10 +1,10 @@
# --------------------------------------------------------------- # ---------------------------------------------------------------
# Workflow File : build-on-Linux-riscv64.yml # Workflow File : build-on-Linux-riscv64.yml
# File Authors : 曾奥然 <ccmywish@qq.com> # File Authors : Aoran Zeng <ccmywish@qq.com>
# Contributors : Nul None <nul@none.org> # Contributors : Nul None <nul@none.org>
# | # |
# Created On : <2023-09-14> # Created On : <2023-09-14>
# Last Modified : <2025-09-12> # Last Modified : <2025-06-20>
# #
# Build chsrc on Linux (riscv64) and upload it to GitHub: the 'pre' release # Build chsrc on Linux (riscv64) and upload it to GitHub: the 'pre' release
# --------------------------------------------------------------- # ---------------------------------------------------------------
@ -45,3 +45,4 @@ jobs:
tag_name: pre tag_name: pre
files: | files: |
./artifacts/chsrc-riscv64-linux ./artifacts/chsrc-riscv64-linux
token: ${{ secrets.UPLOAD_TO_GITHUB }}

View File

@ -1,10 +1,10 @@
# --------------------------------------------------------------- # ---------------------------------------------------------------
# Workflow File : build-on-Linux-x64.yml # Workflow File : build-on-Linux-x64.yml
# File Authors : 曾奥然 <ccmywish@qq.com> # File Authors : Aoran Zeng <ccmywish@qq.com>
# Contributors : Nul None <nul@none.org> # Contributors : Nul None <nul@none.org>
# | # |
# Created On : <2023-09-14> # Created On : <2023-09-14>
# Last Modified : <2025-09-12> # Last Modified : <2025-06-20>
# #
# Build chsrc on Linux (x64) and upload it to GitHub: the 'pre' release # Build chsrc on Linux (x64) and upload it to GitHub: the 'pre' release
# --------------------------------------------------------------- # ---------------------------------------------------------------
@ -20,7 +20,7 @@ jobs:
steps: steps:
- name: 检出代码 - name: 检出代码
uses: actions/checkout@v6 uses: actions/checkout@v4
- name: 构建 - name: 构建
run: | run: |
@ -37,3 +37,4 @@ jobs:
tag_name: pre tag_name: pre
files: | files: |
chsrc-x64-linux chsrc-x64-linux
token: ${{ secrets.UPLOAD_TO_GITHUB }}

View File

@ -1,10 +1,10 @@
# --------------------------------------------------------------- # ---------------------------------------------------------------
# Workflow File : build-on-Windows.yml # Workflow File : build-on-Windows.yml
# File Authors : 曾奥然 <ccmywish@qq.com> # File Authors : Aoran Zeng <ccmywish@qq.com>
# Contributors : Nul None <nul@none.org> # Contributors : Nul None <nul@none.org>
# | # |
# Created On : <2023-09-14> # Created On : <2023-09-14>
# Last Modified : <2025-09-12> # Last Modified : <2025-07-22>
# #
# Build chsrc on Windows and upload it to GitHub: the 'pre' release # Build chsrc on Windows and upload it to GitHub: the 'pre' release
# --------------------------------------------------------------- # ---------------------------------------------------------------
@ -24,7 +24,7 @@ jobs:
steps: steps:
- name: 检出代码 - name: 检出代码
uses: actions/checkout@v6 uses: actions/checkout@v4
- name: 安装 GCC - name: 安装 GCC
uses: msys2/setup-msys2@v2 uses: msys2/setup-msys2@v2
@ -78,3 +78,4 @@ jobs:
chsrc-x64-windows.exe chsrc-x64-windows.exe
chsrc-x86-windows.exe chsrc-x86-windows.exe
chsrc-arm64-android chsrc-arm64-android
token: ${{ secrets.UPLOAD_TO_GITHUB }}

View File

@ -1,10 +1,10 @@
# --------------------------------------------------------------- # ---------------------------------------------------------------
# Workflow File : build-on-macOS.yml # Workflow File : build-on-macOS.yml
# File Authors : 曾奥然 <ccmywish@qq.com> # File Authors : Aoran Zeng <ccmywish@qq.com>
# 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-07-22>
# #
# 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@v4
- name: 检查编译器版本 - name: 检查编译器版本
run: | run: |
@ -45,16 +45,15 @@ jobs:
tag_name: pre tag_name: pre
files: | files: |
chsrc-aarch64-macos chsrc-aarch64-macos
token: ${{ secrets.UPLOAD_TO_GITHUB }}
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@v4
- name: 检查编译器版本 - name: 检查编译器版本
run: | run: |
@ -79,3 +78,4 @@ jobs:
tag_name: pre tag_name: pre
files: | files: |
chsrc-x64-macos chsrc-x64-macos
token: ${{ secrets.UPLOAD_TO_GITHUB }}

View File

@ -1,10 +1,10 @@
# --------------------------------------------------------------- # ---------------------------------------------------------------
# Workflow File : pkg-deb.yml # Workflow File : pkg-deb.yml
# 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-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@v4
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
@ -133,6 +133,7 @@ jobs:
with: with:
# 用 * 省略版本号,以及指代各种架构 # 用 * 省略版本号,以及指代各种架构
files: dist/chsrc_*.deb files: dist/chsrc_*.deb
token: ${{ secrets.UPLOAD_TO_GITHUB }}
- name: 上传附件到GitHub Releases(the 'pre' release) - name: 上传附件到GitHub Releases(the 'pre' release)
if: github.event_name == 'push' if: github.event_name == 'push'
@ -141,6 +142,7 @@ jobs:
tag_name: pre tag_name: pre
# 用 * 指代各种架构 # 用 * 指代各种架构
files: dist-for-pre/chsrc_latest-1_*.deb files: dist-for-pre/chsrc_latest-1_*.deb
token: ${{ secrets.UPLOAD_TO_GITHUB }}
@ -154,7 +156,7 @@ jobs:
steps: steps:
- name: Download all artifacts - name: Download all artifacts
uses: actions/download-artifact@v7 uses: actions/download-artifact@v4
with: with:
pattern: chsrc-deb-files pattern: chsrc-deb-files
merge-multiple: true merge-multiple: true
@ -172,7 +174,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*

5
.gitignore vendored
View File

@ -22,7 +22,7 @@
*.dll *.dll
*.out *.out
*.exe *.exe
*.res
############################## ##############################
@ -41,9 +41,6 @@ chsrc-ci-release
xy xy
fw fw
README.md.bak* README.md.bak*
*.tmp
chsrc_tmp_test.txt
chsrc_tmp_test.txt.bak
# Generated when testing (when there's a bug) # Generated when testing (when there's a bug)
nul nul

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>

11
.vscode/launch.json vendored
View File

@ -8,15 +8,13 @@
"program": "${workspaceFolder}/chsrc-debug", "program": "${workspaceFolder}/chsrc-debug",
"args": [ "args": [
"get", "get",
"nodejs" "python"
], ],
"preLaunchTask": "构建 debug 版 chsrc", "preLaunchTask": "构建 debug 版 chsrc",
"stopAtEntry": true, "stopAtEntry": true,
"cwd": "${workspaceFolder}", "cwd": "${workspaceFolder}",
"environment": [], "environment": [],
// 使false "externalConsole": false,
"externalConsole": true,
// lldb
"MIMode": "gdb", "MIMode": "gdb",
// "miDebuggerPath": "/path/to/gdb", // "miDebuggerPath": "/path/to/gdb",
"setupCommands": [ "setupCommands": [
@ -30,8 +28,7 @@
"text": "-gdb-set disassembly-flavor intel", "text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true "ignoreFailures": true
} }
], ]
"postDebugTask": "停止 debug 程序"
}, },
{ {
@ -61,4 +58,4 @@
] ]
} }
] ]
} }

23
.vscode/settings.json vendored
View File

@ -1,27 +1,12 @@
{ {
"editor.fontLigatures": false,
"C_Cpp.autoAddFileAssociations": false,
"C_Cpp.intelliSenseEngine": "Tag Parser", "C_Cpp.intelliSenseEngine": "Tag Parser",
"C_Cpp.default.browse.limitSymbolsToIncludedHeaders": false, "C_Cpp.default.browse.limitSymbolsToIncludedHeaders": false,
"editor.formatOnSave": false, "editor.formatOnSave": false,
"vscode-just.formatOnSave": false,
"C_Cpp.clang_format_fallbackStyle": "GNU",
"C_Cpp.formatting": "disabled",
"[c]": {
"editor.defaultFormatter": null,
},
"[h]": {
"editor.defaultFormatter": null
},
"[jsonc]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"[yaml]": { "[yaml]": {
"editor.defaultFormatter": "redhat.vscode-yaml" "editor.defaultFormatter": "redhat.vscode-yaml"
}, },
"[jsonc]": {
"vscode-just.formatOnSave": false, "editor.defaultFormatter": "vscode.json-language-features"
}
} }

78
.vscode/tasks.json vendored
View File

@ -17,8 +17,7 @@
"kind": "build", "kind": "build",
"isDefault": true "isDefault": true
}, },
"dependsOn": "停止程序", "detail": "使用 just build 编译"
"detail": "先停止原有程序,然后使用 just build 编译"
}, },
{ {
"type": "shell", "type": "shell",
@ -37,6 +36,7 @@
"kind": "build", "kind": "build",
"isDefault": false "isDefault": false
}, },
"detail": "使用 just build-in-debug-mode 编译 debug 版"
}, },
{ {
"type": "shell", "type": "shell",
@ -94,79 +94,7 @@
"isDefault": false "isDefault": false
}, },
"detail": "使用 just test-xy 测试 xy.h" "detail": "使用 just test-xy 测试 xy.h"
},
{
"type": "shell",
"label": "停止 debug 程序",
"windows": {
"command": "powershell",
"args": [
"-c",
"Get-Process -Name \"chsrc-debug\" -ErrorAction SilentlyContinue | Stop-Process -Force;",
"Get-Process -Name \"gdb\" -ErrorAction SilentlyContinue | Stop-Process -Force;",
"Get-Process -Name \"WindowsDebugLauncher\" -ErrorAction SilentlyContinue | Stop-Process -Force;"
]
},
"linux": {
"command": "bash",
"args": [
"-c",
"if pgrep -f chsrc-debug > /dev/null; then pkill -f chsrc-debug; fi"
]
},
"osx": {
"command": "bash",
"args": [
"-c",
"if pgrep -f chsrc-debug > /dev/null; then pkill -f chsrc-debug; fi"
]
},
"group": "build",
"presentation": {
"echo": true,
"reveal": "silent",
"focus": false,
"panel": "shared",
"showReuseMessage": true,
"clear": false
},
"detail": "停止 debug 版本的 chsrc"
},
{
"type": "shell",
"label": "停止程序",
"windows": {
"command": "powershell",
"args": [
"-c",
"Get-Process -Name \"chsrc\" -ErrorAction SilentlyContinue | Stop-Process -Force;"
]
},
"linux": {
"command": "bash",
"args": [
"-c",
"if pgrep -f chsrc > /dev/null; then pkill -f chsrc; fi"
]
},
"osx": {
"command": "bash",
"args": [
"-c",
"if pgrep -f chsrc > /dev/null; then pkill -f chsrc; fi"
]
},
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared",
"showReuseMessage": true,
"clear": false
},
"detail": "跨平台停止 chsrc"
} }
], ],
"version": "2.0.0" "version": "2.0.0"
} }

View File

@ -2,15 +2,15 @@
# -------------------------------------------------------------- # --------------------------------------------------------------
# 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-Develop.md 来使用
# -------------------------------------------------------------- # --------------------------------------------------------------
#=========== OS Check ================ #=========== OS Check ================
@ -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,12 +3,11 @@
! ------------------------------------------------------------- ! -------------------------------------------------------------
! 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 : Mikachu2333 <mikachu.23333@zohomail.com> ! Contributors : Mikachu2333 <mikachu.23333@zohomail.com>
! | BingChunMoLi <bingchunmoli@bingchunmoli.com>
! | ! |
! Created On : <2023-12-28> ! Created On : <2023-12-28>
! Last Modified : <2025-08-22> ! Last Modified : <2025-07-22>
! ---------------------------------------------------------- --> ! ---------------------------------------------------------- -->
<div align="center"> <div align="center">
@ -17,7 +16,7 @@
全平台通用换源工具与框架 `chsrc`**目标支持 Linux, Windows (native, MSYS2, Cygwin), macOS, BSD, Android 等尽可能多的操作系统环境龙芯、飞腾、RISC-V 等尽可能多的 CPU**。 全平台通用换源工具与框架 `chsrc`**目标支持 Linux, Windows (native, MSYS2, Cygwin), macOS, BSD, Android 等尽可能多的操作系统环境龙芯、飞腾、RISC-V 等尽可能多的 CPU**。
我们使用 **C11** 来完成上述目标。我们并不使用 Python 或 JavaScript 等解释语言,因为一个简单的换源工具,不应该强行塞给用户一个庞大的解释器和数十、数百 MB 其他文件。 我们使用 **C11** 来完成上述目标。我们并不使用 Python 或 JS 等解释语言,因为一个简单的换源工具,不应该强行塞给用户一个庞大的解释器和数十、数百 MB 其他文件。
本软件为**自由软件**SDPX 软件许可证为 `GPL-3.0-or-later and MIT` 本软件为**自由软件**SDPX 软件许可证为 `GPL-3.0-or-later and MIT`
@ -40,35 +39,22 @@
## ❤️ 致所有的朋友们
2025年8月11日我因通宵重构本项目代码而被送去抢救[#252](https://github.com/RubyMetric/chsrc/issues/252)[突发!换源工具 chsrc 作者在重构过程中被送去 120 抢救](https://v2ex.com/t/1151802))。大家给予的关心和帮助让我非常非常感动!在此,我衷心感谢每一位朋友!**无论是开源还是闭源,无论是否为职业程序员,我们其实都是一群使用软件、热心互助、充满友爱的人,这是一个温暖的大家庭**。
我为 `chsrc` 采用 GPL 协议,怀着殷切的期望:**希望能够营造像 Richard Stallman 在创建 GNU 项目之前,在 MIT 那样的氛围——写自己用得上的软件,与大家一起开发、维护,简单纯粹,无关商业利益。就像小区、校园自发组建的足球篮球队,从一次偶然的加入,逐渐成长为互相支持的伙伴**。
这次经历让我更加深刻地体会到:开源,是一种把大家联系在一起的方式,**它让友情、互助和协作成为可能,也让我们在共同的目标中建立起长期的纽带**。
最后,希望大家能够**时刻关注**自己的身体,**你可以随时 `chsrc` `chown` `chgrp` `chmod` 无限次,但是无法 `chbody`**
<br>
## 🤝 协作与贡献 ## 🤝 协作与贡献
> [!TIP] > [!TIP]
> **`chsrc` 不仅是一个命令行工具,同时也是一个体现了 Ruby on Rails 思想的 MVC 换源框架它甚至使你能够在不了解C语言的情况下编写出新的换源方法 (recipe)。** 配合使用 [rawstr4c], 这将比写 shell 脚本更加轻松。 [如何编写 recipe?](./doc/10-如何编写recipe.md) > **`chsrc` 不仅是一个命令行工具,同时也是一个体现了 Ruby on Rails 思想的 MVC 换源框架它甚至使你能够在不了解C语言的情况下编写出新的换源方法 (recipe)。** 配合使用 [rawstr4c], 这将比写 shell 脚本更加轻松。 [Write A Recipe Even If You Don't Know C](./doc/02-Write-A-Recipe-Even-If-You-Dont-Know-C.md)
--- ---
> [!NOTE] > [!NOTE]
> 这也许是你可以参与的第一个现实世界中有用的C语言项目[用 VS Code 一分钟内上手编译、运行、测试 chsrc](./doc/01-开发与构建.md) > 这是你可以参与的第一个现实世界中有用的C语言项目[用 VS Code 一分钟内上手编译、运行、测试 chsrc](./doc/01-Develop.md)
> >
> 欢迎对 GitHub、Gitee 协作不熟悉的人以此为契机学习参与贡献, 欢迎任何编程初学者。[从开发到提交PR我们覆盖全流程文档](./doc/) > 欢迎对 GitHub、Gitee 协作不熟悉的人以此为契机学习参与贡献, 欢迎任何编程初学者。[从开发到提交PR我们覆盖全流程文档](./doc/)
,作者可提供一定的 [贡献指导](https://github.com/RubyMetric/chsrc/discussions/50)
--- ---
> [!IMPORTANT] > [!IMPORTANT]
> **`chsrc` 可换源 65+ 目标。每个人仅仅贡献和维护自己熟悉的部分,回报是得到其他所有领域专家的帮助。** [欢迎成为 recipe 维护者](https://github.com/RubyMetric/chsrc/issues/275) > **`chsrc` 可换源 65+ 目标。每个人仅仅贡献和维护自己熟悉的部分,回报是得到其他所有领域专家的帮助。** [欢迎成为 recipe 维护者](https://github.com/RubyMetric/chsrc/issues/130)
<br> <br>
@ -475,7 +461,7 @@ chsrc set rust | cargo | crate
chsrc set rustup chsrc set rustup
chsrc set go chsrc set go
chsrc set java | maven | mvn | maven-daemon | mvnd | gradle chsrc set java | maven | mvn | gradle
chsrc set clojure | clojars chsrc set clojure | clojars
chsrc set dart | pub chsrc set dart | pub
chsrc set flutter chsrc set flutter

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

@ -2,12 +2,12 @@
! SPDX-License-Identifier: GFDL-1.3-or-later ! SPDX-License-Identifier: GFDL-1.3-or-later
! ------------------------------------------------------------- ! -------------------------------------------------------------
! Doc Type : Markdown ! Doc Type : Markdown
! Doc Name : 01-开发与构建.md ! Doc Name : 01-Develop.md
! Doc Authors : 曾奥然 <ccmywish@qq.com> ! Doc Authors : Aoran Zeng <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-07-21>
! ---------------------------------------------------------- --> ! ---------------------------------------------------------- -->
# 开发 chsrc # 开发 chsrc
@ -53,7 +53,7 @@ git clone https://gitee.com/RubyMetric/chsrc.git -b dev
3. **`RELEASE mode`** 3. **`RELEASE mode`**
4. **`CI-RELEASE mode`** 4. **`CI-RELEASE mode`**
开发时只需要前两种模式;第四种模式只在 GitHub Actions 使用。 第四种只在 GitHub Actions 使用,一般只需要前三者;而在开发时你仅需要前两者;如果不需要 Debug仅仅第一个 **DEV mode** 就够了
**如果你使用 `just`,可以在 VS Code 中获得更好的体验,按 `Ctrl-Shift-B` 直接使用 DEV mode 构建** **如果你使用 `just`,可以在 VS Code 中获得更好的体验,按 `Ctrl-Shift-B` 直接使用 DEV mode 构建**

View File

@ -2,12 +2,12 @@
! SPDX-License-Identifier: GFDL-1.3-or-later ! SPDX-License-Identifier: GFDL-1.3-or-later
! ------------------------------------------------------------- ! -------------------------------------------------------------
! Doc Type : Markdown ! Doc Type : Markdown
! Doc Name : 10-如何编写recipe.md ! Doc Name : 02-Write-A-Recipe-Even-If-You-Dont-Know-C.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 : <2024-08-19> ! Created On : <2024-08-19>
! Last Modified : <2025-10-28> ! Last Modified : <2025-07-21>
! ---------------------------------------------------------- --> ! ---------------------------------------------------------- -->
# Write A Recipe Even If You Don't Know C # Write A Recipe Even If You Don't Know C
@ -18,7 +18,7 @@
<br> <br>
我鼓励你为新的软件添加换源支持,因为通过 `chsrc` 框架,这将比写 shell 脚本更加轻松,你的贡献也将非常有价值。理论上每一个 `recipe` 都需要有专人长时间维护 ([招募](https://github.com/RubyMetric/chsrc/issues/275))。 我鼓励你为新的软件添加换源支持,因为通过 `chsrc` 框架,这将比写 shell 脚本更加轻松,你的贡献也将非常有价值。理论上每一个 `recipe` 都需要有专人长时间维护 ([招募](https://github.com/RubyMetric/chsrc/issues/130))。
- 本项目采用 `GPLv3+` 协议,是真正的**自由软件**,而非仅仅是开源软件 - 本项目采用 `GPLv3+` 协议,是真正的**自由软件**,而非仅仅是开源软件
- 代码规范灵活遵循 `GNU` 标准(若标准干扰了可维护性,则并不采纳) - 代码规范灵活遵循 `GNU` 标准(若标准干扰了可维护性,则并不采纳)
@ -52,10 +52,7 @@
- `source`: 该 `target` 所能换的具体的源,由 `mirror` 提供服务,往往一个 `mirror` 会提供许多 `source` - `source`: 该 `target` 所能换的具体的源,由 `mirror` 提供服务,往往一个 `mirror` 会提供许多 `source`
- `recipe`: 是为一个 `target` 定义的具体换源方法,请参考 `src` 目录中的 `recipe` 目录 - `recipe`: 是为一个 `target` 定义的具体换源方法,请参考 `src` 目录中的 `recipe` 目录
- `chef DSL`:是 `chef Domain Specific Language` 的简写,这是一组以 `chef_` 开头的函数,用来定义维护者信息、可用源等元信息 - `feature`: 一个 `target` 可以支持的功能,比如能否重置回上游默认源等
- **换源链接**: 指镜像站所提供的某一个具体的换源使用的URL
- **测速链接**: 用来测速的URL与 "换源链接" 不同,可分为 **精准测速** 和 **模糊测速**
- **镜像源**: 为了方便,**偶尔**我们将直接称`mirror`和/或`source`为**镜像源**,这只是一种方便性的称呼,可以统称二者,也可以根据上下文指代二者之一 - **镜像源**: 为了方便,**偶尔**我们将直接称`mirror`和/或`source`为**镜像源**,这只是一种方便性的称呼,可以统称二者,也可以根据上下文指代二者之一
@ -79,24 +76,17 @@
5. 在 [Wiki] 中记录的镜像站中寻找可用源;可以额外补充镜像站 5. 在 [Wiki] 中记录的镜像站中寻找可用源;可以额外补充镜像站
6. 使用 chef DSL 定义 `_prelude()` 函数 6. 可以使用这些函数:
该函数将填充 target 所有的必要信息,包括维护信息、换源信息
7. [设置/修改 "换源链接" 和 "测速链接" (how?)](./11-如何设置换源链接与测速链接.md)
8. 按需实现 `_setsrc()` `_getsrc()` `_resetsrc()` 可以使用这些函数:
1. `framework/core.c` 中以 `chsrc_` 开头的所有函数或宏 1. `framework/core.c` 中以 `chsrc_` 开头的所有函数或宏
2. `xy.h` 中以 `xy_` 开头的所有函数或宏 2. `xy.h` 中以 `xy_` 开头的所有函数或宏
3. `chec.c` 中以 `chef_` 开头的所有函数或宏 3. `chec.h` 中以 `chef_` 开头的所有函数或宏
4. `helper.c` 中以 `hp_` 开头的所有函数或宏
一个简单的方法是,在 VS Code 中按快捷键 `Ctrl-T` 搜索上述三种前缀 一个简单的方法是,在 VS Code 中按快捷键 `Ctrl-T` 搜索上述三种前缀
9. 在 `recipe/menu.c` 中登记此 target 7. 在 `recipe/menu.c` 中添加用户可以使用的 `target` 别名
10. [编译、运行、测试 (how?)](./01-开发与构建.md),若无问题可提交 Pull Request 8. [编译、运行、测试 (how?)](./01-Develop.md),若无问题可提交 Pull Request
<br> <br>

View File

@ -2,12 +2,12 @@
! SPDX-License-Identifier: GFDL-1.3-or-later ! SPDX-License-Identifier: GFDL-1.3-or-later
! ------------------------------------------------------------- ! -------------------------------------------------------------
! Doc Type : Markdown ! Doc Type : Markdown
! Doc Name : 02-提交与贡献.md ! Doc Name : 03-CONTRIBUTING.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 : <2024-12-13> ! Created On : <2024-12-13>
! Last Modified : <2025-08-22> ! Last Modified : <2025-07-21>
! ---------------------------------------------------------- --> ! ---------------------------------------------------------- -->
# 贡献说明 # 贡献说明
@ -22,8 +22,6 @@
## 提交与审阅 ## 提交与审阅
当你提交 PR 的时候,一定要将 PR 指定 chsrc 原仓库的 dev 分支。
### 一个简单的 Bug ### 一个简单的 Bug
一个简单的 Bug fix有写权限的维护者可以直接推送到主仓库的 `dev` 分支 一个简单的 Bug fix有写权限的维护者可以直接推送到主仓库的 `dev` 分支
@ -36,14 +34,15 @@
1 1
**如果你是 recipe Chef则你完全负责这个 recipe如果你拥有写权限你可以直接推送代码到 `dev` 分支** 1. **如果你是 recipe Chef则你完全负责这个 recipe如果你拥有写权限你可以直接推送代码到 `dev` 分支**
2. 如果你是 recipe Sous Chef则你需要参考 [04-MAINTAINERS.md](./04-MAINTAINERS.md),如果只有你一个人,且你拥有写权限,你可以直接推送代码。如果有多人,则需要提一个 issue介绍方案然后 @ 所有 Sous Chef 来 review
--- ---
2 2
1. 需要先搜索你修改的部分涉及到的 recipe然后提 issue @ 所有相关的 recipe Chef 来 review 1. 需要先搜索你修改的部分涉及到的 recipe然后提 issue @ 所有相关的 recipe Sous Chef 来 review
2. 如果涉及了所有 recipe则 @ framework Chef而无需把所有 recipe 的 Chef 都喊过来,但是如果觉得有必要,可以 @ 任意你觉得有能力 review 和能给出建议的人来 review 2. 如果涉及了所有 recipe则 @ framework Sous Chef而无需把所有 recipe 的 Sous Chef 都喊过来,但是如果觉得有必要,可以 @ 任意你觉得有能力 review 和能给出建议的人来 review
<br> <br>

View File

@ -1,122 +0,0 @@
<!-- -----------------------------------------------------------
! SPDX-License-Identifier: GFDL-1.3-or-later
! -------------------------------------------------------------
! Doc Type : Markdown
! Doc Name : 03-为什么拒绝使用代码格式化工具.md
! Doc Authors : 曾奥然 <ccmywish@qq.com>
! Contributors : Nul None <nul@none.org>
! Created On : <2025-08-10>
! Last Modified : <2025-08-20>
! ---------------------------------------------------------- -->
# chsrc 代码风格
Ruby 的语法优美性在编程行业中具有标杆地位。Matz松本行弘提出的 **代码应该为人类而写,偶尔为机器执行** 这一理念,已经成为现代编程语言设计的重要指导原则。`chsrc` 项目的第一作者深受 **Ruby** 语言哲学的影响。
本项目起源于 AI 编程尚未流行的时代,所有代码全部依赖人类的耐心来维护。现在,我们的代码以及这篇文章不仅会由人类阅读,也会由 AI 阅读。我们始终坚持:**代码的可读性和维护性是项目长期发展的根本保障**。
<br>
## 为什么我们坚持不使用代码格式化工具
代码格式化工具code formatter在多人协作的代码仓库中确实有其价值**参与的人越多,统一格式的需求越迫切**。然而,`chsrc` 项目经过深思熟虑后,拒绝使用代码格式化工具。让我来说明这一决定背后的深层原因。
### 被强迫使用
`Prettier` 这样的工具表面上带来了统一性,但其代价是什么?**它是极度专制的opiniated**,我们必须**完全交出代码审美的自主权**。今天我们大部分人使用 `Prettier`**并非出于真心的认同,而是因为整个前端生态圈的集体胁迫——不用就意味着被边缘化**。
这种现象的本质令人深思:**少数 `Prettier` 维护者的个人偏好,竟然决定了全球数百万开发者的代码美学标准。这显然是一种技术独裁,坚决拒绝向格式化工具的霸权低头**。
<br>
### 一致性 ≠ 美观 ≠ 可读
格式化工具只保证了表面的一致性,就像一些校服,一致不一定代表美。同样,一致不一定代表代码就是最易读易懂的。
每一个有追求的程序员都应该保留**对代码美学的最后决定权,格式化工具的便利性不应该以牺牲美观性和可维护性为代价**。
<br>
### 满足不了我们的需求
C语言的格式化工具通常选择 `clang-format`,它的配置选项十分丰富,比 `Prettier` 要理性得多。然而,即便如此,**其配置的复杂性和局限性仍然无法满足 chsrc 对代码格式的严苛要求**。如果你是一位 `clang-format` 的配置专家,我们诚挚邀请您告诉我们如何优雅地处理以下代码场景,**也许这能改变我的立场**。
<br>
### 挑战案例
以下是我认为自动格式化工具很难完美处理的代码场景:
`=` 对齐:
```c
char *name = va_arg (args, char*);
char *email = va_arg (args, char*);
```
复杂逻辑的 `=` 对齐:
```c
bool matched = iterate_menu (chsrc_pl_menu, input, &target_tmp);
if (!matched) matched = iterate_menu (chsrc_os_menu, input, &target_tmp);
if (!matched) matched = iterate_menu (chsrc_wr_menu, input, &target_tmp);
```
预处理指令的层次缩进:
```c
#ifdef _WIN32
#define XY_Build_On_Windows 1
#define xy_on_windows true
#ifdef XY_DEBUG
#define xy_debug_mode 1
#endif
#endif
```
...... 等等
<br>
## C语言代码风格
- 整体上基于 `GNU style`,但我们坚持自己的美学原则,在细节上有所改进
- 类型名: `PascalCase_t`,即 `UpperCamelCase_t`
- 函数定义和调用时,**函数名和`()`之间始终保持一个空格**,如果是在宏中,可紧凑一些,无硬性规定
- 函数和函数定义之间**一般保持2个空行**
- 若函数之间有高度关联性,**可用1个空行**
- 若一系列函数和一系列函数存在主题性区别,**可用3个空行**
<br>
## Markdown 写作风格
维护者很多时候不是从渲染好的界面来看 Markdown 文件的,而是阅读 Markdown 源文件,所以 Markdown 在源文件层面也要易读。
我们保持每个主题之间 **1个`<br>` + 3个空行** 的简单风格。
拒绝使用 VS Code 的 `markdownlint` 插件,**因为它总是用它狭隘的标准给我们增加了巨多的黄色下划线**。
<br>
## 其他语言代码风格
我们秉承 **入乡随俗、尊重传统** 的原则,尊重每种语言社区的既定传统。比如,`YAML` 使用2个空格`JSON`使用4个空格`Perl` 使用 Larry Wall 钟爱的4个空格。
我们使用 `.editorconfig` 来确保这些格式的应用。
<br>

331
doc/04-MAINTAINERS.md Normal file
View File

@ -0,0 +1,331 @@
# 协作者与维护者
作为该语言的资深用户、该软件的专家、镜像站维护人员等,你总是对镜像站和源的可用状态拥有一手信息,我们需要你的帮助。如果想要达到最理想的维护状态,每一个 recipe 都需要有专人长时间维护。所以我们在这个文件记录的是愿意**长期**维护的人,如果是一次性提交代码,只需要在对应 recipe 的文件标头中记录即可。
**我们的代码里使用了 recipe (某个菜的烹饪方法) 这个词,因而整个项目便和 "饮食" 有关,比如 `menu`: 汇集了所有的 target 的菜单。因此,我们的维护者身份依然使用了这个惯例:**
一个 recipe 的协作者可分为:
1. **Chef**
主厨: 对一个 recipe 完全负责,有写权限时可以直接推代码
**目前项目的发展阶段还处于 *外行实现内行* 的情况,比如 Homebrew recipe实现者根本不是 Homebrew 的真实用户,只是根据各种文档来实现,然后等待用户反馈。所以这里当前的实现者最多只能是 Sous Chef无法承担 Chef 的责任**
2. **Sous Chef**
副主厨:实现和持续维护 recipe需要和 Chef 一起 review 代码。可参考 [03-CONTRIBUTING.md](./03-CONTRIBUTING.md) 了解项目是如何进行提交和审阅代码的
3. **Taster**
试吃员:对该 target 和 recipe 持续反馈和关注的用户。如果你觉得你无法承担作为维护者的责任,可以退而求其次作为观察者积极参与其中
<br>
**项目采用申请制,请提交 PULL REQUEST 在该文件中添加自己,并在 [issue #130](https://github.com/RubyMetric/chsrc/issues/130) 留言。考虑到真正参与维护的人并不多,所以上述人数均不设限。**
`@`后面跟的是GitHub账户名`@ccmywish`。若使用Gitee账号则使用 `@gitee:ccmywish`。对我们来说,镜像站成员非常重要,所以请额外标注身份,如 `@username [TUNA]`
<br>
## Framework
1. **Chef**: `@ccmywish` `@gitee:G_I_Y`
2. **Sous Chef**:
3. **Taster**:
<br>
## 编程语言
### Ruby
1. **Chef**: `@ccmywish`
2. **Sous Chef**:
3. **Taster**:
### Python
1. **Chef**:
2. **Sous Chef**: `@ccmywish` `@happy-game`
3. **Taster**:
### NodeJS
1. **Chef**:
2. **Sous Chef**: `@ccmywish` `@happy-game`
3. **Taster**:
### Perl
1. **Chef**:
2. **Sous Chef**: `@ccmywish`
3. **Taster**:
### PHP
1. **Chef**:
2. **Sous Chef**: `@ccmywish`
3. **Taster**:
### Go
1. **Chef**:
2. **Sous Chef**: `@ccmywish`
3. **Taster**:
### Rust
1. **Chef**:
2. **Sous Chef**: `@ccmywish`
3. **Taster**:
### Java
1. **Chef**:
2. **Sous Chef**: `@ccmywish`
3. **Taster**:
### Clojure
1. **Chef**:
2. **Sous Chef**:
3. **Taster**:
### NuGet
1. **Chef**:
2. **Sous Chef**:
3. **Taster**:
### Dart
1. **Chef**:
2. **Sous Chef**: `@ccmywish`
3. **Taster**:
### Haskell
1. **Chef**:
2. **Sous Chef**: `@ccmywish`
3. **Taster**:
### OCaml
1. **Chef**:
2. **Sous Chef**: `@ccmywish`
3. **Taster**:
### R
1. **Chef**:
2. **Sous Chef**: `@ccmywish`
3. **Taster**: `@gitee:tfcolin`
### Julia
1. **Chef**:
2. **Sous Chef**: `@ccmywish`
3. **Taster**:
<br>
## 操作系统
### Ubuntu
1. **Chef**: `@ccmywish`
2. **Sous Chef**: `@gitee:G_I_Y`
3. **Taster**: `@wickdynex`
### Debian
1. **Chef**:
2. **Sous Chef**: `@ccmywish` `@gitee:G_I_Y`
3. **Taster**: `@happy-game`
### Fedora
1. **Chef**:
2. **Sous Chef**: `@ccmywish` `@gitee:G_I_Y` `@happy-game`
3. **Taster**:
### Kali
1. **Chef**:
2. **Sous Chef**: `@gitee:G_I_Y`
3. **Taster**:
### Linux Mint
1. **Chef**:
2. **Sous Chef**: `@ccmywish` `@gitee:G_I_Y`
3. **Taster**:
### Armbian
1. **Chef**:
2. **Sous Chef**: `@ccmywish`
3. **Taster**:
### Raspberry Pi OS
1. **Chef**:
2. **Sous Chef**: `@ccmywish`
3. **Taster**:
### ROS
1. **Chef**:
2. **Sous Chef**: `@gitee:G_I_Y` `@ccmywish`
3. **Taster**:
### Trisquel
1. **Chef**:
2. **Sous Chef**: `@ccmywish`
3. **Taster**:
### Arch
1. **Chef**:
2. **Sous Chef**: `@ccmywish` `@gitee:G_I_Y` `@happy-game`
3. **Taster**:
### Manjaro
1. **Chef**:
2. **Sous Chef**: `@gitee:G_I_Y` `@ccmywish`
3. **Taster**:
### msys2
1. **Chef**:
2. **Sous Chef**: `@gitee:G_I_Y` `@ccmywish`
3. **Taster**:
### Alpine
1. **Chef**:
2. **Sous Chef**: `@ccmywish`
3. **Taster**:
### OpenWrt
1. **Chef**:
2. **Sous Chef**: `@ccmywish`
3. **Taster**: `@happy-game`
### Gentoo
1. **Chef**:
2. **Sous Chef**: `@gitee:G_I_Y`
3. **Taster**:
### Void Linux
1. **Chef**:
2. **Sous Chef**: `@ccmywish`
3. **Taster**:
### deepin
1. **Chef**:
2. **Sous Chef**: `@gitee:G_I_Y`
3. **Taster**:
### OpenKylin
1. **Chef**:
2. **Sous Chef**: `@gitee:G_I_Y`
3. **Taster**:
### OpenEuler
1. **Chef**:
2. **Sous Chef**: `@gitee:G_I_Y`
3. **Taster**:
### FreeBSD
1. **Chef**:
2. **Sous Chef**: `@gitee:G_I_Y` `@ccmywish`
3. **Taster**: `@ykla`
### NetBSD
1. **Chef**:
2. **Sous Chef**: `@gitee:G_I_Y` `@ccmywish`
3. **Taster**:
### OpenBSD
1. **Chef**:
2. **Sous Chef**: `@gitee:G_I_Y` `@ccmywish`
3. **Taster**:
<br>
## 软件
### Homebrew
1. **Chef**:
2. **Sous Chef**: `@ccmywish`
3. **Taster**: `@wickdynex`
### WinGet
1. **Chef**:
2. **Sous Chef**: `@ccmywish`
3. **Taster**:
### Flathub
1. **Chef**:
2. **Sous Chef**: `@ccmywish`
3. **Taster**:
### Nix
1. **Chef**:
2. **Sous Chef**: `@ccmywish`
3. **Taster**:
### Guix
1. **Chef**:
2. **Sous Chef**: `@ccmywish`
3. **Taster**:
### CocoaPods
1. **Chef**:
2. **Sous Chef**: `@ccmywish`
3. **Taster**:
### Docker Hub
1. **Chef**:
2. **Sous Chef**: `@ccmywish` `@happy-game`
3. **Taster**:
### Anaconda
1. **Chef**:
2. **Sous Chef**: `@ccmywish`
3. **Taster**: `@happy-game`
### Emacs
1. **Chef**:
2. **Sous Chef**: `@ccmywish`
3. **Taster**:
### Tex Live
1. **Chef**:
2. **Sous Chef**: `@ccmywish`
3. **Taster**:
<br>

View File

@ -1,63 +0,0 @@
<!-- -----------------------------------------------------------
! SPDX-License-Identifier: GFDL-1.3-or-later
! -------------------------------------------------------------
! Doc Type : Markdown
! Doc Name : 11-如何设置换源链接与测速链接.md
! Doc Authors : 曾奥然 <ccmywish@qq.com>
! Contributors : Nul None <nul@none.org>
! |
! Created On : <2025-08-11>
! Last Modified : <2025-08-11>
! ---------------------------------------------------------- -->
# 新增/修改 "换源链接"
`_prelude()` 函数中,在 `def_sources_begin()` 的位置的**第二列**,新增/修改你想要替换的链接。
**注: 以下代码仅起解释作用JavaScript换源的真正实现可能不同**
```c
def_sources_begin()
{&UpstreamProvider, "https://registry.npmjs.org/", FeedByPrelude},
{&NpmMirror, "https://registry.npmmirror.com", FeedByPrelude},
{&Huawei, "https://mirrors.huaweicloud.com/repository/npm/", FeedByPrelude},
{&Tencent, "https://mirrors.cloud.tencent.com/npm/", FeedByPrelude},
{&某新镜像站, "某镜像站提供的换源链接" FeedByPrelude}
def_sources_end()
```
<br>
# 设置/修改 "测速链接"
`_prelude()` 函数中,在 `def_sources_begin()` 的位置的**第三列**,设置/修改你想要替换的链接。
1. 在下面代码的第一行中,我们直接给了一个链接,**这就是精准测速链接**
2. 在下面代码的第二行和第三行中,我们都设置了一个宏 `DelegateToMirror`,这意味着我们没有直接提供精准测速链接,而是让 `chsrc` 去测试其对应镜像站定义的测速链接
- `NpmMirror` 是专用镜像站,所以其测速链接被设置为了 `ACCURATE`,即精准测速
- `Huawei` 是通用镜像站,所以其测速链接被设置为了 `ROUGH `,即模糊测速
3. 在下面代码的第四行中,我们设置了一个宏 `FeedByPrelude`,这意味着我们将在 `_prelude()` 函数的后续动态计算 URL
**注: 以下代码仅起解释作用JavaScript换源的真正实现可能不同**
```c
def_sources_begin()
{&UpstreamProvider, "https://registry.npmjs.org/", "https://registry.npmjs.org/BigFile.tar.gz"},
{&NpmMirror, "https://registry.npmmirror.com", DelegateToMirror},
{&Huawei, "https://mirrors.huaweicloud.com/repository/npm/", DelegateToMirror},
{&Tencent, "https://mirrors.cloud.tencent.com/npm/", FeedByPrelude},
def_sources_end()
// 把所有上述源的 "测速链接" 设置为 "换源链接" + postfix
chef_set_sources_speed_measure_url_with_postfix (this, "/dir/BigFile.tar.gz");
// 基于 "换源链接" 做更自定义的操作
chef_set_sources_speed_measure_url_with_func (this, func, data);
// 调整某一个镜像站(Provider)的 "测速链接"
chef_set_provider_speed_measure_url (&Tencent, "https://mirrors.cloud.tencent.com/npm/BigFile.tar.gz")
// 调整某一个镜像站(Provider)的 "测速精度"
chef_set_provider_speed_measure_accuracy (&UpstreamProvider, ROUGH);;
```

View File

@ -1,34 +0,0 @@
<!-- -----------------------------------------------------------
! SPDX-License-Identifier: GFDL-1.3-or-later
! -------------------------------------------------------------
! Doc Type : Markdown
! Doc Name : 50-协作者与维护者.md
! Doc Authors : 曾奥然 <ccmywish@qq.com>
! Contributors : Nul None <nul@none.org>
! |
! Created On : <2024-12-06>
! Last Modified : <2025-08-22>
! ---------------------------------------------------------- -->
# 协作者与维护者
想要达到最理想的维护状态,每一个 recipe 都需要有专人长时间维护。**我们的代码里使用了 recipe (某个菜的烹饪方法) 这个词,因而整个项目便和 "饮食" 有关,比如 `menu`: 汇集了所有的 target 的菜单。因此,我们的维护者和贡献者身份依然使用了这个惯例:**
1. **Chef**
品控 (主厨): 对一个 recipe 完全负责,有写权限时可以直接推代码
**目前项目的发展阶段还处于 *外行实现内行* 的情况,比如 Homebrew recipe实现者根本不是 Homebrew 的真实用户,只是根据各种文档来实现,然后等待用户反馈。所以这里当前的实现者最多只能是 Cook无法承担 Chef 的责任**
2. **Cook**
掌勺:一个 recipe 的主要作者
3. **Saucier**
调味:一个 recipe 的次要贡献者 (除主要作者外的其他人)
<br>
**Chef 采用申请制,每个 recipe 仅有1人请提交 PULL REQUEST 在对应的 recipe 文件中添加自己,并在 [issue #275
](https://github.com/RubyMetric/chsrc/issues/275) 留言。**

View File

@ -3,31 +3,21 @@
! ------------------------------------------------------------- ! -------------------------------------------------------------
! Doc Type : Markdown ! Doc Type : Markdown
! Doc Name : (Document Introduction.md) ! Doc Name : (Document 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 : <2024-12-27> ! Created On : <2024-12-27>
! Last Modified : <2025-08-22> ! Last Modified : <2025-03-06>
! ---------------------------------------------------------- --> ! ---------------------------------------------------------- -->
# 文档说明 # 文档说明
E2E (End-to-End) 开发文档: E2E (End-to-End) 开发文档:
- 开发环境准备,如何编译和测试,请参考 [01-开发与构建.md](./01-开发与构建.md) 1. 开发环境准备,如何编译和测试,请参考 [./01-Develop.md](./01-Develop.md)
- 直接推送还是提交 PR请参考 [02-提交与贡献.md](./02-提交与贡献.md) 2. 如何编写一个具体的 recipe请参考 [./02-Write-A-Recipe-Even-If-You-Dont-Know-C.md](./02-Write-A-Recipe-Even-If-You-Dont-Know-C.md)
- 代码风格,请参考 [03-为什么拒绝使用代码格式化工具.md](./03-为什么拒绝使用代码格式化工具.md) 3. 直接推送还是提交 PR请参考 [./03-CONTRIBUTING.md](./03-CONTRIBUTING.md)
4. 找谁来审阅 PR请参考 [./04-MAINTAINERS.md](./04-MAINTAINERS.md)
<br>
具体 recipe 相关:
- 如何编写一个具体的 recipe请参考 [10-如何编写recipe.md](./10-如何编写recipe.md)
- 如何修改换源链接、模糊/精准测速链接,请参考 [11-如何设置换源链接与测速链接.md](./11-如何设置换源链接与测速链接.md)
<br>
- 关于维护者身份的说明,请参考 [50-协作者与维护者.md](./50-协作者与维护者.md)
<br> <br>

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-06-16>
.\" ---------------------------------------------------------------- .\" --------------------------------------------------------------
.TH chsrc 1 "2025-10-29" "v0.2.3.1" "RubyMetric chsrc" .TH chsrc 1 "2025-06-16" "v0.2.1.2" "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-06-19>
@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.1.2
@set Doc_Publish_Date 2025-10-29 @set Doc_Publish_Date 2025-06-19
@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

1228
lib/xy.h

File diff suppressed because it is too large Load Diff

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>

File diff suppressed because it is too large Load Diff

View File

@ -1,388 +0,0 @@
/** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Name : chef.c
* File Authors : <ccmywish@qq.com>
* Contributors : BingChunMoLi <bingchunmoli@bingchunmoli.com>
* Created On : <2025-08-09>
* Last Modified : <2025-10-27>
*
* chef DSL: for chefs (recipe makers) to define a target
* ------------------------------------------------------------*/
#pragma once
void
chef_debug_target (Target_t *target)
{
#ifdef XY_DEBUG
if (!target)
{
chsrc_debug2 ("target", "Target is NULL");
return;
}
say ("DEBUG Target Information:");
printf (" Aliases: %s\n", target->aliases);
printf (" Get Function: %p\n", target->getfn);
printf (" Set Function: %p\n", target->setfn);
printf (" Reset Function: %p\n", target->resetfn);
printf (" Prelude Function: %p\n", target->preludefn);
printf (" Inited?: %d\n", target->inited);
printf (" Sources: %p\n", target->sources);
printf (" Sources Count: %d\n", target->sources_n);
printf (" Chef: %p\n", target->chef);
printf (" Cooks: %p\n", target->cooks);
printf (" Cooks Count: %d\n", target->cooks_n);
printf (" Sauciers: %p\n", target->sauciers);
printf (" Sauciers Count: %d\n", target->sauciers_n);
#endif
}
void
chef_debug_contributor (Contributor_t *contributor)
{
#ifdef XY_DEBUG
if (!contributor)
{
chsrc_debug2 ("contrib", "Contributor is NULL");
return;
}
say ("DEBUG Contributor Information:");
printf (" ID: %s\n", contributor->id);
printf (" Name: %s\n", contributor->name);
printf (" Email: %s\n", contributor->email);
printf (" DisplayName: %s\n", contributor->display_name);
#endif
}
/**
* @brief
*
* @param id IDID最好是GitHub用户名 chsrc
* @param display_name 使 name
*/
void
chef_register_contributor (char *id, char *name, char *email, char *display_name)
{
if (!id || !name || !email)
xy_unreached();
Contributor_t *contributor = xy_malloc0 (sizeof (Contributor_t));
contributor->id = xy_strdup (id);
contributor->name = xy_strdup (name);
contributor->email = xy_strdup (email);
if (!display_name)
contributor->display_name = xy_strdup (name);
else
contributor->display_name = xy_strdup (display_name);
xy_map_set (ProgStore.contributors, id, contributor);
}
/**
* @brief Provider
*
* @note Provider UpstreamProvider
*/
void
chef_set_provider_speed_measure_url (SourceProvider_t *provider, char *url)
{
provider->psmi.skip = NotSkip;
provider->psmi.url = xy_strdup (url);
chsrc_debug ("m", xy_strcat (4, "recipe 重新为 ", provider->code, "(镜像站信息本身) 设置测速链接: ", url));
}
/**
* @brief Provider
*
* @note Provider UpstreamProvider
*/
void
chef_set_provider_speed_measure_accuracy (SourceProvider_t *provider, bool accuracy)
{
provider->psmi.accurate = accuracy;
chsrc_debug ("m", xy_strcat (4, "recipe 重新为 ", provider->code, "(镜像站信息本身) 设置测速精度: ", accuracy ? "精准" : "粗略"));
}
/**
* @brief "换源链接"
*/
void
chef_set_sources_speed_measure_url_with_func (
Target_t *target,
char *(*func)(const char *url, const char *user_data),
char *user_data)
{
xy_cant_be_null (target);
Source_t *sources = target->sources;
int n = target->sources_n;
for (int i=0; i<n; i++)
{
Source_t *src = &sources[i];
ProviderType_t type = src->provider->type;
if (src->url)
{
/* 为空时才修改 或者里面是脏数据 */
if (NULL==src->speed_measure_url || !hp_is_url (src->speed_measure_url))
{
src->speed_measure_url = func (src->url, user_data);
}
}
}
}
/**
* @brief "换源链接"
*/
void
chef_set_sources_speed_measure_url_with_postfix (Target_t *target, char *postfix)
{
chef_set_sources_speed_measure_url_with_func (target, xy_2strcat, postfix);
}
/**
* @note : item target standalone
*/
void
chef_use_other_target_sources (Target_t *this, Target_t *other)
{
if (!other->inited)
{
if (other->preludefn)
other->preludefn();
else
{
chef_debug_target (other);
chsrc_panic ("`other` 未定义 _prelude() !");
}
}
this->sources = other->sources;
this->sources_n = other->sources_n;
}
void
chef_allow_english (Target_t *target)
{
xy_cant_be_null (target);
target->can_english = true;
}
void
chef_deny_english (Target_t *target)
{
xy_cant_be_null (target);
target->can_english = false;
}
void
chef_allow_local_mode (Target_t *target, Capability_t cap, const char *explain_zh, const char *explain_en)
{
xy_cant_be_null (target);
target->cap_local = cap;
if (cap == FullyCan)
{
target->cap_local_explain = xy_strdup (CHINESE ? "完全支持项目级换源" : "Supports project-level source switching");
return;
}
if (cap == CanNot)
{
target->cap_local_explain = xy_strdup (CHINESE ? "无法进行项目级换源" : "Unable to perform project-level source switching");
return;
}
target->cap_local_explain = xy_strdup (CHINESE ? explain_zh : explain_en);
}
void
chef_allow_user_define (Target_t *target)
{
xy_cant_be_null (target);
target->can_user_define = true;
target->can_user_define_explain = NULL;
}
void
chef_deny_user_define (Target_t *target)
{
xy_cant_be_null (target);
target->can_user_define = false;
char *reason = CHINESE ? "URL将会根据内部实现重写,因此不能自定义"
: "The URL will be rewritten based on internal implementation, so it cannot be customized";
target->can_user_define_explain = reason;
}
void
chef_set_note (Target_t *target, const char *note_zh, const char *note_en)
{
xy_cant_be_null (target);
const char *msg = CHINESE ? note_zh : note_en;
if (msg)
target->note = xy_strdup (msg);
}
/**
* @brief `id`
*/
Contributor_t *
chef_verify_contributor (const char *id)
{
xy_cant_be_null (id);
Contributor_t *c = xy_map_get (ProgStore.contributors, id);
if (!c)
{
char error[256];
snprintf (error, sizeof (error), "贡献者 %s 不存在, 是否写错?或请在 chsrc-main.c 中登记该贡献者", id);
chsrc_panic (error);
}
return c;
}
/**
* @brief Chef (recipe )
*/
void
chef_set_chef (Target_t *target, const char *id)
{
xy_cant_be_null (target);
/* Chef 可为空 */
if (!id)
{
target->chef = NULL;
return;
}
Contributor_t *c = chef_verify_contributor (id);
target->chef = c;
}
/**
* @brief Cooks (recipe )
*/
void
chef_set_cooks (Target_t *target, size_t count, ...)
{
xy_cant_be_null (target);
if (count == 0)
{
chsrc_panic ("recipe 一定至少有1位作者(cooks)");
return;
}
va_list args;
va_start (args, count);
target->cooks = xy_malloc0 (count * sizeof (Contributor_t*));
target->cooks_n = count;
for (size_t i = 0; i < count; i++)
{
char *id = va_arg (args, char*);
target->cooks[i] = chef_verify_contributor (id);
}
va_end (args);
}
void
chef_set_sauciers (Target_t *target, uint32_t count, ...)
{
xy_cant_be_null (target);
if (count == 0)
{
target->sauciers = NULL;
target->sauciers_n = 0;
return;
}
va_list args;
va_start (args, count);
target->sauciers = xy_malloc0 (count * sizeof (Contributor_t*));
target->sauciers_n = count;
for (uint32_t i = 0; i < count; i++)
{
char *id = va_arg (args, char*);
target->sauciers[i] = chef_verify_contributor (id);
}
}
void
chef_set_created_on (Target_t *target, char *date)
{
xy_cant_be_null (target);
xy_cant_be_null (date);
target->created_on = xy_strdup (date);
}
void
chef_set_last_updated (Target_t *target, char *date)
{
xy_cant_be_null (target);
xy_cant_be_null (date);
target->last_updated = xy_strdup (date);
}
void
chef_set_sources_last_updated (Target_t *target, char *date)
{
xy_cant_be_null (target);
xy_cant_be_null (date);
target->sources_last_updated = xy_strdup (date);
}
/**
* @note target User-Agent
* (chsrc measure)
* _setsrc() _prelude()
*/
void
chef_set_user_agent (char *user_agent)
{
ProgStatus.user_agent = user_agent;
}

View File

@ -1,18 +1,20 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* ------------------------------------------------------------- * -------------------------------------------------------------
* File Name : helper.c * File Name : chef.h
* File Authors : <ccmywish@qq.com> * File Authors : Aoran Zeng <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-07-14>
* *
* 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
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
#pragma once
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 +23,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,11 +36,11 @@ 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] == '/')
return xy_strdup (str); return xy_strdup (str);
return xy_2strcat (str, "/"); return xy_2strjoin (str, "/");
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,16 +1,15 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* ------------------------------------------------------------- * -------------------------------------------------------------
* File Name : mirror.c * File Name : mirror.c
* File Authors : <ccmywish@qq.com> * File Authors : Aoran Zeng <ccmywish@qq.com>
* | <2085471348@qq.com> * | Heng Guo <2085471348@qq.com>
* Contributors : Shengwei Chen <414685209@qq.com> * Contributors : Shengwei Chen <414685209@qq.com>
* | Jialin Lyu <jialinlvcn@aliyun.com> * | Jialin Lyu <jialinlvcn@aliyun.com>
* | Mikachu2333 <mikachu.23333@zohomail.com> * | Mikachu2333 <mikachu.23333@zohomail.com>
* | BingChunMoLi <bingchunmoli@bingchunmoli.com>
* | * |
* Created On : <2023-08-29> * Created On : <2023-08-29>
* Last Modified : <2025-10-07> * Last Modified : <2025-07-14>
* *
* *
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
@ -261,13 +260,6 @@ Huawei =
{NotSkip, NA, NA, "https://mirrors.huaweicloud.com/ubuntu-releases" Big_File_ubuntu, ROUGH} {NotSkip, NA, NA, "https://mirrors.huaweicloud.com/ubuntu-releases" Big_File_ubuntu, ROUGH}
}, },
HuaweiCDN =
{
IS_GeneralMirrorSite,
"huawei-cdn", "Huawei Cloud CDN", "华为开源镜像站(CDN)", "https://repo.huaweicloud.com/",
{NotSkip, NA, NA, "https://repo.huaweicloud.com/ubuntu-releases" Big_File_ubuntu, ROUGH}
},
Volcengine = Volcengine =
{ {
IS_GeneralMirrorSite, IS_GeneralMirrorSite,

View File

@ -2,12 +2,12 @@
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* ------------------------------------------------------------- * -------------------------------------------------------------
* File Name : struct.h * File Name : struct.h
* File Authors : <ccmywish@qq.com> * File Authors : Aoran Zeng <ccmywish@qq.com>
* | <2085471348@qq.com> * | Heng Guo <2085471348@qq.com>
* Contributors : Shengwei Chen <414685209@qq.com> * Contributors : Shengwei Chen <414685209@qq.com>
* | * |
* Created On : <2023-08-29> * Created On : <2023-08-29>
* Last Modified : <2025-08-22> * Last Modified : <2025-07-11>
* *
* chsrc struct * chsrc struct
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
@ -35,7 +35,7 @@ typedef enum ProviderType_t
IS_GeneralMirrorSite, /* 通用镜像站 */ IS_GeneralMirrorSite, /* 通用镜像站 */
IS_DedicatedMirrorSite, /* 专用镜像站 */ IS_DedicatedMirrorSite, /* 专用镜像站 */
IS_UpstreamProvider, /* 上游默认源 */ IS_UpstreamProvider, /* 上游默认源 */
IS_UserDefinedProvider, /* 用户提供 */ IS_VirtualProvider, /* 用户提供 */
} }
ProviderType_t; ProviderType_t;
@ -55,17 +55,18 @@ typedef SourceProvider_t MirrorSite_t;
SourceProvider_t UpstreamProvider = SourceProvider_t UpstreamProvider =
{ {
IS_UpstreamProvider, IS_UpstreamProvider,
/* 引入新的上游默认源时,请使下面第一行的前三个字段保持不变,只添加第四个字段 */ /* 引入新的上游默认源时,请使下面第一行的前三个字段保持不变,只添加第四个字段,可使用 def_upstream 宏 */
"upstream", "Upstream", "上游默认源", NULL, "upstream", "Upstream", "上游默认源", NULL,
/* 引入新的上游默认源时,请完全修改下面这个结构体,可使用 def_need_measure_info 宏 */ /* 引入新的上游默认源时,请完全修改下面这个结构体,可使用 def_need_measure_info 宏 */
{SKIP, "URL未知邀您参与贡献!", "URL unknown, welcome to contribute!", NULL, ACCURATE} {SKIP, "URL未知邀您参与贡献!", "URL unknown, welcome to contribute!", NULL, ACCURATE}
}; };
#define def_upstream IS_UpstreamProvider, "upstream", "Upstream", "上游默认源"
#define def_need_measure_info {SKIP, "缺乏较大的测速对象,邀您参与贡献!", "Lack of large object URL, welcome to contribute!", NULL, ACCURATE} #define def_need_measure_info {SKIP, "缺乏较大的测速对象,邀您参与贡献!", "Lack of large object URL, welcome to contribute!", NULL, ACCURATE}
SourceProvider_t UserDefinedProvider = SourceProvider_t UserDefinedProvider =
{ {
IS_UserDefinedProvider, IS_VirtualProvider,
"user", "用户自定义", "用户自定义", NULL, "user", "用户自定义", "用户自定义", NULL,
{SKIP, "用户自定义源不测速", "SKIP for user-defined source", NULL, ACCURATE} {SKIP, "用户自定义源不测速", "SKIP for user-defined source", NULL, ACCURATE}
}; };
@ -91,89 +92,70 @@ Source_t;
#define DelegateToMirror NULL #define DelegateToMirror NULL
/* 看到该注释的贡献者,你可以帮忙寻找专用测速链接 */ /* 看到该注释的贡献者,你可以帮忙寻找专用测速链接 */
#define NeedContribute NULL #define NeedContribute NULL
/* 由 prelude() 填充 */ /* 由 _sources_prepare 填充 */
#define FeedByPrelude NULL #define FeedBySourcesPrepare NULL
#define def_sources_n(t) const size_t t##_sources_n = xy_arylen(t##_sources)
typedef enum Capability_t enum Capability_t
{ {
CanNot, CanNot,
FullyCan, FullyCan,
PartiallyCan PartiallyCan
} };
Capability_t;
/* Target Feature */
typedef struct Contributor_t typedef struct Feature_t
{ {
char *id; /* 全局唯一贡献者标识符,防止反复写信息,以 @ 开头 */ bool can_get;
char *name; /* 贡献者姓名; 鉴于该项目完全依赖于贡献者,建议留下真实姓名或者昵称 */ bool can_reset; /* 有的reset不是暂时没有实现而是现在的实现根本就无法重置 */
char *email;
char *display_name; /* recipe 结束时会显示贡献者信息,如果你不愿显示真实姓名或者昵称,可以另外提供一个名字 */ bool can_english;
bool can_user_define; /* 用户自定义换源URL */
enum Capability_t cap_locally;
char *cap_locally_explain;
char *note;
} }
Contributor_t; Feature_t;
typedef struct Target_t typedef struct Target_t
{ {
/* 以 / 为分隔符的多个目标别名 */
char *aliases;
void (*getfn) (char *option); void (*getfn) (char *option);
void (*setfn) (char *option); void (*setfn) (char *option);
void (*resetfn) (char *option); void (*resetfn) (char *option);
/* 初始化函数,用于填充该 struct 的各种信息 */ Feature_t (*featfn) (char *option);
void (*preludefn) (void);
bool inited; /* 是否执行过了 preludefn() */
Source_t *sources; Source_t *sources;
int sources_n; size_t sources_n;
/* Features */
bool can_english; /* 是否支持英文输出 */
bool can_user_define; /* 是否支持用户自定义URL来换源 */
char *can_user_define_explain; /* 用户自定义URL的说明 */
Capability_t cap_local; /* 是否支持 local mode */
char *cap_local_explain; /* local mode 的说明 */
char *note; /* 备注 */
/* recipe 维护信息 */
char *created_on;
char *last_updated;
char *sources_last_updated;
Contributor_t *chef; /* 该 recipe *当前*的总负责人 (可以任职也可以休职) */
Contributor_t **cooks; /* 该 recipe 的主要作者 */
int cooks_n;
Contributor_t **sauciers; /* 该 recipe 的次要贡献者 (除主要作者外的其他人) */
int sauciers_n;
} }
Target_t; Target_t;
#define def_target_inner_s(t) NULL, t##_setsrc, NULL, NULL
#define def_target_inner_sr(t) NULL, t##_setsrc, t##_resetsrc, NULL
#define def_target_inner_sf(t) NULL, t##_setsrc, NULL, t##_feat
#define def_target_inner_srf(t) NULL, t##_setsrc, t##_resetsrc, t##_feat
#define def_target_inner_gs(t) t##_getsrc, t##_setsrc, NULL, NULL
#define def_target_inner_gsr(t) t##_getsrc, t##_setsrc, t##_resetsrc, NULL
#define def_target_inner_gsf(t) t##_getsrc, t##_setsrc, NULL, t##_feat
#define def_target_inner_gsrf(t) t##_getsrc, t##_setsrc, t##_resetsrc, t##_feat
#define def_target(t, aliases) void t##_getsrc(char *option);void t##_setsrc(char *option);void t##_resetsrc(char *option); Target_t t##_target={aliases}; #define def_target_sourcesn(t) t##_sources, t##_sources_n
#define chef_allow_gsr(t) this->getfn = t##_getsrc; this->setfn = t##_setsrc; this->resetfn = t##_resetsrc; /* 大部分target还不支持reset所以暂时先默认设置为NULL来过渡 */
#define chef_allow_s(t) this->getfn = NULL; this->setfn = t##_setsrc; this->resetfn = NULL; #define def_target(t) Target_t t##_target = {def_target_inner_gs(t),def_target_sourcesn(t)}
#define chef_allow_sr(t) this->getfn = NULL; this->setfn = t##_setsrc; this->resetfn = t##_resetsrc; #define def_target_s(t) Target_t t##_target = {def_target_inner_s(t),def_target_sourcesn(t)}
#define chef_allow_gs(t) this->getfn = t##_getsrc; this->setfn = t##_setsrc; this->resetfn = NULL; #define def_target_sr(t) Target_t t##_target = {def_target_inner_sr(t),def_target_sourcesn(t)}
#define chef_allow_NOOP(t) #define def_target_sf(t) Target_t t##_target = {def_target_inner_sf(t),def_target_sourcesn(t)}
#define chef_prep_this(t,op) Target_t *this = &t##_target; this->inited = true; chef_allow_##op(t); #define def_target_srf(t) Target_t t##_target = {def_target_inner_srf(t),def_target_sourcesn(t)}
#define def_target_gs(t) Target_t t##_target = {def_target_inner_gs(t),def_target_sourcesn(t)}
#define use_this(t) Target_t *this = &t##_target; #define def_target_gsr(t) Target_t t##_target = {def_target_inner_gsr(t),def_target_sourcesn(t)}
#define chsrc_use_this_source(t) Target_t *this = &t##_target; Source_t source = chsrc_yield_source_and_confirm (this, option); #define def_target_gsf(t) Target_t t##_target = {def_target_inner_gsf(t),def_target_sourcesn(t)}
#define def_target_gsrf(t) Target_t t##_target = {def_target_inner_gsrf(t),def_target_sourcesn(t)}
#define def_sources_begin() Source_t sources[] = {
#define def_sources_end() }; \
this->sources_n = xy_c_array_len(sources); \
char *_sources_storage = xy_malloc0 (sizeof(sources)); \
memcpy (_sources_storage, sources, sizeof(sources)); \
this->sources = (Source_t *)_sources_storage;

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.0-dev"
// 以下四个宏仅用于 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/29"

File diff suppressed because one or more lines are too long

View File

@ -2,10 +2,10 @@
! 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@qq.com> ! Config Authors: Aoran Zeng <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-07-22>
! ---------------------------------------------------------- --> ! ---------------------------------------------------------- -->
# [rawstr4c] input for chsrc # [rawstr4c] input for chsrc
@ -24,7 +24,7 @@
- prefix = `RAWSTR_chsrc` - prefix = `RAWSTR_chsrc`
- output = `:global-variable-only-header` - output = `:global-variable-only-header`
- translate = `:oct` - translate = `:oct`
- no-postfix = `true` - keep-postfix = `false`
<br> <br>
@ -71,8 +71,8 @@
维护: 维护:
邀请您担任 Chef, 为用户把关您熟悉的 recipe 邀请您担任 Chef, 为用户把关您熟悉的 recipe
源代码地址: https://github.com/RubyMetric/chsrc 源代码地址: @url@
成为维护者: https://github.com/RubyMetric/chsrc/issues/275 成为维护者: https://github.com/RubyMetric/chsrc/issues/130
``` ```
<br> <br>
@ -123,7 +123,7 @@ MAINTAIN:
We invite you to become a Chef to ensure the quality of recipes you are familiar with for users: We invite you to become a Chef to ensure the quality of recipes you are familiar with for users:
Source Code: @url@ Source Code: @url@
Become a Maintainer: https://github.com/RubyMetric/chsrc/issues/275 Become a Maintainer: https://github.com/RubyMetric/chsrc/issues/130
``` ```
<br> <br>
@ -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>
@ -174,7 +154,6 @@ Written by authors: Aoran Zeng, Heng Guo, collaborators: Mikachu2333, Happy Game
``` ```
我们同时在 GitHub 和 Gitee 接受 issue 和 Bug 报告: 我们同时在 GitHub 和 Gitee 接受 issue 和 Bug 报告:
- https://github.com/RubyMetric/chsrc/issues - https://github.com/RubyMetric/chsrc/issues
- https://gitee.com/RubyMetric/chsrc/issues - https://gitee.com/RubyMetric/chsrc/issues
@ -209,7 +188,7 @@ Written by authors: Aoran Zeng, Heng Guo, collaborators: Mikachu2333, Happy Game
## 最后告诉用户一些维护信息 ## 最后告诉用户一些维护信息
- name = `op_epilogue` - name = `last_message`
``` ```

View File

@ -1,42 +1,32 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nil Null <nil@null.org>
* Created On : <2023-09-10>
* Last Modified : <2025-07-16>
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
def_target(pl_clojure, "clojure/clojars/cloj/lein"); /**
* @update 2025-07-14
void */
pl_clojure_prelude () static Source_t pl_clojure_sources[] =
{ {
chef_prep_this (pl_clojure, s); {&UpstreamProvider, NULL, NULL},
chef_set_created_on (this, "2023-09-10");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2025-08-21");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 1, "@hezonglun");
chef_allow_local_mode (this, FullyCan, NULL, NULL);
chef_deny_english(this);
chef_allow_user_define(this);
def_sources_begin()
{&UpstreamProvider,"https://repo.clojars.org/", DelegateToUpstream},
{&MirrorZ, "https://mirrors.cernet.edu.cn/clojars/", DelegateToMirror}, {&MirrorZ, "https://mirrors.cernet.edu.cn/clojars/", DelegateToMirror},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/clojars/", DelegateToMirror}, {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/clojars/", DelegateToMirror},
{&Nju, "https://mirror.nju.edu.cn/clojars/", DelegateToMirror}, {&Nju, "https://mirror.nju.edu.cn/clojars/", DelegateToMirror},
{&Nyist, "https://mirror.nyist.edu.cn/clojars/", DelegateToMirror}, {&Nyist, "https://mirror.nyist.edu.cn/clojars/", DelegateToMirror},
{&Ustc, "https://mirrors.ustc.edu.cn/clojars/", DelegateToMirror}, {&Ustc, "https://mirrors.ustc.edu.cn/clojars/", DelegateToMirror},
{&Iscas, "https://mirror.iscas.ac.cn/clojars/", DelegateToMirror} {&Iscas, "https://mirror.iscas.ac.cn/clojars/", DelegateToMirror}
def_sources_end() };
} def_sources_n(pl_clojure);
void void
pl_clojure_setsrc (char *option) pl_clojure_setsrc (char *option)
{ {
chsrc_use_this_source (pl_clojure); chsrc_yield_source_and_confirm (pl_clojure);
if (chsrc_in_local_mode()) if (chsrc_in_local_mode())
{ {
@ -51,5 +41,30 @@ pl_clojure_setsrc (char *option)
println (config); println (config);
} }
chsrc_determine_chgtype (ChgType_Manual);
chsrc_conclude (&source); chsrc_conclude (&source);
} }
/**
* chsrc ls clojure
*/
Feature_t
pl_clojure_feat (char *option)
{
Feature_t f = {0};
f.can_get = false;
f.can_reset = false;
f.cap_locally = CanNot;
f.cap_locally_explain = NULL;
f.can_english = false;
f.can_user_define = true;
f.note = NULL;
return f;
}
def_target_sf(pl_clojure);

View File

@ -1,36 +1,42 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : czyt <czyt.go@gmail.com>
* | MadDogOwner <xiaoran@xrgzs.top>
* |
* Created On : <2023-09-10>
* Major Revision : 2
* Last Modified : <2025-07-11>
*
* 2024-09-14: Dart和Flutter拆分为两个Target
* 3 Dart Flutter URL模式都不一样
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
def_target(pl_dart_flutter, "flutter"); #define PL_Dart_Flutter_Speed_URL_Postfix "/flutter_infra_release/releases/stable/linux/flutter_linux_v1.0.0-stable.tar.xz"
void /**
pl_dart_flutter_prelude (void) * @update 2025-04-15
*/
static SourceProvider_t pl_dart_flutter_upstream =
{ {
chef_prep_this (pl_dart_flutter, gsr); def_upstream, "https://storage.googleapis.com",
{NotSkip, NA, NA, "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_v1.0.0-stable.tar.xz", ACCURATE} // 231 MB
};
chef_set_created_on (this, "2023-09-10"); static Source_t pl_dart_flutter_sources[] =
chef_set_last_updated (this, "2025-07-11"); {
chef_set_sources_last_updated (this, "2025-04-15"); {&pl_dart_flutter_upstream, "https://storage.googleapis.com", DelegateToUpstream},
{&FlutterCN, "https://storage.flutter-io.cn", DelegateToMirror},
{&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn", NULL }, /* 官方文档也没有给后缀,怀疑是否存在问题 */
chef_set_chef (this, NULL); {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/flutter",
chef_set_cooks (this, 1, "@ccmywish"); "https://mirrors.tuna.tsinghua.edu.cn/flutter" PL_Dart_Flutter_Speed_URL_Postfix},
chef_set_sauciers (this, 2, "@czyt", "@xrgzs");
chef_allow_local_mode (this, CanNot, NULL, NULL); {&Nju, "https://mirror.nju.edu.cn/flutter",
chef_allow_english(this); "https://mirror.nju.edu.cn/flutter" PL_Dart_Flutter_Speed_URL_Postfix}
chef_allow_user_define(this); };
def_sources_n(pl_dart_flutter);
def_sources_begin()
{&UpstreamProvider, "https://storage.googleapis.com", FeedByPrelude},
{&FlutterCN, "https://storage.flutter-io.cn", FeedByPrelude},
{&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn", FeedByPrelude }, /* 官方文档也没有给后缀,怀疑是否存在问题 */
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/flutter", FeedByPrelude},
{&Nju, "https://mirror.nju.edu.cn/flutter", FeedByPrelude}
def_sources_end()
chef_set_sources_speed_measure_url_with_postfix (this, "/flutter_infra_release/releases/stable/linux/flutter_linux_v1.0.0-stable.tar.xz");
}
/** /**
@ -51,13 +57,13 @@ pl_dart_flutter_getsrc (char *option)
void void
pl_dart_flutter_setsrc (char *option) pl_dart_flutter_setsrc (char *option)
{ {
chsrc_use_this_source (pl_dart_flutter); chsrc_yield_source_and_confirm (pl_dart_flutter);
char *w = NULL; char *w = NULL;
char *cmd = NULL; char *cmd = NULL;
if (xy.on_windows) if (xy_on_windows)
{ {
cmd = xy_strcat (3, "setx FLUTTER_STORAGE_BASE_URL \"", source.url, "\""); cmd = xy_strjoin (3, "setx FLUTTER_STORAGE_BASE_URL \"", source.url, "\"");
chsrc_run (cmd, RunOpt_No_Last_New_Line); chsrc_run (cmd, RunOpt_No_Last_New_Line);
} }
else else
@ -66,7 +72,7 @@ pl_dart_flutter_setsrc (char *option)
char *bashrc = xy_bashrc; char *bashrc = xy_bashrc;
chsrc_backup (zshrc); chsrc_backup (zshrc);
w = xy_strcat (3, "export FLUTTER_STORAGE_BASE_URL=\"", source.url, "\"\n"); w = xy_strjoin (3, "export FLUTTER_STORAGE_BASE_URL=\"", source.url, "\"\n");
chsrc_append_to_file (w, zshrc); chsrc_append_to_file (w, zshrc);
if (xy_file_exist (bashrc)) if (xy_file_exist (bashrc))
@ -86,3 +92,27 @@ pl_dart_flutter_resetsrc (char *option)
{ {
pl_dart_flutter_setsrc (option); pl_dart_flutter_setsrc (option);
} }
/**
* chsrc ls flutter
*/
Feature_t
pl_dart_flutter_feat (char *option)
{
Feature_t f = {0};
f.can_get = true;
f.can_reset = true;
f.cap_locally = CanNot;
f.cap_locally_explain = NULL;
f.can_english = true;
f.can_user_define = true;
f.note = "该换源通过写入环境变量实现若多次换源请手动清理profile文件";
return f;
}
def_target_gsrf(pl_dart_flutter);

View File

@ -1,36 +1,45 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : czyt <czyt.go@gmail.com>
* | MadDogOwner <xiaoran@xrgzs.top>
* |
* Created On : <2023-09-10>
* Major Revision : 3
* Last Modified : <2025-07-11>
*
* Dart Pub
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
def_target(pl_dart, "dart/pub"); #define PL_Dart_Pub_Speed_URL_Postfix "/packages/flutter_vision/versions/1.1.4.tar.gz"
void /**
pl_dart_prelude (void) * @update 2025-04-15
*/
static SourceProvider_t pl_dart_upstream =
{ {
chef_prep_this (pl_dart, gsr); def_upstream, "https://pub.dev",
{NotSkip, NA, NA, "https://pub.dev/packages/flutter_vision/versions/1.1.4.tar.gz", ACCURATE} // 37.05 MB
};
chef_set_created_on (this, "2023-09-10"); static Source_t pl_dart_sources[] =
chef_set_last_updated (this, "2025-07-11"); {
chef_set_sources_last_updated (this, "2025-04-15"); {&pl_dart_upstream, "https://pub.dev", DelegateToUpstream},
chef_set_chef (this, NULL); {&FlutterCN, "https://pub.flutter-io.cn",
chef_set_cooks (this, 1, "@ccmywish"); "https://pub.flutter-io.cn" PL_Dart_Pub_Speed_URL_Postfix},
chef_set_sauciers (this, 2, "@czyt", "@xrgzs");
chef_allow_local_mode (this, FullyCan, NULL, NULL); {&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/dart-pub",
chef_allow_english(this); "https://mirror.sjtu.edu.cn/dart-pub" PL_Dart_Pub_Speed_URL_Postfix},
chef_allow_user_define(this);
def_sources_begin() {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/dart-pub",
{&UpstreamProvider, "https://pub.dev", FeedByPrelude}, "https://mirrors.tuna.tsinghua.edu.cn/dart-pub" PL_Dart_Pub_Speed_URL_Postfix},
{&FlutterCN, "https://pub.flutter-io.cn", FeedByPrelude},
{&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/dart-pub", FeedByPrelude},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/dart-pub", FeedByPrelude},
{&Nju, "https://mirror.nju.edu.cn/dart-pub", FeedByPrelude}
def_sources_end()
chef_set_sources_speed_measure_url_with_postfix (this, "/packages/flutter_vision/versions/1.1.4.tar.gz"); {&Nju, "https://mirror.nju.edu.cn/dart-pub",
} "https://mirror.nju.edu.cn/dart-pub" PL_Dart_Pub_Speed_URL_Postfix}
};
def_sources_n(pl_dart);
void void
@ -47,13 +56,13 @@ pl_dart_getsrc (char *option)
void void
pl_dart_setsrc (char *option) pl_dart_setsrc (char *option)
{ {
chsrc_use_this_source (pl_dart); chsrc_yield_source_and_confirm (pl_dart);
char *w = NULL; char *w = NULL;
char *cmd = NULL; char *cmd = NULL;
if (xy.on_windows) if (xy_on_windows)
{ {
cmd = xy_strcat (3, "setx PUB_HOSTED_URL \"", source.url, "\""); cmd = xy_strjoin (3, "setx PUB_HOSTED_URL \"", source.url, "\"");
chsrc_run (cmd, RunOpt_No_Last_New_Line); chsrc_run (cmd, RunOpt_No_Last_New_Line);
} }
else else
@ -62,7 +71,7 @@ pl_dart_setsrc (char *option)
char *bashrc = xy_bashrc; char *bashrc = xy_bashrc;
chsrc_backup (zshrc); chsrc_backup (zshrc);
w = xy_strcat (3, "export PUB_HOSTED_URL=\"", source.url, "\"\n"); w = xy_strjoin (3, "export PUB_HOSTED_URL=\"", source.url, "\"\n");
chsrc_append_to_file (w, zshrc); chsrc_append_to_file (w, zshrc);
@ -83,3 +92,24 @@ pl_dart_resetsrc (char *option)
{ {
pl_dart_setsrc (option); pl_dart_setsrc (option);
} }
Feature_t
pl_dart_feat (char *option)
{
Feature_t f = {0};
f.can_get = true;
f.can_reset = true;
f.cap_locally = CanNot;
f.cap_locally_explain = NULL;
f.can_english = true;
f.can_user_define = true;
f.note = "该换源通过写入环境变量实现若多次换源请手动清理profile文件";
return f;
}
def_target_gsrf(pl_dart);

View File

@ -1,7 +1,21 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : czyt <czyt.go@gmail.com>
* | Rui Yang <techoc@foxmail.com>
* |
* Created On : <2023-08-30>
* Major Revision : 1
* Last Modified : <2025-07-12>
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
static SourceProvider_t pl_go_upstream =
{
def_upstream, "https://pkg.go.dev/",
def_need_measure_info
};
static MirrorSite_t GoProxyCN = static MirrorSite_t GoProxyCN =
{ {
IS_DedicatedMirrorSite, IS_DedicatedMirrorSite,
@ -16,44 +30,31 @@ GoProxyIO =
{NotSkip, NA, NA, "https://goproxy.io/github.com/aws/aws-sdk-go/@v/v1.45.2.zip", ACCURATE} // 30 MB {NotSkip, NA, NA, "https://goproxy.io/github.com/aws/aws-sdk-go/@v/v1.45.2.zip", ACCURATE} // 30 MB
}; };
def_target(pl_go, "go/golang/goproxy");
void /**
pl_go_prelude () * @update 2025-07-12
*
* @note
*/
static Source_t pl_go_sources[] =
{ {
chef_prep_this (pl_go, gsr); {&pl_go_upstream, "https://proxy.golang.org", NULL},
{&GoProxyCN, "https://goproxy.cn", DelegateToMirror},
chef_set_created_on (this, "2023-08-30"); {&Ali, "https://mirrors.aliyun.com/goproxy/", NULL},
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2025-07-12");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 2, "@czyt", "@techoc");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this);
chef_allow_user_define(this);
def_sources_begin()
{&UpstreamProvider, "https://proxy.golang.org", DelegateToUpstream},
{&GoProxyCN, "https://goproxy.cn", DelegateToMirror},
{&Ali, "https://mirrors.aliyun.com/goproxy/", DelegateToMirror},
// 暂时停用华为镜像源, 详见 https://github.com/RubyMetric/chsrc/issues/227 // 暂时停用华为镜像源, 详见 https://github.com/RubyMetric/chsrc/issues/227
// {&Huawei, "https://mirrors.huaweicloud.com/goproxy/", DelegateToMirror}, // {&Huawei, "https://mirrors.huaweicloud.com/goproxy/", NULL},
{&GoProxyIO, "https://goproxy.io", DelegateToMirror} {&GoProxyIO, "https://goproxy.io", DelegateToMirror}
def_sources_end() };
} def_sources_n(pl_go);
void void
pl_go_check_cmd () pl_go_check_cmd ()
{ {
char *check_cmd = xy_quiet_cmd ("go version"); char *check_cmd = xy_str_to_quietcmd ("go version");
bool exist = query_program_exist (check_cmd, "go", Noisy_When_Exist|Noisy_When_NonExist); bool exist = query_program_exist (check_cmd, "go", Noisy_When_Exist|Noisy_When_NonExist);
if (!exist) if (!exist)
@ -73,6 +74,8 @@ pl_go_getsrc (char *option)
/** /**
* chsrc set go
*
* @consult https://goproxy.cn/ * @consult https://goproxy.cn/
*/ */
void void
@ -80,20 +83,47 @@ pl_go_setsrc (char *option)
{ {
pl_go_check_cmd (); pl_go_check_cmd ();
chsrc_use_this_source (pl_go); chsrc_yield_source_and_confirm (pl_go);
char *cmd = "go env -w GO111MODULE=on"; char *cmd = "go env -w GO111MODULE=on";
chsrc_run (cmd, RunOpt_Default); chsrc_run (cmd, RunOpt_Default);
cmd = xy_strcat (3, "go env -w GOPROXY=", source.url, ",direct"); cmd = xy_strjoin (3, "go env -w GOPROXY=", source.url, ",direct");
chsrc_run (cmd, RunOpt_Default); chsrc_run (cmd, RunOpt_Default);
chsrc_determine_chgtype (ChgType_Auto);
chsrc_conclude (&source); chsrc_conclude (&source);
} }
/**
* chsrc reset go
*/
void void
pl_go_resetsrc (char *option) pl_go_resetsrc (char *option)
{ {
pl_go_setsrc (option); pl_go_setsrc (option);
} }
/**
* chsrc ls go
*/
Feature_t
pl_go_feat (char *option)
{
Feature_t f = {0};
f.can_get = true;
f.can_reset = true;
f.cap_locally = CanNot;
f.cap_locally_explain = NULL;
f.can_english = false;
f.can_user_define = true;
f.note = NULL;
return f;
}
def_target_gsrf(pl_go);

View File

@ -1,36 +1,26 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nil Null <nil@null.org>
* Created On : <2023-09-10>
* Last Modified : <2025-07-22>
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
def_target(pl_haskell, "haskell/cabal/stack/hackage"); /**
* @update 2023-09-10
void */
pl_haskell_prelude () static Source_t pl_haskell_sources[] =
{ {
chef_prep_this (pl_haskell, s); {&UpstreamProvider, NULL, NULL},
chef_set_created_on (this, "2023-09-10");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2025-08-22");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 1, "@hezonglun");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this);
chef_allow_user_define(this);
def_sources_begin()
{&UpstreamProvider, "https://hackage.haskell.org", DelegateToUpstream},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/hackage", DelegateToMirror}, {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/hackage", DelegateToMirror},
{&Bfsu, "https://mirrors.bfsu.edu.cn/hackage", DelegateToMirror}, {&Bfsu, "https://mirrors.bfsu.edu.cn/hackage", DelegateToMirror},
{&Nju, "https://mirror.nju.edu.cn/hackage", DelegateToMirror}, {&Nju, "https://mirror.nju.edu.cn/hackage", DelegateToMirror},
{&Ustc, "https://mirrors.ustc.edu.cn/hackage", DelegateToMirror}, {&Ustc, "https://mirrors.ustc.edu.cn/hackage", DelegateToMirror},
{&Iscas, "https://mirror.iscas.ac.cn/hackage", DelegateToMirror}, {&Iscas, "https://mirror.iscas.ac.cn/hackage", DelegateToMirror},
{&Nyist, "https://mirror.nyist.edu.cn/hackage", DelegateToMirror} {&Nyist, "https://mirror.nyist.edu.cn/hackage", DelegateToMirror}
def_sources_end() };
} def_sources_n(pl_haskell);
/** /**
@ -39,12 +29,12 @@ pl_haskell_prelude ()
void void
pl_haskell_setsrc (char *option) pl_haskell_setsrc (char *option)
{ {
chsrc_use_this_source (pl_haskell); chsrc_yield_source_and_confirm (pl_haskell);
char *content = xy_str_gsub (RAWSTR_pl_haskell_cabal_config, "@url@", source.url); char *content = xy_str_gsub (RAWSTR_pl_haskell_cabal_config, "@url@", source.url);
char *config = NULL; char *config = NULL;
if (xy.on_windows) if (xy_on_windows)
{ {
config = xy_normalize_path ("~/AppData/Roaming/cabal/config"); config = xy_normalize_path ("~/AppData/Roaming/cabal/config");
} }
@ -53,13 +43,34 @@ pl_haskell_setsrc (char *option)
config = "~/.cabal/config"; config = "~/.cabal/config";
} }
chsrc_note2 (xy_strcat (3, "请向 ", config, " 中手动添加:")); chsrc_note2 (xy_strjoin (3, "请向 ", config, " 中手动添加:"));
println (content); print (content);
config = xy_normalize_path ("~/.stack/config.yaml"); config = xy_normalize_path ("~/.stack/config.yaml");
content = xy_str_gsub (RAWSTR_pl_haskell_stackage_yaml, "@url@", source.url); content = xy_str_gsub (RAWSTR_pl_haskell_stackage_yaml, "@url@", source.url);
chsrc_note2 (xy_strcat (3, "请向 ", config, " 中手动添加:")); chsrc_note2 (xy_strjoin (3, "请向 ", config, " 中手动添加:"));
println (content); print (content);
chsrc_determine_chgtype (ChgType_Manual);
chsrc_conclude (&source); chsrc_conclude (&source);
} }
Feature_t
pl_haskell_feat (char *option)
{
Feature_t f = {0};
f.can_get = false;
f.can_reset = false;
f.cap_locally = CanNot;
f.cap_locally_explain = NA;
f.can_english = false;
f.can_user_define = true;
f.note = NULL;
return f;
}
def_target_sf (pl_haskell);

View File

@ -1,154 +1,84 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nil Null <nil@null.org>
* |
* Created On : <2023-08-31>
* Last Modified : <2025-07-22>
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
def_target(pl_java, "java/maven/mvn/maven-daemon/mvnd/gradle"); static SourceProvider_t pl_java_upstream =
void
pl_java_prelude ()
{ {
chef_prep_this (pl_java, gsr); def_upstream, "https://mvnrepository.com/",
def_need_measure_info
};
chef_set_created_on (this, "2023-08-31"); /**
chef_set_last_updated (this, "2025-08-27"); * @update 2024-12-18
chef_set_sources_last_updated (this, "2024-12-18"); */
static Source_t pl_java_sources[] =
chef_set_chef (this, NULL); {
chef_set_cooks (this, 2, "@BingChunMoLi", "@ccmywish"); {&pl_java_upstream, NULL, NULL},
chef_set_sauciers (this, 0); {&Ali, "https://maven.aliyun.com/repository/public/", DelegateToMirror},
{&Huawei, "https://mirrors.huaweicloud.com/repository/maven/", DelegateToMirror},
chef_allow_local_mode (this, CanNot, NULL, NULL); /* 网易的24小时更新一次 */
chef_deny_english(this); {&Netease, "http://mirrors.163.com/maven/repository/maven-public/", DelegateToMirror}
chef_allow_user_define(this); };
def_sources_n(pl_java);
// 阿里巴巴开源镜像站需要修改为此才能测速
// https://github.com/RubyMetric/chsrc/issues/238#issuecomment-3162367686
chef_set_user_agent ("Maven/3.9.11");
def_sources_begin()
{&UpstreamProvider, "https://repo1.maven.org/maven2/", FeedByPrelude},
{&Ali, "https://maven.aliyun.com/repository/public/", FeedByPrelude},
{&Huawei, "https://mirrors.huaweicloud.com/repository/maven/", FeedByPrelude},
{&HuaweiCDN, "https://repo.huaweicloud.com/repository/maven/", FeedByPrelude},
{&Tencent, "https://mirrors.cloud.tencent.com/nexus/repository/maven-public/",FeedByPrelude},
// 网易的24小时更新一次
{&Netease, "http://mirrors.163.com/maven/repository/maven-public/", FeedByPrelude}
def_sources_end()
// 220MB
chef_set_sources_speed_measure_url_with_postfix (this, "com/tencentcloudapi/tencentcloud-sdk-java/3.1.1033/tencentcloud-sdk-java-3.1.1033-javadoc.jar");
}
void void
pl_java_check_cmd (bool *maven_exist, bool *gradle_exist, bool *maven_daemon_exist) pl_java_check_cmd (bool *maven_exist, bool *gradle_exist)
{ {
*maven_exist = chsrc_check_program ("mvn"); *maven_exist = chsrc_check_program ("mvn");
*gradle_exist = chsrc_check_program ("gradle"); *gradle_exist = chsrc_check_program ("gradle");
*maven_daemon_exist = chsrc_check_program ("mvnd");
if (! *maven_exist && ! *gradle_exist && ! *maven_daemon_exist) if (! *maven_exist && ! *gradle_exist)
{ {
chsrc_error ("maven(maven-daemon) 与 gradle 命令均未找到,请检查是否存在其一"); chsrc_error ("maven 与 gradle 命令均未找到,请检查是否存在其一");
exit (Exit_UserCause); exit (Exit_UserCause);
} }
} }
bool
pl_java_is_maven_home_line (const char *line)
{
if (xy_str_start_with (line, "Maven home:"))
return true;
else
return false;
}
/**
* @consult https://github.com/RubyMetric/chsrc/pull/268#issuecomment-3209071819
*/
char * char *
pl_java_find_maven_config () pl_java_find_maven_config ()
{ {
char *output; char *buf = xy_run ("mvn -v", 2);
int status = xy_run_get_stdout ("mvn -v", &output); char *maven_home = xy_str_delete_prefix (buf, "Maven home: ");
if (0==status) maven_home = xy_str_strip (maven_home);
{
char *maven_home_line = xy_run_iter_lines ("mvn -v", 0, pl_java_is_maven_home_line);
char *maven_home = xy_str_delete_prefix (maven_home_line, "Maven home: ");
char *maven_config = xy_normalize_path (xy_2strcat (maven_home, "/conf/settings.xml"));
return maven_config;
}
chsrc_alert2 ("未找到 maven home, 将使用用户配置文件"); char *maven_config = xy_normalize_path (xy_2strjoin (maven_home, "/conf/settings.xml"));
return "~/.m2/settings.xml"; return maven_config;
} }
char *
pl_java_find_maven_daemon_config ()
{
char *output;
int status = xy_run_get_stdout ("mvnd -v", &output);
if (0==status)
{
char *maven_home_line = xy_run_iter_lines ("mvnd -v", 0, pl_java_is_maven_home_line);
char *maven_home = xy_str_delete_prefix (maven_home_line, "Maven home: ");
char *maven_config = xy_normalize_path (xy_2strcat (maven_home, "/conf/settings.xml"));
return maven_config;
}
chsrc_alert2 ("未找到 maven home, 将使用用户配置文件");
return "~/.m2/settings.xml";
}
void void
pl_java_getsrc (char *option) pl_java_getsrc (char *option)
{ {
bool maven_exist, gradle_exist, maven_daemon_exist; bool maven_exist, gradle_exist;
pl_java_check_cmd (&maven_exist, &gradle_exist, &maven_daemon_exist); pl_java_check_cmd (&maven_exist, &gradle_exist);
if (maven_exist) char *maven_config = pl_java_find_maven_config ();
{ chsrc_note2 (xy_2strjoin ("请查看 ", maven_config));
char *maven_config = pl_java_find_maven_config ();
chsrc_note2 (xy_2strcat ("请查看 ", maven_config));
}
if (maven_daemon_exist)
{
char *maven_config = pl_java_find_maven_daemon_config ();
chsrc_note2 (xy_2strcat ("请查看 ", maven_config));
}
} }
/** /**
* @consult https://developer.aliyun.com/mirror/maven * @consult https://developer.aliyun.com/mirror/maven
*/ */
void void
pl_java_setsrc (char *option) pl_java_setsrc (char *option)
{ {
bool maven_exist, gradle_exist, maven_daemon_exist; bool maven_exist, gradle_exist;
pl_java_check_cmd (&maven_exist, &gradle_exist, &maven_daemon_exist); pl_java_check_cmd (&maven_exist, &gradle_exist);
chsrc_yield_source_and_confirm (pl_java);
chsrc_use_this_source(pl_java);
if (maven_exist) if (maven_exist)
{ {
char *file = xy_str_gsub (RAWSTR_pl_java_maven_config, "@1@", source.mirror->code); char *file = xy_str_gsub (RAWSTR_pl_java_maven_config, "@1@", source.mirror->code);
file = xy_str_gsub (file, "@name@", source.mirror->name); file = xy_str_gsub (file, "@name@", source.mirror->name);
file = xy_str_gsub (file, "@url@", source.url); file = xy_str_gsub (file, "@url@", source.url);
char *maven_config = pl_java_find_maven_config (); char *maven_config = pl_java_find_maven_config ();
chsrc_note2 (xy_strcat (3, "请在 maven 配置文件 ", maven_config, " 中添加:")); chsrc_note2 (xy_strjoin (3, "请在 maven 配置文件 ", maven_config, " 中添加:"));
println (file);
}
if (maven_daemon_exist)
{
char *file = xy_str_gsub (RAWSTR_pl_java_maven_config, "@1@", source.mirror->code);
file = xy_str_gsub (file, "@name@", source.mirror->name);
file = xy_str_gsub (file, "@url@", source.url);
char *maven_daemon_config = pl_java_find_maven_daemon_config ();
chsrc_note2 (xy_strcat (3, "请在 maven daemon 配置文件 ", maven_daemon_config, " 中添加:"));
println (file); println (file);
} }
@ -160,12 +90,26 @@ pl_java_setsrc (char *option)
println (file); println (file);
} }
chsrc_determine_chgtype (ChgType_Manual);
chsrc_conclude (&source); chsrc_conclude (&source);
} }
void Feature_t
pl_java_resetsrc (char *option) pl_java_feat (char *option)
{ {
pl_java_setsrc (option); Feature_t f = {0};
f.can_get = true;
f.can_reset = false;
f.cap_locally = CanNot;
f.cap_locally_explain = NA;
f.can_english = false;
f.can_user_define = true;
f.note = NULL;
return f;
} }
def_target_gsf(pl_java);

View File

@ -1,77 +0,0 @@
/** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later
* ------------------------------------------------------------*/
def_target(pl_js_bun, "bun");
void
pl_js_bun_prelude (void)
{
chef_prep_this (pl_js_bun, gsr);
chef_set_created_on (this, "2024-09-29");
chef_set_last_updated (this, "2025-07-22");
chef_set_sources_last_updated (this, "2025-07-22");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 1, "@lontten");
chef_allow_local_mode (this, FullyCan, NULL, NULL);
chef_allow_english(this);
chef_allow_user_define(this);
chef_use_other_target_sources (this, &pl_js_group_target);
}
/**
* chsrc get bun
*/
void
pl_js_bun_getsrc (char *option)
{
chsrc_view_file ("~/.bunfig.toml");
}
/**
* @consult https://bun.sh/docs/runtime/bunfig#global-vs-local
* @consult https://github.com/RubyMetric/chsrc/issues/83
* @consult https://github.com/RubyMetric/chsrc/pull/90
*
* chsrc set bun
*/
void
pl_js_bun_setsrc (char *option)
{
// 用的是 npm Registry 的源
Source_t source = chsrc_yield_source_and_confirm (&pl_js_group_target, option);
char *content = RAWSTR_pl_js_bun_config;
content = xy_str_gsub (content, "@url@", source.url);
if (chsrc_in_local_mode())
{
chsrc_note2 ("请手动写入以下内容到本项目根目录的 bunfig.toml 文件中");
}
else
{
chsrc_note2 (xy_strcat (3, "请手动写入以下内容到 ", xy_normalize_path ("~/.bunfig.toml"), " 文件中"));
}
println (content);
chsrc_determine_chgtype (ChgType_Auto);
chsrc_conclude (&source);
}
/**
* chsrc reset bun
*/
void
pl_js_bun_resetsrc (char *option)
{
pl_js_bun_setsrc (option);
}

View File

@ -1,77 +0,0 @@
/** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later
* ------------------------------------------------------------*/
static MirrorSite_t NpmMirror =
{
IS_DedicatedMirrorSite,
"npmmirror", "npmmirror", "npmmirror (阿里云赞助)", "https://npmmirror.com/",
{SKIP, NULL, NULL, NULL, ACCURATE}
};
def_target(pl_js_group, "js/javascript/node/nodejs");
void
pl_js_group_prelude (void)
{
chef_prep_this (pl_js_group, gsr);
chef_set_created_on (this, "2023-09-09");
chef_set_last_updated (this, "2025-07-11");
chef_set_sources_last_updated (this, "2025-07-11");
chef_set_chef (this, "@happy-game");
// 组换源的 leader target 应把所有 follower target 的贡献者都记录过来
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 2, "@lontten", "@MrWillCom");
chef_allow_local_mode (this, PartiallyCan,
"支持 npm, yarn v2, pnpm, 不支持 yarn v1",
"Support npm, yarn v2, pnpm, not yarn v1");
chef_allow_english(this);
chef_allow_user_define(this);
def_sources_begin()
{&UpstreamProvider, "https://registry.npmjs.org/", FeedByPrelude}, /* @note 根据 pnpm 官网,有最后的斜线 */
{&NpmMirror, "https://registry.npmmirror.com", FeedByPrelude},
{&Huawei, "https://mirrors.huaweicloud.com/repository/npm/", FeedByPrelude},
{&Tencent, "https://mirrors.cloud.tencent.com/npm/", FeedByPrelude}
def_sources_end()
// 29MB 大小
chef_set_sources_speed_measure_url_with_postfix (this, "/@tensorflow/tfjs/-/tfjs-4.22.0.tgz");
}
def_target(pl_js_nodejs_binary, "__internal_target_nodejs_binary__");
void
pl_js_nodejs_binary_prelude (void)
{
chef_prep_this (pl_js_nodejs_binary, NOOP);
chef_set_created_on (this, "2023-09-09");
chef_set_last_updated (this, "2025-08-22");
chef_set_sources_last_updated (this, "2025-07-11");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 0);
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_allow_english(this);
chef_allow_user_define(this);
def_sources_begin()
{&UpstreamProvider, "https://nodejs.org/dist/", FeedByPrelude},
{&NpmMirror, "https://npmmirror.com/mirrors", FeedByPrelude},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/nodejs-release/",FeedByPrelude},
{&Bfsu, "https://mirrors.bfsu.edu.cn/nodejs-release/",FeedByPrelude},
{&Ustc, "https://mirrors.ustc.edu.cn/node/",FeedByPrelude},
{&Huawei, "https://mirrors.huaweicloud.com/nodejs/",FeedByPrelude},
{&Tencent, "https://mirrors.cloud.tencent.com/nodejs-release/", FeedByPrelude}
def_sources_end()
chef_set_sources_speed_measure_url_with_postfix (this, "/v23.4.0/node-v23.4.0-linux-x64.tar.xz");
}

View File

@ -1,66 +0,0 @@
/** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later
* ------------------------------------------------------------*/
def_target(pl_js_npm, "npm");
void
pl_js_npm_prelude (void)
{
chef_prep_this (pl_js_npm, gsr);
chef_set_created_on (this, "2023-08-30");
chef_set_last_updated (this, "2025-07-11");
chef_set_sources_last_updated (this, "2025-07-11");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 1, "@MrWillCom");
chef_allow_local_mode (this, FullyCan, NULL, NULL);
chef_allow_english(this);
chef_allow_user_define(this);
chef_use_other_target_sources (this, &pl_js_group_target);
}
void
pl_js_npm_getsrc (char *option)
{
chsrc_run ("npm config get registry", RunOpt_No_Last_New_Line);
}
/**
* @consult https://npmmirror.com/
*/
void
pl_js_npm_setsrc (char *option)
{
Source_t source = chsrc_yield_source (&pl_js_group_target, option);
if (chsrc_in_standalone_mode())
chsrc_confirm_source(&source);
char *cmd = NULL;
if (chsrc_in_local_mode())
cmd = xy_2strcat ("npm config --location project set registry ", source.url);
else
cmd = xy_2strcat ("npm config set registry ", source.url);
chsrc_run (cmd, RunOpt_No_Last_New_Line);
if (chsrc_in_standalone_mode())
{
chsrc_determine_chgtype (ChgType_Auto);
chsrc_conclude (&source);
}
}
void
pl_js_npm_resetsrc (char *option)
{
pl_js_npm_setsrc (option);
}

View File

@ -1,70 +0,0 @@
/** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later
* ------------------------------------------------------------*/
def_target(pl_js_nvm, "nvm");
void
pl_js_nvm_prelude (void)
{
chef_prep_this (pl_js_nvm, gsr);
chef_set_created_on (this, "2024-09-23");
chef_set_last_updated (this, "2025-06-19");
chef_set_sources_last_updated (this, "2025-06-19");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 0);
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_allow_english(this);
chef_allow_user_define(this);
chef_set_note (this, "nvm 不支持 Fish shell", "nvm does not support Fish");
chef_use_other_target_sources (this, &pl_js_nodejs_binary_target);
}
void
pl_js_nvm_getsrc (char *option)
{
chsrc_view_env ("NVM_NODEJS_ORG_MIRROR", NULL);
}
/**
* @consult https://github.com/nvm-sh/nvm?tab=readme-ov-file#use-a-mirror-of-node-binaries
* @consult https://mirrors.tuna.tsinghua.edu.cn/help/nodejs-release/
* @issue https://github.com/RubyMetric/chsrc/issues/81
*
* @note nvm Fish
*/
void
pl_js_nvm_setsrc (char *option)
{
Source_t source = chsrc_yield_source_and_confirm (&pl_js_nodejs_binary_target, option);
char *w = xy_strcat (3, "export NVM_NODEJS_ORG_MIRROR=", source.url, "\n");
char *zshrc = xy_zshrc;
char *bashrc = xy_bashrc;
chsrc_append_to_file (w, bashrc);
if (xy_file_exist (zshrc))
chsrc_append_to_file (w, zshrc);
chsrc_determine_chgtype (ChgType_Auto);
chsrc_conclude (&source);
}
void
pl_js_nvm_resetsrc (char *option)
{
// pl_js_nvm_setsrc (ChgType_Reset);
chsrc_error ("暂不支持对 nvm 重置");
exit (Exit_Unsupported);
}

View File

@ -1,67 +0,0 @@
/** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later
* ------------------------------------------------------------*/
def_target(pl_js_pnpm, "pnpm");
void
pl_js_pnpm_prelude (void)
{
chef_prep_this (pl_js_pnpm, gsr);
chef_set_created_on (this, "2024-04-18");
chef_set_last_updated (this, "2025-07-11");
chef_set_sources_last_updated (this, "2025-07-11");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 0);
chef_allow_local_mode (this, FullyCan, NULL, NULL);
chef_allow_english(this);
chef_allow_user_define(this);
chef_use_other_target_sources (this, &pl_js_group_target);
}
void
pl_js_pnpm_getsrc (char *option)
{
chsrc_run ("pnpm config get registry", RunOpt_No_Last_New_Line);
}
/**
* @consult https://pnpm.io/feature-comparison
* @consult https://pnpm.io/cli/config
*/
void
pl_js_pnpm_setsrc (char *option)
{
Source_t source = chsrc_yield_source (&pl_js_group_target, option);
if (chsrc_in_standalone_mode())
chsrc_confirm_source(&source);
char *cmd = NULL;
if (chsrc_in_local_mode())
cmd = xy_2strcat ("pnpm config --location project set registry ", source.url);
else
cmd = xy_2strcat ("pnpm config -g set registry ", source.url);
chsrc_run (cmd, RunOpt_No_Last_New_Line);
if (chsrc_in_standalone_mode())
{
chsrc_determine_chgtype (ChgType_Auto);
chsrc_conclude (&source);
}
}
void
pl_js_pnpm_resetsrc (char *option)
{
pl_js_pnpm_setsrc (option);
}

View File

@ -1,33 +1,23 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nil Null <nil@null.org>
* Created On : <2023-08-31>
* Last Modified : <2025-07-14>
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
def_target(pl_julia, "julia"); /**
* @update 2025-07-14
void */
pl_julia_prelude () static Source_t pl_julia_sources[] =
{ {
chef_prep_this (pl_julia, gs); {&UpstreamProvider, NULL, NULL},
chef_set_created_on (this, "2023-08-31");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2025-08-22");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 1, "@hezonglun");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_allow_english(this);
chef_allow_user_define(this);
def_sources_begin()
{&UpstreamProvider, "https://pkg.julialang.org", DelegateToUpstream},
{&Pku, "https://mirrors.pku.edu.cn/julia", DelegateToMirror}, {&Pku, "https://mirrors.pku.edu.cn/julia", DelegateToMirror},
{&Nju, "https://mirror.nju.edu.cn/julia", DelegateToMirror}, {&Nju, "https://mirror.nju.edu.cn/julia", DelegateToMirror},
{&Iscas, "https://mirror.iscas.ac.cn/julia", DelegateToMirror} {&Iscas, "https://mirror.iscas.ac.cn/julia", DelegateToMirror}
def_sources_end() };
} def_sources_n(pl_julia);
#define PL_Julia_Config "~/.julia/config/startup.jl" #define PL_Julia_Config "~/.julia/config/startup.jl"
@ -52,11 +42,32 @@ pl_julia_getsrc (char *option)
void void
pl_julia_setsrc (char *option) pl_julia_setsrc (char *option)
{ {
chsrc_use_this_source (pl_julia); chsrc_yield_source_and_confirm (pl_julia);
char *w = xy_strcat (3, "ENV[\"JULIA_PKG_SERVER\"] = \"", source.url, "\""); char *w = xy_strjoin (3, "ENV[\"JULIA_PKG_SERVER\"] = \"", source.url, "\"");
chsrc_append_to_file (w, PL_Julia_Config); chsrc_append_to_file (w, PL_Julia_Config);
chsrc_determine_chgtype (ChgType_Untested);
chsrc_conclude (&source); chsrc_conclude (&source);
} }
Feature_t
pl_julia_feat (char *option)
{
Feature_t f = {0};
f.can_get = true;
f.can_reset = false;
f.cap_locally = CanNot;
f.cap_locally_explain = NA;
f.can_english = true;
f.can_user_define = true;
f.note = NULL;
return f;
}
def_target_gsf(pl_julia);

View File

@ -1,5 +1,10 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nil Null <nil@null.org>
* Created On : <2023-09-27>
* Last Modified : <2025-07-14>
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
static MirrorSite_t Api7 = static MirrorSite_t Api7 =
@ -9,30 +14,17 @@ static MirrorSite_t Api7 =
{SKIP, ToFill, ToFill, NULL, ROUGH} {SKIP, ToFill, ToFill, NULL, ROUGH}
}; };
def_target(pl_lua, "lua/luarocks");
void /**
pl_lua_prelude () * @update 2025-07-14
* @note
*/
static Source_t pl_lua_sources[] =
{ {
chef_prep_this (pl_lua, gs); {&UpstreamProvider, NULL, NULL},
{&Api7, "https://luarocks.cn", NULL},
chef_set_created_on (this, "2023-09-27"); };
chef_set_last_updated (this, "2025-08-10"); def_sources_n(pl_lua);
chef_set_sources_last_updated (this, "2025-08-22");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 1, "@hezonglun");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this);
chef_allow_user_define(this);
def_sources_begin()
{&UpstreamProvider, "https://luarocks.org", DelegateToUpstream},
{&Api7, "https://luarocks.cn", DelegateToMirror}
def_sources_end()
}
void void
@ -48,20 +40,41 @@ pl_lua_getsrc (char *option)
void void
pl_lua_setsrc (char *option) pl_lua_setsrc (char *option)
{ {
chsrc_use_this_source (pl_lua); chsrc_yield_source_and_confirm (pl_lua);
char *config = xy_strcat (3, "rocks_servers = {\n" char *config = xy_strjoin (3, "rocks_servers = {\n"
" \"", source.url, "\"\n" " \"", source.url, "\"\n"
"}"); "}");
chsrc_note2 ("请手动修改 ~/.luarocks/config.lua 文件 (用于下载):"); chsrc_note2 ("请手动修改 ~/.luarocks/config.lua 文件 (用于下载):");
println (config); println (config);
char *upload_config = xy_strcat (3, "key = \"<Your API Key>\"\n" char *upload_config = xy_strjoin (3, "key = \"<Your API Key>\"\n"
"server = \"", source.url, "\""); "server = \"", source.url, "\"");
chsrc_note2 ("请手动修改 ~/.luarocks/upload_config.lua 文件 (用于上传):"); chsrc_note2 ("请手动修改 ~/.luarocks/upload_config.lua 文件 (用于上传):");
println (upload_config); println (upload_config);
chsrc_determine_chgtype (ChgType_Manual);
chsrc_conclude (&source); chsrc_conclude (&source);
} }
Feature_t
pl_lua_feat (char *option)
{
Feature_t f = {0};
f.can_get = true;
f.can_reset = false;
f.cap_locally = CanNot;
f.cap_locally_explain = NA;
f.can_english = false;
f.can_user_define = true;
f.note = NULL;
return f;
}
def_target_gsf(pl_lua);

View File

@ -0,0 +1,84 @@
/** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Lontten <lontten@163.com>
* Created On : <2024-09-29>
* Last Modified : <2025-07-22>
* ------------------------------------------------------------*/
/**
* chsrc get bun
*/
void
pl_nodejs_bun_getsrc (char *option)
{
chsrc_view_file ("~/.bunfig.toml");
}
/**
* @consult https://bun.sh/docs/runtime/bunfig#global-vs-local
* @consult https://github.com/RubyMetric/chsrc/issues/83
* @consult https://github.com/RubyMetric/chsrc/pull/90
*
* chsrc set bun
*/
void
pl_nodejs_bun_setsrc (char *option)
{
// 用的是 npm Registry 的源
chsrc_yield_source (pl_nodejs_group);
char *content = RAWSTR_pl_nodejs_bun_config;
content = xy_str_gsub (content, "@url@", source.url);
if (chsrc_in_local_mode())
{
chsrc_note2 ("请手动写入以下内容到本项目根目录的 bunfig.toml 文件中");
}
else
{
chsrc_note2 (xy_strjoin (3, "请手动写入以下内容到 ", xy_normalize_path ("~/.bunfig.toml"), " 文件中"));
}
print (content);
chsrc_determine_chgtype (ChgType_Auto);
chsrc_conclude (&source);
}
/**
* chsrc reset bun
*/
void
pl_nodejs_bun_resetsrc (char *option)
{
pl_nodejs_bun_setsrc (option);
}
/**
* chsrc ls bun
*/
Feature_t
pl_nodejs_bun_feat (char *option)
{
Feature_t f = {0};
f.can_get = true;
f.can_reset = true;
f.cap_locally = FullyCan;
f.cap_locally_explain = NULL;
f.can_english = true;
f.can_user_define = true;
f.note = NULL;
return f;
}
// def_target_gsrf(pl_nodejs_bun);
Target_t pl_nodejs_bun_target = {def_target_inner_gsrf(pl_nodejs_bun),def_target_sourcesn(pl_nodejs_group)};

View File

@ -10,7 +10,7 @@
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
void void
pl_js_check_cmd (bool *npm_exist, bool *yarn_exist, bool *pnpm_exist) pl_nodejs_check_cmd (bool *npm_exist, bool *yarn_exist, bool *pnpm_exist)
{ {
*npm_exist = chsrc_check_program ("npm"); *npm_exist = chsrc_check_program ("npm");
*yarn_exist = chsrc_check_program ("yarn"); *yarn_exist = chsrc_check_program ("yarn");
@ -26,36 +26,42 @@ pl_js_check_cmd (bool *npm_exist, bool *yarn_exist, bool *pnpm_exist)
} }
/**
* chsrc get nodejs
*/
void void
pl_js_group_getsrc (char *option) pl_nodejs_group_getsrc (char *option)
{ {
bool npm_exist, yarn_exist, pnpm_exist; bool npm_exist, yarn_exist, pnpm_exist;
pl_js_check_cmd (&npm_exist, &yarn_exist, &pnpm_exist); pl_nodejs_check_cmd (&npm_exist, &yarn_exist, &pnpm_exist);
hr(); hr();
if (npm_exist) if (npm_exist)
{ {
pl_js_npm_getsrc (option); pl_nodejs_npm_getsrc (option);
br(); br();
} }
if (yarn_exist) if (yarn_exist)
{ {
pl_js_yarn_getsrc (option); pl_nodejs_yarn_getsrc (option);
br(); br();
} }
if (pnpm_exist) if (pnpm_exist)
{ {
pl_js_pnpm_getsrc (option); pl_nodejs_pnpm_getsrc (option);
br(); br();
} }
} }
/**
* chsrc set nodejs
*/
void void
pl_js_group_setsrc (char *option) pl_nodejs_group_setsrc (char *option)
{ {
{ {
char *msg = ENGLISH ? "Three package managers will be replaced for you at the same time: " char *msg = ENGLISH ? "Three package managers will be replaced for you at the same time: "
@ -66,27 +72,26 @@ pl_js_group_setsrc (char *option)
} }
bool npm_exist, yarn_exist, pnpm_exist; bool npm_exist, yarn_exist, pnpm_exist;
pl_js_check_cmd (&npm_exist, &yarn_exist, &pnpm_exist); pl_nodejs_check_cmd (&npm_exist, &yarn_exist, &pnpm_exist);
chsrc_set_target_group_mode (); chsrc_set_target_group_mode ();
chsrc_yield_source_and_confirm (pl_nodejs_group);
chsrc_use_this_source (pl_js_group);
if (npm_exist) if (npm_exist)
{ {
pl_js_npm_setsrc (option); pl_nodejs_npm_setsrc (option);
br(); br();
} }
if (yarn_exist) if (yarn_exist)
{ {
pl_js_yarn_setsrc (option); pl_nodejs_yarn_setsrc (option);
br(); br();
} }
if (pnpm_exist) if (pnpm_exist)
{ {
pl_js_pnpm_setsrc (option); pl_nodejs_pnpm_setsrc (option);
} }
chsrc_determine_chgtype (ChgType_Auto); chsrc_determine_chgtype (ChgType_Auto);
@ -94,8 +99,33 @@ pl_js_group_setsrc (char *option)
} }
/**
* chsrc reset nodejs
*/
void void
pl_js_group_resetsrc (char *option) pl_nodejs_group_resetsrc (char *option)
{ {
pl_js_group_setsrc (option); pl_nodejs_group_setsrc (option);
} }
/**
* chsrc ls nodejs
*/
Feature_t
pl_nodejs_group_feat (char *option)
{
Feature_t f = {0};
f.can_get = true;
f.can_reset = true;
f.cap_locally = FullyCan;
f.cap_locally_explain = "Support `npm` & `yarn v2` & `pnpm`. No support for `yarn v1`";
f.can_english = true;
f.can_user_define = true;
return f;
}
def_target_gsrf (pl_nodejs_group);

View File

@ -1,31 +1,15 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Mr. Will <mr.will.com@outlook.com>
* Created On : <2023-09-09>
* Major Reviison : 3
* Last Modified : <2025-07-11>
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
def_target(pl_js_yarn, "yarn");
void
pl_js_yarn_prelude (void)
{
chef_prep_this (pl_js_yarn, gsr);
chef_set_created_on (this, "2023-09-09");
chef_set_last_updated (this, "2025-07-11");
chef_set_sources_last_updated (this, "2025-07-11");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 1, "@MrWillCom");
chef_allow_local_mode (this, FullyCan, NULL, NULL);
chef_allow_english(this);
chef_allow_user_define(this);
chef_use_other_target_sources (this, &pl_js_group_target);
}
static double static double
pl_js_yarn_get_yarn_version () pl_nodejs_yarn_get_yarn_version ()
{ {
char *ver = xy_run ("yarn --version", 0); char *ver = xy_run ("yarn --version", 0);
double version = atof (ver); double version = atof (ver);
@ -33,11 +17,14 @@ pl_js_yarn_get_yarn_version ()
} }
/**
* chsrc get yarn
*/
void void
pl_js_yarn_getsrc (char *option) pl_nodejs_yarn_getsrc (char *option)
{ {
// 最后一个版本应该是 v1.22.22 // 最后一个版本应该是 v1.22.22
if (pl_js_yarn_get_yarn_version () >= 2) if (pl_nodejs_yarn_get_yarn_version () >= 2)
// https://github.com/RubyMetric/chsrc/issues/53 // https://github.com/RubyMetric/chsrc/issues/53
// 从 Yarn V2 开始,使用新的配置名 // 从 Yarn V2 开始,使用新的配置名
chsrc_run ("yarn config get npmRegistryServer", RunOpt_No_Last_New_Line); chsrc_run ("yarn config get npmRegistryServer", RunOpt_No_Last_New_Line);
@ -51,21 +38,21 @@ pl_js_yarn_getsrc (char *option)
* @consult https://yarnpkg.com/cli/config/set * @consult https://yarnpkg.com/cli/config/set
*/ */
void void
pl_js_yarn_setsrc (char *option) pl_nodejs_yarn_setsrc (char *option)
{ {
Source_t source = chsrc_yield_source (&pl_js_group_target, option); chsrc_yield_source (pl_nodejs_group);
if (chsrc_in_standalone_mode()) if (chsrc_in_standalone_mode())
chsrc_confirm_source(&source); chsrc_confirm_source();
char *cmd = NULL; char *cmd = NULL;
// 从 Yarn V2 开始,使用新的配置名 // 从 Yarn V2 开始,使用新的配置名
if (pl_js_yarn_get_yarn_version () >= 2) if (pl_nodejs_yarn_get_yarn_version () >= 2)
{ {
if (chsrc_in_local_mode()) // Yarn 默认情况下就是基于本项目换源 if (chsrc_in_local_mode()) // Yarn 默认情况下就是基于本项目换源
cmd = xy_2strcat ("yarn config set npmRegistryServer ", source.url); cmd = xy_2strjoin ("yarn config set npmRegistryServer ", source.url);
else else
cmd = xy_2strcat ("yarn config set npmRegistryServer --home ", source.url); cmd = xy_2strjoin ("yarn config set npmRegistryServer --home ", source.url);
chsrc_run (cmd, RunOpt_No_Last_New_Line); chsrc_run (cmd, RunOpt_No_Last_New_Line);
} }
@ -78,8 +65,8 @@ pl_js_yarn_setsrc (char *option)
// 不能直接退出,因为 Leader target 不能就此结束 // 不能直接退出,因为 Leader target 不能就此结束
return; return;
} }
// 不再阻止换源命令输出到终端,即不再调用 xy_quiet_cmd() // 不再阻止换源命令输出到终端,即不再调用 xy_str_to_quietcmd()
cmd = xy_2strcat ("yarn config set registry ", source.url); cmd = xy_2strjoin ("yarn config set registry ", source.url);
chsrc_run (cmd, RunOpt_No_Last_New_Line); chsrc_run (cmd, RunOpt_No_Last_New_Line);
} }
@ -91,8 +78,35 @@ pl_js_yarn_setsrc (char *option)
} }
/**
* chsrc reset yarn
*/
void void
pl_js_yarn_resetsrc (char *option) pl_nodejs_yarn_resetsrc (char *option)
{ {
pl_js_yarn_setsrc (option); pl_nodejs_yarn_setsrc (option);
} }
/**
* chsrc ls yarn
*/
Feature_t
pl_nodejs_yarn_feat (char *option)
{
Feature_t f = {0};
f.can_get = true;
f.can_reset = true;
f.cap_locally = FullyCan;
f.cap_locally_explain = NULL;
f.can_english = true;
f.can_user_define = true;
f.note = NULL;
return f;
}
// def_target_gsrf(pl_nodejs_yarn);
Target_t pl_nodejs_yarn_target = {def_target_inner_gsrf(pl_nodejs_yarn),def_target_sourcesn(pl_nodejs_group)};

View File

@ -0,0 +1,86 @@
/** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nul None <nul@none.org>
* |
* Created On : <2023-09-09>
* Major Revision : 1
* Last Modified : <2025-07-11>
* ------------------------------------------------------------*/
#define PL_Nodejs_Group_Speed_URL_Postfix "/@tensorflow/tfjs/-/tfjs-4.22.0.tgz"
static SourceProvider_t pl_nodejs_npm_upstream =
{
def_upstream, "https://www.npmjs.com/",
{NotSkip, NA, NA, "https://registry.npmjs.org/@tensorflow/tfjs/-/tfjs-4.22.0.tgz", ACCURATE}
};
static MirrorSite_t NpmMirror =
{
IS_DedicatedMirrorSite,
"npmmirror", "npmmirror", "npmmirror (阿里云赞助)", "https://npmmirror.com/",
// 注意,下面这个是跳转后的地址,不确定未来会不会改变
{NotSkip, NA, NA, "https://cdn.npmmirror.com/packages/%40tensorflow/tfjs/4.22.0/tfjs-4.22.0.tgz", ACCURATE} // 29MB
};
/**
* @update 2025-07-11
* @sync https://github.com/RubyMetric/chsrc/wiki/Node.js-MirrorSite
* @sync https://github.com/RubyMetric/chsrc/discussions/85
*
* @note
* Sjtug, Tuna, Lzuoss, Jlu, Bfsu,
*/
static Source_t pl_nodejs_group_sources[] =
{
{&pl_nodejs_npm_upstream, "https://registry.npmjs.org/", DelegateToUpstream}, /* @note 根据 pnpm 官网,有最后的斜线 */
{&NpmMirror, "https://registry.npmmirror.com", DelegateToMirror},
{&Huawei, "https://mirrors.huaweicloud.com/repository/npm/",
"https://mirrors.huaweicloud.com/repository/npm/" PL_Nodejs_Group_Speed_URL_Postfix},
{&Tencent, "https://mirrors.cloud.tencent.com/npm/",
"https://mirrors.cloud.tencent.com/npm/" PL_Nodejs_Group_Speed_URL_Postfix},
};
def_sources_n(pl_nodejs_group);
#define PL_Nodejs_Binary_Speed_URL_Postfix "/v23.4.0/node-v23.4.0-linux-x64.tar.xz"
static SourceProvider_t pl_nodejs_binary_release_upstream =
{
def_upstream, "https://nodejs.org/",
{NotSkip, NA, NA, "https://nodejs.org/dist/v23.4.0/node-v23.4.0.tar.gz", ACCURATE} // 100MB
};
/**
* @update 2025-07-11
* @sync https://github.com/RubyMetric/chsrc/wiki/Node.js-BinaryRelease-MirrorSite
* @sync https://github.com/RubyMetric/chsrc/discussions/85
*
*/
static Source_t pl_nodejs_binary_release_sources[] =
{
{&pl_nodejs_binary_release_upstream, "https://nodejs.org/dist/", DelegateToUpstream},
{&NpmMirror, "https://npmmirror.com/mirrors",
"https://registry.npmmirror.com/-/binary/node/v23.4.0/node-v23.4.0.tar.gz"},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/nodejs-release/",
"https://mirrors.tuna.tsinghua.edu.cn/nodejs-release/" PL_Nodejs_Binary_Speed_URL_Postfix},
{&Bfsu, "https://mirrors.bfsu.edu.cn/nodejs-release/",
"https://mirrors.bfsu.edu.cn/nodejs-release/" PL_Nodejs_Binary_Speed_URL_Postfix},
{&Ustc, "https://mirrors.ustc.edu.cn/node/",
"https://mirrors.ustc.edu.cn/node/" PL_Nodejs_Binary_Speed_URL_Postfix},
{&Huawei, "https://mirrors.huaweicloud.com/nodejs/",
"https://mirrors.huaweicloud.com/nodejs/" PL_Nodejs_Binary_Speed_URL_Postfix},
{&Tencent, "https://mirrors.cloud.tencent.com/nodejs-release/",
"https://mirrors.cloud.tencent.com/nodejs-release/" PL_Nodejs_Binary_Speed_URL_Postfix}
};
def_sources_n(pl_nodejs_binary_release);

View File

@ -0,0 +1,81 @@
/** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Mr. Will <mr.will.com@outlook.com>
* Created On : <2023-08-30>
* Major Revision : 2
* Last Modified : <2025-07-11>
* ------------------------------------------------------------*/
/**
* chsrc get npm
*/
void
pl_nodejs_npm_getsrc (char *option)
{
chsrc_run ("npm config get registry", RunOpt_No_Last_New_Line);
}
/**
* @consult https://npmmirror.com/
*
* chsrc set npm
*/
void
pl_nodejs_npm_setsrc (char *option)
{
chsrc_yield_source (pl_nodejs_group);
if (chsrc_in_standalone_mode())
chsrc_confirm_source();
char *cmd = NULL;
if (chsrc_in_local_mode())
cmd = xy_2strjoin ("npm config --location project set registry ", source.url);
else
cmd = xy_2strjoin ("npm config set registry ", source.url);
chsrc_run (cmd, RunOpt_No_Last_New_Line);
if (chsrc_in_standalone_mode())
{
chsrc_determine_chgtype (ChgType_Auto);
chsrc_conclude (&source);
}
}
/**
* chsrc reset npm
*/
void
pl_nodejs_npm_resetsrc (char *option)
{
pl_nodejs_npm_setsrc (option);
}
/**
* chsrc ls npm
*/
Feature_t
pl_nodejs_npm_feat (char *option)
{
Feature_t f = {0};
f.can_get = true;
f.can_reset = true;
f.cap_locally = FullyCan;
f.cap_locally_explain = NULL;
f.can_english = true;
f.can_user_define = true;
f.note = NULL;
return f;
}
// def_target_gsrf(pl_nodejs_npm);
Target_t pl_nodejs_npm_target = {def_target_inner_gsrf(pl_nodejs_npm),def_target_sourcesn(pl_nodejs_group)};

View File

@ -0,0 +1,83 @@
/** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nul None <nul@none.org>
* |
* Created On : <2024-09-23>
* Last Modified : <2025-06-19>
* ------------------------------------------------------------*/
/**
* chsrc get nvm
*/
void
pl_nodejs_nvm_getsrc (char *option)
{
chsrc_view_env ("NVM_NODEJS_ORG_MIRROR", NULL);
}
/**
* @consult https://github.com/nvm-sh/nvm?tab=readme-ov-file#use-a-mirror-of-node-binaries
* @consult https://mirrors.tuna.tsinghua.edu.cn/help/nodejs-release/
* @issue https://github.com/RubyMetric/chsrc/issues/81
*
* chsrc set nvm
*
* @note nvm does not support Fish
*/
void
pl_nodejs_nvm_setsrc (char *option)
{
chsrc_yield_source_and_confirm (pl_nodejs_binary_release);
char *w = xy_strjoin (3, "export NVM_NODEJS_ORG_MIRROR=", source.url, "\n");
char *zshrc = xy_zshrc;
char *bashrc = xy_bashrc;
chsrc_append_to_file (w, bashrc);
if (xy_file_exist (zshrc))
chsrc_append_to_file (w, zshrc);
chsrc_determine_chgtype (ChgType_Auto);
chsrc_conclude (&source);
}
/**
* chsrc reset nvm
*/
void
pl_nodejs_nvm_resetsrc (char *option)
{
// pl_nodejs_nvm_setsrc (ChgType_Reset);
chsrc_error ("暂不支持对 nvm 重置");
exit (Exit_Unsupported);
}
/**
* chsrc ls nvm
*/
Feature_t
pl_nodejs_nvm_feat (char *option)
{
Feature_t f = {0};
f.can_get = true;
f.can_reset = false;
f.cap_locally = CanNot;
f.cap_locally_explain = "";
f.can_english = false;
f.can_user_define = true;
f.note = NULL;
return f;
}
// def_target_gsrf(pl_nodejs_nvm);
Target_t pl_nodejs_nvm_target = {def_target_inner_gsrf(pl_nodejs_nvm),def_target_sourcesn(pl_nodejs_binary_release)};

View File

@ -0,0 +1,83 @@
/** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nul None <nul@none.org>
* Created On : <2024-04-18>
* Major Revision : 2
* Last Modified : <2025-07-11>
* ------------------------------------------------------------*/
/**
* chsrc get pnpm
*/
void
pl_nodejs_pnpm_getsrc (char *option)
{
chsrc_run ("pnpm config get registry", RunOpt_No_Last_New_Line);
}
/**
* @consult https://pnpm.io/feature-comparison
* @consult https://pnpm.io/cli/config
*
* chsrc set pnpm
*/
void
pl_nodejs_pnpm_setsrc (char *option)
{
chsrc_yield_source (pl_nodejs_group);
if (chsrc_in_standalone_mode())
chsrc_confirm_source();
char *cmd = NULL;
if (chsrc_in_local_mode())
cmd = xy_2strjoin ("pnpm config --location project set registry ", source.url);
else
cmd = xy_2strjoin ("pnpm config -g set registry ", source.url);
chsrc_run (cmd, RunOpt_No_Last_New_Line);
if (chsrc_in_standalone_mode())
{
chsrc_determine_chgtype (ChgType_Auto);
chsrc_conclude (&source);
}
}
/**
* chsrc reset pnpm
*/
void
pl_nodejs_pnpm_resetsrc (char *option)
{
pl_nodejs_pnpm_setsrc (option);
}
/**
* chsrc ls pnpm
*/
Feature_t
pl_nodejs_pnpm_feat (char *option)
{
Feature_t f = {0};
f.can_get = true;
f.can_reset = true;
f.cap_locally = FullyCan;
f.cap_locally_explain = NULL;
f.can_english = true;
f.can_user_define = true;
f.note = NULL;
return f;
}
// def_target_gsrf(pl_nodejs_pnpm);
Target_t pl_nodejs_pnpm_target = {def_target_inner_gsrf(pl_nodejs_pnpm),def_target_sourcesn(pl_nodejs_group)};

View File

@ -1,31 +1,33 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nil Null <nil@null.org>
* Created On : <2023-09-10>
* Last Modified : <2024-08-09>
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
def_target(pl_nuget, "nuget/net/.net/dotnet"); static MirrorSite_t NugetOrg =
void
pl_nuget_prelude ()
{ {
chef_prep_this (pl_nuget, gs); IS_UpstreamProvider,
"nuget.org", "NuGet Org", "Nuget Organization", "https://www.nuget.org/",
{SKIP, ToFill, ToFill, NULL, ROUGH}
};
chef_set_created_on (this, "2023-09-10"); /**
chef_set_last_updated (this, "2025-08-10"); * @update 2024-04-18
chef_set_sources_last_updated (this, "2024-04-18"); * @note {
*
chef_set_chef (this, NULL); * https://mirrors.huaweicloud.com/mirrorDetail/5ebf85de07b41baf6d0882ab?mirrorName=nuget&catalog=language
chef_set_cooks (this, 1, "@ccmywish"); * }
chef_set_sauciers (this, 0); */
static Source_t pl_nuget_sources[] =
chef_allow_local_mode (this, CanNot, NULL, NULL); {
chef_deny_english(this); {&UpstreamProvider, NULL, NULL},
chef_deny_user_define(this); {&NugetOrg, "https://www.nuget.org/api/v2/", NULL},
def_sources_begin()
{&UpstreamProvider, "https://www.nuget.org/api/v3/", DelegateToUpstream},
{&Huawei, "https://mirrors.huaweicloud.com/repository/nuget/v3", DelegateToMirror} {&Huawei, "https://mirrors.huaweicloud.com/repository/nuget/v3", DelegateToMirror}
def_sources_end() };
} def_sources_n(pl_nuget);
void void
@ -35,11 +37,28 @@ pl_nuget_getsrc (char *option)
} }
/**
* https://mirrors.huaweicloud.com/mirrorDetail/5ebf85de07b41baf6d0882ab?mirrorName=nuget&catalog=language
*/
void void
pl_nuget_setsrc (char *option) pl_nuget_setsrc (char *option)
{ {
chsrc_error ("暂时无法为NuGet换源若有需求请提交issue"); chsrc_error ("暂时无法为NuGet换源若有需求请提交issue");
} }
Feature_t
pl_nuget_feat (char *option)
{
Feature_t f = {0};
f.can_get = false;
f.can_reset = false;
f.cap_locally = CanNot;
f.cap_locally_explain = NA;
f.can_english = false;
f.can_user_define = false;
f.note = NULL;
return f;
}
def_target_gsf(pl_nuget);

View File

@ -1,31 +1,21 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nil Null <nil@null.org>
* Created On : <2023-09-15>
* Last Modified : <2025-07-14>
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
def_target(pl_ocaml, "ocaml/opam"); /**
* @update 2025-07-14
void */
pl_ocaml_prelude () static Source_t pl_ocaml_sources[] =
{ {
chef_prep_this (pl_ocaml, gs); {&UpstreamProvider, NULL, NULL},
{&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/git/opam-repository.git", NULL}
chef_set_created_on (this, "2023-09-15"); };
chef_set_last_updated (this, "2025-08-10"); def_sources_n(pl_ocaml);
chef_set_sources_last_updated (this, "2025-07-14");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 1, "@hezonglun");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this);
chef_allow_user_define(this);
def_sources_begin()
{&UpstreamProvider, "https://opam.ocaml.org/", DelegateToUpstream},
{&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/git/opam-repository.git", DelegateToMirror}
def_sources_end()
}
void void
@ -51,16 +41,38 @@ pl_ocaml_setsrc (char *option)
{ {
pl_ocaml_check_cmd (); pl_ocaml_check_cmd ();
chsrc_use_this_source (pl_ocaml); chsrc_yield_source_and_confirm (pl_ocaml);
char *cmd = xy_strcat (3, "opam repo set-url default ", char *cmd = xy_strjoin (3, "opam repo set-url default ",
source.url, source.url,
" --all --set-default"); " --all --set-default");
chsrc_run (cmd, RunOpt_Default); chsrc_run (cmd, RunOpt_Default);
chsrc_alert2 ("如果是首次使用 opam ,请使用以下命令进行初始化"); chsrc_alert2 ("如果是首次使用 opam ,请使用以下命令进行初始化");
println (xy_2strcat ("opam init default ", source.url)); println (xy_2strjoin ("opam init default ", source.url));
chsrc_determine_chgtype (ChgType_SemiAuto);
chsrc_conclude (&source); chsrc_conclude (&source);
} }
Feature_t
pl_ocaml_feat (char *option)
{
Feature_t f = {0};
f.can_get = true;
f.can_reset = false;
f.cap_locally = CanNot;
f.cap_locally_explain = NA;
f.can_english = false;
f.can_user_define = true;
f.note = NULL;
return f;
}
def_target_gsf(pl_ocaml);

View File

@ -1,34 +1,25 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nil Null <nil@null.org>
* Created On : <2023-08-30>
* Last Modified : <2024-11-22>
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
def_target(pl_php, "php/composer"); /**
* @update 2024-09-14
void * @note
pl_php_prelude () */
static Source_t pl_php_sources[] =
{ {
chef_prep_this (pl_php, gs); {&UpstreamProvider, NULL},
{&Ali, "https://mirrors.aliyun.com/composer/"},
chef_set_created_on (this, "2023-08-30"); {&Tencent, "https://mirrors.tencent.com/composer/"},
chef_set_last_updated (this, "2025-08-10"); // {&Tencent_Intra, "https://mirrors.tencentyun.com/composer/"},
chef_set_sources_last_updated (this, "2025-08-24"); {&Huawei, "https://mirrors.huaweicloud.com/repository/php/"}
};
chef_set_chef (this, NULL); def_sources_n(pl_php);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 1, "@hezonglun");
chef_allow_local_mode (this, FullyCan, NULL, NULL);
chef_deny_english(this);
chef_allow_user_define(this);
def_sources_begin()
{&UpstreamProvider, "https://packagist.org/", DelegateToUpstream},
{&Ali, "https://mirrors.aliyun.com/composer/", DelegateToMirror},
{&Tencent, "https://mirrors.tencent.com/composer/", DelegateToMirror},
// {&Tencent_Intra, "https://mirrors.tencentyun.com/composer/", DelegateToMirror},
{&Huawei, "https://mirrors.huaweicloud.com/repository/php/", DelegateToMirror}
def_sources_end()
}
void void
@ -55,7 +46,7 @@ pl_php_setsrc (char *option)
{ {
pl_php_check_cmd (); pl_php_check_cmd ();
chsrc_use_this_source (pl_php); chsrc_yield_source_and_confirm (pl_php);
char *where = " -g "; char *where = " -g ";
if (chsrc_in_local_mode()) if (chsrc_in_local_mode())
@ -63,8 +54,28 @@ pl_php_setsrc (char *option)
where = " "; where = " ";
} }
char *cmd = xy_strcat (4, "composer config", where, "repo.packagist composer ", source.url); char *cmd = xy_strjoin (4, "composer config", where, "repo.packagist composer ", source.url);
chsrc_run (cmd, RunOpt_Default); chsrc_run (cmd, RunOpt_Default);
chsrc_determine_chgtype (ChgType_Auto);
chsrc_conclude (&source); chsrc_conclude (&source);
} }
Feature_t
pl_php_feat (char *option)
{
Feature_t f = {0};
f.can_get = true;
f.can_reset = false;
f.cap_locally = FullyCan;
f.cap_locally_explain = "Support `composer`";
f.can_english = false;
f.can_user_define = true;
return f;
}
def_target_gsf (pl_php);

View File

@ -1,46 +1,33 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nil Null <nil@null.org>
* |
* Created On : <2023-09-31>
* Last Modified : <2025-07-14>
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
def_target(pl_perl, "perl/cpan"); static SourceProvider_t pl_perl_upstream =
void
pl_perl_prelude ()
{ {
chef_prep_this (pl_perl, gs); def_upstream, "https://metacpan.org/",
def_need_measure_info
};
chef_set_created_on (this, "2023-09-31"); /**
chef_set_last_updated (this, "2025-10-07"); * @update 2024-05-24
chef_set_sources_last_updated (this, "2025-10-07"); */
static Source_t pl_perl_sources[] =
chef_set_chef (this, NULL); {
chef_set_cooks (this, 1, "@ccmywish"); {&pl_perl_upstream, NULL, NULL},
chef_set_sauciers (this, 2, "@hezonglun", "@Mikachu2333"); {&Bfsu, "https://mirrors.bfsu.edu.cn/CPAN/", DelegateToMirror},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/CPAN/", DelegateToMirror},
chef_allow_local_mode (this, CanNot, NULL, NULL); {&Bjtu, "https://mirror.bjtu.edu.cn/cpan/", DelegateToMirror},
chef_deny_english (this); {&Hust, "https://mirrors.hust.edu.cn/CPAN/", DelegateToMirror},
chef_allow_user_define (this); {&Ali, "https://mirrors.aliyun.com/CPAN/", DelegateToMirror},
{&Lzuoss, "https://mirror.lzu.edu.cn/CPAN/", DelegateToMirror}
def_sources_begin() };
{&UpstreamProvider, "https://www.cpan.org/", FeedByPrelude}, def_sources_n(pl_perl);
{&MirrorZ, "https://mirrors.cernet.edu.cn/CPAN/", FeedByPrelude},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/CPAN/", FeedByPrelude},
{&Bfsu, "https://mirrors.bfsu.edu.cn/CPAN/", FeedByPrelude},
{&Cqu, "https://mirrors.cqu.edu.cn/CPAN/", FeedByPrelude},
{&Bjtu, "https://mirror.bjtu.edu.cn/cpan/", FeedByPrelude},
{&Nju, "https://mirrors.nju.edu.cn/CPAN/", FeedByPrelude},
{&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()
chef_set_sources_speed_measure_url_with_postfix (this, "authors/id/D/DB/DBAURAIN/Bio-MUST-Apps-FortyTwo-0.213470.tar.gz");
}
void void
@ -67,14 +54,36 @@ pl_perl_getsrc (char *option)
void void
pl_perl_setsrc (char *option) pl_perl_setsrc (char *option)
{ {
chsrc_use_this_source (pl_perl); chsrc_yield_source_and_confirm (pl_perl);
char *cmd = xy_strcat (3, char *cmd = xy_strjoin (3,
"perl -MCPAN -e \"CPAN::HandleConfig->load(); CPAN::HandleConfig->edit('urllist', 'unshift', '", source.url, "'); CPAN::HandleConfig->commit()\""); "perl -MCPAN -e \"CPAN::HandleConfig->load(); CPAN::HandleConfig->edit('urllist', 'unshift', '", source.url, "'); CPAN::HandleConfig->commit()\"");
chsrc_run (cmd, RunOpt_Default); chsrc_run (cmd, RunOpt_Default);
chsrc_alert2 ("请使用 perl -v 以及 cpan -v若 Perl >= v5.36 或 CPAN >= 2.29,请额外手动调用下面的命令"); chsrc_alert2 ("请使用 perl -v 以及 cpan -v若 Perl >= v5.36 或 CPAN >= 2.29,请额外手动调用下面的命令");
p ("perl -MCPAN -e \"CPAN::HandleConfig->load(); CPAN::HandleConfig->edit('pushy_https', 0);; CPAN::HandleConfig->commit()\""); p ("perl -MCPAN -e \"CPAN::HandleConfig->load(); CPAN::HandleConfig->edit('pushy_https', 0);; CPAN::HandleConfig->commit()\"");
chsrc_determine_chgtype (ChgType_SemiAuto);
chsrc_conclude (&source); chsrc_conclude (&source);
} }
Feature_t
pl_perl_feat (char *option)
{
Feature_t f = {0};
f.can_get = true;
f.can_reset = false;
f.cap_locally = CanNot;
f.cap_locally_explain = NA;
f.can_english = false;
f.can_user_define = true;
f.note = NULL;
return f;
}
def_target_gsf(pl_perl);

View File

@ -1,30 +1,15 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nul None <nul@none.org>
* Created On : <2024-06-05>
* Last Modified : <2025-07-11>
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
def_target(pl_python_pdm, "pdm"); /**
* chsrc get pdm
void */
pl_python_pdm_prelude (void)
{
chef_prep_this (pl_python_pdm, gsr);
chef_set_created_on (this, "2024-06-05");
chef_set_last_updated (this, "2025-07-11");
chef_set_sources_last_updated (this, "2025-07-11");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 0);
chef_allow_local_mode (this, FullyCan, NULL, NULL);
chef_allow_english(this);
chef_allow_user_define(this);
chef_use_other_target_sources (this, &pl_python_group_target);
}
void void
pl_python_pdm_getsrc (char *option) pl_python_pdm_getsrc (char *option)
{ {
@ -37,20 +22,22 @@ pl_python_pdm_getsrc (char *option)
/** /**
* @consult https://github.com/RubyMetric/chsrc/issues/19 * @consult https://github.com/RubyMetric/chsrc/issues/19
*
* chsrc set pdm
*/ */
void void
pl_python_pdm_setsrc (char *option) pl_python_pdm_setsrc (char *option)
{ {
Source_t source = chsrc_yield_source (&pl_python_group_target, option); chsrc_yield_source (pl_python_group);
if (chsrc_in_standalone_mode()) if (chsrc_in_standalone_mode())
chsrc_confirm_source(&source); chsrc_confirm_source();
char *cmd = NULL; char *cmd = NULL;
if (chsrc_in_local_mode()) if (chsrc_in_local_mode())
cmd = xy_2strcat ("pdm config --local pypi.url ", source.url); cmd = xy_2strjoin ("pdm config --local pypi.url ", source.url);
else else
cmd = xy_2strcat ("pdm config --global pypi.url ", source.url); cmd = xy_2strjoin ("pdm config --global pypi.url ", source.url);
chsrc_run (cmd, RunOpt_No_Last_New_Line); chsrc_run (cmd, RunOpt_No_Last_New_Line);
@ -61,8 +48,38 @@ pl_python_pdm_setsrc (char *option)
} }
} }
/**
* chsrc reset pdm
*/
void void
pl_python_pdm_resetsrc (char *option) pl_python_pdm_resetsrc (char *option)
{ {
pl_python_pdm_setsrc (option); pl_python_pdm_setsrc (option);
} }
/**
* chsrc ls pdm
*/
Feature_t
pl_python_pdm_feat (char *option)
{
Feature_t f = {0};
f.can_get = true;
f.can_reset = true;
// PDM 完全支持项目级换源
f.cap_locally = FullyCan;
f.cap_locally_explain = NULL;
f.can_english = true;
f.can_user_define = true;
f.note = NULL;
return f;
}
// def_target_gsrf(pl_python_pdm);
Target_t pl_python_pdm_target = {def_target_inner_gsrf(pl_python_pdm),def_target_sourcesn(pl_python_group)};

View File

@ -1,29 +1,17 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nil Null <nil@null.org>
* Created On : <2024-08-08>
* Last Modified : <2025-07-11>
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
def_target(pl_python_poetry, "poetry"); // @note Poetry 默认使用项目级换源
void
pl_python_poetry_prelude (void)
{
chef_prep_this (pl_python_poetry, gsr);
chef_set_created_on (this, "2024-08-08");
chef_set_last_updated (this, "2025-07-11");
chef_set_sources_last_updated (this, "2025-07-11");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 0);
chef_allow_local_mode (this, FullyCan, "Poetry 默认使用项目级换源", "Poetry uses project-level source changing by default");
chef_allow_english(this);
chef_allow_user_define(this);
chef_use_other_target_sources (this, &pl_python_group_target);
}
/**
* chsrc get poetry
*/
void void
pl_python_poetry_getsrc (char *option) pl_python_poetry_getsrc (char *option)
{ {
@ -33,20 +21,22 @@ pl_python_poetry_getsrc (char *option)
/** /**
* @consult https://python-poetry.org/docs/repositories/#project-configuration * @consult https://python-poetry.org/docs/repositories/#project-configuration
*
* chsrc set poetry
*/ */
void void
pl_python_poetry_setsrc (char *option) pl_python_poetry_setsrc (char *option)
{ {
Source_t source = chsrc_yield_source (&pl_python_group_target, option); chsrc_yield_source (pl_python_group);
if (chsrc_in_standalone_mode()) if (chsrc_in_standalone_mode())
chsrc_confirm_source(&source); chsrc_confirm_source();
char *cmd = NULL; char *cmd = NULL;
if (!chsrc_in_local_mode()) if (!chsrc_in_local_mode())
chsrc_alert2 ("Poetry 仅支持项目级换源"); chsrc_alert2 ("Poetry 仅支持项目级换源");
cmd = xy_2strcat ("poetry source add my_mirror ", source.url); cmd = xy_2strjoin ("poetry source add my_mirror ", source.url);
chsrc_run (cmd, RunOpt_No_Last_New_Line); chsrc_run (cmd, RunOpt_No_Last_New_Line);
if (chsrc_in_standalone_mode()) if (chsrc_in_standalone_mode())
@ -57,8 +47,35 @@ pl_python_poetry_setsrc (char *option)
} }
/**
* chsrc reset poetry
*/
void void
pl_python_poetry_resetsrc (char *option) pl_python_poetry_resetsrc (char *option)
{ {
pl_python_poetry_setsrc (option); pl_python_poetry_setsrc (option);
} }
/**
* chsrc ls poetry
*/
Feature_t
pl_python_poetry_feat (char *option)
{
Feature_t f = {0};
f.can_get = true;
f.can_reset = true;
f.cap_locally = FullyCan;
f.cap_locally_explain = NULL;
f.can_english = false;
f.can_user_define = true;
f.note = NULL;
return f;
}
// def_target_gsrf(pl_python_poetry);
Target_t pl_python_poetry_target = {def_target_inner_gsrf(pl_python_poetry),def_target_sourcesn(pl_python_group)};

View File

@ -6,6 +6,7 @@
* | * |
* Created On : <2023-09-03> * Created On : <2023-09-03>
* Last Modified : <2025-07-14> * Last Modified : <2025-07-14>
*
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
void void
@ -57,8 +58,7 @@ pl_python_group_setsrc (char *option)
pl_python_check_unofficial_pkger (&poetry_exist, &pdm_exist, &uv_exist); pl_python_check_unofficial_pkger (&poetry_exist, &pdm_exist, &uv_exist);
chsrc_set_target_group_mode (); chsrc_set_target_group_mode ();
chsrc_yield_source_and_confirm (pl_python_group);
chsrc_use_this_source (pl_python_group);
// 交给后面检查命令的存在性 // 交给后面检查命令的存在性
@ -85,9 +85,27 @@ pl_python_group_setsrc (char *option)
chsrc_conclude (&source); chsrc_conclude (&source);
} }
void void
pl_python_group_resetsrc (char *option) pl_python_group_resetsrc (char *option)
{ {
pl_python_group_setsrc (option); pl_python_group_setsrc (option);
} }
Feature_t
pl_python_group_feat (char *option)
{
Feature_t f = {0};
f.can_get = true;
f.can_reset = true;
f.cap_locally = PartiallyCan;
f.cap_locally_explain = "Support Poetry, PDM, uv. No support for pip";
f.can_english = false;
f.can_user_define = true;
return f;
}
def_target_gsrf(pl_python_group);

View File

@ -1,31 +1,14 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* ------------------------------------------------------------- * -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nul None <nul@none.org>
* Created On : <2024-12-06>
* Last Modified : <2025-07-22>
*
* Rye已经有后继uv了Python group中 * Rye已经有后继uv了Python group中
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
def_target(pl_python_rye, "rye");
void
pl_python_rye_prelude (void)
{
chef_prep_this (pl_python_rye, gsr);
chef_set_created_on (this, "2024-12-06");
chef_set_last_updated (this, "2025-08-09");
chef_set_sources_last_updated (this, "2025-08-09");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 0);
chef_allow_local_mode (this, FullyCan, NULL, NULL);
chef_allow_english(this);
chef_allow_user_define(this);
chef_use_other_target_sources (this, &pl_python_group_target);
}
char * char *
pl_python_find_rye_config () pl_python_find_rye_config ()
{ {
@ -35,24 +18,28 @@ pl_python_find_rye_config ()
return rye_config; return rye_config;
} }
/**
* chsrc get rye
*/
void void
pl_python_rye_getsrc (char *option) pl_python_rye_getsrc (char *option)
{ {
char *rye_config = pl_python_find_rye_config (); char *rye_config = pl_python_find_rye_config ();
chsrc_note2 (xy_strcat (3, "请查看 ", rye_config, " 配置文件中的 [[sources]] 节内容")); chsrc_note2 (xy_strjoin (3, "请查看 ", rye_config, " 配置文件中的 [[sources]] 节内容"));
} }
/** /**
* @consult https://github.com/RubyMetric/chsrc/issues/127 * @consult https://github.com/RubyMetric/chsrc/issues/127
* @consult recipe Java
*
* chsrc set rye
*/ */
void void
pl_python_rye_setsrc (char *option) pl_python_rye_setsrc (char *option)
{ {
/* 并不在 Python group 中,所以不考虑 target group 情况,仅使用 Python group 提供的源 */ /* 并不在 Python group 中,所以不考虑 target group 情况,仅使用 Python group 提供的源 */
Source_t source = chsrc_yield_source_and_confirm (&pl_python_group_target, option); chsrc_yield_source_and_confirm (pl_python_group);
const char *content = RAWSTR_pl_python_rye_config; const char *content = RAWSTR_pl_python_rye_config;
@ -60,16 +47,44 @@ pl_python_rye_setsrc (char *option)
content = xy_str_gsub (content, "@2@", source.url); content = xy_str_gsub (content, "@2@", source.url);
char *rye_config = pl_python_find_rye_config (); char *rye_config = pl_python_find_rye_config ();
chsrc_note2 (xy_strcat (3, "请在配置文件 ", rye_config, " 中添加:")); chsrc_note2 (xy_strjoin (3, "请在配置文件 ", rye_config, " 中添加:"));
println (content); print (content);
chsrc_determine_chgtype (ChgType_Manual); chsrc_determine_chgtype (ChgType_Manual);
chsrc_conclude (&source); chsrc_conclude (&source);
} }
/**
* chsrc reset rye
*/
void void
pl_python_rye_resetsrc (char *option) pl_python_rye_resetsrc (char *option)
{ {
pl_python_rye_setsrc (option); pl_python_rye_setsrc (option);
} }
/**
* chsrc ls rye
*/
Feature_t
pl_python_rye_feat (char *option)
{
Feature_t f = {0};
f.can_get = true;
f.can_reset = true;
f.cap_locally = true;
f.cap_locally_explain = NULL;
f.can_english = false;
f.can_user_define = true;
f.note = NULL;
return f;
}
// def_target_gsrf(pl_python_rye);
Target_t pl_python_rye_target = {def_target_inner_gsrf(pl_python_rye),def_target_sourcesn(pl_python_group)};

View File

@ -1,76 +1,80 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : yongxiang <1926885268@qq.com>
* | happy game <happygame1024@gmail.com>
* |
* Created On : <2023-09-03>
* Major Revision : 1
* Last Modified : <2025-07-14>
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
#include "rawstr4c.h" #include "rawstr4c.h"
def_target(pl_python_group, "python/pypi/py");
/** /**
* @note ${host}/pipi/web/pacakges/56/e4.... * host/pipi/web/pacakges....
* packages * packages
* @note 2025-09-29 pkg 40M
*
* @warning 2025-09-29 Sjtug
*/ */
static char * #define PL_Python_Group_Speed_URL_Postfix "/packages/56/e4/55aaac2b15af4dad079e5af329a79d961e5206589d0e02b1e8da221472ed/tensorflow-2.18.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl"
pl_python_speed_url_constructor (const char *url, const char *user_data)
static SourceProvider_t pl_python_pypi_upstream =
{ {
char *str = xy_str_delete_suffix (url, "/simple"); def_upstream, "https://pypi.org/",
str = xy_2strcat (str, "/packages/fa/80/eb88edc2e2b11cd2dd2e56f1c80b5784d11d6e6b7f04a1145df64df40065/opencv_python-4.12.0.88-cp37-abi3-win_amd64.whl"); {NotSkip, NA, NA, "https://files.pythonhosted.org/packages/56/e4/55aaac2b15af4dad079e5af329a79d961e5206589d0e02b1e8da221472ed/tensorflow-2.18.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", ACCURATE} // 260MB
if (strstr (url, "mirror.sjtu.edu.cn")) };
// e.g. https://mirror.sjtu.edu.cn/pypi-packages/fa/80/eb88edc2e2b11cd2dd2e56f1c80b5784d11d6e6b7f04a1145df64df40065/opencv_python-4.12.0.88-cp37-abi3-win_amd64.whl
str = xy_str_gsub (str, "pypi-packages/packages", "pypi-packages");// 针对 Sjtug
return str; /**
} * @update 2025-07-11
* @note ZjuPyPI服务在校外访问会自动转向Tuna
*/
void static Source_t pl_python_group_sources[] =
pl_python_group_prelude (void)
{ {
chef_prep_this (pl_python_group, gsr); {&pl_python_pypi_upstream, "https://pypi.org/simple", DelegateToUpstream},
chef_set_created_on (this, "2023-09-03"); {&MirrorZ, "https://mirrors.cernet.edu.cn/pypi/web/simple",
chef_set_last_updated (this, "2025-09-30"); "https://mirrors.cernet.edu.cn/pypi/web" PL_Python_Group_Speed_URL_Postfix},
chef_set_sources_last_updated (this, "2025-09-30");
chef_set_chef (this, "@happy-game"); {&Bfsu, "https://mirrors.bfsu.edu.cn/pypi/web/simple",
// 组换源的 leader target 应把所有 follower target 的贡献者都记录过来 "https://mirrors.bfsu.edu.cn/pypi/web" PL_Python_Group_Speed_URL_Postfix},
chef_set_cooks (this, 2, "@ccmywish", "@happy-game");
chef_set_sauciers (this, 3, "@xyx1926885268", "@Kattos", "@Mikachu2333");
chef_allow_local_mode (this, PartiallyCan, "部分包管理器支持项目级换源", "Some package managers support project-level source changing"); {&Lzuoss, "https://mirror.lzu.edu.cn/pypi/web/simple",
chef_allow_english(this); "https://mirror.lzu.edu.cn/pypi/web" PL_Python_Group_Speed_URL_Postfix},
chef_allow_user_define(this);
{&Jlu, "https://mirrors.jlu.edu.cn/pypi/web/simple",
"https://mirrors.jlu.edu.cn/pypi/web" PL_Python_Group_Speed_URL_Postfix},
def_sources_begin() {&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/pypi/web/simple",
{&UpstreamProvider, "https://pypi.org/simple", FeedByPrelude}, "https://mirror.sjtu.edu.cn/pypi/web" PL_Python_Group_Speed_URL_Postfix},
{&MirrorZ, "https://mirrors.cernet.edu.cn/pypi/web/simple", FeedByPrelude},
{&Bfsu, "https://mirrors.bfsu.edu.cn/pypi/web/simple", FeedByPrelude},
// 不要添加Zju浙大的PyPI服务在校外访问会自动转向Tuna
{&Lzuoss, "https://mirror.lzu.edu.cn/pypi/web/simple", FeedByPrelude},
// 2025-09-29 此源已停用
// @ref https://mirrors.jlu.edu.cn/_news/#2025-04-06-pypi-repo-down
// {&Jlu, "https://mirrors.jlu.edu.cn/pypi/web/simple", FeedByPrelude},
{&Sjtug_Siyuan, "https://mirror.sjtu.edu.cn/pypi-packages", FeedByPrelude},
{&Tuna, "https://pypi.tuna.tsinghua.edu.cn/simple", FeedByPrelude},
{&Ali, "https://mirrors.aliyun.com/pypi/simple", FeedByPrelude},
{&Nju, "https://mirror.nju.edu.cn/pypi/web/simple", FeedByPrelude},
{&Pku, "https://mirrors.pku.edu.cn/pypi/web/simple", FeedByPrelude},
{&Tencent, "https://mirrors.cloud.tencent.com/pypi/simple", FeedByPrelude},
// {&Tencent_Intra, "https://mirrors.cloud.tencentyun.com/pypi/simple",FeedByPrelude} {&Tuna, "https://pypi.tuna.tsinghua.edu.cn/simple",
{&Huawei, "https://mirrors.huaweicloud.com/repository/pypi/simple",FeedByPrelude}, "https://pypi.tuna.tsinghua.edu.cn" PL_Python_Group_Speed_URL_Postfix},
{&Hust, "https://mirrors.hust.edu.cn/pypi/web/simple",FeedByPrelude}
{&Ali, "https://mirrors.aliyun.com/pypi/simple/",
"https://mirrors.aliyun.com/pypi" PL_Python_Group_Speed_URL_Postfix},
{&Nju, "https://mirror.nju.edu.cn/pypi/web/simple",
"https://mirror.nju.edu.cn/pypi/web" PL_Python_Group_Speed_URL_Postfix},
{&Pku, "https://mirrors.pku.edu.cn/pypi/web/simple",
"https://mirrors.pku.edu.cn/pypi/web" PL_Python_Group_Speed_URL_Postfix},
{&Tencent, "https://mirrors.cloud.tencent.com/pypi/simple",
"https://mirrors.cloud.tencent.com/pypi" PL_Python_Group_Speed_URL_Postfix},
// {&Tencent_Intra, "https://mirrors.cloud.tencentyun.com/pypi/simple",
// "https://mirrors.cloud.tencentyun.com/pypi" PL_Python_Group_Speed_URL_Postfix,
{&Huawei, "https://mirrors.huaweicloud.com/repository/pypi/simple",
"https://mirrors.huaweicloud.com/repository/pypi" PL_Python_Group_Speed_URL_Postfix},
{&Hust, "https://mirrors.hust.edu.cn/pypi/web/simple",
"https://mirrors.hust.edu.cn/pypi/web" PL_Python_Group_Speed_URL_Postfix},
/* 不启用原因24小时更新一次 */ /* 不启用原因24小时更新一次 */
// {&Netease, "https://mirrors.163.com/.help/pypi.html", NULL} // {&Netease, "https://mirrors.163.com/.help/pypi.html", NULL}
def_sources_end() };
def_sources_n(pl_python_group);
chef_set_sources_speed_measure_url_with_func (this, pl_python_speed_url_constructor, NULL);
}
void void
pl_python_check_unofficial_pkger (bool *poetry_exist, bool *pdm_exist, bool *uv_exist) pl_python_check_unofficial_pkger (bool *poetry_exist, bool *pdm_exist, bool *uv_exist)
@ -82,7 +86,7 @@ pl_python_check_unofficial_pkger (bool *poetry_exist, bool *pdm_exist, bool *uv_
/** /**
* @param[out] prog_name Python NULL * @param[out] prog Python NULL
*/ */
void void
pl_python_get_py_program_name (char **prog_name) pl_python_get_py_program_name (char **prog_name)

View File

@ -1,60 +1,30 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nul None <nul@none.org>
* Created On : <2023-09-03>
* Last Modified : <2025-07-11>
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
def_target(pl_python_pip, "pip"); /**
* chsrc get pip
void */
pl_python_pip_prelude (void)
{
chef_prep_this (pl_python_pip, gsr);
chef_set_created_on (this, "2023-09-03");
chef_set_last_updated (this, "2025-09-12");
chef_set_sources_last_updated (this, "2025-07-11");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 1, "@happy-game");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_allow_english(this);
chef_allow_user_define(this);
chef_use_other_target_sources (this, &pl_python_group_target);
}
void void
pl_python_pip_getsrc (char *option) pl_python_pip_getsrc (char *option)
{ {
char *py_prog_name = NULL; char *py_prog_name = NULL;
pl_python_get_py_program_name (&py_prog_name); pl_python_get_py_program_name (&py_prog_name);
char *cmd = xy_2strcat (py_prog_name, " -m pip config get global.index-url"); char *cmd = xy_2strjoin (py_prog_name, " -m pip config get global.index-url");
chsrc_run (cmd, RunOpt_Default);
int status = chsrc_run_directly (cmd);
if (0 == status)
{
// 执行成功时显示当前源
xy_noop ();
}
else
{
// 执行失败时显示默认源
if (ENGLISH)
chsrc_note2 ("No source configured in pip, showing default upstream source:");
else
chsrc_note2 ("pip 中未配置源,显示默认上游源:");
Source_t default_source = chsrc_yield_source (&pl_python_group_target, "upstream");
say (default_source.url);
}
} }
/** /**
* @consult https://mirrors.tuna.tsinghua.edu.cn/help/pypi/ * @consult https://mirrors.tuna.tsinghua.edu.cn/help/pypi/
*
* chsrc set pip
*/ */
void void
pl_python_pip_setsrc (char *option) pl_python_pip_setsrc (char *option)
@ -68,9 +38,9 @@ pl_python_pip_setsrc (char *option)
return; return;
} }
Source_t source = chsrc_yield_source (&pl_python_group_target, option); chsrc_yield_source (pl_python_group);
if (chsrc_in_standalone_mode()) if (chsrc_in_standalone_mode())
chsrc_confirm_source(&source); chsrc_confirm_source();
char *py_prog_name = NULL; char *py_prog_name = NULL;
pl_python_get_py_program_name (&py_prog_name); pl_python_get_py_program_name (&py_prog_name);
@ -78,7 +48,7 @@ pl_python_pip_setsrc (char *option)
// 这里用的是 config --user会写入用户目录而不是项目目录 // 这里用的是 config --user会写入用户目录而不是项目目录
// https://github.com/RubyMetric/chsrc/issues/39 // https://github.com/RubyMetric/chsrc/issues/39
// 经测试Windows上调用换源命令会写入 C:\Users\RubyMetric\AppData\Roaming\pip\pip.ini // 经测试Windows上调用换源命令会写入 C:\Users\RubyMetric\AppData\Roaming\pip\pip.ini
char *cmd = xy_2strcat (py_prog_name, xy_2strcat (" -m pip config --user set global.index-url ", source.url)); char *cmd = xy_2strjoin (py_prog_name, xy_2strjoin (" -m pip config --user set global.index-url ", source.url));
chsrc_run (cmd, RunOpt_No_Last_New_Line); chsrc_run (cmd, RunOpt_No_Last_New_Line);
if (chsrc_in_standalone_mode()) if (chsrc_in_standalone_mode())
@ -89,8 +59,36 @@ pl_python_pip_setsrc (char *option)
} }
/**
* chsrc reset pip
*/
void void
pl_python_pip_resetsrc (char *option) pl_python_pip_resetsrc (char *option)
{ {
pl_python_pip_setsrc (option); pl_python_pip_setsrc (option);
} }
/**
* chsrc ls pip
*/
Feature_t
pl_python_pip_feat (char *option)
{
Feature_t f = {0};
f.can_get = true;
f.can_reset = true;
// pip 不支持项目级换源
f.cap_locally = CanNot;
f.cap_locally_explain = NULL;
f.can_english = true;
f.can_user_define = true;
f.note = NULL;
return f;
}
// def_target_gsrf(pl_python_pip);
Target_t pl_python_pip_target = {def_target_inner_gsrf(pl_python_pip),def_target_sourcesn(pl_python_group)};

View File

@ -1,22 +1,16 @@
#pragma once #pragma once
/** /**
* Generated by rawstr4c v1.1.0-2025/09/27 * Generated by rawstr4c v0.2.3-2025/07/22
*/ */
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\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\x0a";
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\x0a";
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_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\x0a";
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_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\x0a";
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";

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-07-26>
! ---------------------------------------------------------- --> ! ---------------------------------------------------------- -->
# rawstr4c input for Python # rawstr4c input for Python
@ -15,7 +14,7 @@
- prefix = `RAWSTR_pl_python` - prefix = `RAWSTR_pl_python`
- output = `:global-variable-only-header` - output = `:global-variable-only-header`
- translate = `:hex` - translate = `:hex`
- no-postfix = `true` - keep-postfix = `false`
<br> <br>
@ -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

@ -1,30 +1,15 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : happy game <happygame1024@gmail.com>
* Contributors : ccy <icuichengyi@gmail.com>
* | Aoran Zeng <ccmywish@qq.com>
* |
* Created On : <2024-12-11>
* Major Revision : 1
* Last Modified : <2025-07-26>
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
def_target(pl_python_uv, "uv");
void
pl_python_uv_prelude (void)
{
chef_prep_this (pl_python_uv, gsr);
chef_set_created_on (this, "2024-12-11");
chef_set_last_updated (this, "2025-12-29");
chef_set_sources_last_updated (this, "2025-08-09");
chef_set_chef (this, NULL);
chef_set_cooks (this, 2, "@happy-game", "@MingriLingran");
chef_set_sauciers (this, 2, "@Kattos", "@ccmywish");
chef_allow_local_mode (this, FullyCan, NULL, NULL);
chef_allow_english(this);
chef_allow_user_define(this);
chef_use_other_target_sources (this, &pl_python_group_target);
}
/** /**
* chsrc get uv * chsrc get uv
* *
@ -45,11 +30,11 @@ pl_python_find_uv_config (bool mkdir)
{ {
if (chsrc_in_local_mode()) if (chsrc_in_local_mode())
{ {
return xy_2strcat (PL_Python_uv_Local_ConfigPath, PL_Python_uv_ConfigFile); return xy_2strjoin (PL_Python_uv_Local_ConfigPath, PL_Python_uv_ConfigFile);
} }
else else
{ {
if (xy.on_windows) if (xy_on_windows)
{ {
/* config path on Windows */ /* config path on Windows */
char *appdata = getenv ("APPDATA"); char *appdata = getenv ("APPDATA");
@ -60,12 +45,12 @@ pl_python_find_uv_config (bool mkdir)
return NULL; return NULL;
} }
char *config_dir = xy_2strcat(appdata, "\\uv\\"); char *config_dir = xy_2strjoin(appdata, "\\uv\\");
if (mkdir) if (mkdir)
{ {
chsrc_ensure_dir (config_dir); chsrc_ensure_dir (config_dir);
} }
return xy_2strcat (config_dir, PL_Python_uv_ConfigFile); return xy_2strjoin (config_dir, PL_Python_uv_ConfigFile);
} }
else else
{ {
@ -74,7 +59,7 @@ pl_python_find_uv_config (bool mkdir)
{ {
chsrc_ensure_dir (PL_Python_uv_User_ConfigPath); chsrc_ensure_dir (PL_Python_uv_User_ConfigPath);
} }
return xy_2strcat (PL_Python_uv_User_ConfigPath, PL_Python_uv_ConfigFile); return xy_2strjoin (PL_Python_uv_User_ConfigPath, PL_Python_uv_ConfigFile);
} }
} }
} }
@ -91,33 +76,25 @@ 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);
}
} }
/** /**
* @consult https://docs.astral.sh/uv/configuration/files/ * @consult https://docs.astral.sh/uv/configuration/files/
* https://github.com/RubyMetric/chsrc/issues/139 * https://github.com/RubyMetric/chsrc/issues/139
*
* chsrc set uv
*/ */
void void
pl_python_uv_setsrc (char *option) pl_python_uv_setsrc (char *option)
{ {
chsrc_ensure_program ("uv"); chsrc_ensure_program ("uv");
Source_t source = chsrc_yield_source (&pl_python_group_target, option); chsrc_yield_source (pl_python_group);
if (chsrc_in_standalone_mode()) if (chsrc_in_standalone_mode())
chsrc_confirm_source(&source); chsrc_confirm_source();
char *uv_config = pl_python_find_uv_config (true); char *uv_config = pl_python_find_uv_config (true);
if (NULL==uv_config) if (NULL==uv_config)
@ -129,6 +106,21 @@ 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_On_macOS) || defined(XY_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);
char *append_config_cmd = xy_strjoin (4, "printf '", source_content, "' >> ", uv_config);
if (!xy_file_exist (uv_config)) if (!xy_file_exist (uv_config))
{ {
/* 当 uv_config 不存在,直接写入文件 */ /* 当 uv_config 不存在,直接写入文件 */
@ -137,41 +129,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");
{ int status = system (cmd);
/* 在 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);
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
{ {
@ -187,8 +150,36 @@ pl_python_uv_setsrc (char *option)
} }
/**
* chsrc reset uv
*/
void void
pl_python_uv_resetsrc (char *option) pl_python_uv_resetsrc (char *option)
{ {
pl_python_uv_setsrc (option); pl_python_uv_setsrc (option);
} }
/**
* chsrc ls uv
*/
Feature_t
pl_python_uv_feat (char *option)
{
Feature_t f = {0};
f.can_get = true;
f.can_reset = true;
f.cap_locally = true;
f.cap_locally_explain = NULL;
f.can_english = false;
f.can_user_define = true;
f.note = NULL;
return f;
}
// def_target_gsrf(pl_python_uv);
Target_t pl_python_uv_target = {def_target_inner_gsrf(pl_python_uv),def_target_sourcesn(pl_python_group)};

View File

@ -1,37 +1,30 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nil Null <nil@null.org>
* Created On : <2023-09-21>
* Last Modified : <2025-07-14>
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
def_target(pl_r, "r/cran"); /**
* @update 2023-09-04
void *
pl_r_prelude () * @note
* bioconductor的镜像站
* cran的同时bioconductor
*/
static Source_t pl_r_sources[] =
{ {
chef_prep_this (pl_r, gs); {&UpstreamProvider, NULL, NULL},
chef_set_created_on (this, "2023-09-21");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2025-08-21");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 1, "@hezonglun");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this);
chef_allow_user_define(this);
// 以下注释的是不含有bioconductor的镜像站我们在换cran的同时也直接帮助用户换bioconductor
def_sources_begin()
{&UpstreamProvider, "https://cran.r-project.org/", DelegateToUpstream},
{&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/cran/", DelegateToMirror}, {&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/cran/", DelegateToMirror},
// {&Ali, "https://mirrors.aliyun.com/CRAN/", DelegateToMirror}, // {&Ali, "https://mirrors.aliyun.com/CRAN/", DelegateToMirror},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/CRAN/", DelegateToMirror}, {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/CRAN/", DelegateToMirror},
// {&Sustech, "https://mirrors.sustech.edu.cn/CRAN", DelegateToMirror}, // {&Sustech, "https://mirrors.sustech.edu.cn/CRAN", DelegateToMirror},
// {&Bfsu, "https://mirrors.bfsu.edu.cn/CRAN/", DelegateToMirror}, // {&Bfsu, "https://mirrors.bfsu.edu.cn/CRAN/", DelegateToMirror},
// {&Bjtu, "https://mirror.bjtu.edu.cn/cran/", DelegateToMirror}, // {&Bjtu, "https://mirror.bjtu.edu.cn/cran/", DelegateToMirror},
def_sources_end() };
} def_sources_n(pl_r);
#define PL_R_Config_Windows "~/Documents/.Rprofile" #define PL_R_Config_Windows "~/Documents/.Rprofile"
@ -46,7 +39,7 @@ pl_r_getsrc (char *option)
* options()$repos * options()$repos
* options()$BioC_mirror * options()$BioC_mirror
*/ */
if (xy.on_windows) if (xy_on_windows)
{ {
chsrc_view_file (PL_R_Config_Windows); chsrc_view_file (PL_R_Config_Windows);
} }
@ -62,21 +55,42 @@ pl_r_getsrc (char *option)
void void
pl_r_setsrc (char *option) pl_r_setsrc (char *option)
{ {
chsrc_use_this_source (pl_r); chsrc_yield_source_and_confirm (pl_r);
char *bioconductor_url = xy_str_delete_suffix (xy_str_delete_suffix (source.url, "cran/"), "CRAN/"); char *bioconductor_url = xy_str_delete_suffix (xy_str_delete_suffix (source.url, "cran/"), "CRAN/");
bioconductor_url = xy_2strcat(bioconductor_url, "bioconductor"); bioconductor_url = xy_2strjoin(bioconductor_url, "bioconductor");
const char *w1 = xy_strcat (3, "options(\"repos\" = c(CRAN=\"", source.url, "\"))\n" ); const char *w1 = xy_strjoin (3, "options(\"repos\" = c(CRAN=\"", source.url, "\"))\n" );
const char *w2 = xy_strcat (3, "options(BioC_mirror=\"", bioconductor_url, "\")\n" ); const char *w2 = xy_strjoin (3, "options(BioC_mirror=\"", bioconductor_url, "\")\n" );
char *w = xy_2strcat (w1, w2); char *w = xy_2strjoin (w1, w2);
// 或者我们调用 r.exe --slave -e 上面的内容 // 或者我们调用 r.exe --slave -e 上面的内容
char *config = xy.on_windows ? PL_R_Config_Windows : PL_R_Config_POSIX; char *config = xy_on_windows ? PL_R_Config_Windows : PL_R_Config_POSIX;
chsrc_append_to_file (w, config); chsrc_append_to_file (w, config);
chsrc_determine_chgtype (ChgType_Auto);
chsrc_conclude (&source); chsrc_conclude (&source);
} }
Feature_t
pl_r_feat (char *option)
{
Feature_t f = {0};
f.can_get = true;
f.can_reset = false;
f.cap_locally = CanNot;
f.cap_locally_explain = NA;
f.can_english = false;
f.can_user_define = false;
f.note = NULL;
return f;
}
def_target_gsf(pl_r);

View File

@ -1,7 +1,19 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nil Null <nil@null.org>
* |
* Created On : <2023-08-29>
* Last Modified : <2025-07-14>
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
static SourceProvider_t pl_ruby_upstream =
{
def_upstream, "https://rubygems.org",
{NotSkip, NA, NA, "https://rubygems.org/gems/nokogiri-1.15.0-java.gem", ACCURATE}
};
static MirrorSite_t RubyChina = static MirrorSite_t RubyChina =
{ {
IS_DedicatedMirrorSite, IS_DedicatedMirrorSite,
@ -9,38 +21,24 @@ static MirrorSite_t RubyChina =
{NotSkip, NA, NA, "https://gems.ruby-china.com/rubygems/gems/nokogiri-1.15.0-java.gem", ACCURATE} // 9.9 MB {NotSkip, NA, NA, "https://gems.ruby-china.com/rubygems/gems/nokogiri-1.15.0-java.gem", ACCURATE} // 9.9 MB
}; };
def_target(pl_ruby, "gem/ruby/rb/rubygem/rubygems/bundler"); /**
* @update 2024-12-18
void */
pl_ruby_prelude (void) static Source_t pl_ruby_sources[] =
{ {
chef_prep_this (pl_ruby, gsr); {&pl_ruby_upstream, "https://rubygems.org", NULL},
{&RubyChina, "https://gems.ruby-china.com/", NULL},
{&Ustc, "https://mirrors.ustc.edu.cn/rubygems/", NULL}
chef_set_created_on (this, "2023-08-29"); // {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/rubygems/", NULL},
chef_set_last_updated (this, "2025-08-11"); // {&Bfsu, "https://mirrors.bfsu.edu.cn/rubygems/", NULL},
chef_set_sources_last_updated (this, "2024-12-18");
chef_set_chef (this, "@ccmywish"); // {&Tencent, "https://mirrors.tencent.com/rubygems/", NULL},
chef_set_cooks (this, 1, "@ccmywish"); // {&Tencent_Intra, "https://mirrors.tencentyun.com/rubygems/", NULL},
chef_set_sauciers (this, 1, "@BingChunMoLi"); // {&Ali, "https://mirrors.aliyun.com/rubygems/", NULL},
// {&Huawei, "https://mirrors.huaweicloud.com/repository/rubygems/", NULL},
chef_allow_local_mode (this, PartiallyCan, "支持 bundler. 不支持 gem", "Support bundler. Not support gem"); };
chef_allow_english(this); def_sources_n(pl_ruby);
chef_allow_user_define(this);
def_sources_begin()
{&UpstreamProvider, "https://rubygems.org/", "https://rubygems.org/gems/nokogiri-1.15.0-java.gem"},
{&RubyChina, "https://gems.ruby-china.com/", DelegateToMirror},
{&Ustc, "https://mirrors.ustc.edu.cn/rubygems/", DelegateToMirror}
// {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/rubygems/", DelegateToMirror},
// {&Bfsu, "https://mirrors.bfsu.edu.cn/rubygems/", DelegateToMirror},
// {&Tencent, "https://mirrors.tencent.com/rubygems/", DelegateToMirror},
// {&Tencent_Intra, "https://mirrors.tencentyun.com/rubygems/", DelegateToMirror},
// {&Ali, "https://mirrors.aliyun.com/rubygems/", DelegateToMirror},
// {&Huawei, "https://mirrors.huaweicloud.com/repository/rubygems/", DelegateToMirror},
def_sources_end()
}
void void
@ -50,16 +48,15 @@ pl_ruby_getsrc (char *option)
chsrc_run ("bundle config get mirror.https://rubygems.org", RunOpt_Default); chsrc_run ("bundle config get mirror.https://rubygems.org", RunOpt_Default);
} }
bool void
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_2strjoin ("gem sources -r ", source);
chsrc_run (cmd, RunOpt_Default); chsrc_run (cmd, RunOpt_Default);
} }
return false;
} }
/** /**
@ -70,20 +67,15 @@ pl_ruby_setsrc (char *option)
{ {
chsrc_ensure_program ("gem"); chsrc_ensure_program ("gem");
chsrc_use_this_source (pl_ruby); chsrc_yield_source_and_confirm (pl_ruby);
char *cmd = NULL; char *cmd = NULL;
// step1 xy_run_iter ("gem sources -l", 0, pl_ruby_remove_gem_source);
xy_run_iter_lines ("gem sources -l", 0, pl_ruby_remove_gem_source);
cmd = xy_2strcat ("gem source -a ", source.url); cmd = xy_2strjoin ("gem source -a ", source.url);
chsrc_run (cmd, RunOpt_Default); chsrc_run (cmd, RunOpt_Default);
// 我们在 step1 中,把源全部清空了,但是现在 RubyGems 的行为是: 当清空会自动给你把默认源给加回来
// 所以我们在这一步,最后一次删除默认源,确保它不存在
pl_ruby_remove_gem_source (this->sources[0].url);
chsrc_ensure_program ("bundle"); chsrc_ensure_program ("bundle");
@ -93,7 +85,7 @@ pl_ruby_setsrc (char *option)
where = " --local "; where = " --local ";
} }
cmd = xy_strcat (4, "bundle config", where, "'mirror.https://rubygems.org' ", source.url); cmd = xy_strjoin (4, "bundle config", where, "'mirror.https://rubygems.org' ", source.url);
chsrc_run (cmd, RunOpt_No_Last_New_Line); chsrc_run (cmd, RunOpt_No_Last_New_Line);
chsrc_determine_chgtype (ChgType_Auto); chsrc_determine_chgtype (ChgType_Auto);
@ -105,3 +97,24 @@ pl_ruby_resetsrc (char *option)
{ {
pl_ruby_setsrc (option); pl_ruby_setsrc (option);
} }
Feature_t
pl_ruby_feat (char *option)
{
Feature_t f = {0};
f.can_get = true;
f.can_reset = true;
f.cap_locally = PartiallyCan;
f.cap_locally_explain = "Support `bundler`. No support for `gem`";
f.can_english = true;
f.can_user_define = true;
f.note = NULL;
return f;
}
def_target_gsrf(pl_ruby);

View File

@ -1,189 +1,116 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Mikachu2333 <mikachu.23333@zohomail.com>
* |
* Created On : <2023-08-30>
* Last Modified : <2025-07-22>
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
def_target(pl_rust_cargo, "rust/cargo/crate/crates"); static SourceProvider_t pl_rust_cargo_upstream =
void
pl_rust_cargo_prelude (void)
{ {
chef_prep_this (pl_rust_cargo, gsr); def_upstream, "https://crates.io/",
{NotSkip, NA, NA, "https://crates.io/api/v1/crates/windows/0.58.0/download", ACCURATE}
chef_set_created_on (this, "2023-08-30"); /* 跳转为: https://static.crates.io/crates/windows/windows-0.58.0.crate */
chef_set_last_updated (this, "2025-10-06"); };
chef_set_sources_last_updated (this, "2025-06-18");
chef_set_chef (this, NULL);
chef_set_cooks (this, 2, "@Mikachu2333", "@ccmywish");
chef_set_sauciers (this, 1, "@happy-game");
chef_allow_local_mode (this, FullyCan, NULL, NULL);
chef_deny_english (this);
chef_allow_user_define (this);
// 以下都支持稀疏索引,我们换源时都将默认添加 `sparse+`。链接末尾的 `/` 不能缺少 /**
def_sources_begin() * @update 2025-06-18
{&UpstreamProvider, "https://crates.io/", FeedByPrelude}, *
{&MirrorZ, "https://mirrors.cernet.edu.cn/crates.io-index/", FeedByPrelude}, * @note `sparse+`
{&RsProxyCN, "https://rsproxy.cn/index/", FeedByPrelude}, * @note `/`
{&Ali, "https://mirrors.aliyun.com/crates.io-index/", FeedByPrelude}, */
{&Zju, "https://mirrors.zju.edu.cn/crates.io-index/", FeedByPrelude}, static Source_t pl_rust_cargo_sources[] =
{
{&pl_rust_cargo_upstream, "https://github.com/rust-lang/crates.io-index/", DelegateToUpstream},
{&MirrorZ, "https://mirrors.cernet.edu.cn/crates.io-index/", DelegateToMirror},
{&RsProxyCN, "https://rsproxy.cn/index/", DelegateToMirror},
{&Ali, "https://mirrors.aliyun.com/crates.io-index/",
"https://mirrors.aliyun.com/crates/api/v1/crates/windows/0.58.0/download"},
{&Zju, "https://mirrors.zju.edu.cn/crates.io-index/", DelegateToMirror},
/* 注释原因: (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/", DelegateToMirror},
{&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/crates.io-index/", FeedByPrelude}, {&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/crates.io-index/", DelegateToMirror},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/crates.io-index/",FeedByPrelude}, {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/crates.io-index/", DelegateToMirror},
{&Bfsu, "https://mirrors.bfsu.edu.cn/crates.io-index/", FeedByPrelude}, {&Bfsu, "https://mirrors.bfsu.edu.cn/crates.io-index/", DelegateToMirror},
{&Ustc, "https://mirrors.ustc.edu.cn/crates.io-index/", FeedByPrelude},
{&Ustc, "https://mirrors.ustc.edu.cn/crates.io-index/",
"https://crates-io.proxy.ustclug.org/api/v1/crates/windows/0.58.0/download"},
/* 注释原因: (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/", DelegateToMirror},
{&Cqu, "https://mirrors.cqu.edu.cn/crates.io-index/", FeedByPrelude} {&Cqu, "https://mirrors.cqu.edu.cn/crates.io-index/", DelegateToMirror}
def_sources_end() };
def_sources_n(pl_rust_cargo);
chef_set_sources_speed_measure_url_with_postfix (this, "api/v1/crates/windows/0.58.0/download");
}
void /**
pl_rust_cargo_note_get_src_default () * chsrc get cargo
{ */
if (ENGLISH)
chsrc_note2 ("No source configured in Cargo, showing default upstream source:");
else
chsrc_note2 ("Cargo 中未自定义源,显示默认源:");
Source_t default_source = chsrc_yield_source (&pl_rust_cargo_target, "upstream");
say (default_source.url);
}
void
pl_rust_cargo_note_get_src_mirror (char *url, bool sparse)
{
chsrc_note2 (ENGLISH ? "Custom source found: " : "已找到自定义源:");
say (xy_2strcat (url, sparse ? " (sparse)" : ""));
}
void void
pl_rust_cargo_getsrc (char *option) pl_rust_cargo_getsrc (char *option)
{ {
char *cargo_config_file = xy_normalize_path ("~/.cargo/config.toml"); chsrc_view_file ("~/.cargo/config.toml");
char *raw_content = xy_file_read (cargo_config_file);
char *formatted_content = xy_str_gsub (raw_content, " ", "");
formatted_content = xy_str_gsub (formatted_content, "'", "\"");
XyStrFindResult_t result_has_mirror = xy_str_find (formatted_content, "replace-with");
if (result_has_mirror.found)
{
char *mirror_name = xy_str_next_nonempty_line (formatted_content + result_has_mirror.end + 1);
mirror_name = xy_str_delete_prefix (mirror_name, "=\"");
mirror_name = xy_str_delete_suffix (mirror_name, "\"");
XyStrFindResult_t result_mirror = xy_str_find (formatted_content, xy_strcat (3, "[source.", mirror_name, "]"));
if (!result_mirror.found)
{
pl_rust_cargo_note_get_src_default();
return;
}
char *mirror_url = xy_str_next_nonempty_line (formatted_content + result_mirror.end + 1);
mirror_url = xy_str_delete_prefix (mirror_url, "registry=\"");
mirror_url = xy_str_delete_suffix (mirror_url, "\"");
if (xy_str_find (mirror_url, "sparse+").found)
{
pl_rust_cargo_note_get_src_mirror (xy_str_delete_prefix (mirror_url, "sparse+"), true);
}
}
else
{
pl_rust_cargo_note_get_src_default();
}
} }
void
pl_write_rust_config (const char *path, const char *url)
{
remove (path);
char *content = RAWSTR_pl_rust_cargo_config;
content = xy_str_gsub (content, "@url@", url);
chsrc_overwrite_file (content, path);
}
/** /**
* @consult https://mirrors.tuna.tsinghua.edu.cn/help/crates.io-index/ * @consult https://mirrors.tuna.tsinghua.edu.cn/help/crates.io-index/
* @consult https://help.mirrors.cernet.edu.cn/crates.io-index * @consult https://help.mirrors.cernet.edu.cn/crates.io-index
*
* chsrc set cargo
*/ */
void void
pl_rust_cargo_setsrc (char *option) pl_rust_cargo_setsrc (char *option)
{ {
chsrc_ensure_program ("cargo"); chsrc_yield_source_and_confirm (pl_rust_cargo);
chsrc_use_this_source (pl_rust_cargo); char *content = RAWSTR_pl_rust_cargo_config;
char *default_content = RAWSTR_pl_rust_cargo_config; content = xy_str_gsub (content, "@url@", source.url);
char *cargo_config_dir = "~/.cargo/";
char *cargo_config_file = xy_2strcat (cargo_config_dir, "config.toml");
chsrc_ensure_dir (cargo_config_dir); chsrc_note2 (xy_strjoin (3, "请手动写入以下内容到 ", xy_normalize_path ("~/.cargo/config.toml"), " 文件中:"));
print (content);
cargo_config_file = xy_normalize_path (cargo_config_file);
if (xy_file_exist (cargo_config_file))
{
chsrc_backup (cargo_config_file);
char *raw_content = xy_file_read (cargo_config_file);
XyStrFindResult_t result_has_mirror = xy_str_find (raw_content, "replace-with");
if (!result_has_mirror.found)
{
pl_write_rust_config (cargo_config_file, source.url);
goto finish;
}
char *mirror_name = xy_str_next_nonempty_line (raw_content + result_has_mirror.end + 1);
mirror_name = xy_str_gsub (mirror_name, " ", "");
mirror_name = xy_str_gsub (mirror_name, "'", "\"");
mirror_name = xy_str_delete_prefix (mirror_name, "=\"");
mirror_name = xy_str_delete_suffix (mirror_name, "\"");
XyStrFindResult_t result_mirror = xy_str_find (raw_content, xy_strcat (3, "[source.", mirror_name, "]"));
if (!result_mirror.found)
{
pl_write_rust_config (cargo_config_file, source.url);
goto finish;
}
char *mirror_url = xy_str_next_nonempty_line (raw_content + result_mirror.end + 1);
mirror_url = xy_str_gsub (mirror_url, " ", "");
if (!xy_str_find (mirror_url, "registry").found)
{
pl_write_rust_config (cargo_config_file, source.url);
goto finish;
}
mirror_url = xy_str_delete_prefix (mirror_url, "registry=\"");
mirror_url = xy_str_delete_suffix (mirror_url, "\"");
char *final_content = xy_str_gsub (raw_content, mirror_url, xy_2strcat ("sparse+", source.url));
chsrc_overwrite_file (final_content, cargo_config_file);
goto finish;
}
pl_write_rust_config (cargo_config_file, source.url);
goto finish;
finish:
chsrc_determine_chgtype (ChgType_Auto); chsrc_determine_chgtype (ChgType_Auto);
chsrc_conclude (&source); chsrc_conclude (&source);
} }
/**
* chsrc reset cargo
*/
void void
pl_rust_cargo_resetsrc (char *option) pl_rust_cargo_resetsrc (char *option)
{ {
pl_rust_cargo_setsrc (option); pl_rust_cargo_setsrc (option);
} }
Feature_t
pl_rust_cargo_feat (char *option)
{
Feature_t f = {0};
f.can_get = true;
f.can_reset = true;
f.cap_locally = PartiallyCan;
f.cap_locally_explain = "可以基于本项目换源吗?请帮助确认";
f.can_english = false;
f.can_user_define = true;
f.note = NULL;
return f;
}
def_target_gsrf(pl_rust_cargo);

View File

@ -1,48 +1,40 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Yangmoooo <yangmoooo@outlook.com>
* | Mikachu2333 <mikachu.23333@zohomail.com>
* |
* Created On : <2024-10-02>
* Last Modified : <2025-06-19>
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
// Size: 20MB static SourceProvider_t pl_rust_binary_upstream =
#define PL_Rustup_Speed_URL_Suffix
def_target(pl_rust_rustup, "rustup");
void
pl_rust_rustup_prelude (void)
{ {
chef_prep_this (pl_rust_rustup, gsr); def_upstream, "https://www.rust-lang.org/",
def_need_measure_info
chef_set_created_on (this, "2024-10-02"); };
chef_set_last_updated (this, "2025-08-07");
chef_set_sources_last_updated (this, "2025-08-07");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 2, "@Yangmoooo", "@Mikachu2333");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english (this);
chef_allow_user_define(this);
def_sources_begin()
{&UpstreamProvider, "https://static.rust-lang.org", FeedByPrelude},
{&MirrorZ, "https://mirrors.cernet.edu.cn/rustup", FeedByPrelude},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/rustup", FeedByPrelude},
{&Ustc, "https://mirrors.ustc.edu.cn/rust-static", FeedByPrelude},
{&Nju, "https://mirror.nju.edu.cn/rustup", FeedByPrelude},
{&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/rust-static", FeedByPrelude},
{&Zju, "https://mirrors.zju.edu.cn/rustup", FeedByPrelude},
{&Iscas, "https://mirror.iscas.ac.cn/rustup", FeedByPrelude},
{&Ali, "https://mirrors.aliyun.com/rustup", FeedByPrelude},
{&RsProxyCN, "https://rsproxy.cn", FeedByPrelude}
def_sources_end()
// 20MB大小
chef_set_sources_speed_measure_url_with_postfix (this, "/dist/2025-06-26/cargo-1.88.0-x86_64-unknown-illumos.tar.gz");
}
/**
* @update 2025-06-17
*/
static Source_t pl_rust_rustup_sources[] = {
{&pl_rust_binary_upstream, "https://static.rust-lang.org", NULL},
{&MirrorZ, "https://mirrors.cernet.edu.cn/rustup", NULL},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/rustup", NULL},
{&Ustc, "https://mirrors.ustc.edu.cn/rust-static", NULL},
{&Nju, "https://mirror.nju.edu.cn/rustup", NULL},
{&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/rust-static", NULL},
{&Zju, "https://mirrors.zju.edu.cn/rustup", NULL},
{&Iscas, "https://mirror.iscas.ac.cn/rustup", NULL},
{&Ali, "https://mirrors.aliyun.com/rustup", NULL},
{&RsProxyCN, "https://rsproxy.cn"}};
def_sources_n(pl_rust_rustup);
/**
* chsrc get rustup
*/
void void
pl_rust_rustup_getsrc (char *option) pl_rust_rustup_getsrc (char *option)
{ {
@ -52,26 +44,28 @@ pl_rust_rustup_getsrc (char *option)
/** /**
* @consult https://mirrors.tuna.tsinghua.edu.cn/help/rustup/ * @consult https://mirrors.tuna.tsinghua.edu.cn/help/rustup/
*
* chsrc set rustup
*/ */
void void
pl_rust_rustup_setsrc (char *option) pl_rust_rustup_setsrc (char *option)
{ {
chsrc_use_this_source (pl_rust_rustup); chsrc_yield_source_and_confirm (pl_rust_rustup);
#ifdef XY_Build_On_Windows #ifdef XY_On_Windows
char *cmd1 = xy_strcat (3, "setx RUSTUP_DIST_SERVER \"", source.url, "\""); char *cmd1 = xy_strjoin (3, "setx RUSTUP_DIST_SERVER \"", source.url, "\"");
char *cmd2 = xy_strcat (3, "setx RUSTUP_UPDATE_ROOT \"", source.url, "/rustup\""); char *cmd2 = xy_strjoin (3, "setx RUSTUP_UPDATE_ROOT \"", source.url, "/rustup\"");
char *cmd = xy_strcat (3, cmd1, " & ", cmd2); char *cmd = xy_strjoin (3, cmd1, " & ", cmd2);
chsrc_run (cmd, RunOpt_Dont_Notify_On_Success|RunOpt_No_Last_New_Line); chsrc_run (cmd, RunOpt_Dont_Notify_On_Success|RunOpt_No_Last_New_Line);
#else #else
char *w1 = xy_strcat (3, "export RUSTUP_DIST_SERVER=\"", source.url, "\"\n"); char *w1 = xy_strjoin (3, "export RUSTUP_DIST_SERVER=\"", source.url, "\"\n");
char *w2 = xy_strcat (3, "export RUSTUP_UPDATE_ROOT=\"", source.url, "/rustup\"\n"); char *w2 = xy_strjoin (3, "export RUSTUP_UPDATE_ROOT=\"", source.url, "/rustup\"\n");
char *w = xy_2strcat (w1, w2); char *w = xy_2strjoin (w1, w2);
char *bashrc = xy_bashrc; char *bashrc = xy_bashrc;
if (xy_file_exist (bashrc)) if (xy_file_exist (bashrc))
@ -90,10 +84,10 @@ pl_rust_rustup_setsrc (char *option)
char *fishrc = xy_fishrc; char *fishrc = xy_fishrc;
if (xy_file_exist (fishrc)) if (xy_file_exist (fishrc))
{ {
char *w1 = xy_strcat (3, "set -x RUSTUP_DIST_SERVER ", source.url, "\n"); char *w1 = xy_strjoin (3, "set -x RUSTUP_DIST_SERVER ", source.url, "\n");
char *w2 = xy_strcat (3, "set -x RUSTUP_UPDATE_ROOT ", source.url, "/rustup\n"); char *w2 = xy_strjoin (3, "set -x RUSTUP_UPDATE_ROOT ", source.url, "/rustup\n");
char *w = xy_2strcat (w1, w2); char *w = xy_2strjoin (w1, w2);
chsrc_backup (fishrc); chsrc_backup (fishrc);
chsrc_append_to_file (w, fishrc); chsrc_append_to_file (w, fishrc);
@ -106,9 +100,35 @@ pl_rust_rustup_setsrc (char *option)
} }
/**
* chsrc reset rustup
*/
void void
pl_rust_rustup_resetsrc (char *option) pl_rust_rustup_resetsrc (char *option)
{ {
pl_rust_rustup_setsrc (option); pl_rust_rustup_setsrc (option);
} }
/**
* chsrc ls rustup
*/
Feature_t
pl_rust_rustup_feat (char *option)
{
Feature_t f = {0};
f.can_get = true;
f.can_reset = false;
f.cap_locally = CanNot;
f.cap_locally_explain = "";
f.can_english = false;
f.can_user_define = true;
f.note = NULL;
return f;
}
def_target_gsrf(pl_rust_rustup);

View File

@ -1,22 +1,22 @@
#pragma once #pragma once
/** /**
* Generated by rawstr4c v1.0.0-2025/08/09 * Generated by rawstr4c v0.2.3-2025/07/22
*/ */
char RAWSTR_pl_js_bun_config[] = "\133\151\156\163\164\141\154\154\135\012\162\145\147\151\163\164\162\171\040\075\040\042\100\165\162\154\100\042"; char RAWSTR_pl_nodejs_bun_config[] = "\133\151\156\163\164\141\154\154\135\012\162\145\147\151\163\164\162\171\040\075\040\042\100\165\162\154\100\042\012";
char RAWSTR_pl_java_maven_config[] = "\074\155\151\162\162\157\162\076\012\040\040\040\040\074\151\144\076\100\061\100\074\057\151\144\076\012\040\040\040\040\074\155\151\162\162\157\162\117\146\076\052\074\057\155\151\162\162\157\162\117\146\076\012\040\040\040\040\074\156\141\155\145\076\100\156\141\155\145\100\074\057\156\141\155\145\076\012\040\040\040\040\074\165\162\154\076\100\165\162\154\100\074\057\165\162\154\076\012\074\057\155\151\162\162\157\162\076"; char RAWSTR_pl_java_maven_config[] = "\074\155\151\162\162\157\162\076\012\040\040\040\040\074\151\144\076\100\061\100\074\057\151\144\076\012\040\040\040\040\074\155\151\162\162\157\162\117\146\076\052\074\057\155\151\162\162\157\162\117\146\076\012\040\040\040\040\074\156\141\155\145\076\100\156\141\155\145\100\074\057\156\141\155\145\076\012\040\040\040\040\074\165\162\154\076\100\165\162\154\100\074\057\165\162\154\076\012\074\057\155\151\162\162\157\162\076\012";
char RAWSTR_pl_java_build_gradle[] = "\141\154\154\160\162\157\152\145\143\164\163\040\173\012\040\040\040\040\162\145\160\157\163\151\164\157\162\151\145\163\040\173\012\040\040\040\040\040\040\040\040\155\141\166\145\156\040\173\040\165\162\154\040\047\100\165\162\154\100\047\040\175\012\040\040\040\040\040\040\040\040\155\141\166\145\156\114\157\143\141\154\050\051\012\040\040\040\040\040\040\040\040\155\141\166\145\156\103\145\156\164\162\141\154\050\051\012\040\040\040\040\175\012\175"; char RAWSTR_pl_java_build_gradle[] = "\141\154\154\160\162\157\152\145\143\164\163\040\173\012\040\040\040\040\162\145\160\157\163\151\164\157\162\151\145\163\040\173\012\040\040\040\040\040\040\040\040\155\141\166\145\156\040\173\040\165\162\154\040\047\100\165\162\154\100\047\040\175\012\040\040\040\040\040\040\040\040\155\141\166\145\156\114\157\143\141\154\050\051\012\040\040\040\040\040\040\040\040\155\141\166\145\156\103\145\156\164\162\141\154\050\051\012\040\040\040\040\175\012\175\012";
char RAWSTR_pl_rust_cargo_config[] = "\133\163\157\165\162\143\145\056\143\162\141\164\145\163\055\151\157\135\012\162\145\160\154\141\143\145\055\167\151\164\150\040\075\040\042\155\151\162\162\157\162\042\012\012\133\163\157\165\162\143\145\056\155\151\162\162\157\162\135\012\162\145\147\151\163\164\162\171\040\075\040\042\163\160\141\162\163\145\053\100\165\162\154\100\042\012"; char RAWSTR_pl_rust_cargo_config[] = "\133\163\157\165\162\143\145\056\143\162\141\164\145\163\055\151\157\135\012\162\145\160\154\141\143\145\055\167\151\164\150\040\075\040\047\155\151\162\162\157\162\047\012\012\133\163\157\165\162\143\145\056\155\151\162\162\157\162\135\012\162\145\147\151\163\164\162\171\040\075\040\042\163\160\141\162\163\145\053\100\165\162\154\100\042\012";
char RAWSTR_pl_haskell_cabal_config[] = "\162\145\160\157\163\151\164\157\162\171\040\155\151\162\162\157\162\012\040\040\165\162\154\072\040\100\165\162\154\100\012\040\040\163\145\143\165\162\145\072\040\124\162\165\145"; char RAWSTR_pl_haskell_cabal_config[] = "\162\145\160\157\163\151\164\157\162\171\040\155\151\162\162\157\162\012\040\040\165\162\154\072\040\100\165\162\154\100\012\040\040\163\145\143\165\162\145\072\040\124\162\165\145\012";
char RAWSTR_pl_haskell_stackage_yaml[] = "\160\141\143\153\141\147\145\055\151\156\144\145\170\072\012\040\040\144\157\167\156\154\157\141\144\055\160\162\145\146\151\170\072\040\100\165\162\154\100\012\040\040\150\141\143\153\141\147\145\055\163\145\143\165\162\151\164\171\072\012\040\040\040\040\153\145\171\151\144\163\072\012\040\040\040\040\040\040\055\040\060\141\065\143\067\145\141\064\067\143\144\061\142\061\065\146\060\061\146\065\146\065\061\141\063\063\141\144\144\141\067\145\066\065\065\142\143\060\146\060\142\060\066\061\065\142\141\141\070\145\062\067\061\146\064\143\063\063\065\061\145\062\061\144\012\040\040\040\040\040\040\055\040\061\145\141\071\142\141\063\062\143\065\062\066\144\061\143\143\071\061\141\142\065\145\065\142\144\063\066\064\145\143\065\145\071\145\070\143\142\066\067\061\067\071\141\064\067\061\070\067\062\146\066\145\062\066\146\060\141\145\067\067\063\144\064\062\012\040\040\040\040\040\040\055\040\062\070\060\142\061\060\061\065\063\141\065\062\062\066\070\061\061\066\063\066\065\070\143\142\064\071\146\066\063\062\143\144\145\063\146\063\070\144\067\066\070\142\067\063\066\144\144\142\143\071\060\061\144\071\071\141\061\141\067\067\062\070\063\063\012\040\040\040\040\040\040\055\040\062\141\071\066\142\061\070\070\071\144\143\062\062\061\143\061\067\062\071\066\146\143\143\062\142\142\063\064\142\071\060\070\143\141\071\067\063\064\063\067\066\146\060\146\063\066\061\066\066\060\062\060\060\071\063\065\071\061\066\145\146\062\060\061\012\040\040\040\040\040\040\055\040\062\143\066\143\063\066\062\067\142\144\066\143\071\070\062\071\071\060\062\063\071\064\070\067\146\061\141\142\144\060\062\145\060\070\141\060\062\145\066\143\146\061\066\145\144\142\061\060\065\141\070\060\061\062\144\064\064\064\144\070\067\060\143\063\012\040\040\040\040\040\040\055\040\065\061\146\060\061\066\061\142\071\060\066\060\061\061\142\065\062\143\066\066\061\063\063\067\066\142\061\141\145\071\063\067\066\067\060\144\141\066\071\063\062\062\061\061\063\141\062\064\066\141\060\071\146\070\060\067\143\066\062\146\066\071\062\061\012\040\040\040\040\040\040\055\040\067\067\062\145\071\146\064\143\067\144\142\063\063\144\062\065\061\144\065\143\066\145\063\065\067\061\071\071\143\070\061\071\145\065\066\071\144\061\063\060\070\065\067\144\143\062\062\065\065\064\071\142\064\060\070\064\065\146\146\060\070\071\060\144\012\040\040\040\040\040\040\055\040\141\141\063\061\065\062\070\066\145\066\141\144\062\070\061\141\144\066\061\061\070\062\062\063\065\065\063\063\143\064\061\145\070\060\066\145\065\141\067\070\067\145\060\142\066\144\061\145\067\145\145\146\063\146\060\071\144\061\063\067\144\062\145\071\012\040\040\040\040\040\040\055\040\146\145\063\063\061\065\060\062\066\060\066\070\060\062\146\145\141\143\061\065\145\065\061\064\144\071\142\071\145\141\070\063\146\145\145\070\142\066\146\146\145\146\067\061\063\063\065\064\067\071\141\062\145\066\070\144\070\064\141\144\143\066\142\060\012\040\040\040\040\153\145\171\055\164\150\162\145\163\150\157\154\144\072\040\063\040\043\040\156\165\155\142\145\162\040\157\146\040\153\145\171\163\040\162\145\161\165\151\162\145\144\012\040\040\040\040\043\040\151\147\156\157\162\145\040\145\170\160\151\162\141\164\151\157\156\040\144\141\164\145\054\040\163\145\145\040\150\164\164\160\163\072\057\057\147\151\164\150\165\142\056\143\157\155\057\143\157\155\155\145\162\143\151\141\154\150\141\163\153\145\154\154\057\163\164\141\143\153\057\160\165\154\154\057\064\066\061\064\012\040\040\040\040\151\147\156\157\162\145\055\145\170\160\151\162\171\072\040\156\157"; char RAWSTR_pl_haskell_stackage_yaml[] = "\160\141\143\153\141\147\145\055\151\156\144\145\170\072\012\040\040\144\157\167\156\154\157\141\144\055\160\162\145\146\151\170\072\040\100\165\162\154\100\012\040\040\150\141\143\153\141\147\145\055\163\145\143\165\162\151\164\171\072\012\040\040\040\040\153\145\171\151\144\163\072\012\040\040\040\040\040\040\055\040\060\141\065\143\067\145\141\064\067\143\144\061\142\061\065\146\060\061\146\065\146\065\061\141\063\063\141\144\144\141\067\145\066\065\065\142\143\060\146\060\142\060\066\061\065\142\141\141\070\145\062\067\061\146\064\143\063\063\065\061\145\062\061\144\012\040\040\040\040\040\040\055\040\061\145\141\071\142\141\063\062\143\065\062\066\144\061\143\143\071\061\141\142\065\145\065\142\144\063\066\064\145\143\065\145\071\145\070\143\142\066\067\061\067\071\141\064\067\061\070\067\062\146\066\145\062\066\146\060\141\145\067\067\063\144\064\062\012\040\040\040\040\040\040\055\040\062\070\060\142\061\060\061\065\063\141\065\062\062\066\070\061\061\066\063\066\065\070\143\142\064\071\146\066\063\062\143\144\145\063\146\063\070\144\067\066\070\142\067\063\066\144\144\142\143\071\060\061\144\071\071\141\061\141\067\067\062\070\063\063\012\040\040\040\040\040\040\055\040\062\141\071\066\142\061\070\070\071\144\143\062\062\061\143\061\067\062\071\066\146\143\143\062\142\142\063\064\142\071\060\070\143\141\071\067\063\064\063\067\066\146\060\146\063\066\061\066\066\060\062\060\060\071\063\065\071\061\066\145\146\062\060\061\012\040\040\040\040\040\040\055\040\062\143\066\143\063\066\062\067\142\144\066\143\071\070\062\071\071\060\062\063\071\064\070\067\146\061\141\142\144\060\062\145\060\070\141\060\062\145\066\143\146\061\066\145\144\142\061\060\065\141\070\060\061\062\144\064\064\064\144\070\067\060\143\063\012\040\040\040\040\040\040\055\040\065\061\146\060\061\066\061\142\071\060\066\060\061\061\142\065\062\143\066\066\061\063\063\067\066\142\061\141\145\071\063\067\066\067\060\144\141\066\071\063\062\062\061\061\063\141\062\064\066\141\060\071\146\070\060\067\143\066\062\146\066\071\062\061\012\040\040\040\040\040\040\055\040\067\067\062\145\071\146\064\143\067\144\142\063\063\144\062\065\061\144\065\143\066\145\063\065\067\061\071\071\143\070\061\071\145\065\066\071\144\061\063\060\070\065\067\144\143\062\062\065\065\064\071\142\064\060\070\064\065\146\146\060\070\071\060\144\012\040\040\040\040\040\040\055\040\141\141\063\061\065\062\070\066\145\066\141\144\062\070\061\141\144\066\061\061\070\062\062\063\065\065\063\063\143\064\061\145\070\060\066\145\065\141\067\070\067\145\060\142\066\144\061\145\067\145\145\146\063\146\060\071\144\061\063\067\144\062\145\071\012\040\040\040\040\040\040\055\040\146\145\063\063\061\065\060\062\066\060\066\070\060\062\146\145\141\143\061\065\145\065\061\064\144\071\142\071\145\141\070\063\146\145\145\070\142\066\146\146\145\146\067\061\063\063\065\064\067\071\141\062\145\066\070\144\070\064\141\144\143\066\142\060\012\040\040\040\040\153\145\171\055\164\150\162\145\163\150\157\154\144\072\040\063\040\043\040\156\165\155\142\145\162\040\157\146\040\153\145\171\163\040\162\145\161\165\151\162\145\144\012\040\040\040\040\043\040\151\147\156\157\162\145\040\145\170\160\151\162\141\164\151\157\156\040\144\141\164\145\054\040\163\145\145\040\150\164\164\160\163\072\057\057\147\151\164\150\165\142\056\143\157\155\057\143\157\155\155\145\162\143\151\141\154\150\141\163\153\145\154\154\057\163\164\141\143\153\057\160\165\154\154\057\064\066\061\064\012\040\040\040\040\151\147\156\157\162\145\055\145\170\160\151\162\171\072\040\156\157\012";
char RAWSTR_pl_clojure_project_clj[] = "\050\144\145\146\160\162\157\152\145\143\164\040\155\171\141\160\160\040\042\061\056\060\056\060\042\012\040\040\040\072\144\145\163\143\162\151\160\164\151\157\156\040\042\115\171\040\101\160\160\154\151\143\141\164\151\157\156\042\012\040\040\040\072\144\145\160\145\156\144\145\156\143\151\145\163\040\133\133\154\151\142\061\040\042\061\056\060\056\060\042\135\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\133\154\151\142\062\040\042\062\056\060\056\060\042\135\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\133\154\151\142\063\040\042\063\056\060\056\060\042\135\135\012\040\040\040\072\155\151\162\162\157\162\163\040\173\042\143\154\157\152\141\162\163\042\040\173\072\156\141\155\145\040\042\155\151\162\162\157\162\042\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\072\165\162\154\040\042\100\165\162\154\100\042\175\175\012\040\040\040\072\155\141\151\156\040\154\145\151\156\151\156\147\145\156\056\167\145\142\051"; char RAWSTR_pl_clojure_project_clj[] = "\050\144\145\146\160\162\157\152\145\143\164\040\155\171\141\160\160\040\042\061\056\060\056\060\042\012\040\040\040\072\144\145\163\143\162\151\160\164\151\157\156\040\042\115\171\040\101\160\160\154\151\143\141\164\151\157\156\042\012\040\040\040\072\144\145\160\145\156\144\145\156\143\151\145\163\040\133\133\154\151\142\061\040\042\061\056\060\056\060\042\135\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\133\154\151\142\062\040\042\062\056\060\056\060\042\135\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\133\154\151\142\063\040\042\063\056\060\056\060\042\135\135\012\040\040\040\072\155\151\162\162\157\162\163\040\173\042\143\154\157\152\141\162\163\042\040\173\072\156\141\155\145\040\042\155\151\162\162\157\162\042\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\072\165\162\154\040\042\100\165\162\154\100\042\175\175\012\040\040\040\072\155\141\151\156\040\154\145\151\156\151\156\147\145\156\056\167\145\142\051\012";
char RAWSTR_pl_clojure_projfiles_clj[] = "\072\165\163\145\162\040\173\072\162\145\160\157\163\151\164\157\162\151\145\163\040\133\133\042\143\154\157\152\141\162\163\042\040\173\072\165\162\154\040\042\100\165\162\154\100\042\175\135\135\012\040\040\040\040\040\040\040\073\073\040\157\164\150\145\162\040\072\165\163\145\162\040\160\162\157\146\151\154\145\040\163\145\164\164\151\156\147\163\012\040\040\040\040\040\040\175"; char RAWSTR_pl_clojure_projfiles_clj[] = "\072\165\163\145\162\040\173\072\162\145\160\157\163\151\164\157\162\151\145\163\040\133\133\042\143\154\157\152\141\162\163\042\040\173\072\165\162\154\040\042\100\165\162\154\100\042\175\135\135\012\040\040\040\040\040\040\040\073\073\040\157\164\150\145\162\040\072\165\163\145\162\040\160\162\157\146\151\154\145\040\163\145\164\164\151\156\147\163\012\040\040\040\040\040\040\175\012";

View File

@ -3,9 +3,9 @@
! ------------------------------------------------------------- ! -------------------------------------------------------------
! Config Type : rawstr4c (Markdown) ! Config Type : rawstr4c (Markdown)
! Config Authors: Aoran Zeng <ccmywish@qq.com> ! Config Authors: Aoran Zeng <ccmywish@qq.com>
! Contributors : Happy Game <happygame1024@gmail.com> ! Contributors : Nil Null <nil@null.org>
! Created On : <2025-07-14> ! Created On : <2025-07-14>
! Last Modified : <2025-09-13> ! Last Modified : <2025-07-22>
! ---------------------------------------------------------- --> ! ---------------------------------------------------------- -->
# rawstr4c input for PL # rawstr4c input for PL
@ -13,7 +13,7 @@
- prefix = `RAWSTR_pl` - prefix = `RAWSTR_pl`
- output = `:global-variable-only-header` - output = `:global-variable-only-header`
- translate = `:oct` - translate = `:oct`
- no-postfix = `true` - keep-postfix = `false`
<br> <br>
@ -75,11 +75,10 @@ allprojects {
```toml ```toml
[source.crates-io] [source.crates-io]
replace-with = "mirror" replace-with = 'mirror'
[source.mirror] [source.mirror]
registry = "sparse+@url@" registry = "sparse+@url@"
``` ```
<br> <br>
@ -102,7 +101,7 @@ repository mirror
### stackage ### stackage
- name = `stackage` - name = `stackage`
- no-postfix = `false` - keep-postfix = `true`
- postfix = `yaml` - postfix = `yaml`
```yaml ```yaml

View File

@ -1,201 +1,150 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* ------------------------------------------------------------- * -------------------------------------------------------------
* File Authors : <ccmywish@qq.com> * File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Mikachu2333 <mikachu.23333@zohomail.com> * Contributors : Mikachu2333 <mikachu.23333@zohomail.com>
* | BingChunMoLi <bingchunmoli@bingchunmoli.com>
* | * |
* Created On : <2023-09-01> * Created On : <2023-09-01>
* Major Revision : 5 * Major Revision : 1
* Last Modified : <2025-08-22> * Last Modified : <2025-07-21>
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
#include "lang/rawstr4c.h" /* Begin Target Matrix */
#define t(a) (const char*)(a)
static const char
*pl_ruby [] = {"gem", "ruby", "rb", "rubygem", "rubygems", "bundler", NULL, t(&pl_ruby_target)},
#include "lang/Ruby/Ruby.c" *pl_python[] = {"python", "pypi", "py", NULL, t(&pl_python_group_target)},
#include "lang/Python/common.h" *pl_python_pip[] = {"pip", NULL, t(&pl_python_pip_target)},
#include "lang/Python/pip.c" *pl_python_poetry[] = {"poetry", NULL, t(&pl_python_poetry_target)},
#include "lang/Python/Poetry.c" *pl_python_pdm[] = {"pdm", NULL, t(&pl_python_pdm_target)},
#include "lang/Python/PDM.c" *pl_python_rye[] = {"rye", NULL, t(&pl_python_rye_target)},
#include "lang/Python/Rye.c" *pl_python_uv[] = {"uv", NULL, t(&pl_python_uv_target)},
#include "lang/Python/uv.c"
#include "lang/Python/Python.c"
#include "lang/JavaScript/common.h" *pl_nodejs[] = {"node", "nodejs", NULL, t(&pl_nodejs_group_target)},
#include "lang/JavaScript/npm.c" *pl_nodejs_bun[] = {"bun", NULL, t(&pl_nodejs_bun_target)},
#include "lang/JavaScript/pnpm.c" *pl_nodejs_npm[] = {"npm", NULL, t(&pl_nodejs_npm_target)},
#include "lang/JavaScript/Yarn.c" *pl_nodejs_yarn[] = {"yarn", NULL, t(&pl_nodejs_yarn_target)},
#include "lang/JavaScript/JavaScript.c" *pl_nodejs_pnpm[] = {"pnpm", NULL, t(&pl_nodejs_pnpm_target)},
#include "lang/JavaScript/Bun.c" *pl_nodejs_nvm[] = {"nvm", NULL, t(&pl_nodejs_nvm_target)},
#include "lang/JavaScript/nvm.c"
#include "lang/Perl.c" *pl_perl [] = {"perl", "cpan", NULL, t(&pl_perl_target)},
#include "lang/PHP.c" *pl_php [] = {"php", "composer", NULL, t(&pl_php_target)},
#include "lang/Lua.c" *pl_lua [] = {"lua", "luarocks", NULL, t(&pl_lua_target)},
#include "lang/Go.c" *pl_go [] = {"go", "golang", "goproxy", NULL, t(&pl_go_target)} ,
#include "lang/Java.c"
#include "lang/Rust/common.h" *pl_rust_cargo[] = {"rust", "cargo", "crate", "crates", NULL, t(&pl_rust_cargo_target)},
#include "lang/Rust/rustup.c" *pl_rust_rustup[]= {"rustup", NULL, t(&pl_rust_rustup_target)},
#include "lang/Rust/Cargo.c"
#include "lang/Dart/common.h" *pl_java [] = {"java", "maven", "mvn", "gradle", NULL, t(&pl_java_target)},
#include "lang/Dart/Pub.c" *pl_clojure[]= {"clojure","clojars","cloj", "lein", NULL, t(&pl_clojure_target)},
#include "lang/Dart/Flutter.c"
#include "lang/Haskell.c" *pl_dart [] = {"dart", "pub", NULL, t(&pl_dart_target)},
#include "lang/OCaml.c" *pl_dart_flutter [] = {"flutter", NULL, t(&pl_dart_flutter_target)},
#include "lang/R.c"
#include "lang/Julia.c"
#include "lang/NuGet.c"
#include "lang/Clojure.c"
*pl_nuget[] = {"nuget", "net", ".net", "dotnet", NULL, t(&pl_nuget_target)},
#include "os/rawstr4c.h" *pl_haskell[]= {"haskell", "cabal", "stack", "hackage", NULL, t(&pl_haskell_target)},
#include "os/APT/common.h" *pl_ocaml[] = {"ocaml", "opam", NULL, t(&pl_ocaml_target)},
// Debian-based *pl_r [] = {"cran", "r", NULL, t(&pl_r_target)},
#include "os/APT/Debian.c" *pl_julia [] = {"julia", NULL, t(&pl_julia_target)},
#include "os/APT/Ubuntu.c" **pl_packagers[] =
#include "os/APT/Kali-Linux.c"
#include "os/APT/Raspberry-Pi-OS.c"
// Ubuntu-based
#include "os/APT/Linux-Mint.c"
#include "os/APT/Trisquel.c"
#include "os/APT/Linux-Lite.c"
// Debian-based and Ubuntu-based
#include "os/APT/Armbian.c"
// Independent
#include "os/APT/ROS.c"
#include "os/APT/Termux.c"
#include "os/APT/openKylin.c"
#include "os/APT/deepin.c"
#include "os/YUM/common.h"
#include "os/YUM/Fedora-Linux.c"
#include "os/YUM/AlmaLinux.c"
#include "os/YUM/Rocky-Linux.c"
#include "os/YUM/openEuler.c"
#include "os/YUM/Anolis-OS.c"
#include "os/pacman/Arch-Linux.c"
#include "os/pacman/Manjaro-Linux.c"
#include "os/pacman/MSYS2.c"
#include "os/openSUSE.c"
#include "os/Alpine-Linux.c"
#include "os/Gentoo-Linux.c"
#include "os/Void-Linux.c"
#include "os/Solus.c"
#include "os/OpenWrt.c"
#include "os/BSD/FreeBSD.c"
#include "os/BSD/NetBSD.c"
#include "os/BSD/OpenBSD.c"
#include "ware/TeX-Live.c"
#include "ware/Emacs.c"
#include "ware/WinGet.c"
#include "ware/Homebrew/Homebrew.c"
#include "ware/CocoaPods.c"
#include "ware/Nix.c"
#include "ware/Guix.c"
#include "ware/Flatpak.c"
#include "ware/Docker/Docker.c"
#include "ware/Anaconda/Anaconda.c"
void
chsrc_init_menu ()
{ {
#define add(t) xy_seq_push(ProgStore.pl, &pl_##t##_target); (&pl_##t##_target)->preludefn = pl_##t##_prelude pl_ruby,
add (ruby); pl_python, pl_python_pip, pl_python_poetry, pl_python_pdm, pl_python_rye, pl_python_uv,
add (python_group); pl_nodejs, pl_nodejs_bun,
add (python_pip); pl_nodejs_npm, pl_nodejs_pnpm, pl_nodejs_yarn,
add (python_poetry); pl_nodejs_nvm,
add (python_pdm); pl_perl, pl_php,
add (python_rye); pl_lua,
add (python_uv); pl_rust_cargo, pl_rust_rustup,
add (js_group); pl_go,
add (js_bun); /*pl_nuget,*/
add (js_npm); pl_java, pl_clojure,
add (js_yarn); pl_dart, pl_dart_flutter,
add (js_pnpm); pl_ocaml,
add (js_nvm); pl_r, pl_julia,
add (perl); pl_haskell,
add (php); };
add (lua);
add (go);
add (rust_cargo);
add (rust_rustup);
add (java);
add (clojure);
add (dart);
add (dart_flutter);
add (nuget);
add (haskell);
add (ocaml);
add (r);
add (julia);
#undef add
#define add(t) xy_seq_push(ProgStore.os, &os_##t##_target); (&os_##t##_target)->preludefn = os_##t##_prelude
add (ubuntu);
add (linuxmint);
add (debian);
add (fedora);
add (opensuse);
add (kali);
add (msys2);
add (arch);
add (archlinuxcn);
add (manjaro);
add (gentoo);
add (rockylinux);
add (almalinux);
add (alpine);
add (voidlinux);
add (solus);
add (trisquel);
add (linuxlite);
add (ros);
add (raspberrypi);
add (armbian);
add (openwrt);
add (termux);
add (openkylin);
add (openeuler);
add (anolis);
add (deepin);
add (freebsd);
add (netbsd);
add (openbsd);
#undef add
#define add(t) xy_seq_push(ProgStore.wr, &wr_##t##_target); (&wr_##t##_target)->preludefn = wr_##t##_prelude static const char
add (winget); /* Zorin OS 完全使用 Ubuntu 的换源方法,二者兼容 */
add (homebrew); *os_ubuntu [] = {"ubuntu", "zorinos", NULL, t(&os_ubuntu_target)},
add (cocoapods); *os_linuxmint [] = {"linuxmint", NULL, t(&os_linuxmint_target)},
add (docker); *os_debian [] = {"debian", NULL, t(&os_debian_target)},
add (flatpak); *os_fedora [] = {"fedora", NULL, t(&os_fedora_target)},
add (nix); *os_opensuse [] = {"opensuse", "opensuse-leap", "opensuse-tumbleweed", NULL, t(&os_opensuse_target)},
add (guix); *os_kali [] = {"kali", NULL, t(&os_kali_target)},
add (emacs); *os_msys2 [] = {"msys2", "msys", NULL, t(&os_msys2_target)},
add (tex); *os_arch [] = {"arch", "archlinux", NULL, t(&os_arch_target)},
add (anaconda); *os_archlinuxcn[] = {"archlinuxcn", "archcn",NULL, t(&os_archlinuxcn_target)},
#undef add *os_manjaro [] = {"manjaro", NULL, t(&os_manjaro_target)},
*os_gentoo [] = {"gentoo", NULL, t(&os_gentoo_target)},
*os_rockylinux [] = {"rocky", "rockylinux", NULL, t(&os_rockylinux_target)},
*os_almalinux [] = {"alma", "almalinux", NULL, t(&os_almalinux_target)},
*os_alpine [] = {"alpine", NULL, t(&os_alpine_target)},
*os_voidlinux [] = {"voidlinux", NULL, t(&os_voidlinux_target)},
*os_solus [] = {"solus", NULL, t(&os_solus_target)},
*os_trisquel [] = {"trisquel", NULL, t(&os_trisquel_target)},
*os_linuxlite [] = {"linuxlite", NULL, t(&os_linuxlite_target)},
*os_ros [] = {"ros", "ros2", NULL, t(&os_ros_target)},
// Internal Target 不会由用户使用,需要特殊对待 *os_raspberrypi[] = {"raspi", "raspberrypi",NULL, t(&os_raspberrypi_target)},
pl_js_nodejs_binary_target.preludefn = pl_js_nodejs_binary_prelude; *os_armbian [] = {"armbian", NULL, t(&os_armbian_target)},
} *os_openwrt [] = {"openwrt", "opkg", "LEDE", NULL, t(&os_openwrt_target)},
*os_termux [] = {"termux", NULL, t(&os_termux_target)},
*os_openkylin [] = {"openkylin", NULL, t(&os_openkylin_target)},
*os_openeuler [] = {"openeuler", NULL, t(&os_openeuler_target)},
*os_anolis [] = {"openanolis", "anolis", NULL, t(&os_anolis_target)},
*os_deepin [] = {"deepin", NULL, t(&os_deepin_target)},
*os_freebsd [] = {"freebsd", NULL, t(&os_freebsd_target)},
*os_netbsd [] = {"netbsd", NULL, t(&os_netbsd_target)},
*os_openbsd [] = {"openbsd", NULL, t(&os_openbsd_target)},
**os_systems[] =
{
os_debian, os_ubuntu, os_linuxmint, os_kali,
os_trisquel, os_linuxlite, os_raspberrypi, os_armbian, os_openwrt, os_termux,
os_deepin, os_openkylin, os_ros,
os_fedora, os_rockylinux, os_almalinux, os_openeuler, os_anolis,
os_opensuse,
os_arch, os_archlinuxcn, os_manjaro, os_gentoo,
os_alpine, os_voidlinux, os_solus,
os_msys2,
os_freebsd, os_netbsd, os_openbsd,
};
static const char
*wr_winget [] = {"winget", NULL, t(&wr_winget_target)},
*wr_homebrew[] = {"brew", "homebrew", NULL, t(&wr_homebrew_target)},
*wr_cocoapods[] = {"cocoa", "cocoapods","pod", "cocoapod", NULL, t(&wr_cocoapods_target)},
*wr_dockerhub [] ={"dockerhub", "docker", NULL, t(&wr_dockerhub_target)},
*wr_flathub [] = {"flathub", "flatpak", NULL, t(&wr_flathub_target)},
*wr_nix [] = {"nix", NULL, t(&wr_nix_target)},
*wr_guix [] = {"guix", NULL, t(&wr_guix_target)},
*wr_emacs [] = {"emacs", "elpa", NULL, t(&wr_emacs_target)},
*wr_tex [] = {"latex", "ctan", "tex", "texlive", "miktex", "tlmgr", "mpm", NULL, t(&wr_tex_target)},
*wr_anaconda[] = {"conda", "anaconda", NULL, t(&wr_anaconda_target)},
**wr_softwares[] =
{
wr_winget, wr_homebrew, wr_cocoapods, wr_dockerhub, wr_flathub, wr_nix, wr_guix, wr_emacs, wr_tex, wr_anaconda
};
#undef t
/** /**
* @sync https://github.com/RubyMetric/chsrc/wiki * @sync https://github.com/RubyMetric/chsrc/wiki
*/ */
static MirrorSite_t* static MirrorSite_t*
chsrc_available_mirrors[] = { available_mirrors[] = {
/* ------------------------ 教育网(通用镜像站) ------------------------ */ /* ------------------------ 教育网(通用镜像站) ------------------------ */
&MirrorZ, &Tuna, &Sjtug_Zhiyuan, &Sjtug_Siyuan, &Bfsu, &Ustc, &Zju, &Jlu, &Lzuoss, &Pku, &Bjtu, &Sustech, &Nju, &Xjtu, &MirrorZ, &Tuna, &Sjtug_Zhiyuan, &Sjtug_Siyuan, &Bfsu, &Ustc, &Zju, &Jlu, &Lzuoss, &Pku, &Bjtu, &Sustech, &Nju, &Xjtu,
@ -205,10 +154,12 @@ chsrc_available_mirrors[] = {
&Cqupt, &Cqu, &Neosoft, &Cqupt, &Cqu, &Neosoft,
/* ------------------------ 商业公司(通用镜像站) ------------------------ */ /* ------------------------ 商业公司(通用镜像站) ------------------------ */
&Ali, // &Ali_ECS_VPC, &Ali_ECS_classic, &Ali, // &Ali_ECS_VPC, &Ali_ECS_classic,
&Tencent, // &Tencent_Intra, &Tencent, // &Tencent_Intra,
&Huawei, &HuaweiCDN, &Huawei,
&Volcengine, &Volcengine,
&Netease, &Netease,
&Sohu, &Sohu,
@ -216,11 +167,18 @@ chsrc_available_mirrors[] = {
&Api7, &Fit2Cloud, &DaoCloud, &Api7, &Fit2Cloud, &DaoCloud,
/* ------------------------ 专用镜像站 ------------------------ */ /* ------------------------ 专用镜像站 ------------------------ */
&RubyChina, &EmacsChina, &NpmMirror, &GoProxyIO, &GoProxyCN, &RsProxyCN, &FlutterCN, &RubyChina, &EmacsChina, &NpmMirror, &GoProxyIO, &GoProxyCN, &RsProxyCN, &FlutterCN,
/* 暂不支持 &NugetOrg */ /* 暂不支持 &NugetOrg */
/* ------------------------ chsrc 内部实现 ------------------------ */ /* ------------------------ chsrc 内部实现 ------------------------ */
/* 不要列出 &UpstreamProvider 和 &UserDefinedProvider */ /* 不要列出 &UpstreamProvider 和 &UserDefinedProvider */
}; };
/* End Target Matrix */

View File

@ -1,30 +1,20 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Shengwei Chen <414685209@qq.com>
* Contributors : Aoran Zeng <ccmywish@qq.com>
* | Yangmoooo <yangmoooo@outlook.com>
* |
* Created On : <2024-06-14>
* Last Modified : <2025-07-14>
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
def_target(os_armbian, "armbian"); /**
* @update 2024-11-21
void */
os_armbian_prelude () static Source_t os_armbian_sources[] =
{ {
chef_prep_this (os_armbian, gsr); {&UpstreamProvider, "http://apt.armbian.com", NULL},
chef_set_created_on (this, "2024-06-14");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2024-11-21");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@livelycode36");
chef_set_sauciers (this, 2, "@ccmywish", "@Yangmoooo");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this);
chef_deny_user_define(this);
chef_set_note(this, NULL, NULL);
def_sources_begin()
{&UpstreamProvider, "http://apt.armbian.com", DelegateToUpstream},
{&MirrorZ, "https://mirrors.cernet.edu.cn/armbian", DelegateToMirror}, {&MirrorZ, "https://mirrors.cernet.edu.cn/armbian", DelegateToMirror},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/armbian", DelegateToMirror}, {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/armbian", DelegateToMirror},
{&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/armbian", DelegateToMirror}, {&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/armbian", DelegateToMirror},
@ -32,9 +22,9 @@ os_armbian_prelude ()
{&Sustech, "https://mirrors.sustech.edu.cn/armbian", DelegateToMirror}, {&Sustech, "https://mirrors.sustech.edu.cn/armbian", DelegateToMirror},
{&Ustc, "https://mirrors.ustc.edu.cn/armbian", DelegateToMirror}, {&Ustc, "https://mirrors.ustc.edu.cn/armbian", DelegateToMirror},
{&Nju, "https://mirrors.nju.edu.cn/armbian", DelegateToMirror}, {&Nju, "https://mirrors.nju.edu.cn/armbian", DelegateToMirror},
{&Ali, "https://mirrors.aliyun.com/armbian", DelegateToMirror} {&Ali, "https://mirrors.aliyun.com/armbian", DelegateToMirror},
def_sources_end() };
} def_sources_n(os_armbian);
void void
@ -60,11 +50,11 @@ os_armbian_setsrc (char *option)
{ {
chsrc_ensure_root (); chsrc_ensure_root ();
chsrc_use_this_source (os_armbian); chsrc_yield_source_and_confirm (os_armbian);
chsrc_backup (OS_Armbian_SourceList); chsrc_backup (OS_Armbian_SourceList);
char *cmd = xy_strcat (3, "sed -E -i 's@https?[^ ]*armbian/?[^ ]*@", source.url, char *cmd = xy_strjoin (3, "sed -E -i 's@https?[^ ]*armbian/?[^ ]*@", source.url,
"@g' " OS_Armbian_SourceList); "@g' " OS_Armbian_SourceList);
chsrc_run (cmd, RunOpt_Default); chsrc_run (cmd, RunOpt_Default);
@ -80,3 +70,21 @@ os_armbian_resetsrc (char *option)
{ {
os_armbian_setsrc (option); os_armbian_setsrc (option);
} }
Feature_t
os_armbian_feat (char *option)
{
Feature_t f = {0};
f.can_get = true;
f.can_reset = true;
f.cap_locally = CanNot;
f.can_english = true;
f.can_user_define = true;
return f;
}
def_target_gsrf(os_armbian);

View File

@ -1,48 +1,69 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* | Heng Guo <2085471348@qq.com>
* Contributors : Yangmoooo <yangmoooo@outlook.com>
* | GitHub Copilot <https://github.com/copilot>
* |
* Created On : <2023-09-02>
* Major Revision : 3
* Last Modified : <2025-07-21>
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
def_target(os_debian, "debian"); #define OS_Debian_Speed_URL_Postfix "/dists/bookworm/main/Contents-all.gz"
static SourceProvider_t os_debian_upstream =
{
def_upstream, "https://ftp.debian.org/debian/",
{NotSkip, NA, NA, "https://ftp.debian.org/debian/dists/bookworm/main/Contents-all.gz", ACCURATE} // 32MB
};
/**
* @update 2025-07-11
*/
static Source_t os_debian_sources[] =
{
{&os_debian_upstream, "http://deb.debian.org/debian", DelegateToUpstream},
/* MirrorZ 的速度这么测也是可以的 */
{&MirrorZ, "https://mirrors.cernet.edu.cn/debian/",
"https://mirrors.cernet.edu.cn/debian/" OS_Debian_Speed_URL_Postfix},
{&Ali, "https://mirrors.aliyun.com/debian",
"https://mirrors.aliyun.com/debian" OS_Debian_Speed_URL_Postfix},
{&Volcengine, "https://mirrors.volces.com/debian",
"https://mirrors.volces.com/debian" OS_Debian_Speed_URL_Postfix},
{&Bfsu, "https://mirrors.bfsu.edu.cn/debian",
"https://mirrors.bfsu.edu.cn/debian" OS_Debian_Speed_URL_Postfix},
{&Ustc, "https://mirrors.ustc.edu.cn/debian",
"https://mirrors.ustc.edu.cn/debian" OS_Debian_Speed_URL_Postfix},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/debian",
"https://mirrors.tuna.tsinghua.edu.cn/debian" OS_Debian_Speed_URL_Postfix},
{&Tencent, "https://mirrors.tencent.com/debian",
"https://mirrors.tencent.com/debian" OS_Debian_Speed_URL_Postfix},
// {&Tencent_Intra, "https://mirrors.tencentyun.com/debian", FeedBySourcesPrepare},
/* 不启用原因:过慢 */
// {&Netease, "https://mirrors.163.com/debian", FeedBySourcesPrepare},
/* 不启用原因:过慢 */
// {&Sohu, "https://mirrors.sohu.com/debian", FeedBySourcesPrepare}
};
def_sources_n(os_debian);
void void
os_debian_prelude () os_debian_sources_prepare ()
{ {
chef_prep_this (os_debian, gsr); chsrc_sources_prepare_speedurl_with_postfix (os_debian, OS_Debian_Speed_URL_Postfix);
chef_set_created_on (this, "2023-09-02");
chef_set_last_updated (this, "2025-11-09");
chef_set_sources_last_updated (this, "2025-07-11");
chef_set_chef (this, NULL);
chef_set_cooks (this, 2, "@ccmywish", "@G_I_Y");
chef_set_sauciers (this, 1, "@Yangmoooo");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this);
chef_deny_user_define(this);
chef_set_note(this, NULL, NULL);
def_sources_begin()
{&UpstreamProvider, "http://deb.debian.org/debian", FeedByPrelude},
{&MirrorZ, "https://mirrors.cernet.edu.cn/debian", FeedByPrelude},
{&Ali, "https://mirrors.aliyun.com/debian", FeedByPrelude},
{&Volcengine, "https://mirrors.volces.com/debian", FeedByPrelude},
{&Bfsu, "https://mirrors.bfsu.edu.cn/debian", FeedByPrelude},
{&Ustc, "https://mirrors.ustc.edu.cn/debian", FeedByPrelude},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/debian", FeedByPrelude},
{&Tencent, "https://mirrors.tencent.com/debian", FeedByPrelude}
// {&Tencent_Intra, "https://mirrors.tencentyun.com/debian", FeedByPrelude},
/* 不启用原因:过慢 */
// {&Netease, "https://mirrors.163.com/debian", FeedByPrelude},
/* 不启用原因:过慢 */
// {&Sohu, "https://mirrors.sohu.com/debian", FeedByPrelude}
def_sources_end()
chef_set_sources_speed_measure_url_with_postfix (this, "/dists/bookworm/main/Contents-all.gz");
} }
@ -72,8 +93,8 @@ static bool
os_debian_does_old_sourcelist_use_cdrom (void) os_debian_does_old_sourcelist_use_cdrom (void)
{ {
/* 我们只检查旧版sourcelist因为 common.h 中的填充只支持旧版 */ /* 我们只检查旧版sourcelist因为 common.h 中的填充只支持旧版 */
char *cmd = xy_2strcat ("grep -q '^deb cdrom:' ", OS_Debian_old_SourceList); char *cmd = xy_2strjoin ("grep -q '^deb cdrom:' ", OS_Debian_old_SourceList);
int ret = xy_run_get_status (cmd); int ret = system (cmd);
bool use_cdrom = ret == 0; bool use_cdrom = ret == 0;
return use_cdrom; return use_cdrom;
@ -83,15 +104,15 @@ os_debian_does_old_sourcelist_use_cdrom (void)
void void
os_debian_setsrc_for_deb822 (char *option) os_debian_setsrc_for_deb822 (char *option)
{ {
chsrc_use_this_source (os_debian); chsrc_yield_source_and_confirm (os_debian);
chsrc_backup (OS_Debian_SourceList_DEB822); chsrc_backup (OS_Debian_SourceList_DEB822);
char *cmd = xy_strcat (3, "sed -E -i 's@https?://.*/debian/?@", source.url, "@g' " OS_Debian_SourceList_DEB822); char *cmd = xy_strjoin (3, "sed -E -i 's@https?://.*/debian/?@", source.url, "@g' " OS_Debian_SourceList_DEB822);
chsrc_run (cmd, RunOpt_Default); chsrc_run (cmd, RunOpt_Default);
/* debian-security 源和其他源不一样 */ /* debian-security 源和其他源不一样 */
cmd = xy_strcat (3, "sed -E -i 's@https?://.*/debian-security/?@", source.url, "-security@g' " OS_Debian_SourceList_DEB822); cmd = xy_strjoin (3, "sed -E -i 's@https?://.*/debian-security/?@", source.url, "-security@g' " OS_Debian_SourceList_DEB822);
chsrc_run (cmd, RunOpt_Default); chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line); chsrc_run ("apt update", RunOpt_No_Last_New_Line);
@ -135,7 +156,7 @@ os_debian_setsrc (char *option)
if (use_cdrom) if (use_cdrom)
{ {
chsrc_backup (OS_Debian_old_SourceList); chsrc_backup (OS_Debian_old_SourceList);
int rm_status = xy_run_get_status ("rm " OS_Debian_old_SourceList); int rm_status = system ("rm " OS_Debian_old_SourceList);
if (rm_status != 0) { /* Placate -Wunused-result */ } if (rm_status != 0) { /* Placate -Wunused-result */ }
chsrc_warn2 ("旧版源配置文件中使用了 CDROM 源,已删除(但备份)该配置文件,重新配置"); chsrc_warn2 ("旧版源配置文件中使用了 CDROM 源,已删除(但备份)该配置文件,重新配置");
@ -144,7 +165,7 @@ os_debian_setsrc (char *option)
} }
} }
chsrc_use_this_source (os_debian); chsrc_yield_source_and_confirm (os_debian);
chsrc_alert2 ("如果遇到无法拉取 HTTPS 源的情况,请手动运行:"); chsrc_alert2 ("如果遇到无法拉取 HTTPS 源的情况,请手动运行:");
say ("apt install apt-transport-https ca-certificates"); say ("apt install apt-transport-https ca-certificates");
@ -155,7 +176,7 @@ os_debian_setsrc (char *option)
chsrc_backup (OS_Debian_old_SourceList); chsrc_backup (OS_Debian_old_SourceList);
} }
char *cmd = xy_strcat (3, "sed -E -i \'s@https?://.*/debian/?@", source.url, "@g\' " OS_Debian_old_SourceList); char *cmd = xy_strjoin (3, "sed -E -i \'s@https?://.*/debian/?@", source.url, "@g\' " OS_Debian_old_SourceList);
chsrc_run (cmd, RunOpt_Default); chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line); chsrc_run ("apt update", RunOpt_No_Last_New_Line);
@ -170,3 +191,23 @@ os_debian_resetsrc (char* option)
{ {
os_debian_setsrc (option); os_debian_setsrc (option);
} }
Feature_t
os_debian_feat (char *option)
{
Feature_t f = {0};
f.can_get = true;
f.can_reset = true;
f.cap_locally = CanNot;
f.cap_locally_explain = NULL;
f.can_english = false;
f.can_user_define = true;
f.note = NULL;
return f;
}
def_target_gsrf(os_debian);

View File

@ -1,40 +1,40 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Heng Guo <2085471348@qq.com>
* Contributors : Yangmoooo <yangmoooo@outlook.com>
* | Happy Game <happygame1024@gmail.com>
* |
* Created On : <2023-09-29>
* Last Modified : <2025-07-21>
*
* Kali Linux Debian Testing branch
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
def_target(os_kali, "kali"); static SourceProvider_t os_kali_upstream =
void
os_kali_prelude ()
{ {
chef_prep_this (os_kali, gsr); def_upstream, "http://http.kali.org/kali",
// https://github.com/RubyMetric/chsrc/issues/121
{NotSkip, NA, NA, "https://http.kali.org/kali/dists/kali-dev/Contents-amd64.gz", ACCURATE} // 47MB
};
chef_set_created_on (this, "2023-09-29"); /**
chef_set_last_updated (this, "2025-08-10"); * @update 2025-06-20
chef_set_sources_last_updated (this, "2025-06-20"); */
static Source_t os_kali_sources[] =
chef_set_chef (this, NULL); {
chef_set_cooks (this, 1, "@G_I_Y"); {&os_kali_upstream, "http://http.kali.org/kali", DelegateToUpstream},
chef_set_sauciers (this, 2, "@Yangmoooo", "@happy-game");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this);
chef_deny_user_define(this);
chef_set_note(this, NULL, NULL);
def_sources_begin()
{&UpstreamProvider, "http://http.kali.org/kali", DelegateToUpstream},
{&MirrorZ, "https://mirrors.cernet.edu.cn/kali", DelegateToMirror}, {&MirrorZ, "https://mirrors.cernet.edu.cn/kali", DelegateToMirror},
{&Ali, "https://mirrors.aliyun.com/kali", DelegateToMirror}, {&Ali, "https://mirrors.aliyun.com/kali", DelegateToMirror},
{&Volcengine, "https://mirrors.volces.com/kali", DelegateToMirror}, {&Volcengine, "https://mirrors.volces.com/kali", DelegateToMirror},
{&Bfsu, "https://mirrors.bfsu.edu.cn/kali", DelegateToMirror}, {&Bfsu, "https://mirrors.bfsu.edu.cn/kali", DelegateToMirror},
{&Ustc, "https://mirrors.ustc.edu.cn/kali", DelegateToMirror}, {&Ustc, "https://mirrors.ustc.edu.cn/kali", DelegateToMirror},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/kali", DelegateToMirror} {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/kali", DelegateToMirror},
/* 不启用原因: 未与上游同步 */ /* 不启用原因: 未与上游同步 */
// {&Huawei, "https://mirrors.huaweicloud.com/kali", DelegateToMirror}, // {&Huawei, "https://mirrors.huaweicloud.com/kali", DelegateToMirror},
def_sources_end() };
} def_sources_n(os_kali);
void void
os_kali_getsrc (char *option) os_kali_getsrc (char *option)
@ -47,11 +47,11 @@ os_kali_setsrc (char *option)
{ {
chsrc_ensure_root (); chsrc_ensure_root ();
chsrc_use_this_source (os_kali); chsrc_yield_source_and_confirm (os_kali);
chsrc_backup (OS_Apt_SourceList); chsrc_backup (OS_Apt_SourceList);
char *cmd = xy_strcat (3, "sed -E -i \'s@https?://.*/kali/?@", char *cmd = xy_strjoin (3, "sed -E -i \'s@https?://.*/kali/?@",
source.url, source.url,
"@g\' " OS_Apt_SourceList); "@g\' " OS_Apt_SourceList);
@ -68,3 +68,24 @@ os_kali_resetsrc (char *option)
{ {
os_kali_setsrc (option); os_kali_setsrc (option);
} }
Feature_t
os_kali_feat (char *option)
{
Feature_t f = {0};
f.can_get = true;
f.can_reset = true;
f.cap_locally = CanNot;
f.cap_locally_explain = NULL;
f.can_english = true;
f.can_user_define = true;
f.note = NULL;
return f;
}
def_target_gsrf(os_kali);

View File

@ -1,35 +1,30 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Yangmoooo <yangmoooo@outlook.com>
* |
* Created On : <2023-09-29>
* Last Modified : <2025-07-21>
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
def_target(os_linuxlite, "linuxlite"); static SourceProvider_t os_linuxlite_upstream =
void
os_linuxlite_prelude ()
{ {
chef_prep_this (os_linuxlite, gsr); def_upstream, "http://repo.linuxliteos.com/linuxlite/",
{NotSkip, NA, NA, "http://repo.linuxliteos.com/linuxlite/isos/7.2/linux-lite-7.2-64bit.iso", ACCURATE} // 2.9GB
};
chef_set_created_on (this, "2023-09-29"); /**
chef_set_last_updated (this, "2025-08-10"); * @update 2024-11-21
chef_set_sources_last_updated (this, "2024-11-21"); */
static Source_t os_linuxlite_sources[] =
chef_set_chef (this, NULL); {
chef_set_cooks (this, 1, "@ccmywish"); {&os_linuxlite_upstream, "http://repo.linuxliteos.com/linuxlite/", DelegateToUpstream},
chef_set_sauciers (this, 1, "@Yangmoooo");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this);
chef_deny_user_define(this);
chef_set_note(this, NULL, NULL);
def_sources_begin()
{&UpstreamProvider, "http://repo.linuxliteos.com/linuxlite/", DelegateToUpstream},
{&MirrorZ, "https://mirrors.cernet.edu.cn/linuxliteos/", DelegateToMirror}, {&MirrorZ, "https://mirrors.cernet.edu.cn/linuxliteos/", DelegateToMirror},
{&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/linuxliteos/", DelegateToMirror}, {&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/linuxliteos/", DelegateToMirror},
{&Nju, "https://mirror.nju.edu.cn/linuxliteos/", DelegateToMirror} {&Nju, "https://mirror.nju.edu.cn/linuxliteos/", DelegateToMirror}
def_sources_end() };
} def_sources_n(os_linuxlite);
void void
@ -46,11 +41,11 @@ os_linuxlite_setsrc (char *option)
{ {
chsrc_ensure_root (); chsrc_ensure_root ();
chsrc_use_this_source (os_linuxlite); chsrc_yield_source_and_confirm (os_linuxlite);
chsrc_backup (OS_Apt_SourceList); chsrc_backup (OS_Apt_SourceList);
char *cmd = xy_strcat (3, "sed -E -i 's@https?://.*/.*/?@", source.url, "@g' " OS_Apt_SourceList); char *cmd = xy_strjoin (3, "sed -E -i 's@https?://.*/.*/?@", source.url, "@g' " OS_Apt_SourceList);
chsrc_run ("apt update", RunOpt_No_Last_New_Line); chsrc_run ("apt update", RunOpt_No_Last_New_Line);
@ -64,3 +59,24 @@ os_linuxlite_resetsrc (char *option)
{ {
os_linuxlite_setsrc (option); os_linuxlite_setsrc (option);
} }
Feature_t
os_linuxlite_feat (char *option)
{
Feature_t f = {0};
f.can_get = true;
f.can_reset = true;
f.cap_locally = CanNot;
f.cap_locally_explain = NULL;
f.can_english = true;
f.can_user_define = true;
f.note = NULL;
return f;
}
def_target_gsrf(os_linuxlite);

View File

@ -1,31 +1,21 @@
/** ------------------------------------------------------------ /** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Happy Game <happygame1024@gmail.com>
* |
* Created On : <2023-09-29>
* Last Modified : <2025-07-21>
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
def_target(os_linuxmint, "linuxmint"); /**
* @update 2024-11-21
void * @note Ubuntu的不太一样
os_linuxmint_prelude () */
static Source_t os_linuxmint_sources[] =
{ {
chef_prep_this (os_linuxmint, gs); {&UpstreamProvider, NULL, NULL},
{&MirrorZ, "https://mirrors.cernet.edu.cn/linuxmint/", DelegateToMirror},
chef_set_created_on (this, "2023-09-29");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2024-11-21");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 1, "@happy-game");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_deny_english(this);
chef_deny_user_define(this);
/* @note 实际上镜像站里的内容和Ubuntu的不太一样 */
def_sources_begin()
{&UpstreamProvider, "http://packages.linuxmint.com", DelegateToUpstream},
{&MirrorZ, "https://mirrors.cernet.edu.cn/linuxmint/", DelegateToMirror},
{&Ali, "http://mirrors.aliyun.com/linuxmint-packages/", DelegateToMirror}, {&Ali, "http://mirrors.aliyun.com/linuxmint-packages/", DelegateToMirror},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/linuxmint/", DelegateToMirror}, {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/linuxmint/", DelegateToMirror},
{&Bfsu, "https://mirrors.bfsu.edu.cn/linuxmint/", DelegateToMirror}, {&Bfsu, "https://mirrors.bfsu.edu.cn/linuxmint/", DelegateToMirror},
@ -36,11 +26,11 @@ os_linuxmint_prelude ()
{&Zju, "https://mirrors.zju.edu.cn/linuxmint/", DelegateToMirror}, {&Zju, "https://mirrors.zju.edu.cn/linuxmint/", DelegateToMirror},
{&Sustech, "https://mirrors.sustech.edu.cn/linuxmint/", DelegateToMirror}, {&Sustech, "https://mirrors.sustech.edu.cn/linuxmint/", DelegateToMirror},
{&Iscas, "https://mirror.iscas.ac.cn/linuxmint/", DelegateToMirror}, {&Iscas, "https://mirror.iscas.ac.cn/linuxmint/", DelegateToMirror},
{&Scau, "https://mirrors.scau.edu.cn/linuxmint/", DelegateToMirror} {&Scau, "https://mirrors.scau.edu.cn/linuxmint/", DelegateToMirror},
/* 不启用原因:过慢 */ /* 不启用原因:过慢 */
// {&Netease, "https://mirrors.163.com/linuxmint/packages/", DelegateToMirror} // {&Netease, "https://mirrors.163.com/linuxmint/packages/", DelegateToMirror}
def_sources_end() };
} def_sources_n(os_linuxmint);
void void
@ -49,7 +39,6 @@ os_linuxmint_getsrc (char *option)
chsrc_view_file (OS_LinuxMint_SourceList); chsrc_view_file (OS_LinuxMint_SourceList);
} }
/** /**
* @consult https://help.mirrors.cernet.edu.cn/linuxmint/ * @consult https://help.mirrors.cernet.edu.cn/linuxmint/
*/ */
@ -58,7 +47,7 @@ os_linuxmint_setsrc (char *option)
{ {
chsrc_ensure_root (); chsrc_ensure_root ();
chsrc_use_this_source (os_linuxmint); chsrc_yield_source_and_confirm (os_linuxmint);
chsrc_backup (OS_LinuxMint_SourceList); chsrc_backup (OS_LinuxMint_SourceList);
@ -66,7 +55,7 @@ os_linuxmint_setsrc (char *option)
// 暂不实现自动替换基于debian或ubuntu的基础源 // 暂不实现自动替换基于debian或ubuntu的基础源
char *version_codename = xy_run ("sed -nr 's/^VERSION_CODENAME=([^\"]+)/\1/p' " ETC_OS_RELEASE, 0); char *version_codename = xy_run ("sed -nr 's/^VERSION_CODENAME=([^\"]+)/\1/p' " ETC_OS_RELEASE, 0);
// sed -i '/<version_codename>/ s|http[^ ]*|<source.url>|g' OS_LinuxMint_SourceList // sed -i '/<version_codename>/ s|http[^ ]*|<source.url>|g' OS_LinuxMint_SourceList
char* cmd = xy_strcat (5, "sed -i '/", char* cmd = xy_strjoin (5, "sed -i '/",
version_codename, "/ s|http[^ ]*|", version_codename, "/ s|http[^ ]*|",
source.url, "|g' " OS_LinuxMint_SourceList); source.url, "|g' " OS_LinuxMint_SourceList);
@ -78,3 +67,25 @@ os_linuxmint_setsrc (char *option)
chsrc_warn2 ("完成后请不要再使用 mintsources自带的图形化软件源设置工具进行任何操作因为在操作后无论是否有按“确定”mintsources 均会覆写我们刚才换源的内容"); chsrc_warn2 ("完成后请不要再使用 mintsources自带的图形化软件源设置工具进行任何操作因为在操作后无论是否有按“确定”mintsources 均会覆写我们刚才换源的内容");
chsrc_warn2 ("已自动更换mint主要源, 但mint也使用基于debian或ubuntu的基础源, 可参考对应的debian或ubuntu换源方法进行手动换源"); chsrc_warn2 ("已自动更换mint主要源, 但mint也使用基于debian或ubuntu的基础源, 可参考对应的debian或ubuntu换源方法进行手动换源");
} }
Feature_t
os_linuxmint_feat (char *option)
{
Feature_t f = {0};
f.can_get = true;
f.can_reset = false;
f.cap_locally = CanNot;
f.cap_locally_explain = NULL;
f.can_english = true;
f.can_user_define = true;
f.note = NULL;
return f;
}
def_target_gsf(os_linuxmint);

Some files were not shown because too many files have changed in this diff Show More