From 51971207f2797f51f206372db3387cb8231b599f Mon Sep 17 00:00:00 2001 From: Heng Guo <2085471348@qq.com> Date: Tue, 5 Sep 2023 20:11:31 +0800 Subject: [PATCH] os-mysys2 --- chsrc.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/chsrc.c b/chsrc.c index 8496acc..439af7e 100644 --- a/chsrc.c +++ b/chsrc.c @@ -1041,30 +1041,39 @@ os_openbsd_setsrc(char* option) void os_mysys2_setsrc(char* option) { - int selected = 0; - for (int i=0;iname; - const char* source_abbr = os_mysys2_sources[selected].mirror->abbr; - const char* source_url = os_mysys2_sources[selected].url; + + + source_info source = os_mysys2_sources[index]; + chsrc_say_selection(&source); + char* backup = "cp -rf /etc/pacman.d/mirrorlist.mingw32 /etc/pacman.d/mirrorlist.mingw32.bak"; + chsrc_logcmd(backup); system(backup); backup = "cp -rf /etc/pacman.d/mirrorlist.mingw64 /etc/pacman.d/mirrorlist.mingw64.bak"; + chsrc_logcmd(backup); system(backup); backup = "cp -rf /etc/pacman.d/mirrorlist.msys /etc/pacman.d/mirrorlist.msys.bak"; + chsrc_logcmd(backup); system(backup); xy_info ("chsrc: 备份文件名:1. /etc/pacman.d/mirrorlist.mingw32.bak"); xy_info ("chsrc: 备份文件名:2. /etc/pacman.d/mirrorlist.mingw64.bak"); xy_info ("chsrc: 备份文件名:3. /etc/pacman.d/mirrorlist.msys.bak"); - char* prev = xy_strjoin(3,"请针对你的架构下载安装此目录下的文件:",source_url,"distrib/<架构>/"); + char* prev = xy_strjoin(3,"请针对你的架构下载安装此目录下的文件:",source.url,"distrib/<架构>/"); xy_info (prev); free(prev); - char* cmd = xy_strjoin(3,"sed -i \"s#https\?://mirror.msys2.org/#",source_url,"#g\" /etc/pacman.d/mirrorlist* "); + char* cmd = xy_strjoin(3,"sed -i \"s#https\?://mirror.msys2.org/#",source.url,"#g\" /etc/pacman.d/mirrorlist* "); + chsrc_logcmd(cmd); system(cmd); free(cmd); @@ -1075,8 +1084,7 @@ os_mysys2_setsrc(char* option) // rm = "rm -rf /etc/pacman.d/mirrorlist.msys.bak"; // system(rm); - xy_info ("chsrc: 为 mysys2 命令换源"); - xy_success (xy_2strjoin("chsrc: 感谢镜像提供方:", source_name)); + chsrc_say_thanks(&source); }