Rename inner function

This commit is contained in:
Aoran Zeng
2024-08-18 09:27:22 +08:00
parent 15d9ba817e
commit eba633b6e4
55 changed files with 123 additions and 231 deletions

View File

@@ -43,9 +43,7 @@ os_armbian_setsrc (char *option)
{
chsrc_ensure_root ();
SourceInfo source;
chsrc_yield_source (os_armbian);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_armbian);
chsrc_backup (OS_Armbian_SourceList);
@@ -54,7 +52,7 @@ os_armbian_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeAuto);
chsrc_conclude (&source, ChsrcTypeAuto);
}
#undef OS_Armbian_SourceList

View File

@@ -48,9 +48,7 @@ os_debian_getsrc (char *option)
void
os_debian_setsrc_for_deb822 (char *option)
{
SourceInfo source;
chsrc_yield_source (os_debian);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_debian);
chsrc_note2 ("如果遇到无法拉取 HTTPS 源的情况,我们会使用 HTTP 源并需要您运行:");
puts ("apt install apt-transport-https ca-certificates");
@@ -65,7 +63,7 @@ os_debian_setsrc_for_deb822 (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeAuto);
chsrc_conclude (&source, ChsrcTypeAuto);
}
@@ -89,9 +87,7 @@ os_debian_setsrc (char *option)
// Docker环境下Debian镜像可能不存在该文件
bool sourcelist_exist = ensure_apt_sourcelist (OS_Is_Debian_Literally);
SourceInfo source;
chsrc_yield_source (os_debian);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_debian);
chsrc_note2 ("如果遇到无法拉取 HTTPS 源的情况,我们会使用 HTTP 源并需要您运行:");
puts ("apt install apt-transport-https ca-certificates");
@@ -106,7 +102,7 @@ os_debian_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeAuto);
chsrc_conclude (&source, ChsrcTypeAuto);
}
def_target(os_debian);

View File

@@ -41,9 +41,7 @@ os_kali_setsrc (char *option)
{
chsrc_ensure_root ();
SourceInfo source;
chsrc_yield_source (os_kali);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_kali);
chsrc_backup (OS_Apt_SourceList);
@@ -53,7 +51,7 @@ os_kali_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target(os_kali);

View File

@@ -32,16 +32,14 @@ os_linuxlite_setsrc (char *option)
{
chsrc_ensure_root ();
SourceInfo source;
chsrc_yield_source (os_linuxlite);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_linuxlite);
chsrc_backup (OS_Apt_SourceList);
char *cmd = xy_strjoin (3, "sed -E -i 's@https?://.*/.*/?@", source.url, "@g' " OS_Apt_SourceList);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeAuto);
chsrc_conclude (&source, ChsrcTypeAuto);
}
def_target(os_linuxlite);

View File

@@ -35,9 +35,7 @@ os_linuxmint_setsrc (char *option)
{
chsrc_ensure_root ();
SourceInfo source;
chsrc_yield_source (os_linuxmint);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_linuxmint);
chsrc_backup (OS_LinuxMint_SourceList);
@@ -46,7 +44,7 @@ os_linuxmint_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeAuto);
chsrc_conclude (&source, ChsrcTypeAuto);
chsrc_warn2 ("完成后请不要再使用 mintsources自带的图形化软件源设置工具进行任何操作因为在操作后无论是否有按“确定”mintsources 均会覆写我们刚才换源的内容");
}

View File

@@ -34,9 +34,7 @@ os_ros_setsrc (char *option)
{
chsrc_ensure_root (OS_ROS_SourceList);
SourceInfo source;
chsrc_yield_source (os_ros);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_ros);
chsrc_backup (OS_ROS_SourceList);
@@ -48,7 +46,7 @@ os_ros_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target_s(os_ros);

View File

@@ -35,9 +35,7 @@ os_raspberrypi_setsrc (char *option)
{
chsrc_ensure_root(); // HELP: 不确定是否需要
SourceInfo source;
chsrc_yield_source (os_raspberrypi);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_raspberrypi);
chsrc_backup (OS_RaspberryPi_SourceList);
@@ -46,7 +44,7 @@ os_raspberrypi_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target(os_raspberrypi);

View File

