diff --git a/include/source.h b/include/source.h index da73f3a..8fccf37 100644 --- a/include/source.h +++ b/include/source.h @@ -263,20 +263,6 @@ os_linuxlite_sources[] = { -/** - * @time 2023-09-29 更新 - */ -os_raspberrypi_sources[] = { - {&Upstream, NULL}, - {&MirrorZ, "https://help.mirrors.cernet.edu.cn/raspberrypi/"}, - {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/raspberrypi/"}, - {&Bfsu, "https://mirrors.bfsu.edu.cn/raspberrypi/"}, - {&Ustc, "https://mirrors.ustc.edu.cn/raspberrypi/"}, - {&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/raspberrypi/"}, - {&Sustech, "https://mirrors.sustech.edu.cn/raspberrypi/"} -}, - - /** * @time 2023-09-06 更新 @@ -447,7 +433,7 @@ def_sources_n(os_kali); def_sources_n(os_msys2); def_sources_n(os_rocky); def_sources_n(os_alma); -def_sources_n(os_linuxlite); def_sources_n(os_raspberrypi); +def_sources_n(os_linuxlite); def_sources_n(os_ros); diff --git a/src/chsrc.c b/src/chsrc.c index 59c4154..d07a9c6 100644 --- a/src/chsrc.c +++ b/src/chsrc.c @@ -75,32 +75,7 @@ pl_clojure_setsrc (char *option) #include "recipe/os/apt-family/linuxmint.c" #include "recipe/os/apt-family/trisquel.c" #include "recipe/os/apt-family/armbian.c" - -void -os_raspberrypi_getsrc (char *option) -{ - chsrc_view_file ("/etc/apt/sources.list.d/raspi.list"); -} - -void -os_raspberrypi_setsrc (char *option) -{ - // chsrc_ensure_root(); // HELP: 不确定是否需要 - - SourceInfo source; - chsrc_yield_source (os_raspberrypi); - chsrc_confirm_source (&source); - - chsrc_backup ("/etc/apt/sources.list.d/raspi.list"); - - char *cmd = xy_strjoin (3, "sed -E -i 's@https?://.*/.*/?@", source.url, - "@g' /etc/apt/sources.list.d/raspi.list"); - - chsrc_run (cmd, RunOpt_Default); - chsrc_run ("apt update", RunOpt_No_Last_New_Line); - chsrc_say_lastly (&source, ChsrcTypeUntested); -} - +#include "recipe/os/apt-family/raspberrypi.c" diff --git a/src/recipe/catalog.c b/src/recipe/catalog.c index 0d4f5ed..cea0be5 100644 --- a/src/recipe/catalog.c +++ b/src/recipe/catalog.c @@ -42,7 +42,6 @@ static const char def_target(os_kali); def_target(os_linuxlite); def_target(os_deepin); def_target(os_openkylin); -def_target(os_raspberrypi); def_target_noget(os_fedora); def_target_noget(os_rocky); def_target_noget(os_alma); diff --git a/src/recipe/os/apt-family/common.h b/src/recipe/os/apt-family/common.h index 335454f..f246c7f 100644 --- a/src/recipe/os/apt-family/common.h +++ b/src/recipe/os/apt-family/common.h @@ -7,6 +7,9 @@ * Last Modified : <2024-08-16> * ------------------------------------------------------------*/ +#define OS_Apt_SourceList "/etc/apt/sources.list" +#define OS_Apt_SourceList_D "/etc/apt/sources.list.d/" + /** * @note 从 Debian 12 开始,Debain 的软件源配置文件变更为 DEB822 格式, * 路径为: /etc/apt/sources.list.d/debian.sources" @@ -14,21 +17,18 @@ * @note 从 Ubuntu 24.04 开始,Ubuntu 的软件源配置文件变更为 DEB822 格式, * 路径为: /etc/apt/sources.list.d/ubuntu.sources */ - #define OS_Debian_SourceList_DEB822 "/etc/apt/sources.list.d/debian.sources" #define OS_Ubuntu_SourceList_DEB822 "/etc/apt/sources.list.d/ubuntu.sources" -#define OS_Apt_SourceList "/etc/apt/sources.list" #define ETC_os_release "/etc/os-release" #define OS_Is_Debian_Literally 1 #define OS_Is_Ubuntu 2 - -#define OS_Armbian_SourceList "/etc/apt/sources.list.d/armbian.list" - - +#define OS_LinuxMint_SourceList OS_Apt_SourceList_D "official-package-repositories.list" +#define OS_Armbian_SourceList OS_Apt_SourceList_D "armbian.list" +#define OS_RaspberryPi_SourceList OS_Apt_SourceList_D "raspi.list" /** diff --git a/src/recipe/os/apt-family/linuxmint.c b/src/recipe/os/apt-family/linuxmint.c index dc949e6..0a53389 100644 --- a/src/recipe/os/apt-family/linuxmint.c +++ b/src/recipe/os/apt-family/linuxmint.c @@ -24,7 +24,7 @@ def_sources_n(os_linuxmint); void os_linuxmint_getsrc (char *option) { - chsrc_view_file ("/etc/apt/sources.list.d/official-package-repositories.list"); + chsrc_view_file (OS_LinuxMint_SourceList); } /** @@ -39,10 +39,10 @@ os_linuxmint_setsrc (char *option) chsrc_yield_source (os_linuxmint); chsrc_confirm_source (&source); - chsrc_backup ("/etc/apt/sources.list.d/official-package-repositories.list"); + chsrc_backup (OS_LinuxMint_SourceList); char* cmd = xy_strjoin (3, "sed -E -i 's@https?://.*/.*/?@", source.url, - "@g' /etc/apt/sources.list.d/official-package-repositories.list"); + "@g' " OS_LinuxMint_SourceList); chsrc_run (cmd, RunOpt_Default); chsrc_run ("apt update", RunOpt_No_Last_New_Line); diff --git a/src/recipe/os/apt-family/raspberrypi.c b/src/recipe/os/apt-family/raspberrypi.c new file mode 100644 index 0000000..83f1fb9 --- /dev/null +++ b/src/recipe/os/apt-family/raspberrypi.c @@ -0,0 +1,52 @@ +/** ------------------------------------------------------------ + * SPDX-License-Identifier: GPL-3.0-or-later + * ------------------------------------------------------------- + * File Authors : Aoran Zeng + * Contributors : Nil Null + * Created On : <2023-09-29> + * Last Modified : <2024-08-16> + * + * Raspberry Pi OS 树莓派操作系统,以前称为 Raspbian + * ------------------------------------------------------------*/ + +/** + * @time 2023-09-29 更新 + */ +static SourceInfo +os_raspberrypi_sources[] = { + {&Upstream, NULL}, + {&MirrorZ, "https://help.mirrors.cernet.edu.cn/raspberrypi/"}, + {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/raspberrypi/"}, + {&Bfsu, "https://mirrors.bfsu.edu.cn/raspberrypi/"}, + {&Ustc, "https://mirrors.ustc.edu.cn/raspberrypi/"}, + {&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/raspberrypi/"}, + {&Sustech, "https://mirrors.sustech.edu.cn/raspberrypi/"} +}; +def_sources_n(os_raspberrypi); + +void +os_raspberrypi_getsrc (char *option) +{ + chsrc_view_file (OS_RaspberryPi_SourceList); +} + +void +os_raspberrypi_setsrc (char *option) +{ + chsrc_ensure_root(); // HELP: 不确定是否需要 + + SourceInfo source; + chsrc_yield_source (os_raspberrypi); + chsrc_confirm_source (&source); + + chsrc_backup (OS_RaspberryPi_SourceList); + + char *cmd = xy_strjoin (3, "sed -E -i 's@https?://.*/.*/?@", source.url, + "@g' " OS_RaspberryPi_SourceList); + + chsrc_run (cmd, RunOpt_Default); + chsrc_run ("apt update", RunOpt_No_Last_New_Line); + chsrc_say_lastly (&source, ChsrcTypeUntested); +} + +def_target(os_raspberrypi);