Merge branch 'dev' into dev

This commit is contained in:
冰彦糖 2025-08-23 13:58:54 +08:00 committed by GitHub
commit 93088fe4b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
98 changed files with 2307 additions and 1536 deletions

View File

@ -5,7 +5,7 @@
# | Mikachu2333 <mikachu2333@zohomail.com>
# |
# Created On : <2025-06-19>
# Last Modified : <2025-08-07>
# Last Modified : <2025-08-17>
#
# Test PR
# ---------------------------------------------------------------
@ -14,11 +14,15 @@ name: 测试PR
on:
pull_request:
types: [opened,
synchronize, # 后续提交
ready_for_review, # draft PR 转为正式 PR
review_requested,
reopened]
# 仅在开 pr、草稿转正式、手动要求 review、reopen的时候运行测试
types: [
opened,
# 因 synchronize 将导致 pr 的构建过于频繁而禁用
# synchronize, # 在 pr 者 push commit 时每次构建
ready_for_review, # draft PR 转为正式 PR
review_requested,
reopened,
]
paths:
- "src/**"
- "lib/**"
@ -31,7 +35,7 @@ jobs:
steps:
- name: 检出代码
uses: actions/checkout@v4
uses: actions/checkout@v5
- name: 测试构建情况
run: |
@ -48,7 +52,13 @@ jobs:
steps:
- name: 检出代码
uses: actions/checkout@v4
uses: actions/checkout@v5
- 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: 安装依赖
run: |

View File

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

View File

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

View File

@ -20,7 +20,7 @@ jobs:
steps:
- name: 检出代码
uses: actions/checkout@v4
uses: actions/checkout@v5
- name: 检查编译器版本
run: |
@ -53,7 +53,7 @@ jobs:
steps:
- name: 检出代码
uses: actions/checkout@v4
uses: actions/checkout@v5
- name: 检查编译器版本
run: |

View File

@ -30,7 +30,7 @@ jobs:
steps:
- name: 检出代码
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
ref: gh-build
@ -156,7 +156,7 @@ jobs:
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
uses: actions/download-artifact@v5
with:
pattern: chsrc-deb-files
merge-multiple: true

11
.vscode/launch.json vendored
View File

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

View File

@ -1,6 +1,7 @@
{
"editor.fontLigatures": false,
"C_Cpp.autoAddFileAssociations": false,
"C_Cpp.intelliSenseEngine": "Tag Parser",
"C_Cpp.default.browse.limitSymbolsToIncludedHeaders": false,

78
.vscode/tasks.json vendored
View File

@ -17,7 +17,8 @@
"kind": "build",
"isDefault": true
},
"detail": "使用 just build 编译"
"dependsOn": "停止程序",
"detail": "先停止原有程序,然后使用 just build 编译"
},
{
"type": "shell",
@ -36,7 +37,6 @@
"kind": "build",
"isDefault": false
},
"detail": "使用 just build-in-debug-mode 编译 debug 版"
},
{
"type": "shell",
@ -94,7 +94,79 @@
"isDefault": false
},
"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"
}
}

View File