@@ -37,9 +37,7 @@ os_trisquel_setsrc (char *option)
{
chsrc_ensure_root ();
SourceInfo source;
chsrc_yield_source (os_trisquel);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_trisquel);
chsrc_backup (OS_Apt_SourceList);
@@ -47,7 +45,7 @@ os_trisquel_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target(os_trisquel);

View File

@@ -53,9 +53,7 @@ os_ubuntu_getsrc (char *option)
void
os_ubuntu_setsrc_for_deb822 (char *option)
{
SourceInfo source;
chsrc_yield_source (os_ubuntu);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_ubuntu);
chsrc_backup (OS_Ubuntu_SourceList_DEB822);
@@ -72,7 +70,7 @@ os_ubuntu_setsrc_for_deb822 (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeAuto);
chsrc_conclude (&source, ChsrcTypeAuto);
}
/**
@@ -92,9 +90,7 @@ os_ubuntu_setsrc (char *option)
bool sourcelist_exist = ensure_apt_sourcelist (OS_Is_Ubuntu);
SourceInfo source;
chsrc_yield_source (os_ubuntu);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_ubuntu);
// 不存在的时候,用的是我们生成的无效文件,不要备份
if (sourcelist_exist)
@@ -115,7 +111,7 @@ os_ubuntu_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeAuto);
chsrc_conclude (&source, ChsrcTypeAuto);
}
def_target(os_ubuntu);

View File

@@ -41,9 +41,7 @@ os_deepin_setsrc (char *option)
{
chsrc_ensure_root();
SourceInfo source;
chsrc_yield_source (os_deepin);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_deepin);
chsrc_backup (OS_Apt_SourceList);
@@ -53,7 +51,7 @@ os_deepin_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target(os_deepin);

View File

@@ -32,16 +32,14 @@ os_openkylin_setsrc (char *option)
{
chsrc_ensure_root();
SourceInfo source;
chsrc_yield_source (os_openkylin);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_openkylin);
chsrc_backup (OS_Apt_SourceList);
char *cmd = xy_strjoin (3, "sed -E -i 's@https?://.*/openkylin/?@", source.url, "@g'" OS_Apt_SourceList);
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target(os_openkylin);

View File

@@ -39,9 +39,7 @@ os_alpine_setsrc (char *option)
{
// chsrc_ensure_root(); // HELP: 不确定是否需要root
SourceInfo source;
chsrc_yield_source (os_alpine);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_alpine);
char* cmd = xy_strjoin (3,
"sed -i 's#https\\?://dl-cdn.alpinelinux.org/alpine#", source.url, "#g' /etc/apk/repositories"
@@ -49,7 +47,7 @@ os_alpine_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("apk update", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target(os_alpine);

View File

@@ -42,7 +42,7 @@ os_freebsd_setsrc (char *option)
int index = use_specific_mirror_or_auto_select (option, os_freebsd);
SourceInfo source = os_freebsd_sources[index];
chsrc_confirm_source (&source);
chsrc_confirm_source;
chsrc_log2 ("1. 添加 freebsd-pkg 源 (二进制安装包)");
chsrc_ensure_dir ("/usr/local/etc/pkg/repos");
@@ -128,7 +128,7 @@ os_freebsd_setsrc (char *option)
chsrc_overwrite_file (update, "/etc/freebsd-update.conf");
*/
chsrc_say_lastly (&source, ChsrcTypeSemiAuto);
chsrc_conclude (&source, ChsrcTypeSemiAuto);
}
def_target_s(os_freebsd);

View File

@@ -46,9 +46,7 @@ os_netbsd_setsrc (char *option)
{
chsrc_ensure_root (); // HELP: 不知道是否需要确保root权限
SourceInfo source;
chsrc_yield_source (os_netbsd);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_netbsd);
chsrc_backup ("/usr/pkg/etc/pkgin/repositories.conf");
@@ -59,7 +57,7 @@ os_netbsd_setsrc (char *option)
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);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target(os_netbsd);

View File

@@ -41,14 +41,12 @@ os_openbsd_setsrc (char *option)
{
chsrc_ensure_root ();
SourceInfo source;
chsrc_yield_source (os_openbsd);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_openbsd);
chsrc_backup ("/etc/installurl");
chsrc_overwrite_file (source.url, "/etc/installurl");
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target(os_openbsd);

