diff --git a/include/source.h b/include/source.h index 46a903a..1ef2c79 100644 --- a/include/source.h +++ b/include/source.h @@ -354,22 +354,6 @@ os_freebsd_sources[] = { }, -/** - * @time 2023-09-05 更新 - * @note 源并不完整,且未经测试是否有效 - */ -os_netbsd_sources[] = { - {&Upstream, NULL}, - {&Ali, "https://mirrors.aliyun.com/pkgsrc/packages/NetBSD/"}, - {&Bfsu, "https://mirrors.bfsu.edu.cn/pkgsrc/packages/NetBSD/"}, - {&Ustc, "https://mirrors.ustc.edu.cn/pkgsrc/packages/NetBSD/"}, - {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/pkgsrc/packages/NetBSD/"}, - {&Tencent, "https://mirrors.tencent.com/pkgsrc/packages/NetBSD/"}, - {&Netease, "https://mirrors.163.com/pkgsrc/packages/NetBSD/"}, - {&Sohu, "https://mirrors.sohu.com/pkgsrc/packages/NetBSD/"} -}, - - /** * @time 2023-09-06 更新 @@ -544,7 +528,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_freebsd); def_sources_n(os_ros); diff --git a/src/chsrc.c b/src/chsrc.c index d5e10bc..376e6c3 100644 --- a/src/chsrc.c +++ b/src/chsrc.c @@ -860,44 +860,7 @@ os_freebsd_setsrc (char *option) } - -void -os_netbsd_getsrc (char *option) -{ - chsrc_view_file ("/usr/pkg/etc/pkgin/repositories.conf"); -} - -/** - * 参考: - * 1. https://mirrors.tuna.tsinghua.edu.cn/help/pkgsrc/ - * 2. https://book.bsdcn.org/di-27-zhang-netbsd/di-27.2-jie-huan-yuan-yu-bao-guan-li-qi.html - * - * 根据 @ykla (https://github.com/ykla) - * NetBSD 默认状态下没有 pkgsrc,用户可能安装了也可能没安装 - * - * HELP: 未经测试 - */ -void -os_netbsd_setsrc (char *option) -{ - chsrc_ensure_root (); // HELP: 不知道是否需要确保root权限 - - SourceInfo source; - chsrc_yield_source (os_netbsd); - chsrc_confirm_source (&source); - - chsrc_backup ("/usr/pkg/etc/pkgin/repositories.conf"); - - char *arch = chsrc_get_cpuarch (); - char *vercmd = "cat /etc/os-release | grep \"VERSION=\" | grep -Po \"[8-9].[0-9]+\""; - char *version = xy_run (vercmd, 0, NULL); - - char *url = xy_strjoin (5, source.url, arch, "/", version, "/All"); - chsrc_overwrite_file (url, "/usr/pkg/etc/pkgin/repositories.conf"); - - chsrc_say_lastly (&source, ChsrcTypeUntested); -} - +#include "recipe/os/netbsd.c" #include "recipe/os/openbsd.c" /** diff --git a/src/recipe/catalog.c b/src/recipe/catalog.c index 1a7f847..c3f678e 100644 --- a/src/recipe/catalog.c +++ b/src/recipe/catalog.c @@ -41,7 +41,6 @@ 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_deepin); def_target(os_openkylin); def_target(os_raspberrypi); def_target(os_armbian); diff --git a/src/recipe/os/netbsd.c b/src/recipe/os/netbsd.c new file mode 100644 index 0000000..7f0a307 --- /dev/null +++ b/src/recipe/os/netbsd.c @@ -0,0 +1,65 @@ +/** ------------------------------------------------------------ + * SPDX-License-Identifier: GPL-3.0-or-later + * ------------------------------------------------------------- + * File Authors : Aoran Zeng + * | Heng Guo <2085471348@qq.com> + * Contributors : Nil Null + * Created On : <2023-09-05> + * Last Modified : <2024-08-16> + * ------------------------------------------------------------*/ + +/** + * @time 2023-09-05 更新 + */ +static SourceInfo +os_netbsd_sources[] = { + {&Upstream, NULL}, + {&Ali, "https://mirrors.aliyun.com/pkgsrc/packages/NetBSD/"}, + {&Bfsu, "https://mirrors.bfsu.edu.cn/pkgsrc/packages/NetBSD/"}, + {&Ustc, "https://mirrors.ustc.edu.cn/pkgsrc/packages/NetBSD/"}, + {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/pkgsrc/packages/NetBSD/"}, + {&Tencent, "https://mirrors.tencent.com/pkgsrc/packages/NetBSD/"}, + {&Netease, "https://mirrors.163.com/pkgsrc/packages/NetBSD/"}, + {&Sohu, "https://mirrors.sohu.com/pkgsrc/packages/NetBSD/"} +}; +def_sources_n(os_netbsd); + + +void +os_netbsd_getsrc (char *option) +{ + chsrc_view_file ("/usr/pkg/etc/pkgin/repositories.conf"); +} + +/** + * 参考: + * 1. https://mirrors.tuna.tsinghua.edu.cn/help/pkgsrc/ + * 2. https://book.bsdcn.org/di-27-zhang-netbsd/di-27.2-jie-huan-yuan-yu-bao-guan-li-qi.html + * + * 根据 @ykla (https://github.com/ykla) + * NetBSD 默认状态下没有 pkgsrc,用户可能安装了也可能没安装 + * + * HELP: 未经测试 + */ +void +os_netbsd_setsrc (char *option) +{ + chsrc_ensure_root (); // HELP: 不知道是否需要确保root权限 + + SourceInfo source; + chsrc_yield_source (os_netbsd); + chsrc_confirm_source (&source); + + chsrc_backup ("/usr/pkg/etc/pkgin/repositories.conf"); + + char *arch = chsrc_get_cpuarch (); + char *vercmd = "cat /etc/os-release | grep \"VERSION=\" | grep -Po \"[8-9].[0-9]+\""; + char *version = xy_run (vercmd, 0, NULL); + + char *url = xy_strjoin (5, source.url, arch, "/", version, "/All"); + chsrc_overwrite_file (url, "/usr/pkg/etc/pkgin/repositories.conf"); + + chsrc_say_lastly (&source, ChsrcTypeUntested); +} + +def_target(os_netbsd);