mirror of
https://github.com/TheWhiteDog9487/lag2cn.git
synced 2026-08-14 16:21:28 +08:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b7335b0bb8 | |||
| aae4cb05d2 | |||
| 0806f479d6 | |||
| b41d276b2e |
@@ -32,7 +32,7 @@ jobs:
|
||||
alpine:latest /bin/sh -c '
|
||||
apk update
|
||||
apk add build-base dotnet10-sdk clang
|
||||
dotnet publish language.cs /t:Rebuild --disable-build-servers --force '
|
||||
dotnet publish language.cs '
|
||||
- name: 重命名
|
||||
if: ${{ matrix.runner == 'ubuntu-26.04-arm' }}
|
||||
run: sudo mv artifacts/language/language artifacts/language/language_arm
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
- Ubuntu
|
||||
- Arch Linux
|
||||
- CachyOS
|
||||
- Rocky Linux
|
||||
- AlmaLinux
|
||||
- Fedora
|
||||
|
||||
## 测试通过的系统
|
||||
### **x86_64:**
|
||||
@@ -15,6 +18,9 @@
|
||||
| Debian | 13.2 <br/> 11.6 |
|
||||
| Ubuntu | 26.04 LTS <br/> 25.10 <br/> 25.04 <br/> 24.10 <br/> 24.04.1 LTS <br/> 22.04 LTS <br/> 20.04 LTS |
|
||||
| Arch Linux | 滚动发行 |
|
||||
| Rocky Linux | 10.2 |
|
||||
| AlmaLinux | 10.2 |
|
||||
| Fedora | 44 <br/> 40 |
|
||||
|
||||
### **aarch64:**
|
||||
| 系统名称 | 版本 |
|
||||
@@ -50,7 +56,7 @@ rm language_arm
|
||||
- Clang
|
||||
- build-base或其他等效工具集
|
||||
|
||||
推荐使用Alpine Linux进行编译,因为Alpine的系统libc就是musl,编译出的产物可以直接用而不需要管目标系统glibc的版本问题
|
||||
推荐使用Alpine Linux进行编译,因为Alpine的系统libc就是musl,静态链接之后的体积会比glibc小一些
|
||||
您可以使用下面的Docker命令获得一个Alpine环境
|
||||
```shell
|
||||
docker run --rm -it -v .:/src -w /src alpine
|
||||
|
||||
+43
-4
@@ -67,8 +67,11 @@ void ExecuteCommand(string Command,
|
||||
|
||||
string OsDescription = RuntimeInformation.OSDescription;
|
||||
if (Enum.TryParse<SupportedLinuxDistributions>(OsDescription.Split(' ')[0], out var CurrentSystem) == false){
|
||||
// 对于Arch Linux这种系统名称中间有空格的需要特判
|
||||
if (OsDescription.Contains("Arch Linux")){
|
||||
CurrentSystem = SupportedLinuxDistributions.ArchLinux; }
|
||||
else if (OsDescription.Contains("Rocky Linux")){
|
||||
CurrentSystem = SupportedLinuxDistributions.RockyLinux; }
|
||||
else{
|
||||
string CurrentSupportedLinuxDistributions = string.Join(", ", Enum.GetNames<SupportedLinuxDistributions>());
|
||||
string Message = @$"
|
||||
@@ -96,8 +99,10 @@ switch (CurrentSystem){
|
||||
CheckUser();
|
||||
Console.WriteLine("正在检查语言配置");
|
||||
string[] NewContent = [];
|
||||
File.Copy("/etc/locale.gen", "/etc/locale.gen.bak", true);
|
||||
Console.WriteLine("原始 /etc/locale.gen 文件已备份为 /etc/locale.gen.bak");
|
||||
using var FileStream = new FileStream("/etc/locale.gen", FileMode.Open, FileAccess.ReadWrite, FileShare.None);
|
||||
using (var StreamReader = new StreamReader(FileStream, Encoding.UTF8, true, 1024, true)){
|
||||
using (var StreamReader = new StreamReader(FileStream, new UTF8Encoding(false), true, 1024, true)){
|
||||
NewContent = [.. StreamReader.ReadToEnd()
|
||||
.Split("\n")
|
||||
.Select(Line => Line.Trim())
|
||||
@@ -105,9 +110,15 @@ switch (CurrentSystem){
|
||||
if (Line.Contains("zh_CN.UTF-8 UTF-8")){
|
||||
Line = "zh_CN.UTF-8 UTF-8"; }
|
||||
return Line; } ) ]; }
|
||||
if (NewContent.Any(Line => Line.StartsWith("zh_CN.UTF-8 UTF-8")) == false){
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine("警告:在 /etc/locale.gen 中未检测到 zh_CN.UTF-8 UTF-8 条目,这种情况较为反常,建议您关注后续的执行结果");
|
||||
Console.WriteLine("如果需要恢复备份,请直接使用 /etc/locale.gen.bak 覆盖 /etc/locale.gen");
|
||||
Console.ResetColor();
|
||||
NewContent = [.. NewContent, "zh_CN.UTF-8 UTF-8"]; }
|
||||
FileStream.SetLength(0);
|
||||
FileStream.Seek(0, SeekOrigin.Begin);
|
||||
using (var StreamWriter = new StreamWriter(FileStream, Encoding.UTF8)){
|
||||
using (var StreamWriter = new StreamWriter(FileStream, new UTF8Encoding(false), 1024, true)){
|
||||
foreach (var Line in NewContent){
|
||||
StreamWriter.WriteLine(Line); } }
|
||||
Console.WriteLine("正在生成语言配置");
|
||||
@@ -134,7 +145,32 @@ switch (CurrentSystem){
|
||||
if (File.Exists("/etc/default/locale")){
|
||||
File.Move("/etc/default/locale", "/etc/default/locale.bak", true); }
|
||||
File.CreateSymbolicLink("/etc/default/locale", "/etc/locale.conf"); }
|
||||
break; } }
|
||||
break; }
|
||||
case SupportedLinuxDistributions.RockyLinux or SupportedLinuxDistributions.AlmaLinux or SupportedLinuxDistributions.Fedora: {
|
||||
CheckUser("即将开始安装中文语言包");
|
||||
Console.WriteLine("开始更新语言配置");
|
||||
Console.WriteLine("正在安装中文语言包");
|
||||
ExecuteCommand("dnf", ["install", "-y", "glibc-langpack-zh", "langpacks-zh_CN"]);
|
||||
Console.WriteLine("正在更新语言配置");
|
||||
ExecuteCommand("localectl", ["set-locale", "LANG=zh_CN.UTF-8"]);
|
||||
|
||||
if (IsRunningInsideWSL() && CurrentSystem == SupportedLinuxDistributions.AlmaLinux) {
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("警告:检测到您正在WSL内使用AlmaLinux");
|
||||
Console.WriteLine("目前已知AlmaLinux的WSL镜像可能存在一些问题");
|
||||
Console.WriteLine("如果您遇到了诸如 dnf nano 等软件的显示仍然为英文的问题");
|
||||
Console.WriteLine("请尝试使用dnf重新安装或升级出现问题的软件包,或者直接完整更新系统内所有软件包,这应当可以解决问题");
|
||||
Console.WriteLine();
|
||||
Console.ResetColor(); }
|
||||
break; }
|
||||
default: {
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine($"错误:您当前使用的操作系统 {OsDescription} ,匹配名称 {CurrentSystem} 受到支持,但是lag2cn没有为其配置执行逻辑");
|
||||
Console.WriteLine("这是一个程序Bug,请前往Github仓库开启一个issue,并提供当前输出日志");
|
||||
Console.ResetColor();
|
||||
throw new InvalidOperationException("遗漏的switch匹配"); } }
|
||||
|
||||
Console.WriteLine("配置完成,更改将在您下一次登录Shell时生效,按任意键退出");
|
||||
Console.ReadKey(true);
|
||||
|
||||
@@ -143,4 +179,7 @@ enum SupportedLinuxDistributions {
|
||||
Armbian,
|
||||
Ubuntu,
|
||||
ArchLinux,
|
||||
CachyOS }
|
||||
CachyOS,
|
||||
RockyLinux,
|
||||
AlmaLinux,
|
||||
Fedora }
|
||||
Reference in New Issue
Block a user