From 0cbc76c56efe6ac84b3d52340a4df397439fa4eb Mon Sep 17 00:00:00 2001 From: Aoran Zeng Date: Fri, 16 Aug 2024 00:51:46 +0800 Subject: [PATCH] Split alpine out --- include/source.h | 17 +------------ src/chsrc.c | 30 +---------------------- src/recipe/catalog.c | 2 +- src/recipe/os/alpine.c | 55 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 46 deletions(-) create mode 100644 src/recipe/os/alpine.c diff --git a/include/source.h b/include/source.h index a7f7410..9f7e0cd 100644 --- a/include/source.h +++ b/include/source.h @@ -361,21 +361,6 @@ os_alma_sources[] = { }, -/** - * @time 2024-04-18 更新 - */ -os_alpine_sources[] = { - {&Upstream, NULL}, - {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/alpine"}, - {&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/alpine"}, - {&Sustech, "https://mirrors.sustech.edu.cn/alpine"}, - {&Zju, "https://mirrors.zju.edu.cn/alpine"}, - {&Lzuoss, "https://mirror.lzu.edu.cn/alpine"}, - {&Ali, "https://mirrors.aliyun.com/alpine"}, - {&Tencent, "https://mirrors.cloud.tencent.com/alpine"}, - {&Huawei, "https://mirrors.huaweicloud.com/alpine"} -}, - /** * @time 2023-09-24 更新 @@ -666,7 +651,7 @@ def_sources_n(os_debian); def_sources_n(os_fedora); 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_alpine); def_sources_n(os_rocky); def_sources_n(os_alma); +def_sources_n(os_rocky); def_sources_n(os_alma); def_sources_n(os_void); def_sources_n(os_solus); diff --git a/src/chsrc.c b/src/chsrc.c index b636b9c..9306ad9 100644 --- a/src/chsrc.c +++ b/src/chsrc.c @@ -794,35 +794,7 @@ os_alma_setsrc (char *option) } - -void -os_alpine_getsrc (char *option) -{ - chsrc_view_file ("/etc/apk/repositories"); -} - -/** - * 参考: https://help.mirrors.cernet.edu.cn/alpine/ - */ -void -os_alpine_setsrc (char *option) -{ - // chsrc_ensure_root(); // HELP: 不确定是否需要root - - SourceInfo source; - chsrc_yield_source (os_alpine); - chsrc_confirm_source (&source); - - char* cmd = xy_strjoin (3, - "sed -i 's#https\\?://dl-cdn.alpinelinux.org/alpine#", source.url, "#g' /etc/apk/repositories" - ); - chsrc_run (cmd, RunOpt_Default); - - chsrc_run ("apk update", RunOpt_No_Last_New_Line); - chsrc_say_lastly (&source, ChsrcTypeUntested); -} - - +#include "recipe/os/alpine.c" void os_void_getsrc (char *option) diff --git a/src/recipe/catalog.c b/src/recipe/catalog.c index ce0b8b2..132ee82 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_alpine); def_target(os_void); def_target(os_trisquel); def_target(os_linuxlite); +def_target(os_void); 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/alpine.c b/src/recipe/os/alpine.c new file mode 100644 index 0000000..303289f --- /dev/null +++ b/src/recipe/os/alpine.c @@ -0,0 +1,55 @@ +/** ------------------------------------------------------------ + * 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 2024-04-18 更新 + */ +static SourceInfo +os_alpine_sources[] = { + {&Upstream, NULL}, + {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/alpine"}, + {&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/alpine"}, + {&Sustech, "https://mirrors.sustech.edu.cn/alpine"}, + {&Zju, "https://mirrors.zju.edu.cn/alpine"}, + {&Lzuoss, "https://mirror.lzu.edu.cn/alpine"}, + {&Ali, "https://mirrors.aliyun.com/alpine"}, + {&Tencent, "https://mirrors.cloud.tencent.com/alpine"}, + {&Huawei, "https://mirrors.huaweicloud.com/alpine"} +}; +def_sources_n(os_alpine); + + +void +os_alpine_getsrc (char *option) +{ + chsrc_view_file ("/etc/apk/repositories"); +} + +/** + * 参考: https://help.mirrors.cernet.edu.cn/alpine/ + */ +void +os_alpine_setsrc (char *option) +{ + // chsrc_ensure_root(); // HELP: 不确定是否需要root + + SourceInfo source; + chsrc_yield_source (os_alpine); + chsrc_confirm_source (&source); + + char* cmd = xy_strjoin (3, + "sed -i 's#https\\?://dl-cdn.alpinelinux.org/alpine#", source.url, "#g' /etc/apk/repositories" + ); + chsrc_run (cmd, RunOpt_Default); + + chsrc_run ("apk update", RunOpt_No_Last_New_Line); + chsrc_say_lastly (&source, ChsrcTypeUntested); +} + +def_target(os_alpine);