View File

@@ -33,9 +33,7 @@ os_gentoo_setsrc (char *option)
{
chsrc_ensure_root ();
SourceInfo source;
chsrc_yield_source (os_gentoo);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_gentoo);
chsrc_backup ("/etc/portage/repos.conf/gentoo.conf");
@@ -47,7 +45,7 @@ os_gentoo_setsrc (char *option)
char *towrite = xy_strjoin (3, "GENTOO_MIRRORS=\"https://", source.url, "gentoo\"");
chsrc_append_to_file (towrite, "/etc/portage/make.conf");
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target_s(os_gentoo);

View File

@@ -42,16 +42,14 @@ os_openwrt_setsrc (char *option)
{
chsrc_ensure_root ();
SourceInfo source;
chsrc_yield_source (os_openwrt);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_openwrt);
chsrc_backup (OS_OpenWRT_SourceConfig);
char *cmd = xy_strjoin (3, "sed -E -i 's@https?://.*downloads.openwrt.org@", source.url, "@g' " OS_OpenWRT_SourceConfig);
chsrc_run ("apt update", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeAuto);
chsrc_conclude (&source, ChsrcTypeAuto);
}

View File

@@ -28,13 +28,11 @@ os_solus_setsrc (char *option)
{
chsrc_ensure_root ();
SourceInfo source;
chsrc_yield_source (os_solus);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_solus);
char *cmd = xy_2strjoin ("eopkg add-repo Solus ", source.url);
chsrc_run (cmd, RunOpt_Default);
chsrc_say_lastly (&source, ChsrcTypeAuto);
chsrc_conclude (&source, ChsrcTypeAuto);
}
def_target_s(os_solus);

View File

@@ -33,11 +33,9 @@ os_void_getsrc (char *option)
void
os_void_setsrc (char *option)
{
// chsrc_ensure_root(); // HELP: 不确定是否需要root
chsrc_ensure_root (); // HELP: 不确定是否需要root
SourceInfo source;
chsrc_yield_source (os_void);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_void);
chsrc_ensure_dir ("/etc/xbps.d");
char *cmd = "cp /usr/share/xbps.d/*-repository-*.conf /etc/xbps.d/";
@@ -53,8 +51,8 @@ os_void_setsrc (char *option)
);
chsrc_note2 ("若报错可尝试使用以下命令:");
puts (cmd);
chsrc_say_lastly (&source, ChsrcTypeUntested);
say (cmd);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target(os_void);

View File

@@ -29,16 +29,14 @@ os_almalinux_setsrc (char *option)
{
chsrc_ensure_root ();
SourceInfo source;
chsrc_yield_source (os_almalinux);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_almalinux);
char *cmd = xy_strjoin (3,
"sed -e 's|^mirrorlist=|#mirrorlist=|g' -e 's|^#\\s*baseurl=https://repo.almalinux.org/almalinux|baseurl=", source.url, "|g' -i.bak /etc/yum.repos.d/almalinux*.repo");
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("dnf makecache", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeAuto);
chsrc_conclude (&source, ChsrcTypeAuto);
}
def_target_s(os_almalinux);

View File

@@ -29,16 +29,14 @@ os_anolis_setsrc (char *option)
{
chsrc_ensure_root ();
SourceInfo source;
chsrc_yield_source (os_anolis);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_anolis);
char *cmd = xy_strjoin (3, "sed -i.bak -E 's|https?://(mirrors\\.openanolis\\.cn/anolis)|", source.url, "|g' /etc/yum.repos.d/*.repo");
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("dnf makecache", RunOpt_Default);
chsrc_run ("dnf update", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target_s(os_anolis);

View File

@@ -35,9 +35,7 @@ os_fedora_setsrc (char *option)
{
chsrc_ensure_root ();
SourceInfo source;
chsrc_yield_source (os_fedora);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_fedora);
chsrc_note2 ("Fedora 29 及以下版本暂不支持");
@@ -62,7 +60,7 @@ os_fedora_setsrc (char *option)
chsrc_log2 ("已新增文件 /etc/yum.repos.d/fedora-updates-modular.repo");
chsrc_run ("dnf makecache", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeAuto);
chsrc_conclude (&source, ChsrcTypeAuto);
}
def_target_s(os_fedora);

