diff --git a/include/source.h b/include/source.h index 9f7e0cd..e8148d1 100644 --- a/include/source.h +++ b/include/source.h @@ -362,16 +362,6 @@ os_alma_sources[] = { -/** - * @time 2023-09-24 更新 - */ -os_void_sources[] = { - {&Upstream, NULL}, - {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/voidlinux"}, - {&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/voidlinux"}, - {&Bfsu, "https://mirrors.bfsu.edu.cn/voidlinux"} -}, - /** * @time 2023-09-29 更新 @@ -652,7 +642,6 @@ def_sources_n(os_kali); def_sources_n(os_opensuse); def_sources_n(os_arch); def_sources_n(os_archlinuxcn); def_sources_n(os_msys2); def_sources_n(os_gentoo); def_sources_n(os_rocky); def_sources_n(os_alma); -def_sources_n(os_void); def_sources_n(os_solus); def_sources_n(os_trisquel); def_sources_n(os_linuxlite); def_sources_n(os_raspberrypi); diff --git a/src/chsrc.c b/src/chsrc.c index 9306ad9..0ff7ee0 100644 --- a/src/chsrc.c +++ b/src/chsrc.c @@ -795,44 +795,7 @@ os_alma_setsrc (char *option) #include "recipe/os/alpine.c" - -void -os_void_getsrc (char *option) -{ - char* cmd = "xbps-query -L"; - chsrc_run (cmd, RunOpt_No_Last_New_Line); -} - -/** - * 参考: https://help.mirrors.cernet.edu.cn/voidlinux/ - */ -void -os_void_setsrc (char *option) -{ - // chsrc_ensure_root(); // HELP: 不确定是否需要root - - SourceInfo source; - chsrc_yield_source (os_void); - chsrc_confirm_source (&source); - - 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, - "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, - "sed -i 's|https://alpha.de.repo.voidlinux.org|", source.url, "|g' /etc/xbps.d/*-repository-*.conf" - ); - - chsrc_note2 ("若报错可尝试使用以下命令:"); - puts (cmd); - chsrc_say_lastly (&source, ChsrcTypeUntested); -} - +#include "recipe/os/void.c" /** diff --git a/src/recipe/catalog.c b/src/recipe/catalog.c index 132ee82..ac83252 100644 --- a/src/recipe/catalog.c +++ b/src/recipe/catalog.c @@ -40,7 +40,7 @@ static const char def_target(os_ubuntu); def_target(os_mint); def_target(os_debian); def_target(os_kali); -def_target(os_void); def_target(os_trisquel); def_target(os_linuxlite); +def_target(os_trisquel); def_target(os_linuxlite); def_target(os_netbsd); def_target(os_openbsd); def_target(os_deepin); def_target(os_openkylin); def_target(os_raspberrypi); diff --git a/src/recipe/os/void.c b/src/recipe/os/void.c new file mode 100644 index 0000000..9759429 --- /dev/null +++ b/src/recipe/os/void.c @@ -0,0 +1,60 @@ +/** ------------------------------------------------------------ + * SPDX-License-Identifier: GPL-3.0-or-later + * ------------------------------------------------------------- + * File Authors : Aoran Zeng + * Contributors : Nil Null + * Created On : <2023-09-24> + * Last Modified : <2024-08-09> + * ------------------------------------------------------------*/ + +/** + * @time 2023-09-24 更新 + */ +static SourceInfo +os_void_sources[] = { + {&Upstream, NULL}, + {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/voidlinux"}, + {&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/voidlinux"}, + {&Bfsu, "https://mirrors.bfsu.edu.cn/voidlinux"} +}; +def_sources_n(os_void); + + +void +os_void_getsrc (char *option) +{ + char* cmd = "xbps-query -L"; + chsrc_run (cmd, RunOpt_No_Last_New_Line); +} + +/** + * 参考: https://help.mirrors.cernet.edu.cn/voidlinux/ + */ +void +os_void_setsrc (char *option) +{ + // chsrc_ensure_root(); // HELP: 不确定是否需要root + + SourceInfo source; + chsrc_yield_source (os_void); + chsrc_confirm_source (&source); + + 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, + "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, + "sed -i 's|https://alpha.de.repo.voidlinux.org|", source.url, "|g' /etc/xbps.d/*-repository-*.conf" + ); + + chsrc_note2 ("若报错可尝试使用以下命令:"); + puts (cmd); + chsrc_say_lastly (&source, ChsrcTypeUntested); +} + +def_target(os_void);