@ -3,11 +3,11 @@
! -------------------------------------------------------------
! Doc Type : Markdown
! Doc Name : README.md
! Doc Authors : Aoran Zeng <ccmywish@qq.com>
! Doc Authors : 曾奥然 <ccmywish@qq.com>
! Contributors : Mikachu2333 <mikachu.23333@zohomail.com>
! |
! Created On : <2023-12-28>
! Last Modified : <2025-08-11>
! Last Modified : <2025-08-22>
! ---------------------------------------------------------- -->
<div align="center">
@ -16,7 +16,7 @@
全平台通用换源工具与框架 `chsrc`**目标支持 Linux, Windows (native, MSYS2, Cygwin), macOS, BSD, Android 等尽可能多的操作系统环境龙芯、飞腾、RISC-V 等尽可能多的 CPU**。
我们使用 **C11** 来完成上述目标。我们并不使用 Python 或 JS 等解释语言,因为一个简单的换源工具,不应该强行塞给用户一个庞大的解释器和数十、数百 MB 其他文件。
我们使用 **C11** 来完成上述目标。我们并不使用 Python 或 JavaScript 等解释语言,因为一个简单的换源工具,不应该强行塞给用户一个庞大的解释器和数十、数百 MB 其他文件。
本软件为**自由软件**SDPX 软件许可证为 `GPL-3.0-or-later and MIT`
@ -39,6 +39,20 @@
## ❤️ 致所有的朋友们
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]
@ -47,14 +61,13 @@
---
> [!NOTE]
> 这是你可以参与的第一个现实世界中有用的C语言项目[用 VS Code 一分钟内上手编译、运行、测试 chsrc](./doc/01-开发与构建.md)
> 这也许是你可以参与的第一个现实世界中有用的C语言项目[用 VS Code 一分钟内上手编译、运行、测试 chsrc](./doc/01-开发与构建.md)
>
> 欢迎对 GitHub、Gitee 协作不熟悉的人以此为契机学习参与贡献, 欢迎任何编程初学者。[从开发到提交PR我们覆盖全流程文档](./doc/)
,作者可提供一定的 [贡献指导](https://github.com/RubyMetric/chsrc/discussions/50)
---
> [!IMPORTANT]
> **`chsrc` 可换源 65+ 目标。每个人仅仅贡献和维护自己熟悉的部分,回报是得到其他所有领域专家的帮助。** [欢迎成为 recipe 维护者](https://github.com/RubyMetric/chsrc/issues/130)
> **`chsrc` 可换源 65+ 目标。每个人仅仅贡献和维护自己熟悉的部分,回报是得到其他所有领域专家的帮助。** [欢迎成为 recipe 维护者](https://github.com/RubyMetric/chsrc/issues/275)
<br>

View File

@ -3,11 +3,11 @@
! -------------------------------------------------------------
! Doc Type : Markdown
! Doc Name : 01-开发与构建.md
! Doc Authors : Aoran Zeng <ccmywish@qq.com>
! Contributors : Nul None <nul@none.org>
! Doc Authors : 曾奥然 <ccmywish@qq.com>
! Contributors : Nul None <nul@none.org>
! |
! Created On : <2024-12-27>
! Last Modified : <2025-07-21>
! Last Modified : <2025-08-22>
! ---------------------------------------------------------- -->
# 开发 chsrc
@ -53,7 +53,7 @@ git clone https://gitee.com/RubyMetric/chsrc.git -b dev
3. **`RELEASE mode`**
4. **`CI-RELEASE mode`**
第四种只在 GitHub Actions 使用,一般只需要前三者;而在开发时你仅需要前两者;如果不需要 Debug仅仅第一个 **DEV mode** 就够了
开发时只需要前两种模式;第四种模式只在 GitHub Actions 使用。
**如果你使用 `just`,可以在 VS Code 中获得更好的体验,按 `Ctrl-Shift-B` 直接使用 DEV mode 构建**

View File

@ -3,11 +3,11 @@
! -------------------------------------------------------------
! Doc Type : Markdown
! Doc Name : 02-提交与贡献.md
! Doc Authors : Aoran Zeng <ccmywish@qq.com>
! Contributors : Nul None <nul@none.org>
! Doc Authors : 曾奥然 <ccmywish@qq.com>
! Contributors : Nul None <nul@none.org>
! |
! Created On : <2024-12-13>
! Last Modified : <2025-07-21>
! Last Modified : <2025-08-22>
! ---------------------------------------------------------- -->
# 贡献说明
@ -22,6 +22,8 @@
## 提交与审阅
当你提交 PR 的时候,一定要将 PR 指定 chsrc 原仓库的 dev 分支。
### 一个简单的 Bug
一个简单的 Bug fix有写权限的维护者可以直接推送到主仓库的 `dev` 分支
@ -34,15 +36,14 @@
1
1. **如果你是 recipe Chef则你完全负责这个 recipe如果你拥有写权限你可以直接推送代码到 `dev` 分支**
2. 如果你是 recipe Cook则你需要参考 recipe 中记录的 Cook 信息,如果只有你一个人,且你拥有写权限,你可以直接推送代码。如果有多人,则需要提一个 issue介绍方案然后 @ 所有 Cook 来 review
**如果你是 recipe Chef则你完全负责这个 recipe如果你拥有写权限你可以直接推送代码到 `dev` 分支**
---
2
1. 需要先搜索你修改的部分涉及到的 recipe然后提 issue @ 所有相关的 recipe Cook 来 review
2. 如果涉及了所有 recipe则 @ framework Cook而无需把所有 recipe 的 Cook 都喊过来,但是如果觉得有必要,可以 @ 任意你觉得有能力 review 和能给出建议的人来 review
1. 需要先搜索你修改的部分涉及到的 recipe然后提 issue @ 所有相关的 recipe Chef 来 review
2. 如果涉及了所有 recipe则 @ framework Chef而无需把所有 recipe 的 Chef 都喊过来,但是如果觉得有必要,可以 @ 任意你觉得有能力 review 和能给出建议的人来 review
<br>

View File

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

View File

@ -3,11 +3,11 @@
! -------------------------------------------------------------
! Doc Type : Markdown
! Doc Name : 10-如何编写recipe.md
! Doc Authors : Aoran Zeng <ccmywish@qq.com>
! Contributors : Nul None <nul@none.org>
! Doc Authors : 曾奥然 <ccmywish@qq.com>
! Contributors : Nul None <nul@none.org>
! |
! Created On : <2024-08-19>
! Last Modified : <2025-08-11>
! Last Modified : <2025-08-22>
! ---------------------------------------------------------- -->
# Write A Recipe Even If You Don't Know C
@ -18,7 +18,7 @@
<br>
我鼓励你为新的软件添加换源支持,因为通过 `chsrc` 框架,这将比写 shell 脚本更加轻松,你的贡献也将非常有价值。理论上每一个 `recipe` 都需要有专人长时间维护 ([招募](https://github.com/RubyMetric/chsrc/issues/130))。
我鼓励你为新的软件添加换源支持,因为通过 `chsrc` 框架,这将比写 shell 脚本更加轻松,你的贡献也将非常有价值。理论上每一个 `recipe` 都需要有专人长时间维护 ([招募](https://github.com/RubyMetric/chsrc/issues/275))。
- 本项目采用 `GPLv3+` 协议,是真正的**自由软件**,而非仅仅是开源软件
- 代码规范灵活遵循 `GNU` 标准(若标准干扰了可维护性,则并不采纳)
@ -52,6 +52,8 @@
- `source`: 该 `target` 所能换的具体的源,由 `mirror` 提供服务,往往一个 `mirror` 会提供许多 `source`
- `recipe`: 是为一个 `target` 定义的具体换源方法,请参考 `src` 目录中的 `recipe` 目录
- `chef DSL`:是 `chef Domain Specific Language` 的简写,这是一组以 `chef_` 开头的函数,用来定义维护者信息、可用源等元信息
- **换源链接**: 指镜像站所提供的某一个具体的换源使用的URL
- **测速链接**: 用来测速的URL与 "换源链接" 不同,可分为 **精准测速** 和 **模糊测速**
@ -81,7 +83,7 @@
该函数将填充 target 所有的必要信息,包括维护信息、换源信息
7. [设置/修改 "换源 URL" 和 "测速 URL" (how?)](./11-如何设置换源链接与测速链接.md)
7. [设置/修改 "换源链接" 和 "测速链接" (how?)](./11-如何设置换源链接与测速链接.md)
8. 按需实现 `_setsrc()` `_getsrc()` `_resetsrc()` 可以使用这些函数:

View File

@ -3,8 +3,8 @@
! -------------------------------------------------------------
! Doc Type : Markdown
! Doc Name : 11-如何设置换源链接与测速链接.md
! Doc Authors : Aoran Zeng <ccmywish@qq.com>
! Contributors : Nul None <nul@none.org>
! Doc Authors : 曾奥然 <ccmywish@qq.com>
! Contributors : Nul None <nul@none.org>
! |
! Created On : <2025-08-11>
! Last Modified : <2025-08-11>

View File

@ -1,21 +1,34 @@
<!-- -----------------------------------------------------------
! 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 的文件标头中记录即可。
**我们的代码里使用了 recipe (某个菜的烹饪方法) 这个词,因而整个项目便和 "饮食" 有关,比如 `menu`: 汇集了所有的 target 的菜单。因此,我们的维护者身份依然使用了这个惯例:**
一个 recipe 的协作者可分为:
想要达到最理想的维护状态,每一个 recipe 都需要有专人长时间维护。**我们的代码里使用了 recipe (某个菜的烹饪方法) 这个词,因而整个项目便和 "饮食" 有关,比如 `menu`: 汇集了所有的 target 的菜单。因此,我们的维护者和贡献者身份依然使用了这个惯例:**
1. **Chef**
主厨: 对一个 recipe 完全负责,有写权限时可以直接推代码
品控 (主厨): 对一个 recipe 完全负责,有写权限时可以直接推代码
**目前项目的发展阶段还处于 *外行实现内行* 的情况,比如 Homebrew recipe实现者根本不是 Homebrew 的真实用户,只是根据各种文档来实现,然后等待用户反馈。所以这里当前的实现者最多只能是 Cook无法承担 Chef 的责任**
2. **Cook**
副厨:实现和持续维护 recipe需要和 Chef 一起 review 代码。可参考 [03-CONTRIBUTING.md](./03-CONTRIBUTING.md) 了解项目是如何进行提交和审阅代码的
掌勺:一个 recipe 的主要作者
3. **Saucier**
调味:一个 recipe 的次要贡献者 (除主要作者外的其他人)
<br>
**项目采用申请制Chef 仅有1人Cook 可有多人。请提交 PULL REQUEST 在对应的 recipe 文件中添加自己,并在 [issue #130](https://github.com/RubyMetric/chsrc/issues/130) 留言。**
**Chef 采用申请制,每个 recipe 仅有1人请提交 PULL REQUEST 在对应的 recipe 文件中添加自己,并在 [issue #275
](https://github.com/RubyMetric/chsrc/issues/275) 留言。**

View File

@ -3,11 +3,11 @@
! -------------------------------------------------------------
! Doc Type : Markdown
! Doc Name : (Document Introduction.md)
! Doc Authors : Aoran Zeng <ccmywish@qq.com>
! Contributors : Nul None <nul@none.org>
! Doc Authors : 曾奥然 <ccmywish@qq.com>
! Contributors : Nul None <nul@none.org>
! |
! Created On : <2024-12-27>
! Last Modified : <2025-08-11>
! Last Modified : <2025-08-22>
! ---------------------------------------------------------- -->
# 文档说明
@ -23,7 +23,7 @@ E2E (End-to-End) 开发文档:
具体 recipe 相关:
- 如何编写一个具体的 recipe请参考 [10-如何编写recipe.md](./10-如何编写recipe.md)
- 如何修改换源URL、模糊/精准测速URL,请参考 [11-如何设置换源链接与测速链接.md](./11-如何设置换源链接与测速链接.md)
- 如何修改换源链接、模糊/精准测速链接,请参考 [11-如何设置换源链接与测速链接.md](./11-如何设置换源链接与测速链接.md)
<br>

843
lib/xy.h

File diff suppressed because it is too large Load Diff

View File

@ -1,145 +1,89 @@
/** ------------------------------------------------------------
* Copyright © 2023-2025 Aoran Zeng, Heng Guo
* Copyright © 2023-2025 ,
* SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* Project Name : chsrc
* Project Authors : Aoran Zeng <ccmywish@qq.com>
* | Heng Guo <2085471348@qq.com>
* Contributors : Aaron Ruan <aaron212cn@outlook.com>
* | Rui Chen <rui@chenrui.dev>
* | Shengwei Chen <414685209@qq.com>
* | BlockLune <blocklune@gmail.com>
* | Mr. Will <mr.will.com@outlook.com>
* | Terrasse <terrasse@qq.com>
* | Lontten <lontten@163.com>
* | happy game <happygame1024@gmail.com>
* | Word2VecT <tangzinan@bupt.edu.cn>
* | xuan <wick.dynex@qq.com>
* | GnixAij <gaojiaxing0220@gmail.com>
* | ChatGPT <https://chatgpt.com>
* | czyt <czyt.go@gmail.com>
* | zouri <guoshuaisun@outlook.com>
* | yongxiang <1926885268@qq.com>
* | YU-7 <2747046473@qq.com>
* | juzeon <skyjuzheng@gmail.com>
* | Jialin Lyu <jialinlvcn@aliyun.com>
* | GitHub Copilot <https://github.com/copilot>
* | ccy <icuichengyi@gmail.com>
* | MadDogOwner <xiaoran@xrgzs.top>
* | sanchuanhehe <wyihe5520@gmail.com>
* | Mikachu2333 <mikachu.23333@zohomail.com>
* | Rui Yang <techoc@foxmail.com>
* | BingChunMoLi <bingchunmoli@bingchunmoli.com>
* |
* Created On : <2023-08-28>
* Last Modified : See <Chsrc_Release_Date>
*
* chsrc: Change Source
* chsrc: Change Source
*
*
*
* Change Source everywhere for every software
*
* : ,
* -------------------------------------------------------------
*
*
* Git commit message
* C语言在编译时会无情地把这些信息抹去
*
*
*
* 穿PC中
* ...
* chsrc recipe 便
* 使
*
*
* Richard Stallman GNU MIT
*
*
*
* ------------------------------------------------------------*/
#define Chsrc_Version "0.2.2.3"
#define Chsrc_Release_Date "2025/08/11"
#define Chsrc_Version "0.2.2.3-dev6"
#define Chsrc_Release_Date "2025/08/22"
#define Chsrc_Maintain_URL "https://github.com/RubyMetric/chsrc"
#define Chsrc_Maintain_URL2 "https://gitee.com/RubyMetric/chsrc"
#include "framework/core.c"
#include "framework/chef.c"
void
chsrc_register_contributors ()
{
/* 项目创建者 */
chef_register_contributor ("@ccmywish", "曾奥然", "ccmywish@qq.com", NULL);
// 该 ID 为 Gitee ID
chef_register_contributor ("@G_I_Y", "郭恒", "2085471348@qq.com", NULL);
#include "recipe/lang/rawstr4c.h"
#include "recipe/lang/Ruby/Ruby.c"
#include "recipe/lang/Python/common.h"
#include "recipe/lang/Python/pip.c"
#include "recipe/lang/Python/Poetry.c"
#include "recipe/lang/Python/PDM.c"
#include "recipe/lang/Python/Rye.c"
#include "recipe/lang/Python/uv.c"
#include "recipe/lang/Python/Python.c"
#include "recipe/lang/JavaScript/common.h"
#include "recipe/lang/JavaScript/npm.c"
#include "recipe/lang/JavaScript/pnpm.c"
#include "recipe/lang/JavaScript/Yarn.c"
#include "recipe/lang/JavaScript/JavaScript.c"
#include "recipe/lang/JavaScript/Bun.c"
#include "recipe/lang/JavaScript/nvm.c"
#include "recipe/lang/Perl.c"
#include "recipe/lang/PHP.c"
#include "recipe/lang/Lua.c"
#include "recipe/lang/Go.c"
#include "recipe/lang/Java.c"
#include "recipe/lang/Rust/common.h"
#include "recipe/lang/Rust/rustup.c"
#include "recipe/lang/Rust/Cargo.c"
#include "recipe/lang/Dart/common.h"
#include "recipe/lang/Dart/Pub.c"
#include "recipe/lang/Dart/Flutter.c"
#include "recipe/lang/Haskell.c"
#include "recipe/lang/OCaml.c"
#include "recipe/lang/R.c"
#include "recipe/lang/Julia.c"
#include "recipe/lang/NuGet.c"
#include "recipe/lang/Clojure.c"
#include "recipe/os/rawstr4c.h"
#include "recipe/os/APT/common.h"
// Debian-based
#include "recipe/os/APT/Debian.c"
#include "recipe/os/APT/Ubuntu.c"
#include "recipe/os/APT/Kali-Linux.c"
#include "recipe/os/APT/Raspberry-Pi-OS.c"
// Ubuntu-based
#include "recipe/os/APT/Linux-Mint.c"
#include "recipe/os/APT/Trisquel.c"
#include "recipe/os/APT/Linux-Lite.c"
// Debian-based and Ubuntu-based
#include "recipe/os/APT/Armbian.c"
// Independent
#include "recipe/os/APT/ROS.c"
#include "recipe/os/APT/Termux.c"
#include "recipe/os/APT/openKylin.c"
#include "recipe/os/APT/deepin.c"
#include "recipe/os/YUM/common.h"
#include "recipe/os/YUM/Fedora-Linux.c"
#include "recipe/os/YUM/AlmaLinux.c"
#include "recipe/os/YUM/Rocky-Linux.c"
#include "recipe/os/YUM/openEuler.c"
#include "recipe/os/YUM/Anolis-OS.c"
#include "recipe/os/pacman/Arch-Linux.c"
#include "recipe/os/pacman/Manjaro-Linux.c"
#include "recipe/os/pacman/MSYS2.c"
#include "recipe/os/openSUSE.c"
#include "recipe/os/Alpine-Linux.c"
#include "recipe/os/Gentoo-Linux.c"
#include "recipe/os/Void-Linux.c"
#include "recipe/os/Solus.c"
#include "recipe/os/OpenWrt.c"
#include "recipe/os/BSD/FreeBSD.c"
#include "recipe/os/BSD/NetBSD.c"
#include "recipe/os/BSD/OpenBSD.c"
#include "recipe/ware/TeX-Live.c"
#include "recipe/ware/Emacs.c"
#include "recipe/ware/WinGet.c"
#include "recipe/ware/Homebrew/Homebrew.c"
#include "recipe/ware/CocoaPods.c"
#include "recipe/ware/Nix.c"
#include "recipe/ware/Guix.c"
#include "recipe/ware/Flatpak.c"
#include "recipe/ware/Docker/Docker.c"
#include "recipe/ware/Anaconda/Anaconda.c"
/* 所有贡献者 (按参与贡献时间排序) */
chef_register_contributor ("@Aaron-212", "Aaron Ruan", "aaron212cn@outlook.com", NULL);
chef_register_contributor ("@chenrui333", "Rui Chen", "rui@chenrui.dev", NULL);
chef_register_contributor ("@livelycode36", "Shengwei Chen", "414685209@qq.com", NULL);
chef_register_contributor ("@Gn3po4g", "Peng Gao", "gn3po4g@outlook.com", NULL);
chef_register_contributor ("@BlockLune", "BlockLune", "blocklune@gmail.com", NULL);
chef_register_contributor ("@MrWillCom", "Mr. Will", "mr.will.com@outlook.com", NULL);
chef_register_contributor ("@Jerry-Terrasse", "Terrasse", "terrasse@qq.com", NULL);
chef_register_contributor ("@lontten", "Lontten", "lontten@163.com", NULL);
chef_register_contributor ("@happy-game", "Happy Game", "happygame1024@gmail.com", NULL);
chef_register_contributor ("@Word2VecT", "Word2VecT", "tangzinan@bupt.edu.cn", NULL);
chef_register_contributor ("@wickdynex", "Xuan", "wick.dynex@qq.com", NULL);
chef_register_contributor ("@Efterklang", "GnixAij", "gaojiaxing0220@gmail.com", NULL);
chef_register_contributor ("@czyt", "czyt", "czyt.go@gmail.com", NULL);
chef_register_contributor ("@XUANJI233", "XUANJI233", "xuanji233@outlook.com", NULL);
chef_register_contributor ("@Yangmoooo", "Yangmoooo", "yangmoooo@outlook.com", NULL);
chef_register_contributor ("@zouri", "Zouri", "guoshuaisun@outlook.com", NULL);
chef_register_contributor ("@xyx1926885268", "Yongxiang", "1926885268@qq.com", NULL);
chef_register_contributor ("@YU-7", "YU-7", "2747046473@qq.com", NULL);
chef_register_contributor ("@juzeon", "juzeon", "skyjuzheng@gmail.com", NULL);
chef_register_contributor ("@jialinlvcn", "Jialin Lyu", "jialinlvcn@aliyun.com", NULL);
chef_register_contributor ("@Kattos", "ccy", "icuichengyi@gmail.com", NULL);
chef_register_contributor ("@xrgzs", "MadDogOwner", "xiaoran@xrgzs.top", NULL);
chef_register_contributor ("@sanchuanhehe", "sanchuanhehe", "wyihe5520@gmail.com", NULL);
chef_register_contributor ("@Mikachu2333", "Mikachu2333", "mikachu.23333@zohomail.com", NULL);
chef_register_contributor ("@techoc", "Rui Yang", "techoc@foxmail.com", NULL);
chef_register_contributor ("@BingChunMoLi", "BingChunMoLi", "bingchunmoli@bingchunmoli.com", NULL);
// 该 ID 为 Gitee ID
chef_register_contributor ("@hezonglun", "HeZongLun", "hezonglun123456@outlook.com", NULL);
/**
* AI贡献者
*
* ChatGPTGitHub CopilotDeepSeek
*
* 使AI并没有被记录下来
*/
}
#include "recipe/menu.c"
@ -152,7 +96,7 @@ cli_print_available_mirrors ()
{
{
char *msg = ENGLISH ? "To specify a source, use chsrc set " : "指定使用某源,请使用 chsrc set ";
say (bdblue(xy_strjoin (3, msg, "<target>", " <code>\n")));
say (bdblue(xy_strcat (3, msg, "<target>", " <code>\n")));
}
{
@ -169,7 +113,7 @@ cli_print_available_mirrors ()
say ("--------- -------------- ------------------------------------- ---------------------");
}
for (int i = 0; i < xy_arylen (chsrc_available_mirrors); i++)
for (int i = 0; i < xy_c_array_len (chsrc_available_mirrors); i++)
{
MirrorSite_t *mir = chsrc_available_mirrors[i];
printf ("%-14s%-18s%-41s ", mir->code, mir->abbr, mir->site); say (mir->name);
@ -178,12 +122,13 @@ cli_print_available_mirrors ()
/**
* /
* @brief /
*
* @param aliases alias
* @param callback alias
* @param user_data
* @return true则停止遍历并返回truefalse
* @param aliases alias
* @param callback alias
* @param user_data
*
* @return true则停止遍历并返回truefalse
*/
bool
iterate_aliases (const char *aliases, bool (*callback)(const char *alias, void *user_data), void *user_data)
@ -219,27 +164,28 @@ iterate_aliases (const char *aliases, bool (*callback)(const char *alias, void *
/**
* cli_print_supported_targets_
* cli_print_targets_for_menu
*/
bool
print_alias_callback (const char *alias, void *user_data)
callback_print_alias (const char *alias, void *user_data)
{
printf ("%s ", alias);
return false; // 继续遍历,不停止
}
void
cli_print_supported_targets_ (TargetRegisterInfo_t menu[], size_t size)
callback_print_targets (void *data, void *NOUSE)
{
for (int i = 0; i < size; i++)
{
TargetRegisterInfo_t *entry = &menu[i];
Target_t *target = (Target_t *) data;
// 使用通用的别名遍历函数打印所有别名
iterate_aliases (target->aliases, callback_print_alias, NULL);
br(); // 每个target换行
}
// 使用通用的别名遍历函数打印所有别名
iterate_aliases (entry->target->aliases, print_alias_callback, NULL);
br(); // 每个target换行
}
void
cli_print_targets_for_menu (XySeq_t *menu)
{
xy_seq_each (menu, callback_print_targets, NULL);
br(); // 最后额外换行
}
@ -256,50 +202,51 @@ cli_print_supported_targets ()
char *msg = ENGLISH ? "Programming Languages" : "编程语言";
say (bdgreen(msg));
say ("-------------------------");
cli_print_supported_targets_ (chsrc_pl_menu, xy_arylen(chsrc_pl_menu));
cli_print_targets_for_menu (ProgStore.pl);
}
{
char *msg = ENGLISH ? "Operating Systems" : "操作系统";
say (bdgreen(msg));
say ("-------------------------");
cli_print_supported_targets_ (chsrc_os_menu, xy_arylen(chsrc_os_menu));
cli_print_targets_for_menu (ProgStore.os);
}
{
char *msg = ENGLISH ? "Softwares" : "软件";
say (bdgreen(msg));
say ("-------------------------");
cli_print_supported_targets_ (chsrc_wr_menu, xy_arylen(chsrc_wr_menu));
cli_print_targets_for_menu (ProgStore.wr);
}
}
void
cli_print_supported_pl ()
cli_print_menu (char *menu)
{
char *msg = ENGLISH ? "Support following Programming Languages (same line indicates these targets are compatible)\n"
: "支持对以下编程语言生态换源 (同一行表示这几个目标兼容)\n";
say (bdgreen(msg));
cli_print_supported_targets_ (chsrc_pl_menu, xy_arylen(chsrc_pl_menu));
}
void
cli_print_supported_os ()
{
char *msg = ENGLISH ? "Support following Operating Systems (same line indicates these targets are compatible)\n"
: "支持对以下操作系统换源 (同一行表示这几个目标兼容)\n";
say (bdgreen(msg));
cli_print_supported_targets_ (chsrc_os_menu, xy_arylen(chsrc_os_menu));
}
void
cli_print_supported_wr ()
{
char *msg = ENGLISH ? "Support following Softwares (same line indicates these targets are compatible)\n"
: "支持对以下软件换源 (同一行表示这几个目标兼容)\n";
say (bdgreen(msg));
cli_print_supported_targets_ (chsrc_wr_menu, xy_arylen(chsrc_wr_menu));
if (xy_streql (menu, "pl"))
{
char *msg =
ENGLISH ? "Support following Programming Languages (same line indicates these targets are compatible)\n"
: "支持对以下编程语言生态换源 (同一行表示这几个目标兼容)\n";
say (bdgreen(msg));
cli_print_targets_for_menu (ProgStore.pl);
}
else if (xy_streql (menu, "os"))
{
char *msg =
ENGLISH ? "Support following Operating Systems (same line indicates these targets are compatible)\n"
: "支持对以下操作系统换源 (同一行表示这几个目标兼容)\n";
say (bdgreen(msg));
cli_print_targets_for_menu (ProgStore.os);
}
else if (xy_streql (menu, "wr"))
{
char *msg =
ENGLISH ? "Support following Softwares (same line indicates these targets are compatible)\n"
: "支持对以下软件换源 (同一行表示这几个目标兼容)\n";
say (bdgreen(msg));
cli_print_targets_for_menu (ProgStore.wr);
}
}
@ -334,28 +281,28 @@ cli_print_target_features (Target_t *target, const char *input_target_name)
{
char *msg = ENGLISH ? " Get: View the current source state " : " Get: 查看当前源状态 ";
char *get_msg = xy_strjoin (3, msg, "| chsrc get ", input_target_name);
char *get_msg = xy_strcat (3, msg, "| chsrc get ", input_target_name);
if (target->getfn != NULL) printf (" %s%s\n", bdgreen(YesMark), purple(get_msg));
else printf (" %s%s\n", bdred(NoMark), get_msg);br();
}
{
char *msg = ENGLISH ? " Reset: Reset to the default source " : " Reset: 重置回默认源 ";
char *reset_msg = xy_strjoin (3, msg, "| chsrc reset ", input_target_name);
char *reset_msg = xy_strcat (3, msg, "| chsrc reset ", input_target_name);
if (target->resetfn != NULL) printf (" %s%s\n", bdgreen(YesMark), purple(reset_msg));
else printf (" %s%s\n", bdred(NoMark), reset_msg);br();
}
{
char *msg = ENGLISH ? " UserDefine: using user-defined source URL " : " UserDefine: 用户自定义换源URL ";
char *user_define_msg = xy_strjoin (5, msg, "| chsrc set ", input_target_name, " https://user-define-url.org/", input_target_name);
char *msg = ENGLISH ? " UserDefine: using user-defined source link " : " UserDefine: 用户自定义换源链接 ";
char *user_define_msg = xy_strcat (5, msg, "| chsrc set ", input_target_name, " https://user-define-url.org/", input_target_name);
if (target->can_user_define) printf (" %s%s\n", bdgreen(YesMark), purple(user_define_msg));
else printf (" %s%s\n", bdred(NoMark), user_define_msg);br();
}
{
char *msg = ENGLISH ? " Locally: Change source only for this project " : " Locally: 仅对本项目换源 ";
char *locally_msg = xy_strjoin (3, msg, "| chsrc set -local ", input_target_name);
char *locally_msg = xy_strcat (3, msg, "| chsrc set -local ", input_target_name);
switch (target->cap_local)
{
@ -376,7 +323,7 @@ cli_print_target_features (Target_t *target, const char *input_target_name)
{
char *msg = ENGLISH ? " English: Output in English " : " English: 英文输出 ";
char *english_msg = xy_strjoin (3, msg, "| chsrc set -en ", input_target_name);
char *english_msg = xy_strcat (3, msg, "| chsrc set -en ", input_target_name);
if (target->can_english) printf (" %s%s\n", bdgreen(YesMark), purple(english_msg));
else printf (" %s%s\n", bdred(NoMark), english_msg);br();
}
@ -384,7 +331,7 @@ cli_print_target_features (Target_t *target, const char *input_target_name)
if (target->note)
{
char *msg = ENGLISH ? "NOTE: " : "备注: ";
printf ("%s%s\n", bdyellow (msg), bdyellow (target->note));
printf ("%s%s\n\n", bdyellow (msg), bdyellow (target->note));
}
}
@ -392,29 +339,14 @@ cli_print_target_features (Target_t *target, const char *input_target_name)
void
cli_print_target_maintain_info (Target_t *target, const char *input_target_name)
{
if (target->authors && target->authors_n > 0)
{
char *msg = ENGLISH ? "Recipe Original Authors: " : "食谱原始作者: ";
printf ("%s", bdblue(msg));
for (size_t i = 0; i < target->authors_n; i++)
{
if (i > 0) printf (", ");
printf ("%s <%s>",
target->authors[i].name ? target->authors[i].name : "Unknown",
target->authors[i].email ? target->authors[i].email : "unknown@example.com");
}
printf ("\n");
}
if (target->created_on)
{
char *msg = ENGLISH ? "Recipe Created On: " : "食谱创建时间: ";
printf ("%s%s\n", bdblue(msg), target->created_on);
}
{
char *msg = ENGLISH ? "Current Chef: " : "当前主厨: ";
char *msg = ENGLISH ? "Current Chef: " : "品控: ";
if (target->chef)
{
printf ("%s%s <%s>\n", bdblue(msg),
@ -423,14 +355,14 @@ cli_print_target_maintain_info (Target_t *target, const char *input_target_name)
}
else
{
char *msg1 = CHINESE ? "暂空缺, 欢迎担任!" : "Vacant, Welcome to hold the position";
char *msg1 = CHINESE ? "该 recipe 的负责人暂空缺, 欢迎担任" : "Vacant, Welcome to hold the position";
printf ("%s%s\n", bdblue(msg), bdgreen(msg1));
}
}
{
char *msg = ENGLISH ? "Current Cooks: " : "当前副厨: ";
char *msg = ENGLISH ? "Cooks: " : "掌勺: ";
if (target->cooks && target->cooks_n > 0)
{
printf ("%s", bdblue(msg));
@ -438,35 +370,33 @@ cli_print_target_maintain_info (Target_t *target, const char *input_target_name)
{
if (i > 0) printf (", ");
printf ("%s <%s>",
target->cooks[i].name ? target->cooks[i].name : "Unknown",
target->cooks[i].email ? target->cooks[i].email : "unknown@example.com");
target->cooks[i]->name ? target->cooks[i]->name : "Unknown",
target->cooks[i]->email ? target->cooks[i]->email : "unknown@example.com");
}
printf ("\n");
}
else
{
char *msg1 = CHINESE ? "暂空缺, 欢迎担任!" : "Vacant, Welcome to hold the position!";
char *msg1 = CHINESE ? "暂空缺, 欢迎担任" : "Vacant, Welcome to hold the position";
printf ("%s%s\n", bdblue(msg), bdgreen(msg1));
}
}
{
char *msg = ENGLISH ? "Contributors: " : "贡献者: ";
if (target->contributors && target->contributors_n > 0)
char *msg = ENGLISH ? "Sauciers: " : "调味: ";
if (target->sauciers && target->sauciers_n > 0)
{
printf ("%s", bdblue(msg));
for (size_t i = 0; i < target->contributors_n; i++)
for (size_t i = 0; i < target->sauciers_n; i++)
{
if (i > 0) printf (", ");
printf ("%s <%s>",
target->contributors[i].name ? target->contributors[i].name : "Unknown",
target->contributors[i].email ? target->contributors[i].email : "unknown@example.com");
printf ("%s <%s>", target->sauciers[i]->name, target->sauciers[i]->email );
}
printf ("\n");
br();
}
else
{
char *msg1 = CHINESE ? "暂空缺, 欢迎参与贡献!" : "Vacant, Welcome to contribute!";
char *msg1 = CHINESE ? "暂空缺, 欢迎参与贡献" : "Vacant, Welcome to contribute!";
printf ("%s%s\n", bdblue(msg), bdgreen(msg1));
}
}
@ -496,7 +426,7 @@ cli_print_version ()
void
cli_print_help ()
{
char *version_string = purple("v" Chsrc_Version "-" Chsrc_Release_Date);
char *version_string = "v" Chsrc_Version "-" Chsrc_Release_Date;
const char *raw = CHINESE ? RAWSTR_chsrc_USAGE_CHINESE : RAWSTR_chsrc_USAGE_ENGLISH;
@ -521,64 +451,98 @@ cli_print_issues ()
/**
* iterate_menu_
* @brief callback_find_target()
*/
bool
match_alias_callback (const char *alias, void *user_data)
callback_match_alias (const char *alias, void *user_data)
{
const char *input = (const char *)user_data;
return xy_streql_ic (input, alias);
}
/**
* @brief iterate_menu()
*/
bool
callback_is_one_of_target_aliases (void *data, void *input)
{
Target_t *target = (Target_t *) data;
if (iterate_aliases (target->aliases, callback_match_alias, input))
{
target->preludefn();
return true;
}
else
return false;
}
/**
* @param:input @param:menu target
* `input` `menu` target
* prelude
*
* @param[in] menu menu
* @param[in] size menu
* @param[in] input
* @param[out] target Target_t
* @param[in] menu menu
* @param[in] input
* @param[out] target Target_t
*
* @return truefalse
*/
#define iterate_menu(ary, input, target) iterate_menu_(ary, xy_arylen(ary), input, target)
bool
iterate_menu_ (TargetRegisterInfo_t menu[], size_t size, const char *input, Target_t **target)
iterate_menu (XySeq_t *menu, const char *input, Target_t **target)
{
for (int i = 0; i < size; i++)
Target_t *t = xy_seq_find (menu, callback_is_one_of_target_aliases, (void *) input);
if (t)
{
TargetRegisterInfo_t *entry = &menu[i];
*target = t;
t->preludefn();
return true;
}
else
{
*target = NULL;
return false;
}
}
if (iterate_aliases (entry->target->aliases, match_alias_callback, (void *)input))
{
if (entry->prelude)
{
entry->prelude();
}
else
{
chsrc_error ("该target未定义 prelude()");
}
*target = entry->target;
return true;
}
void
callback_perform_all_prelude_for_menu (void *data, void *NOUSE)
{
Target_t *target = (Target_t *) data;
if (!target->preludefn)
{
chef_debug_target (target);
chsrc_panic ("未定义 _prelude() !");
}
*target = NULL;
return false;
target->preludefn();
}
/**
* @brief _prelude()
*
* DEBUG Get, Set, Reset
*
*/
void
chsrc_perform_all_prelude ()
{
chsrc_debug ("prelude", "DEBUG模式下, 额外检查所有 _prelude() 是否能正常工作");
xy_seq_each (ProgStore.pl, callback_perform_all_prelude_for_menu, NULL);
xy_seq_each (ProgStore.os, callback_perform_all_prelude_for_menu, NULL);
xy_seq_each (ProgStore.wr, callback_perform_all_prelude_for_menu, NULL);
}
/**
*
* @brief
*/
void
cli_notify_lastly_for_users ()
chsrc_op_epilogue ()
{
br();
chsrc_note2 (RAWSTR_chsrc_last_message);
chsrc_note2 (RAWSTR_chsrc_op_epilogue);
}
@ -592,7 +556,7 @@ typedef enum {
} TargetOp;
/**
* target @param:code
* target `code`
*
* @param input
* @param code target要执行的操作
@ -603,11 +567,13 @@ typedef enum {
bool
get_target (const char *input, TargetOp code, char *option)
{
chsrc_register_contributors ();
Target_t *target = NULL;
bool matched = iterate_menu (chsrc_pl_menu, input, &target);
if (!matched) matched = iterate_menu (chsrc_os_menu, input, &target);
if (!matched) matched = iterate_menu (chsrc_wr_menu, input, &target);
bool matched = iterate_menu (ProgStore.pl, input, &target);
if (!matched) matched = iterate_menu (ProgStore.os, input, &target);
if (!matched) matched = iterate_menu (ProgStore.wr, input, &target);
if (!matched) return false;
@ -617,7 +583,7 @@ get_target (const char *input, TargetOp code, char *option)
{
target->setfn(option);
}
else chsrc_error (xy_strjoin (3, "暂未对 ", input, " 实现 set 功能,邀您帮助: chsrc issue"));
else chsrc_error (xy_strcat (3, "暂未对 ", input, " 实现 set 功能,邀您帮助: chsrc issue"));
}
else if (TargetOp_Reset_Source==code)
{
@ -625,7 +591,7 @@ get_target (const char *input, TargetOp code, char *option)
{
target->resetfn(option);
}
else chsrc_error (xy_strjoin (3, "暂未对 ", input, " 实现 reset 功能,邀您帮助: chsrc issue"));
else chsrc_error (xy_strcat (3, "暂未对 ", input, " 实现 reset 功能,邀您帮助: chsrc issue"));
}
else if (TargetOp_Get_Source==code)
{
@ -633,13 +599,13 @@ get_target (const char *input, TargetOp code, char *option)
{
target->getfn("");
}
else chsrc_error (xy_strjoin (3, "暂未对 ", input, " 实现 get 功能,邀您帮助: chsrc issue"));
else chsrc_error (xy_strcat (3, "暂未对 ", input, " 实现 get 功能,邀您帮助: chsrc issue"));
}
else if (TargetOp_List_Config==code)
{
{
char *msg = ENGLISH ? "To specify a source, use chsrc set " : "指定使用某源,请使用 chsrc set ";
say (bdblue(xy_strjoin (3, msg, input, " <code>\n")));
say (bdblue(xy_strcat (3, msg, input, " <code>\n")));
}
{
@ -649,7 +615,7 @@ get_target (const char *input, TargetOp code, char *option)
{
char *msg1 = ENGLISH ? "Mirror abbr" : "镜像站简写";
char *msg2 = ENGLISH ? "Source URL" : "换源URL";
char *msg2 = ENGLISH ? "Source URL" : "换源链接";
char *msg3 = ENGLISH ? "Mirror Name" : "镜像站";
char *format = ENGLISH ? " %-13s%-33s%-38s%s\n" : " %-13s%-36s%-46s%s\n";
printf (format, "code", msg1, msg2, msg3);
@ -679,19 +645,26 @@ get_target (const char *input, TargetOp code, char *option)
if (TargetOp_Set_Source==code || TargetOp_Measure_Source==code)
{
cli_notify_lastly_for_users();
chsrc_op_epilogue ();
}
#ifdef XY_DEBUG
chef_debug_target (target);
chsrc_perform_all_prelude ();
#endif
return true;
}
int
main (int argc, char const *argv[])
{
xy_useutf8 (); argc -= 1;
chsrc_init_framework ();
chsrc_init_menu ();
argc -= 1;
if (0==argc)
{
@ -760,7 +733,7 @@ main (int argc, char const *argv[])
else
{
char *msg = ENGLISH ? "Unknown option: " : "未识别的命令行选项 ";
chsrc_error (xy_2strjoin (msg, argv[i])); return Exit_Unknown;
chsrc_error (xy_2strcat (msg, argv[i])); return Exit_Unknown;
}
cli_arg_Target_pos++;
cli_arg_Mirror_pos++;
@ -815,25 +788,39 @@ main (int argc, char const *argv[])
else
{
target = argv[cli_arg_Target_pos];
if (xy_streql (target, "mirrors") || xy_streql (target, "mirror"))
if ( xy_streql (target, "mirrors")
|| xy_streql (target, "mirror"))
{
cli_print_available_mirrors (); return Exit_OK;
cli_print_available_mirrors ();
return Exit_OK;
}
else if (xy_streql (target, "targets") || xy_streql (target, "target"))
else if ( xy_streql (target, "targets")
|| xy_streql (target, "target"))
{
cli_print_supported_targets (); return Exit_OK;
cli_print_supported_targets ();
return Exit_OK;
}
else if (xy_streql (target, "os"))
{
cli_print_supported_os (); return Exit_OK;
cli_print_menu ("os");
return Exit_OK;
}
else if (xy_streql (target, "lang") || xy_streql (target, "pl") || xy_streql (target, "language"))
else if ( xy_streql (target, "lang")
|| xy_streql (target, "pl")
|| xy_streql (target, "language"))
{
cli_print_supported_pl(); return Exit_OK;
cli_print_menu ("pl");
return Exit_OK;
}
else if (xy_streql (target, "ware") || xy_streql (target, "software"))
else if ( xy_streql (target, "ware")
|| xy_streql (target, "software"))
{
cli_print_supported_wr (); return Exit_OK;
cli_print_menu ("wr");
return Exit_OK;
}
matched = get_target (target, TargetOp_List_Config, NULL);
@ -943,7 +930,7 @@ main (int argc, char const *argv[])
{
char *msg1 = ENGLISH ? "Unknown command `" : "不支持的命令 ";
char *msg2 = ENGLISH ? "`. Use `chsrc help` to view usage" : ". 请使用 chsrc help 查看使用方式";
chsrc_error (xy_strjoin (3, msg1, command, msg2));
chsrc_error (xy_strcat (3, msg1, command, msg2));
return Exit_Unknown;
}

View File

@ -2,10 +2,10 @@
* SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Name : chef-helper.c
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nul None <nul@none.org>
* File Authors : <ccmywish@qq.com>
* Contributors : Nul None <nul@none.org>
* Created On : <2025-07-14>
* Last Modified : <2025-08-09>
* Last Modified : <2025-08-20>
*
* For chefs (recipe makers) and sometimes framewoker
* to do some work not releated to OS operations
@ -40,5 +40,5 @@ chef_ensure_trailing_slash (char *str)
if (len == 0 || str[len - 1] == '/')
return xy_strdup (str);
return xy_2strjoin (str, "/");
return xy_2strcat (str, "/");
}

View File

@ -2,47 +2,122 @@
* SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Name : chef.c
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nul None <nul@none.org>
* File Authors : <ccmywish@qq.com>
* Contributors : Nul None <nul@none.org>
* Created On : <2025-08-09>
* Last Modified : <2025-08-11>
* Last Modified : <2025-08-22>
*
* chef DSL: for chefs (recipe makers) to define a target
* ------------------------------------------------------------*/
#pragma once
#define chef_allow_gsr(t) this->getfn = t##_getsrc; this->setfn = t##_setsrc; this->resetfn = t##_resetsrc;
#define chef_allow_s(t) this->getfn = NULL; this->setfn = t##_setsrc; this->resetfn = NULL;
#define chef_allow_sr(t) this->getfn = NULL; this->setfn = t##_setsrc; this->resetfn = t##_resetsrc;
#define chef_allow_gs(t) this->getfn = t##_getsrc; this->setfn = t##_setsrc; this->resetfn = NULL;
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_strjoin (4, "recipe 重新为 ", provider->code, " 设置测速链接: ", 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_strjoin (4, "recipe 重新为 ", provider->code, " 设置测速精度: ", accuracy ? "精准" : "粗略"));
chsrc_debug ("m", xy_strcat (4, "recipe 重新为 ", provider->code, "(镜像站信息本身) 设置测速精度: ", accuracy ? "精准" : "粗略"));
}
/**
* @brief "换源 URL"
* @brief "换源链接"
*/
void
chef_set_sources_speed_measure_url_with_func (
@ -50,8 +125,11 @@ chef_set_sources_speed_measure_url_with_func (
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];
@ -69,30 +147,48 @@ chef_set_sources_speed_measure_url_with_func (
/**
* @brief "换源 URL"
* @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_2strjoin, 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)
{
if (!target)
return;
xy_cant_be_null (target);
target->can_english = true;
}
void
chef_forbid_english (Target_t *target)
{
if (!target)
return;
xy_cant_be_null (target);
target->can_english = false;
}
@ -100,8 +196,7 @@ chef_forbid_english (Target_t *target)
void
chef_allow_local_mode (Target_t *target, Capability_t cap, const char *explain_zh, const char *explain_en)
{
if (!target)
return;
xy_cant_be_null (target);
target->cap_local = cap;
@ -124,8 +219,7 @@ chef_allow_local_mode (Target_t *target, Capability_t cap, const char *explain_z
void
chef_allow_user_define (Target_t *target)
{
if (!target)
return;
xy_cant_be_null (target);
target->can_user_define = true;
target->can_user_define_explain = NULL;
@ -134,8 +228,7 @@ chef_allow_user_define (Target_t *target)
void
chef_forbid_user_define (Target_t *target)
{
if (!target)
return;
xy_cant_be_null (target);
target->can_user_define = false;
@ -148,113 +241,116 @@ chef_forbid_user_define (Target_t *target)
void
chef_set_note (Target_t *target, const char *note_zh, const char *note_en)
{
if (!target)
return;
xy_cant_be_null (target);
const char *msg = CHINESE ? note_zh : note_en;
if (msg)
target->note = xy_strdup(msg);
target->note = xy_strdup (msg);
}
void
chef_set_contributors (Target_t *target, uint32_t count, ...)
/**
* @brief `id`
*/
Contributor_t *
chef_verify_contributor (const char *id)
{
if (!target || count==0)
return;
xy_cant_be_null (id);
target->contributors_n = count;
target->contributors = xy_malloc0 (count * sizeof(Contributor_t));
va_list args;
va_start(args, count);
for (uint32_t i = 0; i < count; i++)
Contributor_t *c = xy_map_get (ProgStore.contributors, id);
if (!c)
{
char *name = va_arg(args, char*);
char *email = va_arg(args, char*);
target->contributors[i].name = xy_strdup (name);
target->contributors[i].email = xy_strdup (email);
char error[256];
snprintf (error, sizeof (error), "贡献者 %s 不存在, 是否写错?或请在 chsrc-main.c 中登记该贡献者", id);
chsrc_panic (error);
}
return c;
}
/**
* @brief Chef (recipe )
*/
void
chef_set_authors (Target_t *target, size_t count, ...)
chef_set_chef (Target_t *target, const char *id)
{
if (!target || count == 0)
return;
xy_cant_be_null (target);
va_list args;
va_start(args, count);
target->authors = xy_malloc0 (count * sizeof(Contributor_t));
target->authors_n = count;
for (size_t i = 0; i < count; i++)
/* Chef 可为空 */
if (!id)
{
char *name = va_arg(args, char*);
char *email = va_arg(args, char*);
target->authors[i].name = xy_strdup(name);
target->authors[i].email = xy_strdup(email);
target->chef = NULL;
return;
}
va_end(args);
}
void
chef_set_chef (Target_t *target, char *name, char *email)
{
if (!target || !name || !email)
return;
target->chef = xy_malloc0 (sizeof(Contributor_t));
target->chef->name = xy_strdup (name);
target->chef->email = xy_strdup (email);
Contributor_t *c = chef_verify_contributor (id);
target->chef = c;
}
/**
* @brief Cooks (recipe )
*/
void
chef_set_cooks (Target_t *target, size_t count, ...)
{
if (!target)
return;
xy_cant_be_null (target);
if (count == 0)
{
target->cooks = NULL;
target->cooks_n = 0;
chsrc_panic ("recipe 一定至少有1位作者(cooks)");
return;
}
va_list args;
va_start(args, count);
va_start (args, count);
target->cooks = xy_malloc0 (count * sizeof(Contributor_t));
target->cooks = xy_malloc0 (count * sizeof (Contributor_t*));
target->cooks_n = count;
for (size_t i = 0; i < count; i++)
{
char *name = va_arg(args, char*);
char *email = va_arg(args, char*);
target->cooks[i].name = xy_strdup(name);
target->cooks[i].email = xy_strdup(email);
char *id = va_arg (args, char*);
target->cooks[i] = chef_verify_contributor (id);
}
va_end(args);
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)
{
if (!target)
return;
xy_cant_be_null (target);
xy_cant_be_null (date);
target->created_on = xy_strdup (date);
}
@ -263,8 +359,8 @@ chef_set_created_on (Target_t *target, char *date)
void
chef_set_last_updated (Target_t *target, char *date)
{
if (!target)
return;
xy_cant_be_null (target);
xy_cant_be_null (date);
target->last_updated = xy_strdup (date);
}
@ -273,36 +369,8 @@ chef_set_last_updated (Target_t *target, char *date)
void
chef_set_sources_last_updated (Target_t *target, char *date)
{
if (!target)
return;
xy_cant_be_null (target);
xy_cant_be_null (date);
target->sources_last_updated = xy_strdup (date);
}
void
chef_debug_target (Target_t *target)
{
#ifdef XY_DEBUG
if (!target)
{
chsrc_debug2 ("t", "Target is NULL");
return;
}
say ("Debug Target Information:");
printf (" Get Function: %p\n", target->getfn);
printf (" Set Function: %p\n", target->setfn);
printf (" Reset Function: %p\n", target->resetfn);
printf (" Sources: %p\n", target->sources);
printf (" Sources Count: %lld\n", target->sources_n);
printf (" Authors: %p\n", target->authors);
printf (" Authors Count: %lld\n", target->authors_n);
printf (" Chef: %p\n", target->chef);
printf (" Cooks: %p\n", target->cooks);
printf (" Cooks Count: %lld\n", target->cooks_n);
printf (" Contributors: %p\n", target->contributors);
printf (" Contributors Count: %lld\n", target->contributors_n);
#endif
}

View File

@ -2,14 +2,14 @@
* SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Name : core.c
* File Authors : Aoran Zeng <ccmywish@qq.com>
* | Heng Guo <2085471348@qq.com>
* File Authors : <ccmywish@qq.com>
* | <2085471348@qq.com>
* Contributors : Peng Gao <gn3po4g@outlook.com>
* | Happy Game <happygame10124@gmail.com>
* | Yangmoooo <yangmoooo@outlook.com>
* |
* Created On : <2023-08-29>
* Last Modified : <2025-08-10>
* Last Modified : <2025-08-22>
*
* chsrc framework
* ------------------------------------------------------------*/
@ -137,6 +137,21 @@ ProgStatus =
};
/* Global Program Store */
struct
{
XySeq_t *pl;
XySeq_t *os;
XySeq_t *wr;
XyMap_t *contributors; /* 所有贡献者 */
}
ProgStore =
{
.pl = NULL,
.os = NULL,
.wr = NULL,
.contributors = NULL,
};
@ -159,6 +174,7 @@ ProgStatus =
#define chsrc_debug(dom,str)
#endif
#define chsrc_verbose(str) xy_info(App_Name "(VERBOSE)",str)
#define chsrc_panic(reason) xy_error(App_Name "(PANIC)",reason); exit(Exit_MaintainerCause)
#define faint(str) xy_str_to_faint(str)
#define red(str) xy_str_to_red(str)
@ -206,6 +222,20 @@ chsrc_alert2 (const char *str)
}
void
chsrc_init_framework ()
{
xy_init ();
ProgStore.contributors = xy_map_new ();
ProgStore.pl = xy_seq_new ();
ProgStore.os = xy_seq_new ();
ProgStore.wr = xy_seq_new ();
}
void
chsrc_log_write (const char *filename)
{
@ -219,8 +249,8 @@ chsrc_log_backup (const char *filename)
{
char *msg = ENGLISH ? "BACKUP" : "备份";
char *bak = xy_2strjoin (filename, ".bak");
xy_log_brkt (blue(App_Name), bdblue(msg), xy_strjoin (3, bdyellow(filename), " -> ", bdgreen(bak)));
char *bak = xy_2strcat (filename, ".bak");
xy_log_brkt (blue(App_Name), bdblue(msg), xy_strcat (3, bdyellow(filename), " -> ", bdgreen(bak)));
}
#define YesMark "✓"
@ -251,12 +281,12 @@ log_check_result (const char *check_what, const char *check_type, bool exist)
if (!exist)
{
xy_log_brkt (App_Name, bdred (chk_msg), xy_strjoin (5,
xy_log_brkt (App_Name, bdred (chk_msg), xy_strcat (5,
red (NoMark " "), check_type, " ", red (check_what), not_exist_msg));
}
else
{
xy_log_brkt (App_Name, bdgreen (chk_msg), xy_strjoin (5,
xy_log_brkt (App_Name, bdgreen (chk_msg), xy_strcat (5,
green (YesMark " "), check_type, " ", green (check_what), exist_msg));
}
}
@ -288,7 +318,7 @@ log_cmd_result (bool result, int exit_status)
{
char buf[8] = {0};
sprintf (buf, "%d", exit_status);
char *log = xy_2strjoin (red (fail_msg), bdred (buf));
char *log = xy_2strcat (red (fail_msg), bdred (buf));
xy_log_brkt (red (App_Name), bdred (run_msg), log);
}
}
@ -303,11 +333,11 @@ log_cmd_result (bool result, int exit_status)
/**
*
*
* @param check_cmd @param:prog_name @param:prog_name
* @param check_cmd `prog_name` `prog_name`
* 使 python Windows上
* Microsoft Store
*
* @param prog_name
* @param prog_name
*
*/
bool
@ -325,7 +355,7 @@ query_program_exist (char *check_cmd, char *prog_name, int mode)
{
if (mode & Noisy_When_NonExist)
{
// xy_warn (xy_strjoin(4, "× 命令 ", progname, " 不存在,", buf));
// xy_warn (xy_strcat(4, "× 命令 ", progname, " 不存在,", buf));
log_check_result (prog_name, msg, false);
}
return false;
@ -340,33 +370,37 @@ query_program_exist (char *check_cmd, char *prog_name, int mode)
/**
* @brief '' chsrc_check_program()
* @brief chsrc_check_program()
*
* 使 "调用 程序名 --version" ( cmd_to_check_program2())
*
*
* 1. ()
* 2. 使 --version mvn
* 3. --version ()
*
* @note Unix where zsh 使sh Bash 使
* Unix 使 which whereis
* @note
* 1. Unix 'where' Zsh 使sh Bash 使
* 2. Linux 'which' 'whereis' 使 'command -v'
*/
static char *
cmd_to_check_program (char *prog_name)
{
char *check_tool = xy_on_windows ? "where " : "which ";
char *check_tool = xy_on_windows ? "where " : "command -v ";
char *quiet_cmd = xy_str_to_quietcmd (xy_2strjoin (check_tool, prog_name));
char *quiet_cmd = xy_str_to_quietcmd (xy_2strcat (check_tool, prog_name));
return quiet_cmd;
}
/**
* @brief ` --version`
*
* @deprecated
*
* 1. ()
* 2. 使 --version mvn
* 3. --version ()
*/
XY_Deprecate_This("Use cmd_to_check_program() instead")
static char *
cmd_to_check_program2 (char *prog_name)
{
char *quiet_cmd = xy_str_to_quietcmd (xy_2strjoin (prog_name, " --version"));
char *quiet_cmd = xy_str_to_quietcmd (xy_2strcat (prog_name, " --version"));
return quiet_cmd;
}
@ -431,7 +465,7 @@ chsrc_ensure_program (char *prog_name)
{
char *msg1 = ENGLISH ? "not found " : "未找到 ";
char *msg2 = ENGLISH ? " command, please check for existence" : " 命令,请检查是否存在";
chsrc_error (xy_strjoin (3, msg1, prog_name, msg2));
chsrc_error (xy_strcat (3, msg1, prog_name, msg2));
exit (Exit_UserCause);
}
}
@ -476,7 +510,7 @@ query_mirror_exist (Source_t *sources, size_t size, char *target_name, char *inp
{
char *msg1 = ENGLISH ? "Currently " : "当前 ";
char *msg2 = ENGLISH ? " doesn't have any source available. Please contact the maintainers" : " 无任何可用源,请联系维护者";
chsrc_error (xy_strjoin (3, msg1, target_name, msg2));
chsrc_error (xy_strcat (3, msg1, target_name, msg2));
exit (Exit_MaintainerCause);
}
@ -484,7 +518,7 @@ query_mirror_exist (Source_t *sources, size_t size, char *target_name, char *inp
{
char *msg1 = ENGLISH ? "Currently " : "当前 ";
char *msg2 = ENGLISH ? " only the upstream source exists. Please contact the maintainers" : " 仅存在上游默认源,请联系维护者";
chsrc_error (xy_strjoin (3, msg1, target_name, msg2));
chsrc_error (xy_strcat (3, msg1, target_name, msg2));
exit (Exit_MaintainerCause);
}
@ -503,7 +537,7 @@ query_mirror_exist (Source_t *sources, size_t size, char *target_name, char *inp
: " 目前唯一可用镜像站,感谢他们的慷慨支持";
const char *name = ENGLISH ? sources[1].mirror->abbr
: sources[1].mirror->name;
chsrc_succ (xy_strjoin (4, name, msg1, target_name, msg2));
chsrc_succ (xy_strcat (4, name, msg1, target_name, msg2));
}
if (xy_streql ("first", input))
@ -532,11 +566,11 @@ query_mirror_exist (Source_t *sources, size_t size, char *target_name, char *inp
{
char *msg1 = ENGLISH ? "Mirror site " : "镜像站 ";
char *msg2 = ENGLISH ? " doesn't exist" : " 不存在";
chsrc_error (xy_strjoin (3, msg1, input, msg2));
chsrc_error (xy_strcat (3, msg1, input, msg2));
}
char *msg = ENGLISH ? "To see available sources, use chsrc list " : "查看可使用源,请使用 chsrc list ";
chsrc_error (xy_2strjoin (msg, target_name));
chsrc_error (xy_2strcat (msg, target_name));
exit (Exit_UserCause);
}
return idx;
@ -609,11 +643,11 @@ measure_speed_for_url (void *url)
/**
* @note L: RubyChina, npmmirror
*/
char *curl_cmd = xy_strjoin (10, "curl -qsL ", ipv6,
char *curl_cmd = #xy_strcat (8, "curl -qsL ", ipv6,
" -o ", os_devnull,
" -w \"%{http_code} %{speed_download}\" -m", time_sec,
" -A ", ProgStatus.user_agent, " ", url);
// chsrc_info (xy_2strjoin ("测速命令 ", curl_cmd));
char *curl_buf = xy_run (curl_cmd, 0);
return curl_buf;
@ -637,8 +671,8 @@ parse_and_say_curl_result (char *curl_buf)
if (200!=http_code)
{
char *http_code_str = yellow (xy_2strjoin ("HTTP码 ", curl_buf));
say (xy_strjoin (3, speedstr, " | ", http_code_str));
char *http_code_str = yellow (xy_2strcat ("HTTP码 ", curl_buf));
say (xy_strcat (3, speedstr, " | ", http_code_str));
}
else
{
@ -709,7 +743,7 @@ measure_speed_for_every_source (Source_t sources[], int size, double speed_recor
{
char *msg1 = ENGLISH ? "Maintainers don't offer " : "维护者未提供 ";
char *msg2 = ENGLISH ? " mirror site's speed measure link, so skip it" : " 镜像站测速链接,跳过该站点(需修复)";
chsrc_warn (xy_strjoin (3, msg1, provider->code, msg2));
chsrc_warn (xy_strcat (3, msg1, provider->code, msg2));
speed = 0;
speed_records[i] = speed;
@ -721,7 +755,7 @@ measure_speed_for_every_source (Source_t sources[], int size, double speed_recor
if (chef_is_url (provider_speed_url))
{
url = xy_strdup (provider_speed_url);
chsrc_debug ("m", xy_2strjoin ("使用镜像站整体测速链接: ", url));
chsrc_debug ("m", xy_2strcat ("使用镜像站整体测速链接: ", url));
}
}
else if (provider_skip)
@ -735,13 +769,13 @@ measure_speed_for_every_source (Source_t sources[], int size, double speed_recor
{
url = xy_strdup (dedicated_speed_url);
has_dedicated_speed_url = true;
chsrc_debug ("m", xy_2strjoin ("使用专用测速链接: ", url));
chsrc_debug ("m", xy_2strcat ("使用专用测速链接: ", url));
}
else
{
/* 防止维护者没填这里有一些脏数据我们软处理假装该链接URL不存在 */
has_dedicated_speed_url = false;
chsrc_debug ("m", xy_2strjoin ("专用测速链接为脏数据,请修复: ", provider->name));
chsrc_debug ("m", xy_2strcat ("专用测速链接为脏数据,请修复: ", provider->name));
}
}
@ -777,7 +811,7 @@ measure_speed_for_every_source (Source_t sources[], int size, double speed_recor
{
skip_reason = ENGLISH ? "SKIP for no reason" : "无理由跳过";
}
measure_msgs[i] = xy_strjoin (4, faint(" x "), msg, " ", yellow(faint(skip_reason)));
measure_msgs[i] = xy_strcat (4, faint(" x "), msg, " ", yellow(faint(skip_reason)));
println (measure_msgs[i]);
/* 下一位 */
@ -804,11 +838,11 @@ measure_speed_for_every_source (Source_t sources[], int size, double speed_recor
if (xy_streql ("upstream", provider->code))
{
measure_msgs[i] = xy_strjoin (7, faint(" ^ "), msg, " (", src.url, ") ", accurate_msg, faint(" ... "));
measure_msgs[i] = xy_strcat (7, faint(" ^ "), msg, " (", src.url, ") ", accurate_msg, faint(" ... "));
}
else
{
measure_msgs[i] = xy_strjoin (5, faint(" - "), msg, " ", accurate_msg, faint(" ... "));
measure_msgs[i] = xy_strcat (5, faint(" - "), msg, " ", accurate_msg, faint(" ... "));
}
print (measure_msgs[i]);
@ -848,7 +882,7 @@ auto_select_mirror (Source_t *sources, size_t size, const char *target_name)
{
char *msg1 = ENGLISH ? "Currently " : "当前 ";
char *msg2 = ENGLISH ? "No any source, please contact maintainers: chsrc issue" : " 无任何可用源,请联系维护者: chsrc issue";
chsrc_error (xy_strjoin (3, msg1, target_name, msg2));
chsrc_error (xy_strcat (3, msg1, target_name, msg2));
exit (Exit_MaintainerCause);
}
@ -913,21 +947,21 @@ auto_select_mirror (Source_t *sources, size_t size, const char *target_name)
: " 目前唯一可用镜像站,感谢他们的慷慨支持";
const char *name = ENGLISH ? sources[fast_idx].mirror->abbr
: sources[fast_idx].mirror->name;
say (xy_strjoin (5, msg1, bdgreen(name), green(is), green(target_name), green(msg2)));
say (xy_strcat (5, msg1, bdgreen(name), green(is), green(target_name), green(msg2)));
}
else
{
char *msg = ENGLISH ? "FASTEST mirror site: " : "最快镜像站: ";
const char *name = ENGLISH ? sources[fast_idx].mirror->abbr
: sources[fast_idx].mirror->name;
say (xy_2strjoin (msg, green(name)));
say (xy_2strcat (msg, green(name)));
}
// https://github.com/RubyMetric/chsrc/pull/71
if (in_measure_mode())
{
char *msg = ENGLISH ? "URL of above source: " : "镜像源地址: ";
say (xy_2strjoin (msg, green(sources[fast_idx].url)));
say (xy_2strcat (msg, green(sources[fast_idx].url)));
}
return fast_idx;
@ -988,6 +1022,14 @@ source_has_empty_url (Source_t *source)
Source_t
chsrc_yield_source (Target_t *t, char *option)
{
/**
* _setsrc() _prelude()
* _prelude()
*
* _setsrc()
*/
if (!t->inited) t->preludefn();
Source_t source;
if (chsrc_in_target_group_mode() && ProgStatus.leader_selected_index==-1)
{
@ -1046,7 +1088,7 @@ chsrc_confirm_source (Source_t *source)
else
{
char *msg = ENGLISH ? "SELECT mirror site: " : "选中镜像站: ";
say (xy_strjoin (5, msg, green (source->mirror->abbr), " (", green (source->mirror->code), ")"));
say (xy_strcat (5, msg, green (source->mirror->abbr), " (", green (source->mirror->code), ")"));
}
hr();
@ -1095,7 +1137,7 @@ chsrc_custom_user_agent (char *user_agent)
#define MSG_EN_STILL "Still need to operate manually according to the above prompts. "
#define MSG_CN_STILL "仍需按上述提示手工操作"
#define thank_mirror(msg) chsrc_log(xy_2strjoin(msg,purple(ENGLISH?source->mirror->abbr:source->mirror->name)))
#define thank_mirror(msg) chsrc_log(xy_2strcat(msg,purple(ENGLISH?source->mirror->abbr:source->mirror->name)))
/**
* @param source NULL
@ -1323,17 +1365,17 @@ chsrc_run_as_a_service (const char *cmd)
FILE *
chsrc_make_tmpfile (char *filename, char *postfix, bool loud, char **tmpfilename)
{
#ifdef XY_On_Windows
#ifdef XY_Build_On_Windows
/**
* Windows mkstemps() mkstemp() _mktemp_s()
* postfix
* PowerShell 使 -File .ps1
* 使 Windows
*/
char *tmpfile = xy_strjoin (3, "chsrc_tmp_", filename, postfix);
char *tmpfile = xy_strcat (3, "chsrc_tmp_", filename, postfix);
FILE *f = fopen (tmpfile, "w+");
#else
char *tmpfile = xy_strjoin (5, "/tmp/", "chsrc_tmp_", filename, "_XXXXXX", postfix);
char *tmpfile = xy_strcat (5, "/tmp/", "chsrc_tmp_", filename, "_XXXXXX", postfix);
size_t postfix_len = strlen (postfix);
/* 和 _mktemp_s() 参数不同,前者是整个缓存区大小,这里的长度是后缀长度 */
@ -1344,14 +1386,14 @@ chsrc_make_tmpfile (char *filename, char *postfix, bool loud, char **tmpfilename
if (!f)
{
char *msg = CHINESE ? "无法创建临时文件: " : "Unable to create temporary file: ";
msg = xy_2strjoin (msg, tmpfile);
msg = xy_2strcat (msg, tmpfile);
chsrc_error2 (msg);
exit (Exit_ExternalError);
}
else if (loud)
{
char *msg = CHINESE ? "已创建临时文件: " : "Temporary file created: ";
msg = xy_2strjoin (msg, tmpfile);
msg = xy_2strcat (msg, tmpfile);
chsrc_succ2 (msg);
}
@ -1389,7 +1431,7 @@ chsrc_run_as_bash_file (const char *script_content)
char *msg = CHINESE ? "即将执行 Bash 脚本内容:" : "The Bash script content will be executed:";
chsrc_note2 (msg);
println (faint(script_content));
char *cmd = xy_2strjoin ("bash ", tmpfile);
char *cmd = xy_2strcat ("bash ", tmpfile);
chsrc_run (cmd, RunOpt_Dont_Abort_On_Failure);
remove (tmpfile);
}
@ -1409,7 +1451,7 @@ chsrc_run_as_sh_file (const char *script_content)
char *msg = CHINESE ? "即将执行 sh 脚本内容:" : "The sh script content will be executed:";
chsrc_note2 (msg);
println (faint(script_content));
char *cmd = xy_2strjoin ("sh ", tmpfile);
char *cmd = xy_2strcat ("sh ", tmpfile);
chsrc_run (cmd, RunOpt_Dont_Abort_On_Failure);
remove (tmpfile);
}
@ -1428,7 +1470,7 @@ chsrc_run_as_pwsh_file (const char *script_content)
char *msg = CHINESE ? "即将执行 PowerShell 脚本内容:" : "The PowerShell script content will be executed:";
chsrc_note2 (msg);
println (faint(script_content));
char *cmd = xy_2strjoin ("pwsh ", tmpfile);
char *cmd = xy_2strcat ("pwsh ", tmpfile);
chsrc_run (cmd, RunOpt_Dont_Abort_On_Failure);
remove (tmpfile);
}
@ -1443,7 +1485,7 @@ XY_Deprecate_This("Don't use this function")
void
chsrc_run_in_inline_bash_shell (const char *cmdline)
{
char *cmd = xy_strjoin (3, "bash -c '", cmdline, "'");
char *cmd = xy_strcat (3, "bash -c '", cmdline, "'");
chsrc_run (cmd, RunOpt_Dont_Abort_On_Failure);
}
@ -1457,7 +1499,7 @@ XY_Deprecate_This("Don't use this function")
void
chsrc_run_in_inline_pwsh_shell (const char *cmdline)
{
char *cmd = xy_strjoin (3, "pwsh -Command '", cmdline, "'");
char *cmd = xy_strcat (3, "pwsh -Command '", cmdline, "'");
chsrc_run (cmd, RunOpt_Dont_Abort_On_Failure);
}
@ -1474,25 +1516,25 @@ chsrc_view_env (const char *var1, ...)
bool first = true;
while (var)
{
#ifdef XY_On_Windows
#ifdef XY_Build_On_Windows
if (first)
{
cmd = xy_strjoin (3, "set ", var, " ");
cmd = xy_strcat (3, "set ", var, " ");
first = false;
}
else
{
cmd = xy_strjoin (4, cmd, "& set ", var, " ");
cmd = xy_strcat (4, cmd, "& set ", var, " ");
}
#else
if (first)
{
cmd = xy_strjoin (5, "echo ", var, "=$", var, " ");
cmd = xy_strcat (5, "echo ", var, "=$", var, " ");
first = false;
}
else
{
cmd = xy_strjoin (6, cmd, "; echo ", var, "=$", var, " ");
cmd = xy_strcat (6, cmd, "; echo ", var, "=$", var, " ");
}
#endif
var = va_arg (vars, const char *);
@ -1508,7 +1550,7 @@ chsrc_view_env (const char *var1, ...)
*/
// chsrc_run (cmd, RunOpt_Dont_Notify_On_Success|RunOpt_No_Last_New_Line|RunOpt_Dont_Abort_On_Failure);
int status = system (cmd);
if (status!=0) {/* NOOP */}
if (status!=0) { xy_noop(); }
}
else
{
@ -1525,11 +1567,11 @@ chsrc_view_file (const char *path)
path = xy_normalize_path (path);
if (xy_on_windows)
{
cmd = xy_2strjoin ("type ", path);
cmd = xy_2strcat ("type ", path);
}
else
{
cmd = xy_2strjoin ("cat ", path);
cmd = xy_2strcat ("cat ", path);
}
chsrc_run_as_a_service (cmd);
@ -1555,13 +1597,13 @@ chsrc_ensure_dir (const char *dir)
{
mkdir_cmd = "mkdir -p ";
}
char *cmd = xy_2strjoin (mkdir_cmd, dir);
char *cmd = xy_2strcat (mkdir_cmd, dir);
cmd = xy_str_to_quietcmd (cmd);
chsrc_run_as_a_service (cmd);
char *msg = ENGLISH ? "Directory doesn't exist, created automatically " : "目录不存在,已自动创建 ";
chsrc_alert2 (xy_2strjoin (msg, dir));
chsrc_alert2 (xy_2strcat (msg, dir));
}
@ -1580,8 +1622,8 @@ chsrc_append_to_file (const char *str, const char *filename)
FILE *f = fopen (file, "a");
if (NULL==f)
{
char *msg = ENGLISH ? xy_2strjoin ("Unable to open file to write: ", file)
: xy_2strjoin ("无法打开文件以写入: ", file);
char *msg = ENGLISH ? xy_2strcat ("Unable to open file to write: ", file)
: xy_2strcat ("无法打开文件以写入: ", file);
chsrc_error2 (msg);
exit (Exit_UserCause);
}
@ -1591,8 +1633,8 @@ chsrc_append_to_file (const char *str, const char *filename)
size_t ret = fwrite (str, len, 1, f);
if (ret != 1)
{
char *msg = ENGLISH ? xy_2strjoin ("Write failed to ", file)
: xy_2strjoin ("写入文件失败: ", file);
char *msg = ENGLISH ? xy_2strcat ("Write failed to ", file)
: xy_2strcat ("写入文件失败: ", file);
chsrc_error2 (msg);
exit (Exit_UserCause);
}
@ -1607,11 +1649,11 @@ log_anyway:
char *cmd = NULL;
if (xy_on_windows)
{
cmd = xy_strjoin (4, "echo ", str, " >> ", file);
cmd = xy_strcat (4, "echo ", str, " >> ", file);
}
else
{
cmd = xy_strjoin (4, "echo '", str, "' >> ", file);
cmd = xy_strcat (4, "echo '", str, "' >> ", file);
}
chsrc_run_a_service (cmd);
*/
@ -1636,7 +1678,7 @@ chsrc_prepend_to_file (const char *str, const char *filename)
}
else
{
cmd = xy_strjoin (4, "sed -i '1i ", str, "' ", file);
cmd = xy_strcat (4, "sed -i '1i ", str, "' ", file);
}
chsrc_run_as_a_service (cmd);
@ -1660,11 +1702,11 @@ chsrc_overwrite_file (const char *str, const char *filename)
char *cmd = NULL;
if (xy_on_windows)
{
cmd = xy_strjoin (4, "echo ", str, " > ", file);
cmd = xy_strcat (4, "echo ", str, " > ", file);
}
else
{
cmd = xy_strjoin (4, "echo '", str, "' > ", file);
cmd = xy_strcat (4, "echo '", str, "' > ", file);
}
chsrc_run_as_a_service (cmd);
@ -1687,14 +1729,14 @@ chsrc_backup (const char *path)
if (!exist)
{
char *msg = ENGLISH ? "File doesn't exist, skip backup: " : "文件不存在,跳过备份: ";
chsrc_alert2 (xy_2strjoin (msg, path));
chsrc_alert2 (xy_2strcat (msg, path));
return;
}
if (xy_on_bsd || xy_on_macos)
{
/* BSD 和 macOS 的 cp 不支持 --backup 选项 */
cmd = xy_strjoin (5, "cp -f ", path, " ", path, ".bak");
cmd = xy_strcat (5, "cp -f ", path, " ", path, ".bak");
}
else if (xy_on_windows)
{
@ -1702,7 +1744,7 @@ chsrc_backup (const char *path)
* @note /Y
* @note "已复制 1个文件"
*/
cmd = xy_strjoin (5, "copy /Y ", path, " ", path, ".bak 1>nul");
cmd = xy_strcat (5, "copy /Y ", path, " ", path, ".bak 1>nul");
}
else
{
@ -1717,12 +1759,12 @@ chsrc_backup (const char *path)
/* cp (GNU coreutils) 9.4 */
if (strstr (ver, "GNU coreutils"))
{
cmd = xy_strjoin (5, "cp ", path, " ", path, ".bak --backup='t'");
cmd = xy_strcat (5, "cp ", path, " ", path, ".bak --backup='t'");
}
else
{
/* 非 GNU 的 cp 可能不支持 --backup ,如 busybox cp */
cmd = xy_strjoin (5, "cp -f ", path, " ", path, ".bak");
cmd = xy_strcat (5, "cp -f ", path, " ", path, ".bak");
}
}
@ -1742,7 +1784,7 @@ chsrc_get_cpuarch ()
char *ret;
char *msg;
#if XY_On_Windows
#if XY_Build_On_Windows
SYSTEM_INFO info;
GetSystemInfo (&info);
WORD num = info.wProcessorArchitecture;
@ -1795,7 +1837,7 @@ chsrc_get_cpucore ()
{
int cores = 2;
#if XY_On_Windows
#if XY_Build_On_Windows
SYSTEM_INFO info;
GetSystemInfo (&info);
DWORD num = info.dwNumberOfProcessors;

View File

@ -2,12 +2,12 @@
* SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Name : struct.h
* File Authors : Aoran Zeng <ccmywish@qq.com>
* | Heng Guo <2085471348@qq.com>
* File Authors : <ccmywish@qq.com>
* | <2085471348@qq.com>
* Contributors : Shengwei Chen <414685209@qq.com>
* |
* Created On : <2023-08-29>
* Last Modified : <2025-08-11>
* Last Modified : <2025-08-22>
*
* chsrc struct
* ------------------------------------------------------------*/
@ -94,8 +94,6 @@ Source_t;
/* 由 prelude() 填充 */
#define FeedByPrelude NULL
#define def_sources_n(t) const size_t t##_sources_n = xy_arylen(t##_sources)
typedef enum Capability_t
{
@ -109,8 +107,10 @@ Capability_t;
typedef struct Contributor_t
{
char *name;
char *id; /* 全局唯一贡献者标识符,防止反复写信息,以 @ 开头 */
char *name; /* 贡献者姓名; 鉴于该项目完全依赖于贡献者,建议留下真实姓名或者昵称 */
char *email;
char *display_name; /* recipe 结束时会显示贡献者信息,如果你不愿显示真实姓名或者昵称,可以另外提供一个名字 */
}
Contributor_t;
@ -124,8 +124,12 @@ typedef struct Target_t
void (*setfn) (char *option);
void (*resetfn) (char *option);
Source_t *sources;
size_t sources_n;
/* 初始化函数,用于填充该 struct 的各种信息 */
void (*preludefn) (void);
bool inited; /* 是否执行过了 preludefn() */
Source_t *sources;
int sources_n;
/* Features */
@ -140,41 +144,36 @@ typedef struct Target_t
char *note; /* 备注 */
/* Recipe maintain info */
/* recipe 维护信息 */
char *created_on;
char *last_updated;
char *sources_last_updated;
Contributor_t *authors;
size_t authors_n;
Contributor_t *contributors;
size_t contributors_n;
Contributor_t *chef; /* Chef 仅有一个 */
Contributor_t *cooks; /* Cook 可以有多个 */
size_t cooks_n;
Contributor_t *chef; /* 该 recipe *当前*的总负责人 (可以任职也可以休职) */
Contributor_t **cooks; /* 该 recipe 的主要作者 */
int cooks_n;
Contributor_t **sauciers; /* 该 recipe 的次要贡献者 (除主要作者外的其他人) */
int sauciers_n;
}
Target_t;
typedef struct TargetRegisterInfo_t
{
Target_t *target; /* target 本身 */
void (*prelude) (void); /* 填充 target 信息等预置操作 */
}
TargetRegisterInfo_t;
#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};
/* 以下宏仅能放在 prelude() 中使用 */
#define chef_allow_gsr(t) this->getfn = t##_getsrc; this->setfn = t##_setsrc; this->resetfn = t##_resetsrc;
#define chef_allow_s(t) this->getfn = NULL; this->setfn = t##_setsrc; this->resetfn = NULL;
#define chef_allow_sr(t) this->getfn = NULL; this->setfn = t##_setsrc; this->resetfn = t##_resetsrc;
#define chef_allow_gs(t) this->getfn = t##_getsrc; this->setfn = t##_setsrc; this->resetfn = NULL;
#define chef_allow_NOOP(t)
#define chef_prep_this(t,op) Target_t *this = &t##_target; this->inited = true; chef_allow_##op(t);
#define use_this(t) Target_t *this = &t##_target;
#define use_this_source(t) use_this(t); Source_t source = chsrc_yield_source_and_confirm (this, option);
#define chsrc_use_this_source(t) Target_t *this = &t##_target; Source_t source = chsrc_yield_source_and_confirm (this, option);
#define def_sources_begin() Source_t sources[] = {
#define def_sources_end() }; \
this->sources_n = xy_arylen(sources); \
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

@ -12,5 +12,5 @@ char RAWSTR_chsrc_for_v[] = "\143\150\163\162\143\040\100\166\145\162\100\012\10
char RAWSTR_chsrc_for_issue[] = "\346\210\221\344\273\254\345\220\214\346\227\266\345\234\250\040\107\151\164\110\165\142\040\345\222\214\040\107\151\164\145\145\040\346\216\245\345\217\227\040\151\163\163\165\145\040\345\222\214\040\102\165\147\040\346\212\245\345\221\212\072\012\012\040\040\055\040\150\164\164\160\163\072\057\057\147\151\164\150\165\142\056\143\157\155\057\122\165\142\171\115\145\164\162\151\143\057\143\150\163\162\143\057\151\163\163\165\145\163\012\040\040\055\040\150\164\164\160\163\072\057\057\147\151\164\145\145\056\143\157\155\057\122\165\142\171\115\145\164\162\151\143\057\143\150\163\162\143\057\151\163\163\165\145\163\012\012\012\346\254\242\350\277\216\345\217\202\344\270\216\345\205\267\344\275\223\344\273\273\345\212\241\072\012\012\040\040\040\123\150\145\154\154\040\141\165\164\157\055\143\157\155\160\154\145\164\151\157\156\040\347\273\210\347\253\257\345\221\275\344\273\244\350\207\252\345\212\250\350\241\245\345\205\250\072\012\012\040\040\040\040\040\040\040\040\150\164\164\160\163\072\057\057\147\151\164\150\165\142\056\143\157\155\057\122\165\142\171\115\145\164\162\151\143\057\143\150\163\162\143\057\151\163\163\165\145\163\057\062\060\064\012\012\040\040\040\346\220\234\351\233\206\344\270\212\346\270\270\351\273\230\350\256\244\346\272\220\345\234\260\345\235\200\357\274\214\345\270\256\345\212\251\350\277\233\350\241\214\040\143\150\163\162\143\040\162\145\163\145\164\072\012\012\040\040\040\040\040\040\040\040\150\164\164\160\163\072\057\057\147\151\164\150\165\142\056\143\157\155\057\122\165\142\171\115\145\164\162\151\143\057\143\150\163\162\143\057\151\163\163\165\145\163\057\061\061\061\012\012\040\040\040\346\220\234\351\233\206\346\265\213\351\200\237\345\234\260\345\235\200\357\274\214\350\277\233\350\241\214\347\262\276\345\207\206\346\265\213\351\200\237\072\012\012\040\040\040\040\040\040\040\040\150\164\164\160\163\072\057\057\147\151\164\150\165\142\056\143\157\155\057\122\165\142\171\115\145\164\162\151\143\057\143\150\163\162\143\057\151\163\163\165\145\163\057\062\060\065\012\012\040\040\040\345\270\256\345\212\251\346\262\241\346\234\211\351\242\204\347\274\226\350\257\221\347\232\204\345\271\263\345\217\260\347\274\226\345\206\231\040\163\150\145\154\154\040\350\204\232\346\234\254\072\012\012\040\040\040\040\040\040\040\040\150\164\164\160\163\072\057\057\147\151\164\150\165\142\056\143\157\155\057\122\165\142\171\115\145\164\162\151\143\057\143\150\163\162\143\057\151\163\163\165\145\163\057\062\063\060\012\012\012\346\224\257\346\214\201\347\232\204\351\200\232\347\224\250\351\225\234\345\203\217\347\253\231\072\012\040\040\055\040\150\164\164\160\163\072\057\057\147\151\164\150\165\142\056\143\157\155\057\122\165\142\171\115\145\164\162\151\143\057\143\150\163\162\143\057\167\151\153\151\012";
char RAWSTR_chsrc_last_message[] = "\012\040\040\040\052\040\347\262\276\345\207\206\346\265\213\351\200\237\072\040\350\203\275\347\234\237\345\256\236\345\217\215\346\230\240\344\275\240\346\234\252\346\235\245\344\275\277\347\224\250\350\257\245\350\265\204\346\272\220\346\227\266\347\232\204\351\200\237\345\272\246\357\274\214\345\233\240\344\270\272\345\256\203\347\233\264\346\216\245\346\265\213\351\207\217\344\275\240\345\205\263\346\263\250\347\232\204\351\202\243\344\270\252\350\265\204\346\272\220\343\200\202\012\040\040\040\052\040\346\250\241\347\263\212\346\265\213\351\200\237\072\040\344\273\205\344\273\243\350\241\250\350\257\245\351\225\234\345\203\217\347\253\231\346\217\220\344\276\233\346\234\215\345\212\241\347\232\204\344\270\200\344\270\252\345\217\257\350\203\275\351\200\237\345\272\246\343\200\202\345\233\240\350\200\214\345\217\257\350\203\275\344\274\232\345\207\272\347\216\260\346\265\213\351\200\237\346\225\260\345\200\274\350\276\203\351\253\230\357\274\214\344\275\206\345\256\236\351\231\205\344\275\277\347\224\250\344\275\223\351\252\214\344\270\215\344\275\263\347\232\204\347\216\260\350\261\241\343\200\202\012\345\275\223\344\275\240\351\201\207\345\210\260\346\250\241\347\263\212\346\265\213\351\200\237\346\227\266\357\274\214\350\257\267\345\260\275\345\217\257\350\203\275\345\220\221\346\210\221\344\273\254\346\217\220\344\272\244\345\207\206\347\241\256\347\232\204\346\265\213\351\200\237\351\223\276\346\216\245\072\040\143\150\163\162\143\040\151\163\163\165\145";
char RAWSTR_chsrc_op_epilogue[] = "\012\040\040\040\052\040\347\262\276\345\207\206\346\265\213\351\200\237\072\040\350\203\275\347\234\237\345\256\236\345\217\215\346\230\240\344\275\240\346\234\252\346\235\245\344\275\277\347\224\250\350\257\245\350\265\204\346\272\220\346\227\266\347\232\204\351\200\237\345\272\246\357\274\214\345\233\240\344\270\272\345\256\203\347\233\264\346\216\245\346\265\213\351\207\217\344\275\240\345\205\263\346\263\250\347\232\204\351\202\243\344\270\252\350\265\204\346\272\220\343\200\202\012\040\040\040\052\040\346\250\241\347\263\212\346\265\213\351\200\237\072\040\344\273\205\344\273\243\350\241\250\350\257\245\351\225\234\345\203\217\347\253\231\346\217\220\344\276\233\346\234\215\345\212\241\347\232\204\344\270\200\344\270\252\345\217\257\350\203\275\351\200\237\345\272\246\343\200\202\345\233\240\350\200\214\345\217\257\350\203\275\344\274\232\345\207\272\347\216\260\346\265\213\351\200\237\346\225\260\345\200\274\350\276\203\351\253\230\357\274\214\344\275\206\345\256\236\351\231\205\344\275\277\347\224\250\344\275\223\351\252\214\344\270\215\344\275\263\347\232\204\347\216\260\350\261\241\343\200\202\012\345\275\223\344\275\240\351\201\207\345\210\260\346\250\241\347\263\212\346\265\213\351\200\237\346\227\266\357\274\214\350\257\267\345\260\275\345\217\257\350\203\275\345\220\221\346\210\221\344\273\254\346\217\220\344\272\244\345\207\206\347\241\256\347\232\204\346\265\213\351\200\237\351\223\276\346\216\245\072\040\143\150\163\162\143\040\151\163\163\165\145";

View File

@ -2,10 +2,10 @@
! SPDX-License-Identifier: GPL-3.0-or-later
! -------------------------------------------------------------
! Config Type : rawstr4c (Markdown)
! Config Authors: Aoran Zeng <ccmywish@qq.com>
! Contributors : Nil Null <nil@null.org>
! Config Authors: 曾奥然 <ccmywish@qq.com>
! Contributors : Nil Null <nil@null.org>
! Created On : <2025-07-22>
! Last Modified : <2025-08-09>
! Last Modified : <2025-08-22>
! ---------------------------------------------------------- -->
# [rawstr4c] input for chsrc
@ -72,7 +72,7 @@
邀请您担任 Chef, 为用户把关您熟悉的 recipe
源代码地址: https://github.com/RubyMetric/chsrc
成为维护者: https://github.com/RubyMetric/chsrc/issues/130
成为维护者: https://github.com/RubyMetric/chsrc/issues/275
```
<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:
Source Code: @url@
Become a Maintainer: https://github.com/RubyMetric/chsrc/issues/130
Become a Maintainer: https://github.com/RubyMetric/chsrc/issues/275
```
<br>
@ -189,7 +189,7 @@ Written by Aoran Zeng, Heng Guo and contributors. (See chsrc-main.c)
## 最后告诉用户一些维护信息
- name = `last_message`
- name = `op_epilogue`
```

View File

@ -7,24 +7,22 @@ def_target(pl_clojure, "clojure/clojars/cloj/lein");
void
pl_clojure_prelude ()
{
use_this(pl_clojure);
chef_allow_s(pl_clojure);
chef_prep_this (pl_clojure, s);
chef_set_created_on (this, "2023-09-10");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2025-07-14");
chef_set_sources_last_updated (this, "2025-08-21");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 0);
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_forbid_english(this);
chef_allow_user_define(this);
def_sources_begin()
{&UpstreamProvider, NULL, DelegateToUpstream},
{&UpstreamProvider,"https://repo.clojars.org/", DelegateToUpstream},
{&MirrorZ, "https://mirrors.cernet.edu.cn/clojars/", DelegateToMirror},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/clojars/", DelegateToMirror},
{&Nju, "https://mirror.nju.edu.cn/clojars/", DelegateToMirror},
@ -38,7 +36,7 @@ pl_clojure_prelude ()
void
pl_clojure_setsrc (char *option)
{
use_this_source(pl_clojure);
chsrc_use_this_source (pl_clojure);
if (chsrc_in_local_mode())
{

View File

@ -7,19 +7,15 @@ def_target(pl_dart_flutter, "flutter");
void
pl_dart_flutter_prelude (void)
{
use_this(pl_dart_flutter);
chef_allow_gsr(pl_dart_flutter);
chef_prep_this (pl_dart_flutter, gsr);
chef_set_created_on (this, "2023-09-10");
chef_set_last_updated (this, "2025-07-11");
chef_set_sources_last_updated (this, "2025-04-15");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 2,
"czyt", "czyt.go@gmail.com",
"MadDogOwner", "xiaoran@xrgzs.top");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 2, "@czyt", "@xrgzs");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_allow_english(this);
@ -55,13 +51,13 @@ pl_dart_flutter_getsrc (char *option)
void
pl_dart_flutter_setsrc (char *option)
{
use_this_source(pl_dart_flutter);
chsrc_use_this_source (pl_dart_flutter);
char *w = NULL;
char *cmd = NULL;
if (xy_on_windows)
{
cmd = xy_strjoin (3, "setx FLUTTER_STORAGE_BASE_URL \"", source.url, "\"");
cmd = xy_strcat (3, "setx FLUTTER_STORAGE_BASE_URL \"", source.url, "\"");
chsrc_run (cmd, RunOpt_No_Last_New_Line);
}
else
@ -70,7 +66,7 @@ pl_dart_flutter_setsrc (char *option)
char *bashrc = xy_bashrc;
chsrc_backup (zshrc);
w = xy_strjoin (3, "export FLUTTER_STORAGE_BASE_URL=\"", source.url, "\"\n");
w = xy_strcat (3, "export FLUTTER_STORAGE_BASE_URL=\"", source.url, "\"\n");
chsrc_append_to_file (w, zshrc);
if (xy_file_exist (bashrc))

View File

@ -7,19 +7,15 @@ def_target(pl_dart, "dart/pub");
void
pl_dart_prelude (void)
{
use_this(pl_dart);
chef_allow_gsr(pl_dart);
chef_prep_this (pl_dart, gsr);
chef_set_created_on (this, "2023-09-10");
chef_set_last_updated (this, "2025-07-11");
chef_set_sources_last_updated (this, "2025-04-15");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 2,
"czyt", "czyt.go@gmail.com",
"MadDogOwner", "xiaoran@xrgzs.top");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 2, "@czyt", "@xrgzs");
chef_allow_local_mode (this, FullyCan, NULL, NULL);
chef_allow_english(this);
@ -51,13 +47,13 @@ pl_dart_getsrc (char *option)
void
pl_dart_setsrc (char *option)
{
use_this_source(pl_dart);
chsrc_use_this_source (pl_dart);
char *w = NULL;
char *cmd = NULL;
if (xy_on_windows)
{
cmd = xy_strjoin (3, "setx PUB_HOSTED_URL \"", source.url, "\"");
cmd = xy_strcat (3, "setx PUB_HOSTED_URL \"", source.url, "\"");
chsrc_run (cmd, RunOpt_No_Last_New_Line);
}
else
@ -66,7 +62,7 @@ pl_dart_setsrc (char *option)
char *bashrc = xy_bashrc;
chsrc_backup (zshrc);
w = xy_strjoin (3, "export PUB_HOSTED_URL=\"", source.url, "\"\n");
w = xy_strcat (3, "export PUB_HOSTED_URL=\"", source.url, "\"\n");
chsrc_append_to_file (w, zshrc);

View File

@ -21,19 +21,15 @@ def_target(pl_go, "go/golang/goproxy");
void
pl_go_prelude ()
{
use_this(pl_go);
chef_allow_gsr(pl_go);
chef_prep_this (pl_go, gsr);
chef_set_created_on (this, "2023-08-30");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2025-07-12");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 2,
"czyt", "czyt.go@gmail.com",
"Rui Yang", "techoc@foxmail.com");
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_forbid_english(this);
@ -84,12 +80,12 @@ pl_go_setsrc (char *option)
{
pl_go_check_cmd ();
use_this_source(pl_go);
chsrc_use_this_source (pl_go);
char *cmd = "go env -w GO111MODULE=on";
chsrc_run (cmd, RunOpt_Default);
cmd = xy_strjoin (3, "go env -w GOPROXY=", source.url, ",direct");
cmd = xy_strcat (3, "go env -w GOPROXY=", source.url, ",direct");
chsrc_run (cmd, RunOpt_Default);
chsrc_conclude (&source);

View File

@ -7,24 +7,22 @@ def_target(pl_haskell, "haskell/cabal/stack/hackage");
void
pl_haskell_prelude ()
{
use_this(pl_haskell);
chef_allow_s(pl_haskell);
chef_prep_this (pl_haskell, s);
chef_set_created_on (this, "2023-09-10");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2023-09-10");
chef_set_sources_last_updated (this, "2025-08-22");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 0);
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_forbid_english(this);
chef_allow_user_define(this);
def_sources_begin()
{&UpstreamProvider, NULL, DelegateToUpstream},
{&UpstreamProvider, "https://hackage.haskell.org", DelegateToUpstream},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/hackage", DelegateToMirror},
{&Bfsu, "https://mirrors.bfsu.edu.cn/hackage", DelegateToMirror},
{&Nju, "https://mirror.nju.edu.cn/hackage", DelegateToMirror},
@ -41,7 +39,7 @@ pl_haskell_prelude ()
void
pl_haskell_setsrc (char *option)
{
use_this_source(pl_haskell);
chsrc_use_this_source (pl_haskell);
char *content = xy_str_gsub (RAWSTR_pl_haskell_cabal_config, "@url@", source.url);
@ -55,12 +53,12 @@ pl_haskell_setsrc (char *option)
config = "~/.cabal/config";
}
chsrc_note2 (xy_strjoin (3, "请向 ", config, " 中手动添加:"));
chsrc_note2 (xy_strcat (3, "请向 ", config, " 中手动添加:"));
println (content);
config = xy_normalize_path ("~/.stack/config.yaml");
content = xy_str_gsub (RAWSTR_pl_haskell_stackage_yaml, "@url@", source.url);
chsrc_note2 (xy_strjoin (3, "请向 ", config, " 中手动添加:"));
chsrc_note2 (xy_strcat (3, "请向 ", config, " 中手动添加:"));
println (content);
chsrc_conclude (&source);

View File

@ -7,18 +7,15 @@ def_target(pl_java, "java/maven/mvn/maven-daemon/mvnd/gradle");
void
pl_java_prelude ()
{
use_this(pl_java);
chef_allow_gsr(pl_java);
chef_prep_this (pl_java, gsr);
chef_set_created_on (this, "2023-08-31");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2024-12-18");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 1,
"BingChunMoLi", "bingchunmoli@bingchunmoli.com");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 1, "@BingChunMoLi");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
@ -85,7 +82,6 @@ pl_java_find_maven_config ()
return "~/.m2/settings.xml";
}
char *
pl_java_find_maven_daemon_config ()
{
@ -114,12 +110,12 @@ pl_java_getsrc (char *option)
if (maven_exist)
{
char *maven_config = pl_java_find_maven_config ();
chsrc_note2 (xy_2strjoin ("请查看 ", maven_config));
chsrc_note2 (xy_2strcat ("请查看 ", maven_config));
}
if(maven_daemon_exist)
{
char *maven_config = pl_java_find_maven_daemon_config ();
chsrc_note2 (xy_2strjoin ("请查看 ", maven_config));
chsrc_note2 (xy_2strcat ("请查看 ", maven_config));
}
}
@ -137,7 +133,7 @@ pl_java_setsrc (char *option)
bool maven_exist, gradle_exist, maven_daemon_exist;
pl_java_check_cmd (&maven_exist, &gradle_exist, &maven_daemon_exist);
use_this_source(pl_java);
chsrc_use_this_source(pl_java);
use_custom_user_agent();
if (maven_exist)
{
@ -145,7 +141,7 @@ pl_java_setsrc (char *option)
file = xy_str_gsub (file, "@name@", source.mirror->name);
file = xy_str_gsub (file, "@url@", source.url);
char *maven_config = pl_java_find_maven_config ();
chsrc_note2 (xy_strjoin (3, "请在 maven 配置文件 ", maven_config, " 中添加:"));
chsrc_note2 (xy_strcat (3, "请在 maven 配置文件 ", maven_config, " 中添加:"));
println (file);
}

View File

@ -7,26 +7,21 @@ def_target(pl_js_bun, "bun");
void
pl_js_bun_prelude (void)
{
use_this(pl_js_bun);
chef_allow_gsr(pl_js_bun);
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_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 1,
"Lontten", "lontten@163.com");
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);
// 用的是 npm Registry 的源,所以使用 pl_js_group 的源
this->sources = pl_js_group_target.sources;
this->sources_n = pl_js_group_target.sources_n;
chef_use_other_target_sources (this, &pl_js_group_target);
}
/**
@ -62,7 +57,7 @@ pl_js_bun_setsrc (char *option)
}
else
{
chsrc_note2 (xy_strjoin (3, "请手动写入以下内容到 ", xy_normalize_path ("~/.bunfig.toml"), " 文件中"));
chsrc_note2 (xy_strcat (3, "请手动写入以下内容到 ", xy_normalize_path ("~/.bunfig.toml"), " 文件中"));
}
println (content);

View File

@ -70,8 +70,7 @@ pl_js_group_setsrc (char *option)
chsrc_set_target_group_mode ();
use_this(pl_js_group);
Source_t source = chsrc_yield_source_and_confirm (this, option);
chsrc_use_this_source (pl_js_group);
if (npm_exist)
{

View File

@ -7,26 +7,21 @@ def_target(pl_js_yarn, "yarn");
void
pl_js_yarn_prelude (void)
{
use_this(pl_js_yarn);
chef_allow_gsr(pl_js_yarn);
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_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 1,
"Mr. Will", "mr.will.com@outlook.com");
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);
// 使用 pl_js_group 的源
this->sources = pl_js_group_target.sources;
this->sources_n = pl_js_group_target.sources_n;
chef_use_other_target_sources (this, &pl_js_group_target);
}
static double
@ -68,9 +63,9 @@ pl_js_yarn_setsrc (char *option)
if (pl_js_yarn_get_yarn_version () >= 2)
{
if (chsrc_in_local_mode()) // Yarn 默认情况下就是基于本项目换源
cmd = xy_2strjoin ("yarn config set npmRegistryServer ", source.url);
cmd = xy_2strcat ("yarn config set npmRegistryServer ", source.url);
else
cmd = xy_2strjoin ("yarn config set npmRegistryServer --home ", source.url);
cmd = xy_2strcat ("yarn config set npmRegistryServer --home ", source.url);
chsrc_run (cmd, RunOpt_No_Last_New_Line);
}
@ -84,7 +79,7 @@ pl_js_yarn_setsrc (char *option)
return;
}
// 不再阻止换源命令输出到终端,即不再调用 xy_str_to_quietcmd()
cmd = xy_2strjoin ("yarn config set registry ", source.url);
cmd = xy_2strcat ("yarn config set registry ", source.url);
chsrc_run (cmd, RunOpt_No_Last_New_Line);
}

View File

@ -14,17 +14,16 @@ def_target(pl_js_group, "js/javascript/node/nodejs");
void
pl_js_group_prelude (void)
{
use_this(pl_js_group);
chef_allow_gsr(pl_js_group);
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_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 1, "happy game", "happygame1024@gmail.com");
chef_set_contributors (this,0);
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",
@ -45,22 +44,20 @@ pl_js_group_prelude (void)
def_target(pl_js_nodejs_binary, "__internal_use_nodejs_binary__");
def_target(pl_js_nodejs_binary, "__internal_target_nodejs_binary__");
void
pl_js_nodejs_binary_prelude (void)
{
use_this(pl_js_nodejs_binary);
chef_allow_gsr(pl_js_group);
chef_prep_this (pl_js_nodejs_binary, NOOP);
chef_set_created_on (this, "2023-09-09");
chef_set_last_updated (this, "2025-07-11");
chef_set_last_updated (this, "2025-08-22");
chef_set_sources_last_updated (this, "2025-07-11");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 0);
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);

View File

@ -7,26 +7,21 @@ def_target(pl_js_npm, "npm");
void
pl_js_npm_prelude (void)
{
use_this(pl_js_npm);
chef_allow_gsr(pl_js_npm);
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_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 1,
"Mr. Will", "mr.will.com@outlook.com");
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);
// 使用 pl_js_group 的源
this->sources = pl_js_group_target.sources;
this->sources_n = pl_js_group_target.sources_n;
chef_use_other_target_sources (this, &pl_js_group_target);
}
@ -50,9 +45,9 @@ pl_js_npm_setsrc (char *option)
char *cmd = NULL;
if (chsrc_in_local_mode())
cmd = xy_2strjoin ("npm config --location project set registry ", source.url);
cmd = xy_2strcat ("npm config --location project set registry ", source.url);
else
cmd = xy_2strjoin ("npm config set registry ", source.url);
cmd = xy_2strcat ("npm config set registry ", source.url);
chsrc_run (cmd, RunOpt_No_Last_New_Line);

View File

@ -7,17 +7,15 @@ def_target(pl_js_nvm, "nvm");
void
pl_js_nvm_prelude (void)
{
use_this(pl_js_nvm);
chef_allow_gsr(pl_js_nvm);
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_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 0);
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);
@ -25,9 +23,7 @@ pl_js_nvm_prelude (void)
chef_set_note (this, "nvm 不支持 Fish shell", "nvm does not support Fish");
// 使用 pl_js_nodejs_binary 的源
this->sources = pl_js_nodejs_binary_target.sources;
this->sources_n = pl_js_nodejs_binary_target.sources_n;
chef_use_other_target_sources (this, &pl_js_nodejs_binary_target);
}
@ -50,7 +46,7 @@ pl_js_nvm_setsrc (char *option)
{
Source_t source = chsrc_yield_source_and_confirm (&pl_js_nodejs_binary_target, option);
char *w = xy_strjoin (3, "export NVM_NODEJS_ORG_MIRROR=", source.url, "\n");
char *w = xy_strcat (3, "export NVM_NODEJS_ORG_MIRROR=", source.url, "\n");
char *zshrc = xy_zshrc;
char *bashrc = xy_bashrc;

View File

@ -7,25 +7,21 @@ def_target(pl_js_pnpm, "pnpm");
void
pl_js_pnpm_prelude (void)
{
use_this(pl_js_pnpm);
chef_allow_gsr(pl_js_pnpm);
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_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 0);
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);
// 使用 pl_js_group 的源
this->sources = pl_js_group_target.sources;
this->sources_n = pl_js_group_target.sources_n;
chef_use_other_target_sources (this, &pl_js_group_target);
}
@ -50,9 +46,9 @@ pl_js_pnpm_setsrc (char *option)
char *cmd = NULL;
if (chsrc_in_local_mode())
cmd = xy_2strjoin ("pnpm config --location project set registry ", source.url);
cmd = xy_2strcat ("pnpm config --location project set registry ", source.url);
else
cmd = xy_2strjoin ("pnpm config -g set registry ", source.url);
cmd = xy_2strcat ("pnpm config -g set registry ", source.url);
chsrc_run (cmd, RunOpt_No_Last_New_Line);

View File

@ -7,24 +7,22 @@ def_target(pl_julia, "julia");
void
pl_julia_prelude ()
{
use_this(pl_julia);
chef_allow_gs(pl_julia);
chef_prep_this (pl_julia, gs);
chef_set_created_on (this, "2023-08-31");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2025-07-14");
chef_set_sources_last_updated (this, "2025-08-22");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 0);
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, NULL, DelegateToUpstream},
{&UpstreamProvider, "https://pkg.julialang.org", DelegateToUpstream},
{&Pku, "https://mirrors.pku.edu.cn/julia", DelegateToMirror},
{&Nju, "https://mirror.nju.edu.cn/julia", DelegateToMirror},
{&Iscas, "https://mirror.iscas.ac.cn/julia", DelegateToMirror}
@ -54,9 +52,9 @@ pl_julia_getsrc (char *option)
void
pl_julia_setsrc (char *option)
{
use_this_source(pl_julia);
chsrc_use_this_source (pl_julia);
char *w = xy_strjoin (3, "ENV[\"JULIA_PKG_SERVER\"] = \"", source.url, "\"");
char *w = xy_strcat (3, "ENV[\"JULIA_PKG_SERVER\"] = \"", source.url, "\"");
chsrc_append_to_file (w, PL_Julia_Config);

View File

@ -14,24 +14,22 @@ def_target(pl_lua, "lua/luarocks");
void
pl_lua_prelude ()
{
use_this(pl_lua);
chef_allow_gs(pl_lua);
chef_prep_this (pl_lua, gs);
chef_set_created_on (this, "2023-09-27");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2025-07-14");
chef_set_sources_last_updated (this, "2025-08-22");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 0);
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_forbid_english(this);
chef_allow_user_define(this);
def_sources_begin()
{&UpstreamProvider, NULL, DelegateToUpstream},
{&UpstreamProvider, "https://luarocks.org", DelegateToUpstream},
{&Api7, "https://luarocks.cn", DelegateToMirror}
def_sources_end()
}
@ -50,17 +48,16 @@ pl_lua_getsrc (char *option)
void
pl_lua_setsrc (char *option)
{
use_this(pl_lua);
Source_t source = chsrc_yield_source_and_confirm (this, option);
chsrc_use_this_source (pl_lua);
char *config = xy_strjoin (3, "rocks_servers = {\n"
char *config = xy_strcat (3, "rocks_servers = {\n"
" \"", source.url, "\"\n"
"}");
chsrc_note2 ("请手动修改 ~/.luarocks/config.lua 文件 (用于下载):");
println (config);
char *upload_config = xy_strjoin (3, "key = \"<Your API Key>\"\n"
char *upload_config = xy_strcat (3, "key = \"<Your API Key>\"\n"
"server = \"", source.url, "\"");
chsrc_note2 ("请手动修改 ~/.luarocks/upload_config.lua 文件 (用于上传):");

View File

@ -7,17 +7,15 @@ def_target(pl_nuget, "nuget/net/.net/dotnet");
void
pl_nuget_prelude ()
{
use_this(pl_nuget);
chef_allow_gs(pl_nuget);
chef_prep_this (pl_nuget, gs);
chef_set_created_on (this, "2023-09-10");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2024-04-18");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 0);
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_forbid_english(this);

View File

@ -7,17 +7,15 @@ def_target(pl_ocaml, "ocaml/opam");
void
pl_ocaml_prelude ()
{
use_this(pl_ocaml);
chef_allow_gs(pl_ocaml);
chef_prep_this (pl_ocaml, gs);
chef_set_created_on (this, "2023-09-15");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2025-07-14");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 0);
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_forbid_english(this);
@ -53,16 +51,16 @@ pl_ocaml_setsrc (char *option)
{
pl_ocaml_check_cmd ();
use_this_source(pl_ocaml);
chsrc_use_this_source (pl_ocaml);
char *cmd = xy_strjoin (3, "opam repo set-url default ",
char *cmd = xy_strcat (3, "opam repo set-url default ",
source.url,
" --all --set-default");
chsrc_run (cmd, RunOpt_Default);
chsrc_alert2 ("如果是首次使用 opam ,请使用以下命令进行初始化");
println (xy_2strjoin ("opam init default ", source.url));
println (xy_2strcat ("opam init default ", source.url));
chsrc_conclude (&source);
}

View File

@ -7,17 +7,15 @@ def_target(pl_php, "php/composer");
void
pl_php_prelude ()
{
use_this(pl_php);
chef_allow_gs(pl_php);
chef_prep_this (pl_php, gs);
chef_set_created_on (this, "2023-08-30");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2024-09-14");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 0);
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_forbid_english(this);
@ -57,8 +55,7 @@ pl_php_setsrc (char *option)
{
pl_php_check_cmd ();
use_this(pl_php);
Source_t source = chsrc_yield_source_and_confirm (this, option);
chsrc_use_this_source (pl_php);
char *where = " -g ";
if (chsrc_in_local_mode())
@ -66,7 +63,7 @@ pl_php_setsrc (char *option)
where = " ";
}
char *cmd = xy_strjoin (4, "composer config", where, "repo.packagist composer ", source.url);
char *cmd = xy_strcat (4, "composer config", where, "repo.packagist composer ", source.url);
chsrc_run (cmd, RunOpt_Default);
chsrc_conclude (&source);

View File

@ -7,24 +7,22 @@ def_target(pl_perl, "perl/cpan");
void
pl_perl_prelude ()
{
use_this(pl_perl);
chef_allow_gs(pl_perl);
chef_prep_this (pl_perl, gs);
chef_set_created_on (this, "2023-09-31");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2024-05-24");
chef_set_sources_last_updated (this, "2025-08-21");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 0);
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_forbid_english(this);
chef_allow_user_define(this);
def_sources_begin()
{&UpstreamProvider, NULL, DelegateToUpstream},
{&UpstreamProvider, "https://www.cpan.org/", DelegateToUpstream},
{&Bfsu, "https://mirrors.bfsu.edu.cn/CPAN/", DelegateToMirror},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/CPAN/", DelegateToMirror},
{&Bjtu, "https://mirror.bjtu.edu.cn/cpan/", DelegateToMirror},
@ -59,9 +57,9 @@ pl_perl_getsrc (char *option)
void
pl_perl_setsrc (char *option)
{
use_this_source(pl_perl);
chsrc_use_this_source (pl_perl);
char *cmd = xy_strjoin (3,
char *cmd = xy_strcat (3,
"perl -MCPAN -e \"CPAN::HandleConfig->load(); CPAN::HandleConfig->edit('urllist', 'unshift', '", source.url, "'); CPAN::HandleConfig->commit()\"");
chsrc_run (cmd, RunOpt_Default);

View File

@ -7,25 +7,21 @@ def_target(pl_python_pdm, "pdm");
void
pl_python_pdm_prelude (void)
{
use_this(pl_python_pdm);
chef_allow_gsr(pl_python_pdm);
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_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 0);
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 0);
chef_allow_local_mode (this, FullyCan, "支持项目级配置", "Supports project-level configuration");
chef_allow_local_mode (this, FullyCan, NULL, NULL);
chef_allow_english(this);
chef_allow_user_define(this);
// 使用 pl_python_group 的源
this->sources = pl_python_group_target.sources;
this->sources_n = pl_python_group_target.sources_n;
chef_use_other_target_sources (this, &pl_python_group_target);
}
@ -52,9 +48,9 @@ pl_python_pdm_setsrc (char *option)
char *cmd = NULL;
if (chsrc_in_local_mode())
cmd = xy_2strjoin ("pdm config --local pypi.url ", source.url);
cmd = xy_2strcat ("pdm config --local pypi.url ", source.url);
else
cmd = xy_2strjoin ("pdm config --global pypi.url ", source.url);
cmd = xy_2strcat ("pdm config --global pypi.url ", source.url);
chsrc_run (cmd, RunOpt_No_Last_New_Line);

View File

@ -7,25 +7,21 @@ def_target(pl_python_poetry, "poetry");
void
pl_python_poetry_prelude (void)
{
use_this(pl_python_poetry);
chef_allow_gsr(pl_python_poetry);
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_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 0);
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);
// 使用 pl_python_group 的源
this->sources = pl_python_group_target.sources;
this->sources_n = pl_python_group_target.sources_n;
chef_use_other_target_sources (this, &pl_python_group_target);
}
void
@ -50,7 +46,7 @@ pl_python_poetry_setsrc (char *option)
if (!chsrc_in_local_mode())
chsrc_alert2 ("Poetry 仅支持项目级换源");
cmd = xy_2strjoin ("poetry source add my_mirror ", source.url);
cmd = xy_2strcat ("poetry source add my_mirror ", source.url);
chsrc_run (cmd, RunOpt_No_Last_New_Line);
if (chsrc_in_standalone_mode())

View File

@ -58,8 +58,7 @@ pl_python_group_setsrc (char *option)
chsrc_set_target_group_mode ();
use_this(pl_python_group);
Source_t source = chsrc_yield_source_and_confirm (this, option);
chsrc_use_this_source (pl_python_group);
// 交给后面检查命令的存在性

View File

@ -9,25 +9,21 @@ def_target(pl_python_rye, "rye");
void
pl_python_rye_prelude (void)
{
use_this(pl_python_rye);
chef_allow_gsr(pl_python_rye);
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_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 0);
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 0);
chef_allow_local_mode (this, FullyCan, "支持项目级配置", "Supports project-level configuration");
chef_allow_local_mode (this, FullyCan, NULL, NULL);
chef_allow_english(this);
chef_allow_user_define(this);
// 使用 pl_python_group 的源
this->sources = pl_python_group_target.sources;
this->sources_n = pl_python_group_target.sources_n;
chef_use_other_target_sources (this, &pl_python_group_target);
}
char *
@ -45,7 +41,7 @@ void
pl_python_rye_getsrc (char *option)
{
char *rye_config = pl_python_find_rye_config ();
chsrc_note2 (xy_strjoin (3, "请查看 ", rye_config, " 配置文件中的 [[sources]] 节内容"));
chsrc_note2 (xy_strcat (3, "请查看 ", rye_config, " 配置文件中的 [[sources]] 节内容"));
}
@ -64,7 +60,7 @@ pl_python_rye_setsrc (char *option)
content = xy_str_gsub (content, "@2@", source.url);
char *rye_config = pl_python_find_rye_config ();
chsrc_note2 (xy_strjoin (3, "请在配置文件 ", rye_config, " 中添加:"));
chsrc_note2 (xy_strcat (3, "请在配置文件 ", rye_config, " 中添加:"));
println (content);
chsrc_determine_chgtype (ChgType_Manual);

View File

@ -14,7 +14,7 @@ static char *
pl_python_speed_url_constructor (const char *url, const char *user_data)
{
char *str = xy_str_delete_suffix (url, "/simple");
str = xy_2strjoin (str, "/packages/56/e4/55aaac2b15af4dad079e5af329a79d961e5206589d0e02b1e8da221472ed/tensorflow-2.18.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl");
str = xy_2strcat (str, "/packages/56/e4/55aaac2b15af4dad079e5af329a79d961e5206589d0e02b1e8da221472ed/tensorflow-2.18.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl");
return str;
}
@ -22,19 +22,16 @@ pl_python_speed_url_constructor (const char *url, const char *user_data)
void
pl_python_group_prelude (void)
{
use_this(pl_python_group);
chef_allow_gsr(pl_python_group);
chef_prep_this (pl_python_group, gsr);
chef_set_created_on (this, "2023-09-03");
chef_set_last_updated (this, "2025-07-14");
chef_set_sources_last_updated (this, "2025-07-11");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 1, "happy game", "happygame1024@gmail.com");
chef_set_contributors (this, 1,
"yongxiang", "1926885268@qq.com");
chef_set_chef (this, "@happy-game");
// 组换源的 leader target 应把所有 follower target 的贡献者都记录过来
chef_set_cooks (this, 2, "@ccmywish", "@happy-game");
chef_set_sauciers (this, 2, "@xyx1926885268", "@Kattos");
chef_allow_local_mode (this, PartiallyCan, "部分包管理器支持项目级换源", "Some package managers support project-level source changing");
chef_allow_english(this);
@ -76,7 +73,7 @@ pl_python_check_unofficial_pkger (bool *poetry_exist, bool *pdm_exist, bool *uv_
/**
* @param[out] prog Python NULL
* @param[out] prog_name Python NULL
*/
void
pl_python_get_py_program_name (char **prog_name)

View File

@ -7,25 +7,21 @@ def_target(pl_python_pip, "pip");
void
pl_python_pip_prelude (void)
{
use_this(pl_python_pip);
chef_allow_gsr(pl_python_pip);
chef_prep_this (pl_python_pip, gsr);
chef_set_created_on (this, "2023-09-03");
chef_set_last_updated (this, "2025-07-11");
chef_set_sources_last_updated (this, "2025-07-11");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 0);
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);
// 使用 pl_python_group 的源
this->sources = pl_python_group_target.sources;
this->sources_n = pl_python_group_target.sources_n;
chef_use_other_target_sources (this, &pl_python_group_target);
}
@ -35,7 +31,7 @@ pl_python_pip_getsrc (char *option)
char *py_prog_name = NULL;
pl_python_get_py_program_name (&py_prog_name);
char *cmd = xy_2strjoin (py_prog_name, " -m pip config get global.index-url");
char *cmd = xy_2strcat (py_prog_name, " -m pip config get global.index-url");
chsrc_run (cmd, RunOpt_Default);
}
@ -65,7 +61,7 @@ pl_python_pip_setsrc (char *option)
// 这里用的是 config --user会写入用户目录而不是项目目录
// https://github.com/RubyMetric/chsrc/issues/39
// 经测试Windows上调用换源命令会写入 C:\Users\RubyMetric\AppData\Roaming\pip\pip.ini
char *cmd = xy_2strjoin (py_prog_name, xy_2strjoin (" -m pip config --user set global.index-url ", source.url));
char *cmd = xy_2strcat (py_prog_name, xy_2strcat (" -m pip config --user set global.index-url ", source.url));
chsrc_run (cmd, RunOpt_No_Last_New_Line);
if (chsrc_in_standalone_mode())

View File

@ -7,27 +7,21 @@ def_target(pl_python_uv, "uv");
void
pl_python_uv_prelude (void)
{
use_this(pl_python_uv);
chef_allow_gsr(pl_python_uv);
chef_prep_this (pl_python_uv, gsr);
chef_set_created_on (this, "2024-12-11");
chef_set_last_updated (this, "2025-08-09");
chef_set_sources_last_updated (this, "2025-08-09");
chef_set_authors (this, 1, "happy game", "happygame1024@gmail.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 2,
"ccy", "icuichengyi@gmail.com",
"Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@happy-game");
chef_set_sauciers (this, 2, "@Kattos", "@ccmywish");
chef_allow_local_mode (this, FullyCan, NULL, NULL);
chef_allow_english(this);
chef_allow_user_define(this);
// 使用 pl_python_group 的源
this->sources = pl_python_group_target.sources;
this->sources_n = pl_python_group_target.sources_n;
chef_use_other_target_sources (this, &pl_python_group_target);
}
@ -51,7 +45,7 @@ pl_python_find_uv_config (bool mkdir)
{
if (chsrc_in_local_mode())
{
return xy_2strjoin (PL_Python_uv_Local_ConfigPath, PL_Python_uv_ConfigFile);
return xy_2strcat (PL_Python_uv_Local_ConfigPath, PL_Python_uv_ConfigFile);
}
else
{
@ -66,12 +60,12 @@ pl_python_find_uv_config (bool mkdir)
return NULL;
}
char *config_dir = xy_2strjoin(appdata, "\\uv\\");
char *config_dir = xy_2strcat(appdata, "\\uv\\");
if (mkdir)
{
chsrc_ensure_dir (config_dir);
}
return xy_2strjoin (config_dir, PL_Python_uv_ConfigFile);
return xy_2strcat (config_dir, PL_Python_uv_ConfigFile);
}
else
{
@ -80,7 +74,7 @@ pl_python_find_uv_config (bool mkdir)
{
chsrc_ensure_dir (PL_Python_uv_User_ConfigPath);
}
return xy_2strjoin (PL_Python_uv_User_ConfigPath, PL_Python_uv_ConfigFile);
return xy_2strcat (PL_Python_uv_User_ConfigPath, PL_Python_uv_ConfigFile);
}
}
}
@ -125,7 +119,7 @@ pl_python_uv_setsrc (char *option)
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)
#if defined(XY_Build_On_macOS) || defined(XY_Build_On_BSD)
char *sed_cmd = "sed -i '' ";
#else
char *sed_cmd = "sed -i ";

View File

@ -7,17 +7,15 @@ def_target(pl_r, "r/cran");
void
pl_r_prelude ()
{
use_this(pl_r);
chef_allow_gs(pl_r);
chef_prep_this (pl_r, gs);
chef_set_created_on (this, "2023-09-21");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2023-09-04");
chef_set_sources_last_updated (this, "2025-08-21");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 0);
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_forbid_english(this);
@ -25,7 +23,7 @@ pl_r_prelude ()
// 以下注释的是不含有bioconductor的镜像站我们在换cran的同时也直接帮助用户换bioconductor
def_sources_begin()
{&UpstreamProvider, NULL, DelegateToUpstream},
{&UpstreamProvider, "https://cran.r-project.org/", DelegateToUpstream},
{&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/cran/", DelegateToMirror},
// {&Ali, "https://mirrors.aliyun.com/CRAN/", DelegateToMirror},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/CRAN/", DelegateToMirror},
@ -64,15 +62,15 @@ pl_r_getsrc (char *option)
void
pl_r_setsrc (char *option)
{
use_this_source(pl_r);
chsrc_use_this_source (pl_r);
char *bioconductor_url = xy_str_delete_suffix (xy_str_delete_suffix (source.url, "cran/"), "CRAN/");
bioconductor_url = xy_2strjoin(bioconductor_url, "bioconductor");
bioconductor_url = xy_2strcat(bioconductor_url, "bioconductor");
const char *w1 = xy_strjoin (3, "options(\"repos\" = c(CRAN=\"", source.url, "\"))\n" );
const char *w2 = xy_strjoin (3, "options(BioC_mirror=\"", bioconductor_url, "\")\n" );
const char *w1 = xy_strcat (3, "options(\"repos\" = c(CRAN=\"", source.url, "\"))\n" );
const char *w2 = xy_strcat (3, "options(BioC_mirror=\"", bioconductor_url, "\")\n" );
char *w = xy_2strjoin (w1, w2);
char *w = xy_2strcat (w1, w2);
// 或者我们调用 r.exe --slave -e 上面的内容

View File

@ -14,17 +14,15 @@ def_target(pl_ruby, "gem/ruby/rb/rubygem/rubygems/bundler");
void
pl_ruby_prelude (void)
{
use_this(pl_ruby);
chef_allow_gsr(pl_ruby);
chef_prep_this (pl_ruby, gsr);
chef_set_created_on (this, "2023-08-29");
chef_set_last_updated (this, "2025-08-11");
chef_set_sources_last_updated (this, "2024-12-18");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, "Aoran Zeng", "ccmywish@qq.com");
chef_set_cooks (this, 0);
chef_set_contributors (this, 0);
chef_set_chef (this, "@ccmywish");
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 0);
chef_allow_local_mode (this, PartiallyCan, "支持 bundler. 不支持 gem", "Support bundler. Not support gem");
chef_allow_english(this);
@ -58,7 +56,7 @@ pl_ruby_remove_gem_source (const char *source)
char *cmd = NULL;
if (chef_is_url (source))
{
cmd = xy_2strjoin ("gem sources -r ", source);
cmd = xy_2strcat ("gem sources -r ", source);
chsrc_run (cmd, RunOpt_Default);
}
return false
@ -72,14 +70,14 @@ pl_ruby_setsrc (char *option)
{
chsrc_ensure_program ("gem");
use_this_source(pl_ruby);
chsrc_use_this_source (pl_ruby);
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_2strjoin ("gem source -a ", source.url);
cmd = xy_2strcat ("gem source -a ", source.url);
chsrc_run (cmd, RunOpt_Default);
// 我们在 step1 中,把源全部清空了,但是现在 RubyGems 的行为是: 当清空会自动给你把默认源给加回来
@ -95,7 +93,7 @@ pl_ruby_setsrc (char *option)
where = " --local ";
}
cmd = xy_strjoin (4, "bundle config", where, "'mirror.https://rubygems.org' ", source.url);
cmd = xy_strcat (4, "bundle config", where, "'mirror.https://rubygems.org' ", source.url);
chsrc_run (cmd, RunOpt_No_Last_New_Line);
chsrc_determine_chgtype (ChgType_Auto);

View File

@ -7,19 +7,15 @@ def_target(pl_rust_cargo, "rust/cargo/crate/crates");
void
pl_rust_cargo_prelude (void)
{
use_this(pl_rust_cargo);
chef_allow_gsr(pl_rust_cargo);
chef_prep_this (pl_rust_cargo, gsr);
chef_set_created_on (this, "2023-08-30");
chef_set_last_updated (this, "2025-07-22");
chef_set_sources_last_updated (this, "2025-06-18");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 1,
"Mikachu2333", "mikachu.23333@zohomail.com");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 1, "@Mikachu2333");
chef_allow_local_mode (this, PartiallyCan, "可以基于本项目换源吗?请帮助确认", "Can it change sources based on this project? Please help confirm");
chef_forbid_english (this);
@ -66,13 +62,13 @@ pl_rust_cargo_getsrc (char *option)
void
pl_rust_cargo_setsrc (char *option)
{
use_this_source(pl_rust_cargo);
chsrc_use_this_source (pl_rust_cargo);
char *content = RAWSTR_pl_rust_cargo_config;
content = xy_str_gsub (content, "@url@", source.url);
chsrc_note2 (xy_strjoin (3, "请手动写入以下内容到 ", xy_normalize_path ("~/.cargo/config.toml"), " 文件中:"));
chsrc_note2 (xy_strcat (3, "请手动写入以下内容到 ", xy_normalize_path ("~/.cargo/config.toml"), " 文件中:"));
println (content);
chsrc_determine_chgtype (ChgType_Auto);

View File

@ -10,19 +10,15 @@ def_target(pl_rust_rustup, "rustup");
void
pl_rust_rustup_prelude (void)
{
use_this(pl_rust_rustup);
chef_allow_gsr(pl_rust_rustup);
chef_prep_this (pl_rust_rustup, gsr);
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_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 2,
"Yangmoooo", "yangmoooo@outlook.com",
"Mikachu2333", "mikachu.23333@zohomail.com");
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_forbid_english (this);
@ -60,22 +56,22 @@ pl_rust_rustup_getsrc (char *option)
void
pl_rust_rustup_setsrc (char *option)
{
use_this_source(pl_rust_rustup);
chsrc_use_this_source (pl_rust_rustup);
#ifdef XY_On_Windows
#ifdef XY_Build_On_Windows
char *cmd1 = xy_strjoin (3, "setx RUSTUP_DIST_SERVER \"", source.url, "\"");
char *cmd2 = xy_strjoin (3, "setx RUSTUP_UPDATE_ROOT \"", source.url, "/rustup\"");
char *cmd1 = xy_strcat (3, "setx RUSTUP_DIST_SERVER \"", source.url, "\"");
char *cmd2 = xy_strcat (3, "setx RUSTUP_UPDATE_ROOT \"", source.url, "/rustup\"");
char *cmd = xy_strjoin (3, cmd1, " & ", cmd2);
char *cmd = xy_strcat (3, cmd1, " & ", cmd2);
chsrc_run (cmd, RunOpt_Dont_Notify_On_Success|RunOpt_No_Last_New_Line);
#else
char *w1 = xy_strjoin (3, "export RUSTUP_DIST_SERVER=\"", source.url, "\"\n");
char *w2 = xy_strjoin (3, "export RUSTUP_UPDATE_ROOT=\"", source.url, "/rustup\"\n");
char *w1 = xy_strcat (3, "export RUSTUP_DIST_SERVER=\"", source.url, "\"\n");
char *w2 = xy_strcat (3, "export RUSTUP_UPDATE_ROOT=\"", source.url, "/rustup\"\n");
char *w = xy_2strjoin (w1, w2);
char *w = xy_2strcat (w1, w2);
char *bashrc = xy_bashrc;
if (xy_file_exist (bashrc))
@ -94,10 +90,10 @@ pl_rust_rustup_setsrc (char *option)
char *fishrc = xy_fishrc;
if (xy_file_exist (fishrc))
{
char *w1 = xy_strjoin (3, "set -x RUSTUP_DIST_SERVER ", source.url, "\n");
char *w2 = xy_strjoin (3, "set -x RUSTUP_UPDATE_ROOT ", source.url, "/rustup\n");
char *w1 = xy_strcat (3, "set -x RUSTUP_DIST_SERVER ", source.url, "\n");
char *w2 = xy_strcat (3, "set -x RUSTUP_UPDATE_ROOT ", source.url, "/rustup\n");
char *w = xy_2strjoin (w1, w2);
char *w = xy_2strcat (w1, w2);
chsrc_backup (fishrc);
chsrc_append_to_file (w, fishrc);

View File

@ -1,102 +1,192 @@
/** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* File Authors : <ccmywish@qq.com>
* Contributors : Mikachu2333 <mikachu.23333@zohomail.com>
* |
* Created On : <2023-09-01>
* Major Revision : 3
* Last Modified : <2025-08-10>
* Major Revision : 5
* Last Modified : <2025-08-22>
* ------------------------------------------------------------*/
#define t(o) &o##_target, &o##_prelude
#include "lang/rawstr4c.h"
TargetRegisterInfo_t
chsrc_pl_menu[] =
#include "lang/Ruby/Ruby.c"
#include "lang/Python/common.h"
#include "lang/Python/pip.c"
#include "lang/Python/Poetry.c"
#include "lang/Python/PDM.c"
#include "lang/Python/Rye.c"
#include "lang/Python/uv.c"
#include "lang/Python/Python.c"
#include "lang/JavaScript/common.h"
#include "lang/JavaScript/npm.c"
#include "lang/JavaScript/pnpm.c"
#include "lang/JavaScript/Yarn.c"
#include "lang/JavaScript/JavaScript.c"
#include "lang/JavaScript/Bun.c"
#include "lang/JavaScript/nvm.c"
#include "lang/Perl.c"
#include "lang/PHP.c"
#include "lang/Lua.c"
#include "lang/Go.c"
#include "lang/Java.c"
#include "lang/Rust/common.h"
#include "lang/Rust/rustup.c"
#include "lang/Rust/Cargo.c"
#include "lang/Dart/common.h"
#include "lang/Dart/Pub.c"
#include "lang/Dart/Flutter.c"
#include "lang/Haskell.c"
#include "lang/OCaml.c"
#include "lang/R.c"
#include "lang/Julia.c"
#include "lang/NuGet.c"
#include "lang/Clojure.c"
#include "os/rawstr4c.h"
#include "os/APT/common.h"
// Debian-based
#include "os/APT/Debian.c"
#include "os/APT/Ubuntu.c"
#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 ()
{
{t(pl_ruby)},
{t(pl_python_group)},
{t(pl_python_pip)},
{t(pl_python_poetry)},
{t(pl_python_pdm)},
{t(pl_python_rye)},
{t(pl_python_uv)},
{t(pl_js_group)},
{t(pl_js_bun)},
{t(pl_js_npm)},
{t(pl_js_yarn)},
{t(pl_js_pnpm)},
{t(pl_js_nvm)},
{t(pl_perl)},
{t(pl_php)},
{t(pl_lua)},
{t(pl_go)},
{t(pl_rust_cargo)},
{t(pl_rust_rustup)},
{t(pl_java)},
{t(pl_clojure)},
{t(pl_dart)},
{t(pl_dart_flutter)},
{t(pl_nuget)},
{t(pl_haskell)},
{t(pl_ocaml)},
{t(pl_r)},
{t(pl_julia)},
};
#define add(t) xy_seq_push(ProgStore.pl, &pl_##t##_target); (&pl_##t##_target)->preludefn = pl_##t##_prelude
add (ruby);
add (python_group);
add (python_pip);
add (python_poetry);
add (python_pdm);
add (python_rye);
add (python_uv);
add (js_group);
add (js_bun);
add (js_npm);
add (js_yarn);
add (js_pnpm);
add (js_nvm);
add (perl);
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
add (winget);
add (homebrew);
add (cocoapods);
add (docker);
add (flatpak);
add (nix);
add (guix);
add (emacs);
add (tex);
add (anaconda);
#undef add
TargetRegisterInfo_t
chsrc_os_menu[] =
{
{t(os_ubuntu)},
{t(os_linuxmint)},
{t(os_debian)},
{t(os_fedora)},
{t(os_opensuse)},
{t(os_kali)},
{t(os_msys2)},
{t(os_arch)},
{t(os_archlinuxcn)},
{t(os_manjaro)},
{t(os_gentoo)},
{t(os_rockylinux)},
{t(os_almalinux)},
{t(os_alpine)},
{t(os_voidlinux)},
{t(os_solus)},
{t(os_trisquel)},
{t(os_linuxlite)},
{t(os_ros)},
{t(os_raspberrypi)},
{t(os_armbian)},
{t(os_openwrt)},
{t(os_termux)},
{t(os_openkylin)},
{t(os_openeuler)},
{t(os_anolis)},
{t(os_deepin)},
{t(os_freebsd)},
{t(os_netbsd)},
{t(os_openbsd)},
};
TargetRegisterInfo_t
chsrc_wr_menu[] =
{
{t(wr_winget)},
{t(wr_homebrew)},
{t(wr_cocoapods)},
{t(wr_docker)},
{t(wr_flatpak)},
{t(wr_nix)},
{t(wr_guix)},
{t(wr_emacs)},
{t(wr_tex)},
{t(wr_anaconda)},
};
#undef t
// Internal Target 不会由用户使用,需要特殊对待
pl_js_nodejs_binary_target.preludefn = pl_js_nodejs_binary_prelude;
}

View File

@ -7,19 +7,15 @@ def_target(os_armbian, "armbian");
void
os_armbian_prelude ()
{
use_this(os_armbian);
chef_allow_gsr(os_armbian);
chef_prep_this (os_armbian, gsr);
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_authors (this, 1, "Shengwei Chen", "414685209@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 2,
"Aoran Zeng", "ccmywish@qq.com",
"Yangmoooo", "yangmoooo@outlook.com");
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_forbid_english(this);
@ -64,11 +60,11 @@ os_armbian_setsrc (char *option)
{
chsrc_ensure_root ();
use_this_source(os_armbian);
chsrc_use_this_source (os_armbian);
chsrc_backup (OS_Armbian_SourceList);
char *cmd = xy_strjoin (3, "sed -E -i 's@https?[^ ]*armbian/?[^ ]*@", source.url,
char *cmd = xy_strcat (3, "sed -E -i 's@https?[^ ]*armbian/?[^ ]*@", source.url,
"@g' " OS_Armbian_SourceList);
chsrc_run (cmd, RunOpt_Default);

View File

@ -7,20 +7,15 @@ def_target(os_debian, "debian");
void
os_debian_prelude ()
{
use_this(os_debian);
chef_allow_gsr(os_debian);
chef_prep_this (os_debian, gsr);
chef_set_created_on (this, "2023-09-02");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2025-07-11");
chef_set_authors (this, 2,
"Aoran Zeng", "ccmywish@qq.com",
"Heng Guo", "2085471348@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 1,
"Yangmoooo", "yangmoooo@outlook.com");
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_forbid_english(this);
@ -77,7 +72,7 @@ static bool
os_debian_does_old_sourcelist_use_cdrom (void)
{
/* 我们只检查旧版sourcelist因为 common.h 中的填充只支持旧版 */
char *cmd = xy_2strjoin ("grep -q '^deb cdrom:' ", OS_Debian_old_SourceList);
char *cmd = xy_2strcat ("grep -q '^deb cdrom:' ", OS_Debian_old_SourceList);
int ret = system (cmd);
bool use_cdrom = ret == 0;
@ -88,15 +83,15 @@ os_debian_does_old_sourcelist_use_cdrom (void)
void
os_debian_setsrc_for_deb822 (char *option)
{
use_this_source(os_debian);
chsrc_use_this_source (os_debian);
chsrc_backup (OS_Debian_SourceList_DEB822);
char *cmd = xy_strjoin (3, "sed -E -i 's@https?://.*/debian/?@", source.url, "@g' " OS_Debian_SourceList_DEB822);
char *cmd = xy_strcat (3, "sed -E -i 's@https?://.*/debian/?@", source.url, "@g' " OS_Debian_SourceList_DEB822);
chsrc_run (cmd, RunOpt_Default);
/* debian-security 源和其他源不一样 */
cmd = xy_strjoin (3, "sed -E -i 's@https?://.*/debian-security/?@", source.url, "-security@g' " OS_Debian_SourceList_DEB822);
cmd = xy_strcat (3, "sed -E -i 's@https?://.*/debian-security/?@", source.url, "-security@g' " OS_Debian_SourceList_DEB822);
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
@ -149,7 +144,7 @@ os_debian_setsrc (char *option)
}
}
use_this_source(os_debian);
chsrc_use_this_source (os_debian);
chsrc_alert2 ("如果遇到无法拉取 HTTPS 源的情况,请手动运行:");
say ("apt install apt-transport-https ca-certificates");
@ -160,7 +155,7 @@ os_debian_setsrc (char *option)
chsrc_backup (OS_Debian_old_SourceList);
}
char *cmd = xy_strjoin (3, "sed -E -i \'s@https?://.*/debian/?@", source.url, "@g\' " OS_Debian_old_SourceList);
char *cmd = xy_strcat (3, "sed -E -i \'s@https?://.*/debian/?@", source.url, "@g\' " OS_Debian_old_SourceList);
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);

View File

@ -7,19 +7,15 @@ def_target(os_kali, "kali");
void
os_kali_prelude ()
{
use_this(os_kali);
chef_allow_gsr(os_kali);
chef_prep_this (os_kali, gsr);
chef_set_created_on (this, "2023-09-29");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2025-06-20");
chef_set_authors (this, 1, "Heng Guo", "2085471348@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 2,
"Yangmoooo", "yangmoooo@outlook.com",
"Happy Game", "happygame1024@gmail.com");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@G_I_Y");
chef_set_sauciers (this, 2, "@Yangmoooo", "@happy-game");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
@ -51,11 +47,11 @@ os_kali_setsrc (char *option)
{
chsrc_ensure_root ();
use_this_source(os_kali);
chsrc_use_this_source (os_kali);
chsrc_backup (OS_Apt_SourceList);
char *cmd = xy_strjoin (3, "sed -E -i \'s@https?://.*/kali/?@",
char *cmd = xy_strcat (3, "sed -E -i \'s@https?://.*/kali/?@",
source.url,
"@g\' " OS_Apt_SourceList);

View File

@ -7,18 +7,15 @@ def_target(os_linuxlite, "linuxlite");
void
os_linuxlite_prelude ()
{
use_this(os_linuxlite);
chef_allow_gsr(os_linuxlite);
chef_prep_this (os_linuxlite, gsr);
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_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 1,
"Yangmoooo", "yangmoooo@outlook.com");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 1, "@Yangmoooo");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
@ -49,11 +46,11 @@ os_linuxlite_setsrc (char *option)
{
chsrc_ensure_root ();
use_this_source(os_linuxlite);
chsrc_use_this_source (os_linuxlite);
chsrc_backup (OS_Apt_SourceList);
char *cmd = xy_strjoin (3, "sed -E -i 's@https?://.*/.*/?@", source.url, "@g' " OS_Apt_SourceList);
char *cmd = xy_strcat (3, "sed -E -i 's@https?://.*/.*/?@", source.url, "@g' " OS_Apt_SourceList);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);

View File

@ -7,18 +7,15 @@ def_target(os_linuxmint, "linuxmint");
void
os_linuxmint_prelude ()
{
use_this(os_linuxmint);
chef_allow_gs(os_linuxmint);
chef_prep_this (os_linuxmint, gs);
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_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 1,
"Happy Game", "happygame1024@gmail.com");
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_forbid_english(this);
@ -61,7 +58,7 @@ os_linuxmint_setsrc (char *option)
{
chsrc_ensure_root ();
use_this_source(os_linuxmint);
chsrc_use_this_source (os_linuxmint);
chsrc_backup (OS_LinuxMint_SourceList);
@ -69,7 +66,7 @@ os_linuxmint_setsrc (char *option)
// 暂不实现自动替换基于debian或ubuntu的基础源
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
char* cmd = xy_strjoin (5, "sed -i '/",
char* cmd = xy_strcat (5, "sed -i '/",
version_codename, "/ s|http[^ ]*|",
source.url, "|g' " OS_LinuxMint_SourceList);

View File

@ -7,19 +7,15 @@ def_target(os_ros, "ros/ros2");
void
os_ros_prelude ()
{
use_this(os_ros);
chef_allow_gs(os_ros);
chef_prep_this (os_ros, gs);
chef_set_created_on (this, "2023-09-03");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2024-04-18");
chef_set_authors (this, 1, "Heng Guo", "2085471348@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 2,
"Aoran Zeng", "ccmywish@qq.com",
"zouri", "guoshuaisun@outlook.com");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@G_I_Y");
chef_set_sauciers (this, 2, "@ccmywish", "@zouri");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
@ -59,12 +55,12 @@ os_ros_setsrc (char *option)
{
chsrc_ensure_root ();
use_this_source(os_ros);
chsrc_use_this_source (os_ros);
chsrc_backup (OS_ROS_SourceList);
char *cmd = NULL;
cmd = xy_strjoin(3, "sed -E -i \'s@https?://.*/ros/ubuntu/?@", source.url, "/ros/ubuntu@g\' " OS_ROS_SourceList);
cmd = xy_strcat(3, "sed -E -i \'s@https?://.*/ros/ubuntu/?@", source.url, "/ros/ubuntu@g\' " OS_ROS_SourceList);
chsrc_run(cmd, RunOpt_Default);
cmd = "apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654";

View File

@ -9,18 +9,15 @@ def_target(os_raspberrypi, "raspi/raspberrypi");
void
os_raspberrypi_prelude ()
{
use_this(os_raspberrypi);
chef_allow_gsr(os_raspberrypi);
chef_prep_this (os_raspberrypi, gsr);
chef_set_created_on (this, "2023-09-29");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2023-09-29");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 1,
"Yangmoooo", "yangmoooo@outlook.com");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 1, "@Yangmoooo");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
@ -53,11 +50,11 @@ os_raspberrypi_setsrc (char *option)
{
chsrc_ensure_root(); // HELP: 不确定是否需要
use_this_source(os_raspberrypi);
chsrc_use_this_source (os_raspberrypi);
chsrc_backup (OS_RaspberryPi_SourceList);
char *cmd = xy_strjoin (3, "sed -E -i 's@https?://.*/.*/?@", source.url,
char *cmd = xy_strcat (3, "sed -E -i 's@https?://.*/.*/?@", source.url,
"@g' " OS_RaspberryPi_SourceList);
chsrc_run (cmd, RunOpt_Default);

View File

@ -7,17 +7,15 @@ def_target(os_termux, "termux");
void
os_termux_prelude ()
{
use_this(os_termux);
chef_allow_gsr(os_termux);
chef_prep_this (os_termux, gsr);
chef_set_created_on (this, "2025-03-04");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2025-03-04");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 0);
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_forbid_english(this);
@ -61,9 +59,9 @@ os_termux_setsrc (char *option)
// chsrc_ensure_root (); Termux下禁止使用root
use_this_source(os_termux);
chsrc_use_this_source (os_termux);
char *cmd = xy_strjoin (3, "sed -i 's@^\\(deb.*stable main\\)$@#\\1\\ndeb ",
char *cmd = xy_strcat (3, "sed -i 's@^\\(deb.*stable main\\)$@#\\1\\ndeb ",
source.url, "apt/termux-main stable main@' " OS_Termux_SourceList);
chsrc_run (cmd, RunOpt_Default);

View File

@ -9,17 +9,15 @@ def_target(os_trisquel, "trisquel");
void
os_trisquel_prelude ()
{
use_this(os_trisquel);
chef_allow_gsr(os_trisquel);
chef_prep_this (os_trisquel, gsr);
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_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 0);
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_forbid_english(this);
@ -53,11 +51,11 @@ os_trisquel_setsrc (char *option)
{
chsrc_ensure_root ();
use_this_source(os_trisquel);
chsrc_use_this_source (os_trisquel);
chsrc_backup (OS_Apt_SourceList);
char *cmd = xy_strjoin (3, "sed -E -i 's@https?://.*/trisquel/?@", source.url, "@g' /etc/apt/sources.list");
char *cmd = xy_strcat (3, "sed -E -i 's@https?://.*/trisquel/?@", source.url, "@g' /etc/apt/sources.list");
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);

View File

@ -8,20 +8,15 @@ def_target(os_ubuntu, "ubuntu/zorinos");
void
os_ubuntu_prelude ()
{
use_this(os_ubuntu);
chef_allow_gsr(os_ubuntu);
chef_prep_this (os_ubuntu, gsr);
chef_set_created_on (this, "2023-08-30");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2025-07-11");
chef_set_authors (this, 2,
"Aoran Zeng", "ccmywish@qq.com",
"Heng Guo", "2085471348@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 1,
"Zhao", "1792582687@qq.com");
chef_set_chef (this, NULL);
chef_set_cooks (this, 2, "@ccmywish", "@G_I_Y");
chef_set_sauciers (this, 1, "@XUANJI233");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
@ -80,7 +75,7 @@ os_ubuntu_getsrc (char *option)
void
os_ubuntu_setsrc_for_deb822 (char *option)
{
use_this_source(os_ubuntu);
chsrc_use_this_source (os_ubuntu);
chsrc_backup (OS_Ubuntu_SourceList_DEB822);
@ -88,11 +83,11 @@ os_ubuntu_setsrc_for_deb822 (char *option)
char *cmd = NULL;
if (strncmp (arch, "x86_64", 6)==0)
{
cmd = xy_strjoin (3, "sed -E -i \'s@https?://.*/ubuntu/?@", source.url, "@g\' " OS_Ubuntu_SourceList_DEB822);
cmd = xy_strcat (3, "sed -E -i \'s@https?://.*/ubuntu/?@", source.url, "@g\' " OS_Ubuntu_SourceList_DEB822);
}
else
{
cmd = xy_strjoin (3, "sed -E -i \'s@https?://.*/ubuntu-ports/?@", source.url, "-ports@g\' " OS_Ubuntu_SourceList_DEB822);
cmd = xy_strcat (3, "sed -E -i \'s@https?://.*/ubuntu-ports/?@", source.url, "-ports@g\' " OS_Ubuntu_SourceList_DEB822);
}
chsrc_run (cmd, RunOpt_Default);
@ -123,7 +118,7 @@ os_ubuntu_setsrc (char *option)
bool sourcelist_exist = ensure_debian_or_ubuntu_old_sourcelist (OS_Is_Ubuntu);
use_this_source(os_ubuntu);
chsrc_use_this_source (os_ubuntu);
/* 不存在的时候,用的是我们生成的无效文件,不要备份 */
if (sourcelist_exist)
@ -135,11 +130,11 @@ os_ubuntu_setsrc (char *option)
char *cmd = NULL;
if (0==strncmp (arch, "x86_64", 6))
{
cmd = xy_strjoin (3, "sed -E -i \'s@https?://.*/ubuntu/?@", source.url, "@g\' " OS_Ubuntu_old_SourceList);
cmd = xy_strcat (3, "sed -E -i \'s@https?://.*/ubuntu/?@", source.url, "@g\' " OS_Ubuntu_old_SourceList);
}
else
{
cmd = xy_strjoin (3, "sed -E -i \'s@https?://.*/ubuntu-ports/?@", source.url, "-ports@g\' " OS_Ubuntu_old_SourceList);
cmd = xy_strcat (3, "sed -E -i \'s@https?://.*/ubuntu-ports/?@", source.url, "-ports@g\' " OS_Ubuntu_old_SourceList);
}
chsrc_run (cmd, RunOpt_Default);

View File

@ -7,18 +7,15 @@ def_target(os_deepin, "deepin");
void
os_deepin_prelude ()
{
use_this(os_deepin);
chef_allow_gsr(os_deepin);
chef_prep_this (os_deepin, gsr);
chef_set_created_on (this, "2023-09-26");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2024-09-14");
chef_set_authors (this, 1, "Heng Guo", "2085471348@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 1,
"Yangmoooo", "yangmoooo@outlook.com");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@G_I_Y");
chef_set_sauciers (this, 1, "@Yangmoooo");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
@ -56,11 +53,11 @@ os_deepin_setsrc (char *option)
{
chsrc_ensure_root();
use_this_source(os_deepin);
chsrc_use_this_source (os_deepin);
chsrc_backup (OS_Apt_SourceList);
char *cmd = xy_strjoin (3, "sed -E -i \'s@https?://.*/deepin/?@",
char *cmd = xy_strcat (3, "sed -E -i \'s@https?://.*/deepin/?@",
source.url,
"@g\' " OS_Apt_SourceList);

View File

@ -10,18 +10,15 @@ def_target(os_openkylin, "openkylin");
void
os_openkylin_prelude ()
{
use_this(os_openkylin);
chef_allow_gsr(os_openkylin);
chef_prep_this (os_openkylin, gsr);
chef_set_created_on (this, "2023-09-06");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2023-09-29");
chef_set_authors (this, 1, "Heng Guo", "2085471348@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 1,
"Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@G_I_Y");
chef_set_sauciers (this, 1, "@ccmywish");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
@ -47,11 +44,11 @@ os_openkylin_setsrc (char *option)
{
chsrc_ensure_root();
use_this_source(os_openkylin);
chsrc_use_this_source (os_openkylin);
chsrc_backup (OS_Apt_SourceList);
char *cmd = xy_strjoin (3, "sed -E -i 's@https?://.*/openkylin/?@", source.url, "@g'" OS_Apt_SourceList);
char *cmd = xy_strcat (3, "sed -E -i 's@https?://.*/openkylin/?@", source.url, "@g'" OS_Apt_SourceList);
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);

View File

@ -7,18 +7,15 @@ def_target(os_alpine, "alpine");
void
os_alpine_prelude ()
{
use_this(os_alpine);
chef_allow_gs(os_alpine);
chef_prep_this (os_alpine, gs);
chef_set_created_on (this, "2023-09-24");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2024-09-14");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 1,
"Yangmoooo", "yangmoooo@outlook.com");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 1, "@Yangmoooo");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_allow_english(this);
@ -57,9 +54,9 @@ os_alpine_setsrc (char *option)
{
// chsrc_ensure_root(); // HELP: 不确定是否需要root
use_this_source(os_alpine);
chsrc_use_this_source (os_alpine);
char* cmd = xy_strjoin (3,
char* cmd = xy_strcat (3,
"sed -i 's#https\\?://dl-cdn.alpinelinux.org/alpine#", source.url, "#g' /etc/apk/repositories"
);
chsrc_run (cmd, RunOpt_Default);

View File

@ -7,17 +7,15 @@ def_target(os_freebsd, "freebsd");
void
os_freebsd_prelude ()
{
use_this(os_freebsd);
chef_allow_s(os_freebsd);
chef_prep_this (os_freebsd, s);
chef_set_created_on (this, "2023-09-03");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2023-09-27");
chef_set_authors (this, 2, "Aoran Zeng", "ccmywish@qq.com", "Heng Guo", "2085471348@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 0);
chef_set_chef (this, NULL);
chef_set_cooks (this, 2, "@ccmywish", "@G_I_Y");
chef_set_sauciers (this, 0);
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
@ -48,7 +46,7 @@ os_freebsd_setsrc (char *option)
// 据 @yklaFreeBSD不自带sudo但是我们依然要保证是root权限
chsrc_ensure_root ();
use_this(os_freebsd);
use_this (os_freebsd);
int index = use_specific_mirror_or_auto_select (option, this);
Source_t source = this->sources[index];
@ -57,9 +55,9 @@ os_freebsd_setsrc (char *option)
chsrc_log2 ("1. 添加 freebsd-pkg 源 (二进制安装包)");
chsrc_ensure_dir ("/usr/local/etc/pkg/repos");
char *conf = xy_strjoin (3, "/usr/local/etc/pkg/repos/", source.mirror->code, ".conf");
char *conf = xy_strcat (3, "/usr/local/etc/pkg/repos/", source.mirror->code, ".conf");
char *pkg_content = xy_strjoin (4,
char *pkg_content = xy_strcat (4,
source.mirror->code, ": { \n"
" url: \"http://", source.url, "/freebsd-pkg/${ABI}/latest\",\n"
"}\n"
@ -68,7 +66,7 @@ os_freebsd_setsrc (char *option)
chsrc_overwrite_file (pkg_content, conf);
chsrc_note2 (
xy_strjoin (3, "若要使用季度分支,请在", conf ,"中将latest改为quarterly"));
xy_strcat (3, "若要使用季度分支,请在", conf ,"中将latest改为quarterly"));
chsrc_alert2 ("若要使用HTTPS源请先安装securtiy/ca_root_ns并将'http'改成'https',最后使用'pkg update -f'刷新缓存即可\n");
br();
@ -84,14 +82,14 @@ os_freebsd_setsrc (char *option)
{
source = this->sources[index-1]; // 使用NJU的前一个源即USTC源
}
char *git_cmd = xy_strjoin (3, "git clone --depth 1 https://", source.url, "/freebsd-ports/ports.git /usr/ports");
char *git_cmd = xy_strcat (3, "git clone --depth 1 https://", source.url, "/freebsd-ports/ports.git /usr/ports");
chsrc_run (git_cmd, RunOpt_Default);
source = this->sources[index]; // 恢复至选中的源
chsrc_alert2 ("下次更新请使用 git -C /usr/ports pull 而非使用 gitup");
}
else
{
char *fetch = xy_strjoin (3, "fetch https://", source.url, "/freebsd-ports/ports.tar.gz"); // 70多MB
char *fetch = xy_strcat (3, "fetch https://", source.url, "/freebsd-ports/ports.tar.gz"); // 70多MB
char *unzip = "tar -zxvf ports.tar.gz -C /usr/ports";
char *delete = "rm ports.tar.gz";
chsrc_run (fetch, RunOpt_Default);
@ -105,7 +103,7 @@ os_freebsd_setsrc (char *option)
// https://help.mirrors.cernet.edu.cn/FreeBSD-ports/
chsrc_backup ("/etc/make.conf");
char *ports = xy_strjoin (3, "MASTER_SITE_OVERRIDE?=http://", source.url, "/freebsd-ports/distfiles/${DIST_SUBDIR}/\n");
char *ports = xy_strcat (3, "MASTER_SITE_OVERRIDE?=http://", source.url, "/freebsd-ports/distfiles/${DIST_SUBDIR}/\n");
chsrc_append_to_file (ports, "/etc/make.conf");
@ -113,7 +111,7 @@ os_freebsd_setsrc (char *option)
/*
chsrc_backup ("/etc/portsnap.conf");
char *portsnap =xy_strjoin(3,"s@(.*)SERVERNAME=[\\.|a-z|A-Z]*@\\1SERVERNAME=", source.url,
char *portsnap =xy_strcat(3,"s@(.*)SERVERNAME=[\\.|a-z|A-Z]*@\\1SERVERNAME=", source.url,
"@g < /etc/portsnap.conf.bak");
chsrc_overwrite_file (portsnap, "/etc/portsnap.conf");
@ -131,7 +129,7 @@ os_freebsd_setsrc (char *option)
char *update_cp = "cp /etc/freebsd-update.conf /etc/freebsd-update.conf.bak";
chsrc_run (update_cp, RunOpt_Default);
char *update =xy_strjoin (3,"s@(.*)SERVERNAME [\\.|a-z|A-Z]*@\\1SERVERNAME ",
char *update =xy_strcat (3,"s@(.*)SERVERNAME [\\.|a-z|A-Z]*@\\1SERVERNAME ",
source.url,
"@g < /etc/freebsd-update.conf.bak");

View File

@ -7,17 +7,15 @@ def_target(os_netbsd, "netbsd");
void
os_netbsd_prelude ()
{
use_this(os_netbsd);
chef_allow_gs(os_netbsd);
chef_prep_this (os_netbsd, gs);
chef_set_created_on (this, "2023-09-05");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2025-07-31");
chef_set_authors (this, 2, "Aoran Zeng", "ccmywish@qq.com", "Heng Guo", "2085471348@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 0);
chef_set_chef (this, NULL);
chef_set_cooks (this, 2, "@ccmywish", "@G_I_Y");
chef_set_sauciers (this, 0);
chef_allow_local_mode (this, CanNot, NULL, NULL);
@ -60,7 +58,7 @@ os_netbsd_setsrc (char *option)
{
chsrc_ensure_root ();
use_this_source(os_netbsd);
chsrc_use_this_source (os_netbsd);
chsrc_backup ("/usr/pkg/etc/pkgin/repositories.conf");
@ -68,7 +66,7 @@ os_netbsd_setsrc (char *option)
char *vercmd = "cat /etc/os-release | grep \"VERSION=\" | grep -Po \"[8-9].[0-9]+\"";
char *version = xy_run (vercmd, 0);
char *url = xy_strjoin (5, chef_ensure_trailing_slash (source.url), arch, "/", version, "/All");
char *url = xy_strcat (5, chef_ensure_trailing_slash (source.url), arch, "/", version, "/All");
chsrc_overwrite_file (url, "/usr/pkg/etc/pkgin/repositories.conf");
chsrc_conclude (&source);

View File

@ -7,17 +7,15 @@ def_target(os_openbsd, "openbsd");
void
os_openbsd_prelude ()
{
use_this(os_openbsd);
chef_allow_gs(os_openbsd);
chef_prep_this (os_openbsd, gs);
chef_set_created_on (this, "2023-09-03");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2025-07-31");
chef_set_authors (this, 2, "Heng Guo", "2085471348@qq.com", "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 0);
chef_set_chef (this, NULL);
chef_set_cooks (this, 2, "@G_I_Y", "@ccmywish");
chef_set_sauciers (this, 0);
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
@ -59,7 +57,7 @@ os_openbsd_setsrc (char *option)
{
chsrc_ensure_root ();
use_this_source(os_openbsd);
chsrc_use_this_source (os_openbsd);
chsrc_backup ("/etc/installurl");
chsrc_overwrite_file (source.url, "/etc/installurl");

View File

@ -7,18 +7,15 @@ def_target(os_gentoo, "gentoo");
void
os_gentoo_prelude ()
{
use_this(os_gentoo);
chef_allow_s(os_gentoo);
chef_prep_this (os_gentoo, s);
chef_set_created_on (this, "2023-09-05");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2025-06-20");
chef_set_authors (this, 1, "Heng Guo", "2085471348@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 1,
"Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@G_I_Y");
chef_set_sauciers (this, 1, "@ccmywish");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_allow_english(this);
@ -45,16 +42,16 @@ os_gentoo_setsrc (char *option)
{
chsrc_ensure_root ();
use_this_source(os_gentoo);
chsrc_use_this_source (os_gentoo);
chsrc_backup ("/etc/portage/repos.conf/gentoo.conf");
char *cmd = xy_strjoin (3, "sed -i \"s#rsync://.*/gentoo-portage#rsync://",
char *cmd = xy_strcat (3, "sed -i \"s#rsync://.*/gentoo-portage#rsync://",
source.url,
"gentoo-portage#g");
chsrc_run (cmd, RunOpt_Default);
char *w = xy_strjoin (3, "GENTOO_MIRRORS=\"https://", source.url, "gentoo\"\n");
char *w = xy_strcat (3, "GENTOO_MIRRORS=\"https://", source.url, "gentoo\"\n");
chsrc_append_to_file (w, "/etc/portage/make.conf");

View File

@ -7,19 +7,15 @@ def_target(os_openwrt, "openwrt/opkg/LEDE");
void
os_openwrt_prelude ()
{
use_this(os_openwrt);
chef_allow_gsr(os_openwrt);
chef_prep_this (os_openwrt, gsr);
chef_set_created_on (this, "2024-08-08");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2024-12-14");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 2,
"Yangmoooo", "yangmoooo@outlook.com",
"happy game", "happygame1024@gmail.com");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 2, "@Yangmoooo", "@happy-game");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_allow_english(this);
@ -61,11 +57,11 @@ os_openwrt_setsrc (char *option)
{
chsrc_ensure_root ();
use_this_source(os_openwrt);
chsrc_use_this_source (os_openwrt);
chsrc_backup (OS_OpenWRT_SourceConfig);
char *cmd = xy_strjoin (3, "sed -E -i 's@https?://.*/releases@", source.url, "/releases@g' " OS_OpenWRT_SourceConfig);
char *cmd = xy_strcat (3, "sed -E -i 's@https?://.*/releases@", source.url, "/releases@g' " OS_OpenWRT_SourceConfig);
chsrc_run (cmd, RunOpt_No_Last_New_Line);
chsrc_run ("opkg update", RunOpt_No_Last_New_Line);

View File

@ -7,17 +7,15 @@ def_target(os_solus, "solus");
void
os_solus_prelude ()
{
use_this(os_solus);
chef_allow_s(os_solus);
chef_prep_this (os_solus, s);
chef_set_created_on (this, "2023-09-29");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2023-09-29");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 0);
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 0);
chef_allow_local_mode (this, CanNot, NULL, NULL);
@ -43,9 +41,9 @@ os_solus_setsrc (char *option)
{
chsrc_ensure_root ();
use_this_source(os_solus);
chsrc_use_this_source (os_solus);
char *cmd = xy_2strjoin ("eopkg add-repo Solus ", source.url);
char *cmd = xy_2strcat ("eopkg add-repo Solus ", source.url);
chsrc_run (cmd, RunOpt_Default);
chsrc_determine_chgtype (ChgType_Auto);

View File

@ -7,18 +7,15 @@ def_target(os_voidlinux, "voidlinux");
void
os_voidlinux_prelude ()
{
use_this(os_voidlinux);
chef_allow_gsr(os_voidlinux);
chef_prep_this (os_voidlinux, gsr);
chef_set_created_on (this, "2023-09-24");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2024-12-18");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 1,
"Yangmoooo", "yangmoooo@outlook.com");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 1, "@Yangmoooo");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
@ -52,18 +49,18 @@ os_voidlinux_setsrc (char *option)
{
chsrc_ensure_root ();
use_this_source(os_voidlinux);
chsrc_use_this_source (os_voidlinux);
chsrc_ensure_dir ("/etc/xbps.d");
char *cmd = "cp /usr/share/xbps.d/*-repository-*.conf /etc/xbps.d/";
chsrc_run (cmd, RunOpt_Default);
cmd = xy_strjoin (3,
cmd = xy_strcat (3,
"sed -i 's|https://repo-default.voidlinux.org|", source.url, "|g' /etc/xbps.d/*-repository-*.conf"
);
chsrc_run (cmd, RunOpt_Default);
cmd = xy_strjoin (3,
cmd = xy_strcat (3,
"sed -i 's|https://alpha.de.repo.voidlinux.org|", source.url, "|g' /etc/xbps.d/*-repository-*.conf"
);

View File

@ -7,18 +7,15 @@ def_target(os_almalinux, "alma/almalinux");
void
os_almalinux_prelude ()
{
use_this(os_almalinux);
chef_allow_s(os_almalinux);
chef_prep_this (os_almalinux, s);
chef_set_created_on (this, "2024-06-12");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2024-12-18");
chef_set_sources_last_updated (this, "2025-08-22");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 1,
"Yangmoooo", "yangmoooo@outlook.com");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 1, "@Yangmoooo");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
@ -27,7 +24,7 @@ os_almalinux_prelude ()
chef_set_note(this, NULL, NULL);
def_sources_begin()
{&UpstreamProvider, "http://repo.almalinux.org/almalinux", FeedByPrelude},
{&UpstreamProvider, "http://repo.almalinux.org/almalinux", DelegateToUpstream},
{&Ali, "https://mirrors.aliyun.com/almalinux", FeedByPrelude},
{&Volcengine, "https://mirrors.volces.com/almalinux", FeedByPrelude},
{&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/almalinux", FeedByPrelude},
@ -35,7 +32,10 @@ os_almalinux_prelude ()
{&Nju, "https://mirror.nju.edu.cn/almalinux", FeedByPrelude}
def_sources_end()
chef_set_provider_speed_measure_url (&UpstreamProvider, "https://raw.repo.almalinux.org/almalinux/9.5/isos/x86_64/AlmaLinux-9-latest-x86_64-minimal.iso");
#define link "/9.6/isos/x86_64/AlmaLinux-9-latest-x86_64-minimal.iso"
chef_set_sources_speed_measure_url_with_postfix (this, link);
chef_set_provider_speed_measure_url (&UpstreamProvider, "https://raw.repo.almalinux.org/almalinux" link);
#undef link
}
/**
@ -46,9 +46,9 @@ os_almalinux_setsrc (char *option)
{
chsrc_ensure_root ();
use_this_source(os_almalinux);
chsrc_use_this_source (os_almalinux);
char *cmd = xy_strjoin (3,
char *cmd = xy_strcat (3,
"sed -e 's|^mirrorlist=|#mirrorlist=|g' -e 's|^#\\s*baseurl=https://repo.almalinux.org/almalinux|baseurl=", source.url, "|g' -i.bak /etc/yum.repos.d/almalinux*.repo");
chsrc_run (cmd, RunOpt_Default);

View File

@ -7,17 +7,15 @@ def_target(os_anolis, "anolis/openanolis");
void
os_anolis_prelude ()
{
use_this(os_anolis);
chef_allow_s(os_anolis);
chef_prep_this (os_anolis, s);
chef_set_created_on (this, "2023-09-24");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2024-06-12");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 0);
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_forbid_english(this);
@ -41,9 +39,9 @@ os_anolis_setsrc (char *option)
{
chsrc_ensure_root ();
use_this_source(os_anolis);
chsrc_use_this_source (os_anolis);
char *cmd = xy_strjoin (3, "sed -i.bak -E 's|https?://(mirrors\\.openanolis\\.cn/anolis)|", source.url, "|g' /etc/yum.repos.d/*.repo");
char *cmd = xy_strcat (3, "sed -i.bak -E 's|https?://(mirrors\\.openanolis\\.cn/anolis)|", source.url, "|g' /etc/yum.repos.d/*.repo");
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("dnf makecache", RunOpt_Default);

View File

@ -7,20 +7,15 @@ def_target(os_fedora, "fedora");
void
os_fedora_prelude ()
{
use_this(os_fedora);
chef_allow_sr(os_fedora);
chef_prep_this (os_fedora, sr);
chef_set_created_on (this, "2023-09-26");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2025-06-20");
chef_set_authors (this, 2,
"Heng Guo", "2085471348@qq.com",
"happy game", "happygame1024@gmail.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 1, "happy game", "happygame1024@gmail.com");
chef_set_contributors (this, 1,
"Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, "@happy-game");
chef_set_cooks (this, 2, "@G_I_Y", "@happy-game");
chef_set_sauciers (this, 1, "@ccmywish");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
@ -55,7 +50,7 @@ os_fedora_setsrc (char *option)
{
chsrc_ensure_root ();
use_this_source(os_fedora);
chsrc_use_this_source (os_fedora);
chsrc_alert2 ("Fedora 38 及以下版本暂不支持");
@ -63,7 +58,7 @@ os_fedora_setsrc (char *option)
chsrc_backup ("/etc/yum.repos.d/fedora-updates.repo");
// 取消对 baseurl 的注释
char* cmd = xy_strjoin (5, "sed ",
char* cmd = xy_strcat (5, "sed ",
"-i 's|^#baseurl=|baseurl=",
"|g' ",
"/etc/yum.repos.d/fedora.repo ",
@ -73,7 +68,7 @@ os_fedora_setsrc (char *option)
// 替换
// (1) baseurl=<<URL>>/releases/...
// (2) baseurl=<<URL>>/updates/...
cmd = xy_strjoin (7, "sed ",
cmd = xy_strcat (7, "sed ",
"-i -E 's!^baseurl=.*?/(releases|updates)/!baseurl=",
source.url,
"/\\1/",

View File

@ -7,18 +7,15 @@ def_target(os_rockylinux, "rocky/rockylinux");
void
os_rockylinux_prelude ()
{
use_this(os_rockylinux);
chef_allow_sr(os_rockylinux);
chef_prep_this (os_rockylinux, sr);
chef_set_created_on (this, "2023-09-24");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2025-06-20");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 1,
"happy game", "happygame1024@gmail.com");
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_forbid_english(this);
@ -49,7 +46,7 @@ os_rockylinux_setsrc (char *option)
{
chsrc_ensure_root ();
use_this_source(os_rockylinux);
chsrc_use_this_source (os_rockylinux);
char *version_str = xy_run ("sed -nr 's/ROCKY_SUPPORT_PRODUCT_VERSION=\"(.*)\"/\\1/p' " ETC_OS_RELEASE, 0);
double version = atof (version_str);
@ -58,7 +55,7 @@ os_rockylinux_setsrc (char *option)
if (version < 9)
{
cmd = xy_strjoin (3,
cmd = xy_strcat (3,
"sed -e 's|^mirrorlist=|#mirrorlist=|g' "
"-e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=", source.url, "|g' "
"-i.bak /etc/yum.repos.d/Rocky-*.repo"
@ -70,7 +67,7 @@ os_rockylinux_setsrc (char *option)
}
else
{
cmd = xy_strjoin (3,
cmd = xy_strcat (3,
"sed -e 's|^mirrorlist=|#mirrorlist=|g' "
"-e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=", source.url, "|g' "
"-i.bak /etc/yum.repos.d/rocky-extras.repo /etc/yum.repos.d/rocky.repo"

View File

@ -7,21 +7,15 @@ def_target(os_openeuler, "openeuler");
void
os_openeuler_prelude ()
{
use_this(os_openeuler);
chef_allow_gs(os_openeuler);
chef_prep_this (os_openeuler, gs);
chef_set_created_on (this, "2023-09-06");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2025-06-20");
chef_set_authors (this, 1, "Heng Guo", "2085471348@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 3,
"Aoran Zeng", "ccmywish@qq.com",
"Yangmoooo", "yangmoooo@outlook.com",
"happy game", "happygame1024@gmail.com");
chef_set_cooks (this, 1, "@G_I_Y");
chef_set_chef (this, NULL);
chef_set_sauciers (this, 3, "@ccmywish", "@Yangmoooo", "@happy-game");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
@ -66,14 +60,14 @@ os_openeuler_setsrc (char *option)
{
chsrc_ensure_root ();
use_this_source(os_openeuler);
chsrc_use_this_source (os_openeuler);
chsrc_backup (OS_openEuler_SourceList);
// 替换 baseurl=<<URL>>/openEuler-xx.xx/...
// openEuler-xx.xx 为 openEuler 版本号
// sed -E 's!^baseurl=.*?/openEuler-([^/]+)!baseurl=$(source.url)/openEuler-\1/!g' OS_openEuler_SourceList
char* cmd = xy_strjoin (6, "sed ",
char* cmd = xy_strcat (6, "sed ",
"-i -E 's!^baseurl=.*?/openEuler-([^/]+)!baseurl=",
source.url,
"openEuler-\\1",

View File

@ -7,18 +7,15 @@ def_target(os_opensuse, "opensuse/opensuse-leap/opensuse-tumbleweed");
void
os_opensuse_prelude ()
{
use_this(os_opensuse);
chef_allow_s(os_opensuse);
chef_prep_this (os_opensuse, s);
chef_set_created_on (this, "2023-09-17");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2025-06-20");
chef_set_authors (this, 1, "Heng Guo", "2085471348@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 1,
"Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL);
chef_set_cooks (this, 2, "@ccmywish", "@G_I_Y");
chef_set_sauciers (this, 0);
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
@ -46,7 +43,7 @@ os_opensuse_setsrc (char *option)
{
// chsrc_ensure_root ();
use_this_source(os_opensuse);
chsrc_use_this_source (os_opensuse);
while (1) {
chsrc_note2 ("请选择你的操作系统为:");

View File

@ -10,19 +10,15 @@ def_target(os_arch, "arch/archlinux");
void
os_arch_prelude ()
{
use_this(os_arch);
chef_allow_gs(os_arch);
chef_prep_this (os_arch, gs);
chef_set_created_on (this, "2023-09-05");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2025-06-20");
chef_set_authors (this, 2, "Aoran Zeng", "ccmywish@qq.com",
"Heng Guo", "2085471348@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 1, "happy game", "happygame1024@gmail.com");
chef_set_contributors (this, 1,
"happy game", "happygame1024@gmail.com");
chef_set_chef (this, "@happy-game");
chef_set_cooks (this, 2, "@ccmywish", "@G_I_Y");
chef_set_sauciers (this, 1, "@happy-game");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
@ -70,7 +66,7 @@ os_arch_setsrc (char *option)
{
chsrc_ensure_root ();
use_this_source(os_arch);
chsrc_use_this_source (os_arch);
chsrc_backup (OS_Pacman_MirrorList);
@ -81,12 +77,12 @@ os_arch_setsrc (char *option)
if (strncmp(arch, "x86_64", 6)==0)
{
is_x86 = true;
to_write = xy_strjoin (3, "Server = ", source.url, "/$repo/os/$arch");
to_write = xy_strcat (3, "Server = ", source.url, "/$repo/os/$arch");
}
else
{
is_x86 = false;
to_write = xy_strjoin (3, "Server = ", source.url, "arm/$arch/$repo");
to_write = xy_strcat (3, "Server = ", source.url, "arm/$arch/$repo");
}
/* 配置文件中,越前面的优先级越高 */
@ -116,18 +112,15 @@ def_target(os_archlinuxcn, "archlinuxcn/archcn");
void
os_archlinuxcn_prelude ()
{
use_this(os_archlinuxcn);
chef_allow_gs(os_archlinuxcn);
chef_prep_this (os_archlinuxcn, gs);
chef_set_created_on (this, "2023-09-05");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2024-07-03");
chef_set_authors (this, 2, "Aoran Zeng", "ccmywish@qq.com", "Heng Guo", "2085471348@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 1,
"happy game", "happygame1024@gmail.com");
chef_set_chef (this, NULL);
chef_set_cooks (this, 2, "@ccmywish", "@G_I_Y");
chef_set_sauciers (this, 1, "@happy-game");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
@ -169,7 +162,7 @@ os_archlinuxcn_setsrc (char *option)
{
chsrc_ensure_root ();
use_this_source(os_archlinuxcn);
chsrc_use_this_source (os_archlinuxcn);
chsrc_backup (OS_Pacman_ArchLinuxCN_MirrorList);
@ -181,13 +174,13 @@ os_archlinuxcn_setsrc (char *option)
if (ret == 0)
{
char *sed_cmd = xy_strjoin (4, "sed -i '/\\[archlinuxcn\\]/{n;s|^Server = .*|Server = ",
char *sed_cmd = xy_strcat (4, "sed -i '/\\[archlinuxcn\\]/{n;s|^Server = .*|Server = ",
source.url, "$arch|;}' ", OS_Pacman_ArchLinuxCN_MirrorList);
chsrc_run (sed_cmd, RunOpt_Default);
}
else
{
char *archlinuxcn_config = xy_strjoin (3, "\n[archlinuxcn]\nServer = ", source.url, "$arch\n");
char *archlinuxcn_config = xy_strcat (3, "\n[archlinuxcn]\nServer = ", source.url, "$arch\n");
chsrc_append_to_file (archlinuxcn_config, OS_Pacman_ArchLinuxCN_MirrorList);
}

View File

@ -7,18 +7,15 @@ def_target(os_msys2, "msys2/msys");
void
os_msys2_prelude ()
{
use_this(os_msys2);
chef_allow_s(os_msys2);
chef_prep_this (os_msys2, s);
chef_set_created_on (this, "2023-09-06");
chef_set_last_updated (this, "2025-08-10");
chef_set_sources_last_updated (this, "2025-06-20");
chef_set_authors (this, 1, "Heng Guo", "2085471348@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 1,
"Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@G_I_Y");
chef_set_sauciers (this, 1, "@ccmywish");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
@ -46,18 +43,18 @@ os_msys2_prelude ()
void
os_msys2_setsrc (char *option)
{
use_this_source(os_msys2);
chsrc_use_this_source (os_msys2);
chsrc_backup ("/etc/pacman.d/mirrorlist.mingw32");
chsrc_backup ("/etc/pacman.d/mirrorlist.mingw64");
chsrc_backup ("/etc/pacman.d/mirrorlist.msys");
char *prev = xy_strjoin (3, "请针对你的架构下载安装此目录下的文件:",
char *prev = xy_strcat (3, "请针对你的架构下载安装此目录下的文件:",
source.url,
"distrib/<架构>/");
chsrc_note2 (prev);
char *cmd = xy_strjoin (3, "sed -i \"s#https\?://mirror.msys2.org/#",
char *cmd = xy_strcat (3, "sed -i \"s#https\?://mirror.msys2.org/#",
source.url,
"#g\" /etc/pacman.d/mirrorlist* ");

View File

@ -7,16 +7,14 @@ def_target(os_manjaro, "manjaro");
void
os_manjaro_prelude ()
{
use_this(os_manjaro);
chef_allow_s(os_manjaro);
chef_prep_this (os_manjaro, s);
chef_set_created_on (this, "2023-09-06");
chef_set_last_updated (this, "2025-08-10");
chef_set_authors (this, 1, "Heng Guo", "2085471348@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 0);
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@G_I_Y");
chef_set_sauciers (this, 0);
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);

View File

@ -2,11 +2,11 @@
* SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Name : recipe-template.c
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nil Null <nil@null.org>
* File Authors : <ccmywish@qq.com>
* Contributors : Mikachu2333 <mikachu.23333@zohomail.com>
* |
* Created On : <2024-08-09>
* Last Modified : <2025-08-11>
* Last Modified : <2025-08-22>
* -------------------------------------------------------------
*
*
@ -58,29 +58,24 @@ RubyMetric = {
void
<category>_<target>_prelude (void)
{
use_this(<category>_<target>);
chef_allow_gsr(<category>_<target>);
// chef_allow_s(<category>_<target>);
// chef_allow_gs(<category>_<target>);
// chef_allow_sr(<category>_<target>);
// op 可以为 NOOP|s|sr|gsr|gs, 代表支持 Get Set Reset 三种操作
chef_prep_this (<category>_<target>, op);
chef_set_created_on (this, "2024-08-09");
chef_set_last_updated (this, "2025-08-12");
chef_set_sources_last_updated (this, "2025-08-11");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 1,
"Nil Null", "nil@null.org");
chef_set_created_on (this, "2024-08-09"); // 文件创建日期
chef_set_last_updated (this, "2025-08-12"); // 文件最后一次更新日期
chef_set_sources_last_updated (this, "2025-08-11"); // 镜像源最后一次更新日期
chef_set_chef (this, "@ccmywish"); // recipe 负责人
chef_set_cooks (this, 2, "@ccmywish", "@nilnull"); // recipe 核心作者
// 做了贡献?将自己的信息加在这里!
chef_set_sauciers (this, 2, "@nulnone", "@someone");
chef_allow_local_mode (this, PartiallyCan, "具体说明是否支持项目级换源...", "Tell users the local mode support");
// chef_allow_english(this);
// chef_allow_english(this); // 项目是否支持英文
chef_forbid_english(this);
// chef_allow_user_define(this);
// chef_allow_user_define(this); // 是否支持用户自定义镜像源
chef_forbid_user_define(this);
chef_set_note ("中文备注说明...", "English note...");
@ -117,7 +112,7 @@ void
<category>_<target>_setsrc (char *option)
{
/* 下面这行是必须的,注入 source 变量 */
use_this_source(<category>_<target>);
chsrc_use_this_source (<category>_<target>);
/* 如果是 target group你可能想要指定不同的 target 来使用它的源 */
// Source_t source = chsrc_yield_source_and_confirm (&pl_js_group_target, option);
@ -141,3 +136,7 @@ void
/* 往往统一在 _setsrc() 中实现,直接调用即可 */
// <category>_<target>_setsrc (option);
}
// 最后,请将自己的文件加入到 menu.c 和 chsrc-main.c 对应的位置
// 形式可以参考其附近的其他食谱

View File

@ -9,19 +9,15 @@ def_target(wr_anaconda, "conda/anaconda");
void
wr_anaconda_prelude ()
{
use_this(wr_anaconda);
chef_allow_gs(wr_anaconda);
chef_prep_this (wr_anaconda, gs);
chef_set_created_on (this, "2023-09-10");
chef_set_last_updated (this, "2025-08-09");
chef_set_sources_last_updated (this, "2025-07-14");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 2,
"Yangmoooo", "yangmoooo@outlook.com",
"yongxiang", "1926885268@qq.com");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 2, "@Yangmoooo", "@xyx1926885268");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
@ -56,12 +52,12 @@ wr_anaconda_getsrc (char *option)
void
wr_anaconda_setsrc (char *option)
{
use_this_source(wr_anaconda);
chsrc_use_this_source (wr_anaconda);
char *w = xy_str_gsub (RAWSTR_wr_anaconda_condarc, "@1@", source.url);
/* Windows 也是在这里 */
char *configfile = xy_2strjoin (xy_os_home, "/.condarc");
char *configfile = xy_2strcat (xy_os_home, "/.condarc");
if (xy_on_windows)
{
@ -78,7 +74,7 @@ wr_anaconda_setsrc (char *option)
}
}
chsrc_note2 (xy_strjoin (3, "请向 ", configfile, " 中手动添加:"));
chsrc_note2 (xy_strcat (3, "请向 ", configfile, " 中手动添加:"));
println (w);
chsrc_note2 ("然后运行 conda clean -i 清除索引缓存,保证用的是镜像站提供的索引");

View File

@ -7,17 +7,15 @@ def_target(wr_cocoapods, "cocoa/cocoapods/cocoapod");
void
wr_cocoapods_prelude ()
{
use_this(wr_cocoapods);
chef_allow_s(wr_cocoapods);
chef_prep_this (wr_cocoapods, s);
chef_set_created_on (this, "2024-06-08");
chef_set_last_updated (this, "2025-08-09");
chef_set_sources_last_updated (this, "2025-07-13");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 0);
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 0);
chef_allow_local_mode (this, CanNot, NULL, NULL);
@ -40,17 +38,17 @@ wr_cocoapods_prelude ()
void
wr_cocoapods_setsrc (char *option)
{
use_this_source(wr_cocoapods);
chsrc_use_this_source (wr_cocoapods);
chsrc_note2 ("请手动执行以下命令:");
p("cd ~/.cocoapods/repos");
p("pod repo remove master");
char *git_cmd = xy_strjoin (3, "git clone ", source.url, " master");
char *git_cmd = xy_strcat (3, "git clone ", source.url, " master");
p(git_cmd);
br();
chsrc_note2 ("最后进入项目工程目录在Podfile中第一行加入:");
char *source_str = xy_strjoin (3, "source '", source.url, "'");
char *source_str = xy_strcat (3, "source '", source.url, "'");
p(source_str);
chsrc_determine_chgtype (ChgType_Manual);

View File

@ -24,19 +24,15 @@ def_target(wr_docker, "docker/dockerhub");
void
wr_docker_prelude ()
{
use_this(wr_docker);
chef_allow_gs(wr_docker);
chef_prep_this (wr_docker, gs);
chef_set_created_on (this, "2024-06-08");
chef_set_last_updated (this, "2025-08-09");
chef_set_sources_last_updated (this, "2025-07-14");
chef_set_authors (this, 2,
"happy game", "happygame1024@gmail.com",
"Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 1, "happy game", "happygame1024@gmail.com");
chef_set_contributors (this, 0);
chef_set_chef (this, "@happy-game");
chef_set_cooks (this, 2, "@happy-game", "@ccmywish");
chef_set_sauciers (this, 0);
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
@ -75,7 +71,7 @@ wr_docker_setsrc (char *option)
{
chsrc_ensure_root ();
use_this_source(wr_docker);
chsrc_use_this_source (wr_docker);
if (xy_on_linux || xy_on_bsd)
{
@ -118,7 +114,7 @@ wr_docker_setsrc (char *option)
/* 不存在 /etc/docker/daemon.json 时可以直接写入文件 */
chsrc_alert2 ("未找到Docker配置文件, 将自动创建");
chsrc_ensure_dir ("/etc/docker");
chsrc_run ( xy_2strjoin ("touch ", WR_Docker_ConfigFile), RunOpt_Default);
chsrc_run ( xy_2strcat ("touch ", WR_Docker_ConfigFile), RunOpt_Default);
chsrc_append_to_file (to_add, WR_Docker_ConfigFile);
}

View File

@ -14,17 +14,15 @@ def_target(wr_emacs, "emacs/elpa");
void
wr_emacs_prelude ()
{
use_this(wr_emacs);
chef_allow_s(wr_emacs);
chef_prep_this (wr_emacs, s);
chef_set_created_on (this, "2023-10-10");
chef_set_last_updated (this, "2025-08-09");
chef_set_sources_last_updated (this, "2025-07-13");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 0);
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_forbid_english(this);
@ -49,7 +47,7 @@ wr_emacs_prelude ()
void
wr_emacs_setsrc (char *option)
{
use_this_source(wr_emacs);
chsrc_use_this_source (wr_emacs);
chsrc_note2 ("Emacs换源涉及Elisp, 需要手动查阅并换源:");
p (source.url);

View File

@ -7,18 +7,15 @@ def_target(wr_flatpak, "flatpak/flathub");
void
wr_flatpak_prelude ()
{
use_this(wr_flatpak);
chef_allow_gsr(wr_flatpak);
chef_prep_this (wr_flatpak, gsr);
chef_set_created_on (this, "2023-09-11");
chef_set_last_updated (this, "2025-08-09");
chef_set_sources_last_updated (this, "2025-05-27");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 1,
"Jialin Lyu", "jialinlvcn@aliyun.com");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 1, "@jialinlvcn");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
@ -66,10 +63,10 @@ wr_flatpak_getsrc (char *option)
void
wr_flatpak_setsrc (char *option)
{
use_this_source(wr_flatpak);
chsrc_use_this_source (wr_flatpak);
chsrc_alert2 ("若出现问题,可先调用以下命令:");
char *note = xy_strjoin (3,
char *note = xy_strcat (3,
"wget ", source.url, "/flathub.gpg\n"
"flatpak remote-modify --gpg-import=flathub.gpg flathub"
);
@ -80,7 +77,7 @@ wr_flatpak_setsrc (char *option)
"尝试运行 flatpak remote-modify flathub --url=https://flathub.org/repo";
say (repo_note);
char *cmd = xy_2strjoin ("flatpak remote-modify flathub --url=", source.url);
char *cmd = xy_2strcat ("flatpak remote-modify flathub --url=", source.url);
chsrc_run (cmd, RunOpt_Default);
chsrc_determine_chgtype (ChgType_Auto);

View File

@ -7,17 +7,15 @@ def_target(wr_guix, "guix");
void
wr_guix_prelude ()
{
use_this(wr_guix);
chef_allow_s(wr_guix);
chef_prep_this (wr_guix, s);
chef_set_created_on (this, "2023-09-11");
chef_set_last_updated (this, "2025-08-09");
chef_set_sources_last_updated (this, "2025-07-13");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 0);
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_forbid_english(this);
@ -39,9 +37,9 @@ wr_guix_prelude ()
void
wr_guix_setsrc (char *option)
{
use_this_source(wr_guix);
chsrc_use_this_source (wr_guix);
char *file = xy_strjoin (3, "(list (channel\n"
char *file = xy_strcat (3, "(list (channel\n"
" (inherit (car %default-channels))\n"
" (url \"", source.url, "\")))");

View File

@ -9,18 +9,15 @@ def_target(wr_homebrew, "brew/homebrew");
void
wr_homebrew_prelude ()
{
use_this(wr_homebrew);
chef_allow_gs(wr_homebrew);
chef_prep_this (wr_homebrew, gs);
chef_set_created_on (this, "2023-09-10");
chef_set_last_updated (this, "2025-08-09");
chef_set_sources_last_updated (this, "2025-07-13");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 1,
"Word2VecT", "tangzinan@bupt.edu.cn");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 1, "@Word2VecT");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_allow_english(this);
@ -43,7 +40,7 @@ void
wr_homebrew_getsrc (char *option)
{
int status = system (RAWSTR_wr_homebrew_read_config_cmd);
if (status != 0) { /* NOOP */ }
if (status != 0) { xy_noop(); }
}
/**
@ -56,7 +53,7 @@ wr_homebrew_getsrc (char *option)
void
wr_homebrew_setsrc (char *option)
{
use_this_source(wr_homebrew);
chsrc_use_this_source (wr_homebrew);
char *w = xy_str_gsub (RAWSTR_wr_homebrew_config_in_bash, "@1@", source.url);

View File

@ -7,17 +7,15 @@ def_target(wr_nix, "nix");
void
wr_nix_prelude ()
{
use_this(wr_nix);
chef_allow_s(wr_nix);
chef_prep_this (wr_nix, s);
chef_set_created_on (this, "2023-09-26");
chef_set_last_updated (this, "2025-08-09");
chef_set_sources_last_updated (this, "2025-07-13");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 0);
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_forbid_english(this);
@ -52,21 +50,21 @@ wr_nix_setsrc (char *option)
{
wr_nix_check_cmd ();
use_this_source(wr_nix);
chsrc_use_this_source (wr_nix);
char *cmd = xy_strjoin (3, "nix-channel --add ", source.url, "nixpkgs-unstable nixpkgs");
char *cmd = xy_strcat (3, "nix-channel --add ", source.url, "nixpkgs-unstable nixpkgs");
chsrc_run (cmd, RunOpt_Default);
char *w = xy_strjoin (3, "substituters = ", source.url, "store https://cache.nixos.org/");
char *w = xy_strcat (3, "substituters = ", source.url, "store https://cache.nixos.org/");
chsrc_append_to_file (w, "~/.config/nix/nix.conf");
chsrc_run ("nix-channel --update", RunOpt_Default);
chsrc_note2 ("若你使用的是NixOS请确认你的系统版本<version>如22.11),并手动运行:");
cmd = xy_strjoin (3, "nix-channel --add ", source.url, "nixpkgs-<version> nixpkgs");
cmd = xy_strcat (3, "nix-channel --add ", source.url, "nixpkgs-<version> nixpkgs");
p(cmd);
cmd = xy_strjoin (3, "nix.settings.substituters = [ \"", source.url, "store\" ];");
cmd = xy_strcat (3, "nix.settings.substituters = [ \"", source.url, "store\" ];");
chsrc_note2 ("若你使用的是NixOS请额外添加下述内容至 configuration.nix 中");
p(cmd);

View File

@ -9,18 +9,15 @@ def_target(wr_tex, "latex/ctan/tex/texlive/miktex/tlmgr/mpm");
void
wr_tex_prelude ()
{
use_this(wr_tex);
chef_allow_gs(wr_tex);
chef_prep_this (wr_tex, gs);
chef_set_created_on (this, "2023-09-10");
chef_set_last_updated (this, "2025-08-09");
chef_set_sources_last_updated (this, "2025-07-28");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 1,
"Mikachu2333", "mikachu.23333@zohomail.com");
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 1, "@Mikachu2333");
chef_allow_local_mode (this, CanNot, NULL, NULL);
chef_forbid_english(this);
@ -85,20 +82,20 @@ wr_tex_setsrc (char *option)
bool tlmgr_exist, mpm_exist;
wr_tex_check_cmd (&tlmgr_exist, &mpm_exist);
use_this_source(wr_tex);
chsrc_use_this_source (wr_tex);
char *cmd = NULL;
if (tlmgr_exist)
{
cmd = xy_2strjoin ("tlmgr option repository ", source.url);
cmd = xy_2strcat ("tlmgr option repository ", source.url);
chsrc_run (cmd, RunOpt_Default);
}
if (mpm_exist)
{
char *miktex_url = xy_2strjoin (xy_str_delete_suffix (source.url, "texlive/tlnet"), "win32/miktex/tm/packages/");
cmd = xy_2strjoin ("mpm --set-repository=", miktex_url);
char *miktex_url = xy_2strcat (xy_str_delete_suffix (source.url, "texlive/tlnet"), "win32/miktex/tm/packages/");
cmd = xy_2strcat ("mpm --set-repository=", miktex_url);
chsrc_run (cmd, RunOpt_Default);
}

View File

@ -7,17 +7,15 @@ def_target(wr_winget, "winget");
void
wr_winget_prelude ()
{
use_this(wr_winget);
chef_allow_gsr(wr_winget);
chef_prep_this (wr_winget, gsr);
chef_set_created_on (this, "2024-06-07");
chef_set_last_updated (this, "2025-07-13");
chef_set_last_updated (this, "2025-08-17");
chef_set_sources_last_updated (this, "2025-07-13");
chef_set_authors (this, 1, "Aoran Zeng", "ccmywish@qq.com");
chef_set_chef (this, NULL, NULL);
chef_set_cooks (this, 0);
chef_set_contributors (this, 0);
chef_set_chef (this, NULL);
chef_set_cooks (this, 1, "@ccmywish");
chef_set_sauciers (this, 1, "@Mikachu2333");
chef_forbid_english(this);
chef_allow_user_define(this);
@ -46,10 +44,13 @@ wr_winget_getsrc (char *option)
void
wr_winget_setsrc (char *option)
{
use_this_source(wr_winget);
chsrc_use_this_source (wr_winget);
chsrc_run ("winget source remove winget", RunOpt_Default);
chsrc_run (xy_strjoin (3, "winget source add winget ", source.url, " --trust-level trusted"), RunOpt_Default);
// 2025.8.17 此前用户可能隐式使用默认源导致 remove 失败,故使用 Dont_Abort
chsrc_run ("winget source remove winget", RunOpt_Dont_Abort_On_Failure);
// 2025.8.18 执行两次相同的命令后继续设置,无报错,换源成功。具体原因不明
chsrc_run ("winget source remove winget", RunOpt_Dont_Abort_On_Failure);
chsrc_run (xy_strcat (3, "winget source add winget ", source.url, " --trust-level trusted"), RunOpt_Default);
chsrc_determine_chgtype (ChgType_Auto);
chsrc_conclude (&source);

View File

@ -62,7 +62,7 @@ main (int argc, char const *argv[])
chsrc_overwrite_file ("overwrite", bkup);
chsrc_view_file (bkup);
chsrc_log (xy_2strjoin ("CPU arch = ", chsrc_get_cpuarch ()));
chsrc_log (xy_2strcat ("CPU arch = ", chsrc_get_cpuarch ()));
print ("chsrc: CPU cores = ");
println (chsrc_get_cpucore ());

View File

@ -1,33 +1,45 @@
/** ------------------------------------------------------------
* SPDX-License-Identifier: MIT
* -------------------------------------------------------------
* File Name : xy.c
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nil Null <nil@null.org>
* |
* Test File : xy.c
* Test Authors : <ccmywish@qq.com>
* Contributors : Mikachu2333 <mikachu.23333@zohomail.com>
* Created On : <2023-08-30>
* Last Modified : <2025-08-08>
* Last Modified : <2025-08-22>
*
* Test xy.h
* ------------------------------------------------------------*/
#include "xy.h"
void
print_str_for_seq (void *str, void *NOUSE)
{
print ((char *) str);
}
void
print_str_for_map (const char *key, void *value, void *NOUSE)
{
println (xy_strcat (4, " ", key, " => ", (char *) value));
}
int
main (int argc, char const *argv[])
{
xy_useutf8 ();
xy_init ();
println (xy_os_depend_str ("Hello, Windows!", "Hello, Unix!"));
println (3);
double dbl = 3.1415;
println (dbl);
say (xy_2strjoin ("Xi", "'an"));
say (xy_strjoin (2, "Xi", "'an"));
say (xy_strjoin (3, "屈身守分,", "以待天时,", "不可与命争也"));
say (xy_strjoin (4, "水落鱼梁浅,", "天寒梦泽深。", "羊公碑字在,", "读罢泪沾襟。"));
say (xy_strjoin (6, "楚山横地出,", "汉水接天回。", "冠盖非新里,", "章华即旧台。", "习池风景异,", "归路满尘埃。"));
say (xy_2strcat ("Xi", "'an"));
say (xy_strcat (2, "Xi", "'an"));
say (xy_strcat (3, "屈身守分,", "以待天时,", "不可与命争也"));
say (xy_strcat (4, "水落鱼梁浅,", "天寒梦泽深。", "羊公碑字在,", "读罢泪沾襟。"));
say (xy_strcat (6, "楚山横地出,", "汉水接天回。", "冠盖非新里,", "章华即旧台。", "习池风景异,", "归路满尘埃。"));
print (xy_str_to_bold ("粗体"));
print (xy_str_to_faint ("浅体"));
@ -97,9 +109,23 @@ main (int argc, char const *argv[])
assert (xy_dir_exist ("~"));
if (xy_on_windows)
{
say (xy_normalize_path ("~"));
say (xy_normalize_path ("~/"));
// xy_parent_dir() 得到的结果一定是不包含尾斜杠的目录名
assert_str (xy_parent_dir (xy_normalize_path ("~")), "C:\\Users");
assert_str (xy_parent_dir (xy_normalize_path ("~/")), "C:\\Users");
assert (xy_dir_exist ("C:\\Users"));
say (xy_win_powershell_profile);
say (xy_win_powershellv5_profile);
assert (xy_file_exist (xy_win_powershell_profile));
assert (true == xy_file_exist (xy_win_powershellv5_profile));
assert (xy_dir_exist ("C:\\Users"));
assert_str (xy_normalize_path ("C:\\a bc\\def\\"), "C:\\a bc\\def\\");
assert_str (xy_normalize_path ("a/b c/d"), "a\\b c\\d");
assert_str (xy_normalize_path ("a/b c/d/"), "a\\b c\\d\\");
assert_str (xy_parent_dir ("a/b c/d"), "a\\b c");
assert_str (xy_parent_dir ("a/b c\\d/"), "a\\b c");
}
else
{
@ -117,6 +143,30 @@ main (int argc, char const *argv[])
println (xy_normalize_path (" \n ~/haha/test/123 \n\r "));
assert_str (xy_normalize_path ("~/haha/test"), xy_parent_dir (" ~/haha/test/123"));
XySeq_t *seq = xy_seq_new ();
xy_seq_push (seq, "Hello");
xy_seq_push (seq, "World");
assert_str ("Hello", xy_seq_at (seq, 1));
assert_str ("World", xy_seq_at (seq, 2));
xy_seq_each (seq, print_str_for_seq, NULL); br();
xy_seq_pop (seq);
assert (1 == xy_seq_len (seq));
XyMap_t *map = xy_map_new ();
xy_map_set (map, "Hello", "World");
xy_map_set (map, "你好", "世界");
assert_str ("World", xy_map_get (map, "Hello"));
assert_str ("世界", xy_map_get (map, "你好"));
xy_map_set (map, "Hello", "chsrc");
assert_str ("chsrc", xy_map_get (map, "Hello"));
assert (2 == xy_map_len (map));
echo ("{");
xy_map_each (map, print_str_for_map, NULL);
echo ("}");
xy_succ ("测试完成", "xy.h 测试全部通过");
// xy_unimplemented();

View File

@ -0,0 +1,17 @@
# ---------------------------------------------------------------
# SPDX-License-Identifier: GPL-3.0-or-later
# ---------------------------------------------------------------
# File Name : git-ignore-vscode-settings.ps1
# File Authors : Aoran Zeng <ccmywish@qq.com>
# Created On : <2025-08-17>
# Last Modified : <2025-08-17>
#
# VS Code 的某些操作/插件会频繁地修改我们的 .vscode/settings.json
# 文件,非常非常烦人,但是该文件又应该被加入仓库,所以我们使用以下
# 命令来忽略它在本地的变化
# ---------------------------------------------------------------
git update-index --skip-worktree .\.vscode\settings.json
# 恢复方法是:
# git update-index --no-skip-worktree .\.vscode\settings.json