From ccaf8d2b334a9c9cb9270f747f10983a82ff93de Mon Sep 17 00:00:00 2001 From: Aoran Zeng Date: Fri, 16 Aug 2024 01:21:05 +0800 Subject: [PATCH] Split openbsd out --- include/source.h | 17 +------------ src/chsrc.c | 28 +-------------------- src/recipe/catalog.c | 2 +- src/recipe/os/openbsd.c | 54 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 44 deletions(-) create mode 100644 src/recipe/os/openbsd.c diff --git a/include/source.h b/include/source.h index f1e8f63..46a903a 100644 --- a/include/source.h +++ b/include/source.h @@ -370,21 +370,6 @@ os_netbsd_sources[] = { }, -/** - * @time 2023-09-02 更新 - * @note 源并不完整,且未经测试是否有效 - */ -os_openbsd_sources[] = { - {&Upstream, NULL}, - {&Ali, "https://mirrors.aliyun.com/OpenBSD/"}, - {&Bfsu, "https://mirrors.bfsu.edu.cn/OpenBSD/"}, - {&Ustc, "https://mirrors.ustc.edu.cn/OpenBSD/"}, - {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/OpenBSD/"}, - {&Tencent, "https://mirrors.tencent.com/OpenBSD/"}, - {&Netease, "https://mirrors.163.com/OpenBSD/"}, - {&Sohu, "https://mirrors.sohu.com/OpenBSD/"} -}, - /** * @time 2023-09-06 更新 @@ -559,7 +544,7 @@ def_sources_n(os_rocky); def_sources_n(os_alma); def_sources_n(os_linuxlite); def_sources_n(os_raspberrypi); def_sources_n(os_armbian); -def_sources_n(os_freebsd); def_sources_n(os_netbsd); def_sources_n(os_openbsd); +def_sources_n(os_freebsd); def_sources_n(os_netbsd); def_sources_n(os_ros); diff --git a/src/chsrc.c b/src/chsrc.c index 822dcd1..d5e10bc 100644 --- a/src/chsrc.c +++ b/src/chsrc.c @@ -898,33 +898,7 @@ os_netbsd_setsrc (char *option) chsrc_say_lastly (&source, ChsrcTypeUntested); } - - -void -os_openbsd_getsrc (char *option) -{ - chsrc_view_file ("/etc/installurl"); -} - -/** - * 参考: - * 1. https://mirrors.tuna.tsinghua.edu.cn/help/openbsd/ - * 2. https://book.bsdcn.org/di-26-zhang-openbsd/di-26.2-jie-pei-zhi.html - */ -void -os_openbsd_setsrc (char *option) -{ - chsrc_ensure_root (); - - SourceInfo source; - chsrc_yield_source (os_openbsd); - chsrc_confirm_source (&source); - - chsrc_backup ("/etc/installurl"); - chsrc_overwrite_file (source.url, "/etc/installurl"); - - chsrc_say_lastly (&source, ChsrcTypeUntested); -} +#include "recipe/os/openbsd.c" /** * 参考: diff --git a/src/recipe/catalog.c b/src/recipe/catalog.c index cfcca76..1a7f847 100644 --- a/src/recipe/catalog.c +++ b/src/recipe/catalog.c @@ -41,7 +41,7 @@ static const char def_target(os_ubuntu); def_target(os_mint); def_target(os_debian); def_target(os_kali); def_target(os_linuxlite); -def_target(os_netbsd); def_target(os_openbsd); +def_target(os_netbsd); def_target(os_deepin); def_target(os_openkylin); def_target(os_raspberrypi); def_target(os_armbian); diff --git a/src/recipe/os/openbsd.c b/src/recipe/os/openbsd.c new file mode 100644 index 0000000..9dab7eb --- /dev/null +++ b/src/recipe/os/openbsd.c @@ -0,0 +1,54 @@ +/** ------------------------------------------------------------ + * SPDX-License-Identifier: GPL-3.0-or-later + * ------------------------------------------------------------- + * File Authors : Heng Guo <2085471348@qq.com> + * | Aoran Zeng + * Contributors : Nil Null + * Created On : <2023-09-03> + * Last Modified : <2024-08-16> + * ------------------------------------------------------------*/ + +/** + * @time 2023-09-02 更新 + */ +static SourceInfo +os_openbsd_sources[] = { + {&Upstream, NULL}, + {&Ali, "https://mirrors.aliyun.com/OpenBSD/"}, + {&Bfsu, "https://mirrors.bfsu.edu.cn/OpenBSD/"}, + {&Ustc, "https://mirrors.ustc.edu.cn/OpenBSD/"}, + {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/OpenBSD/"}, + {&Tencent, "https://mirrors.tencent.com/OpenBSD/"}, + {&Netease, "https://mirrors.163.com/OpenBSD/"}, + {&Sohu, "https://mirrors.sohu.com/OpenBSD/"} +}; +def_sources_n(os_openbsd); + + +void +os_openbsd_getsrc (char *option) +{ + chsrc_view_file ("/etc/installurl"); +} + +/** + * 参考: + * 1. https://mirrors.tuna.tsinghua.edu.cn/help/openbsd/ + * 2. https://book.bsdcn.org/di-26-zhang-openbsd/di-26.2-jie-pei-zhi.html + */ +void +os_openbsd_setsrc (char *option) +{ + chsrc_ensure_root (); + + SourceInfo source; + chsrc_yield_source (os_openbsd); + chsrc_confirm_source (&source); + + chsrc_backup ("/etc/installurl"); + chsrc_overwrite_file (source.url, "/etc/installurl"); + + chsrc_say_lastly (&source, ChsrcTypeUntested); +} + +def_target(os_openbsd);