View File

@@ -33,9 +33,7 @@ os_rockylinux_setsrc (char *option)
{
chsrc_ensure_root ();
SourceInfo source;
chsrc_yield_source (os_rockylinux);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_rockylinux);
char *cmd = xy_strjoin (3,
"sed -e 's|^mirrorlist=|#mirrorlist=|g' "
@@ -44,7 +42,7 @@ os_rockylinux_setsrc (char *option)
);
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("dnf makecache", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target_s(os_rockylinux);

View File

@@ -32,9 +32,7 @@ os_openeuler_setsrc (char *option)
{
chsrc_ensure_root ();
SourceInfo source;
chsrc_yield_source (os_openeuler);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_openeuler);
chsrc_backup (OS_openEuler_SourceList);
@@ -45,7 +43,7 @@ os_openeuler_setsrc (char *option)
chsrc_overwrite_file (towrite, OS_openEuler_SourceList);
chsrc_run ("dnf makecache", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeAuto);
chsrc_conclude (&source, ChsrcTypeAuto);
}
def_target_s(os_openeuler);

View File

@@ -33,9 +33,7 @@ os_opensuse_setsrc (char *option)
{
chsrc_ensure_root (); // HELP: 不知道是否需要确保root权限
SourceInfo source;
chsrc_yield_source (os_opensuse);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_opensuse);
char *source_nselect = "zypper mr -da";
chsrc_run (source_nselect, RunOpt_Default);
@@ -76,7 +74,7 @@ os_opensuse_setsrc (char *option)
chsrc_run (cmd5, RunOpt_Default);
chsrc_run (cmd6, RunOpt_Default);
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target_s(os_opensuse);

View File

@@ -59,9 +59,7 @@ os_arch_setsrc (char *option)
{
chsrc_ensure_root ();
SourceInfo source;
chsrc_yield_source (os_arch);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_arch);
chsrc_backup (OS_Pacman_MirrorList);
@@ -91,7 +89,7 @@ os_arch_setsrc (char *option)
{
chsrc_run ("pacman -Syy", RunOpt_No_Last_New_Line);
}
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
@@ -109,9 +107,7 @@ os_archlinuxcn_setsrc (char *option)
{
chsrc_ensure_root ();
SourceInfo source;
chsrc_yield_source (os_archlinuxcn);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_archlinuxcn);
chsrc_backup (OS_Pacman_MirrorList);
@@ -126,7 +122,7 @@ os_archlinuxcn_setsrc (char *option)
chsrc_run ("pacman -Sy archlinuxcn-keyring", RunOpt_Default);
chsrc_run ("pacman -Syy", RunOpt_No_Last_New_Line);
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
#undef OS_Pacman_MirrorList

View File

@@ -31,9 +31,7 @@ def_sources_n(os_msys2);
void
os_msys2_setsrc (char *option)
{
SourceInfo source;
chsrc_yield_source (os_msys2);
chsrc_confirm_source (&source);
chsrc_yield_source_and_confirm (os_msys2);
chsrc_backup ("/etc/pacman.d/mirrorlist.mingw32");
chsrc_backup ("/etc/pacman.d/mirrorlist.mingw64");
@@ -49,7 +47,7 @@ os_msys2_setsrc (char *option)
"#g\" /etc/pacman.d/mirrorlist* ");
chsrc_run (cmd, RunOpt_Default);
chsrc_say_lastly (&source, ChsrcTypeUntested);
chsrc_conclude (&source, ChsrcTypeUntested);
}
def_target_s(os_msys2);

View File

@@ -20,7 +20,7 @@ os_manjaro_setsrc (char *option)
chsrc_run (cmd, RunOpt_Default);
chsrc_run ("pacman -Syy", RunOpt_No_Last_New_Line);
chsrc_say_lastly (NULL, ChsrcTypeAuto);
chsrc_conclude (NULL, ChsrcTypeAuto);
}
TargetInfo os_manjaro_target = {NULL, os_manjaro_setsrc, NULL, NULL, 0};