Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add os armbian #38

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ sudo chsrc set ros 或 set ros2
sudo chsrc set trisquel
sudo chsrc set lite 或 set linuxlite
sudo chsrc set raspi 或 set raspberrypi
sudo chsrc set armbian

sudo chsrc set euler 或 set openeuler
sudo chsrc set anolis 或 set openanolis
Expand Down
23 changes: 20 additions & 3 deletions include/source.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
* SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File : source.h
* Authors : Aoran Zeng <ccmywish@qq.com>
* | Heng Guo <2085471348@qq.com>
* Authors : Aoran Zeng <ccmywish@qq.com>
* | Heng Guo <2085471348@qq.com>
* | Shengwei Chen <414685209@qq.com>
* Created on : <2023-08-29>
* Last modified : <2024-06-14>
* Last modified : <2024-06-20>
*
* 镜像站与换源信息
* ------------------------------------------------------------*/
Expand Down Expand Up @@ -688,6 +689,21 @@ os_raspberrypi_sources[] = {
},


/**
* 2024-06-20 更新
*/
os_armbian_sources[] = {
{&Upstream, NULL},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/armbian"},
{&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/armbian"},
{&Bfsu, "https://mirrors.bfsu.edu.cn/armbian"},
{&Sustech, "https://mirrors.sustech.edu.cn/armbian"},
{&Ustc, "https://mirrors.ustc.edu.cn/armbian"},
{&Nju, "https://mirrors.nju.edu.cn/armbian"},
{&Ali, "https://mirrors.aliyun.com/armbian"},
},


/**
* 2023-09-27 更新
*
Expand Down Expand Up @@ -956,6 +972,7 @@ 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);
def_sources_n(os_armbian);

def_sources_n(os_freebsd); def_sources_n(os_netbsd); def_sources_n(os_openbsd);

Expand Down
47 changes: 43 additions & 4 deletions src/chsrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
* SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File : chsrc.c
* Authors : Aoran Zeng <ccmywish@qq.com>
* | Heng Guo <2085471348@qq.com>
* Authors : Aoran Zeng <ccmywish@qq.com>
* | Heng Guo <2085471348@qq.com>
* | Shengwei Chen <414685209@qq.com>
* Created on : <2023-08-28>
* Last modified : <2024-06-14>
* Last modified : <2024-06-20>
*
* chsrc: Change Source —— 全平台通用命令行换源工具
* ------------------------------------------------------------*/
Expand Down Expand Up @@ -1140,6 +1141,42 @@ os_raspberrypi_setsrc (char *option)



void
os_armbian_getsrc (char *option)
{
if (chsrc_check_file ("/etc/apt/sources.list.d/armbian.list"))
{
chsrc_take_a_look_at_file ("/etc/apt/sources.list.d/armbian.list");
return;
}

chsrc_error_remarkably ("缺少源配置文件!路径:/etc/apt/sources.list.d/armbian.list");
}

/**
* 参考: https://mirrors.tuna.tsinghua.edu.cn/help/armbian
*/
void
os_armbian_setsrc (char *option)
{
chsrc_ensure_root ();

SourceInfo source;
chsrc_yield_source (os_armbian);
chsrc_confirm_source (&source);

chsrc_backup ("/etc/apt/sources.list.d/armbian.list");

char *cmd = xy_strjoin (3, "sed -E -i 's@https?[^ ]*armbian/?[^ ]*@", source.url,
"@g' /etc/apt/sources.list.d/armbian.list");

chsrc_run (cmd, RunOpt_Fatal_On_Error);
chsrc_run ("apt update", RunOpt_Fatal_On_Error | RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeAuto);
}



void
os_deepin_getsrc(char *option)
{
Expand Down Expand Up @@ -2297,6 +2334,7 @@ def_target(os_alpine); def_target(os_void); def_target(os_trisquel); def_target(
def_target(os_netbsd); def_target(os_openbsd);
def_target(os_deepin); def_target(os_openkylin);
def_target(os_raspberrypi);
def_target(os_armbian);
def_target_noget(os_fedora);
def_target_noget(os_opensuse);
def_target_noget(os_arch);
Expand Down Expand Up @@ -2330,6 +2368,7 @@ static const char
*os_trisquel [] = {"trisquel", NULL, t(&os_trisquel_target)},
*os_linuxlite [] = {"lite", "linuxlite", NULL, t(&os_linuxlite_target)},
*os_raspberrypi[] = {"raspi", "raspberrypi",NULL, t(&os_raspberrypi_target)},
*os_armbian [] = {"armbian", NULL, t(&os_armbian_target)},
*os_freebsd [] = {"freebsd", NULL, t(&os_freebsd_target)},
*os_netbsd [] = {"netbsd", NULL, t(&os_netbsd_target)},
*os_openbsd [] = {"openbsd", NULL, t(&os_openbsd_target)},
Expand All @@ -2344,7 +2383,7 @@ static const char
os_arch, os_manjaro, os_gentoo,
os_rocky, os_alma,
os_alpine, os_void, os_solus, os_ros,
os_trisquel, os_linuxlite, os_raspberrypi,
os_trisquel, os_linuxlite, os_raspberrypi, os_armbian,
os_deepin, os_openeuler, os_anolis, os_openkylin,
os_msys2,
os_freebsd, os_netbsd, os_openbsd,
Expand Down