mirror of
https://github.com/RubyMetric/chsrc
synced 2025-07-24 01:09:34 +08:00
Use chsrc_alert2()
This commit is contained in:
parent
fa4a69b4b9
commit
92f341179b
@ -1575,7 +1575,7 @@ chsrc_ensure_dir (const char *dir)
|
||||
chsrc_run_as_a_service (cmd);
|
||||
|
||||
char *msg = ENGLISH ? "Directory doesn't exist, created automatically " : "目录不存在,已自动创建 ";
|
||||
chsrc_note2 (xy_2strjoin (msg, dir));
|
||||
chsrc_alert2 (xy_2strjoin (msg, dir));
|
||||
}
|
||||
|
||||
|
||||
@ -1701,7 +1701,7 @@ chsrc_backup (const char *path)
|
||||
if (!exist)
|
||||
{
|
||||
char *msg = ENGLISH ? "File doesn't exist, skip backup: " : "文件不存在,跳过备份: ";
|
||||
chsrc_note2 (xy_2strjoin (msg, path));
|
||||
chsrc_alert2 (xy_2strjoin (msg, path));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ pl_nodejs_group_setsrc (char *option)
|
||||
"npm, pnpm, yarn. If you need to change the source independently, "
|
||||
"please run independently `chsrc set <pkg-manager>`"
|
||||
: "将同时更换3个包管理器 npm, pnpm, Yarn 的源,若需要独立换源,请独立运行 chsrc set <pkg-manager>";
|
||||
chsrc_note2 (msg);
|
||||
chsrc_alert2 (msg);
|
||||
}
|
||||
|
||||
bool npm_exist, yarn_exist, pnpm_exist;
|
||||
|
@ -49,8 +49,8 @@ pl_ocaml_setsrc (char *option)
|
||||
|
||||
chsrc_run (cmd, RunOpt_Default);
|
||||
|
||||
chsrc_note2 ("如果是首次使用 opam ,请使用以下命令进行初始化");
|
||||
p(xy_2strjoin ("opam init default ", source.url));
|
||||
chsrc_alert2 ("如果是首次使用 opam ,请使用以下命令进行初始化");
|
||||
println (xy_2strjoin ("opam init default ", source.url));
|
||||
|
||||
chsrc_determine_chgtype (ChgType_SemiAuto);
|
||||
chsrc_conclude (&source);
|
||||
|
@ -60,7 +60,7 @@ pl_perl_setsrc (char *option)
|
||||
"perl -MCPAN -e \"CPAN::HandleConfig->load(); CPAN::HandleConfig->edit('urllist', 'unshift', '", source.url, "'); CPAN::HandleConfig->commit()\"");
|
||||
chsrc_run (cmd, RunOpt_Default);
|
||||
|
||||
chsrc_note2 ("请使用 perl -v 以及 cpan -v,若 Perl >= v5.36 或 CPAN >= 2.29,请额外手动调用下面的命令");
|
||||
chsrc_alert2 ("请使用 perl -v 以及 cpan -v,若 Perl >= v5.36 或 CPAN >= 2.29,请额外手动调用下面的命令");
|
||||
p ("perl -MCPAN -e \"CPAN::HandleConfig->load(); CPAN::HandleConfig->edit('pushy_https', 0);; CPAN::HandleConfig->commit()\"");
|
||||
|
||||
chsrc_determine_chgtype (ChgType_SemiAuto);
|
||||
|
@ -15,7 +15,7 @@
|
||||
void
|
||||
pl_python_poetry_getsrc (char *option)
|
||||
{
|
||||
chsrc_note2 ("poetry换源情况: 请查阅本项目 pyproject.toml 中 [[tool.poetry.source]]");
|
||||
chsrc_note2 ("poetry换源情况: 请查看本项目 pyproject.toml 中 [[tool.poetry.source]]");
|
||||
}
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ pl_python_poetry_setsrc (char *option)
|
||||
char *cmd = NULL;
|
||||
|
||||
if (!chsrc_in_local_mode())
|
||||
chsrc_note2 ("Poertry 仅支持项目级换源");
|
||||
chsrc_alert2 ("Poetry 仅支持项目级换源");
|
||||
|
||||
cmd = xy_2strjoin ("poetry source add my_mirror ", source.url);
|
||||
chsrc_run (cmd, RunOpt_No_Last_New_Line);
|
||||
|
@ -48,7 +48,7 @@ pl_python_group_setsrc (char *option)
|
||||
"pip, Poetry, PDM. If you need to change the source independently, "
|
||||
"please run independently `chsrc set <pkg-manager>`"
|
||||
: "将同时更换4个包管理器 pip, Poetry, PDM, uv 的源,若需要独立换源,请独立运行 chsrc set <pkg-manager>";
|
||||
chsrc_note2 (msg);
|
||||
chsrc_alert2 (msg);
|
||||
}
|
||||
|
||||
bool pdm_exist = false,
|
||||
|
@ -96,7 +96,7 @@ pl_rust_rustup_setsrc (char *option)
|
||||
|
||||
chsrc_determine_chgtype (ChgType_Auto);
|
||||
chsrc_conclude (&source);
|
||||
chsrc_note2 ("请重启终端使rustup环境变量生效");
|
||||
chsrc_alert2 ("请重启终端使rustup环境变量生效");
|
||||
}
|
||||
|
||||
|
||||
|
@ -140,7 +140,7 @@ os_debian_setsrc (char *option)
|
||||
return;
|
||||
}
|
||||
|
||||
chsrc_note2 ("将基于旧格式(非DEB822)换源");
|
||||
chsrc_alert2 ("将基于旧格式(非DEB822)换源");
|
||||
|
||||
/* Docker环境下,Debian镜像可能不存在该文件 */
|
||||
bool sourcelist_exist = ensure_debian_or_ubuntu_old_sourcelist (OS_Is_Debian_Literally);
|
||||
@ -167,7 +167,7 @@ os_debian_setsrc (char *option)
|
||||
|
||||
chsrc_yield_source_and_confirm (os_debian);
|
||||
|
||||
chsrc_note2 ("如果遇到无法拉取 HTTPS 源的情况,请手动运行:");
|
||||
chsrc_alert2 ("如果遇到无法拉取 HTTPS 源的情况,请手动运行:");
|
||||
say ("apt install apt-transport-https ca-certificates");
|
||||
|
||||
/* 不存在的时候,用的是我们生成的用来填充占位的无效文件,不要备份 */
|
||||
|
@ -131,7 +131,7 @@ os_ubuntu_setsrc (char *option)
|
||||
return;
|
||||
}
|
||||
|
||||
chsrc_note2 ("将基于旧格式(非DEB822)换源");
|
||||
chsrc_alert2 ("将基于旧格式(非DEB822)换源");
|
||||
|
||||
bool sourcelist_exist = ensure_debian_or_ubuntu_old_sourcelist (OS_Is_Ubuntu);
|
||||
|
||||
|
@ -60,7 +60,7 @@ os_freebsd_setsrc (char *option)
|
||||
chsrc_note2 (
|
||||
xy_strjoin (3, "若要使用季度分支,请在", conf ,"中将latest改为quarterly"));
|
||||
|
||||
chsrc_note2 ("若要使用HTTPS源,请先安装securtiy/ca_root_ns,并将'http'改成'https',最后使用'pkg update -f'刷新缓存即可\n");
|
||||
chsrc_alert2 ("若要使用HTTPS源,请先安装securtiy/ca_root_ns,并将'http'改成'https',最后使用'pkg update -f'刷新缓存即可\n");
|
||||
br();
|
||||
|
||||
chsrc_log2 ("2. 修改 freebsd-ports 源");
|
||||
@ -77,7 +77,7 @@ os_freebsd_setsrc (char *option)
|
||||
char *git_cmd = xy_strjoin (3, "git clone --depth 1 https://", source.url, "/freebsd-ports/ports.git /usr/ports");
|
||||
chsrc_run (git_cmd, RunOpt_Default);
|
||||
source = os_freebsd_sources[index]; // 恢复至选中的源
|
||||
chsrc_note2 ("下次更新请使用 git -C /usr/ports pull 而非使用 gitup");
|
||||
chsrc_alert2 ("下次更新请使用 git -C /usr/ports pull 而非使用 gitup");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -114,7 +114,7 @@ os_freebsd_setsrc (char *option)
|
||||
|
||||
|
||||
// HELP: 暂时没有源提供
|
||||
chsrc_note2 ("4. 抱歉,目前境内无 freebsd-update 源,若存在请报告issue,谢谢");
|
||||
chsrc_alert2 ("4. 抱歉,目前境内无 freebsd-update 源,若存在请报告issue,谢谢");
|
||||
/*
|
||||
chsrc_log2 ("3. 修改 freebsd-update 源");
|
||||
|
||||
|
@ -44,7 +44,7 @@ os_fedora_setsrc (char *option)
|
||||
|
||||
chsrc_yield_source_and_confirm (os_fedora);
|
||||
|
||||
chsrc_note2 ("Fedora 38 及以下版本暂不支持");
|
||||
chsrc_alert2 ("Fedora 38 及以下版本暂不支持");
|
||||
|
||||
chsrc_backup ("/etc/yum.repos.d/fedora.repo");
|
||||
chsrc_backup ("/etc/yum.repos.d/fedora-updates.repo");
|
||||
@ -69,7 +69,7 @@ os_fedora_setsrc (char *option)
|
||||
"/etc/yum.repos.d/fedora-updates.repo");
|
||||
chsrc_run (cmd, RunOpt_Default);
|
||||
|
||||
chsrc_note2 ("已更换baseurl, 但Fedora默认会优先使用metalink来匹配最快的源, 若在获取metadata时速度较慢可自行将其注释:");
|
||||
chsrc_alert2 ("已更换baseurl, 但Fedora默认会优先使用metalink来匹配最快的源, 若在获取metadata时速度较慢可自行将其注释:");
|
||||
chsrc_log2 ("(1) /etc/yum.repos.d/fedora.repo");
|
||||
chsrc_log2 ("(2) /etc/yum.repos.d/fedora-updates.repo");
|
||||
|
||||
|
@ -56,7 +56,7 @@ wr_anaconda_setsrc (char *option)
|
||||
{
|
||||
if (xy_file_exist (configfile))
|
||||
{
|
||||
chsrc_note2 ("配置文件不存在,将使用 conda 命令创建");
|
||||
chsrc_alert2 ("配置文件不存在,将使用 conda 命令创建");
|
||||
bool conda_exist = chsrc_check_program ("conda");
|
||||
if (!conda_exist)
|
||||
{
|
||||
|
@ -89,7 +89,7 @@ wr_dockerhub_setsrc (char *option)
|
||||
char *result = xy_run (cmd, 0);
|
||||
if (result && !xy_streql (result, "null"))
|
||||
{
|
||||
chsrc_note2 ("已存在源,无需重复添加");
|
||||
chsrc_alert2 ("已存在源,无需重复添加");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -101,7 +101,7 @@ wr_dockerhub_setsrc (char *option)
|
||||
}
|
||||
else
|
||||
{
|
||||
chsrc_note2 ("未找到 jq 命令, 将使用 sed 换源");
|
||||
chsrc_alert2 ("未找到 jq 命令, 将使用 sed 换源");
|
||||
char *cmd = xy_str_gsub (RAWSTR_wr_dockerhub_sed_command, "@1@", source.url);
|
||||
cmd = xy_str_gsub (cmd, "@2@", WR_DockerHub_ConfigFile);
|
||||
chsrc_run (cmd, RunOpt_Default);
|
||||
@ -110,7 +110,7 @@ wr_dockerhub_setsrc (char *option)
|
||||
else
|
||||
{
|
||||
/* 不存在 /etc/docker/daemon.json 时可以直接写入文件 */
|
||||
chsrc_note2 ("未找到Docker配置文件, 将自动创建");
|
||||
chsrc_alert2 ("未找到Docker配置文件, 将自动创建");
|
||||
chsrc_ensure_dir ("/etc/docker");
|
||||
chsrc_run ( xy_2strjoin ("touch ", WR_DockerHub_ConfigFile), RunOpt_Default);
|
||||
|
||||
@ -120,12 +120,12 @@ wr_dockerhub_setsrc (char *option)
|
||||
if (xy_on_linux)
|
||||
{
|
||||
/* 由于 systemctl restart docker 会导致所有容器停止,所以不自动重启 */
|
||||
chsrc_note2 ("请自行运行: sudo systemctl restart docker");
|
||||
chsrc_note2 ("该命令会重启所有容器, 请在合适的时机执行");
|
||||
chsrc_alert2 ("请自行运行: sudo systemctl restart docker");
|
||||
chsrc_alert2 ("该命令会重启所有容器, 请在合适的时机执行");
|
||||
}
|
||||
else
|
||||
{
|
||||
chsrc_note2 ("然后请手动重启 docker 服务");
|
||||
chsrc_alert2 ("然后请手动重启 docker 服务");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -66,7 +66,7 @@ wr_flathub_setsrc (char *option)
|
||||
{
|
||||
chsrc_yield_source_and_confirm (wr_flathub);
|
||||
|
||||
chsrc_note2 ("若出现问题,可先调用以下命令:");
|
||||
chsrc_alert2 ("若出现问题,可先调用以下命令:");
|
||||
char *note = xy_strjoin (3,
|
||||
"wget ", source.url, "/flathub.gpg\n"
|
||||
"flatpak remote-modify --gpg-import=flathub.gpg flathub"
|
||||
|
@ -75,7 +75,7 @@ wr_homebrew_setsrc (char *option)
|
||||
|
||||
chsrc_determine_chgtype (ChgType_Auto);
|
||||
chsrc_conclude (&source);
|
||||
chsrc_note2 ("请重启终端使Homebrew环境变量生效");
|
||||
chsrc_alert2 ("请重启终端使Homebrew环境变量生效");
|
||||
}
|
||||
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
* File Authors : Aoran Zeng <ccmywish@qq.com>
|
||||
* Contributors : Nil Null <nil@null.org>
|
||||
* Created On : <2024-12-14>
|
||||
* Last Modified : <2025-07-14>
|
||||
* Last Modified : <2025-07-21>
|
||||
*
|
||||
* 该文件最好启用 DEBUG mode 编译
|
||||
* ------------------------------------------------------------*/
|
||||
@ -35,6 +35,7 @@ main (int argc, char const *argv[])
|
||||
chsrc_succ2 ("chsrc_succ2");
|
||||
chsrc_log2 ("chsrc_log2");
|
||||
chsrc_note2 ("chsrc_note2");
|
||||
chsrc_alert2 ("chsrc_alert2");
|
||||
chsrc_warn2 ("chsrc_warn2");
|
||||
chsrc_error2 ("chsrc_error2");
|
||||
chsrc_debug2 ("fw", "chsrc_debug2");
|
||||
|
Loading…
x
Reference in New Issue
Block a user