mirror of
https://github.com/RubyMetric/chsrc
synced 2025-09-12 21:53:48 +08:00
尽量消除对 system()
的直接调用
This commit is contained in:
parent
9d1a287f91
commit
7b01893dc8
@ -142,7 +142,7 @@ pl_python_uv_setsrc (char *option)
|
|||||||
/* 当 uv_config 存在,如果存在 [[index]] 则更新,否则追加到文件末尾 */
|
/* 当 uv_config 存在,如果存在 [[index]] 则更新,否则追加到文件末尾 */
|
||||||
char *cmd = xy_str_gsub (RAWSTR_pl_python_test_uv_if_set_source, "@f@", uv_config);
|
char *cmd = xy_str_gsub (RAWSTR_pl_python_test_uv_if_set_source, "@f@", uv_config);
|
||||||
chsrc_ensure_program ("grep");
|
chsrc_ensure_program ("grep");
|
||||||
int status = system (cmd);
|
int status = xy_run_get_status (cmd);
|
||||||
if (0==status)
|
if (0==status)
|
||||||
{
|
{
|
||||||
chsrc_run (update_config_cmd, RunOpt_Default);
|
chsrc_run (update_config_cmd, RunOpt_Default);
|
||||||
|
@ -10,7 +10,7 @@ os_debian_prelude ()
|
|||||||
chef_prep_this (os_debian, gsr);
|
chef_prep_this (os_debian, gsr);
|
||||||
|
|
||||||
chef_set_created_on (this, "2023-09-02");
|
chef_set_created_on (this, "2023-09-02");
|
||||||
chef_set_last_updated (this, "2025-08-10");
|
chef_set_last_updated (this, "2025-09-12");
|
||||||
chef_set_sources_last_updated (this, "2025-07-11");
|
chef_set_sources_last_updated (this, "2025-07-11");
|
||||||
|
|
||||||
chef_set_chef (this, NULL);
|
chef_set_chef (this, NULL);
|
||||||
@ -73,7 +73,7 @@ os_debian_does_old_sourcelist_use_cdrom (void)
|
|||||||
{
|
{
|
||||||
/* 我们只检查旧版sourcelist,因为 common.h 中的填充只支持旧版 */
|
/* 我们只检查旧版sourcelist,因为 common.h 中的填充只支持旧版 */
|
||||||
char *cmd = xy_2strcat ("grep -q '^deb cdrom:' ", OS_Debian_old_SourceList);
|
char *cmd = xy_2strcat ("grep -q '^deb cdrom:' ", OS_Debian_old_SourceList);
|
||||||
int ret = system (cmd);
|
int ret = xy_run_get_status (cmd);
|
||||||
bool use_cdrom = ret == 0;
|
bool use_cdrom = ret == 0;
|
||||||
|
|
||||||
return use_cdrom;
|
return use_cdrom;
|
||||||
@ -135,7 +135,7 @@ os_debian_setsrc (char *option)
|
|||||||
if (use_cdrom)
|
if (use_cdrom)
|
||||||
{
|
{
|
||||||
chsrc_backup (OS_Debian_old_SourceList);
|
chsrc_backup (OS_Debian_old_SourceList);
|
||||||
int rm_status = system ("rm " OS_Debian_old_SourceList);
|
int rm_status = xy_run_get_status ("rm " OS_Debian_old_SourceList);
|
||||||
if (rm_status != 0) { /* Placate -Wunused-result */ }
|
if (rm_status != 0) { /* Placate -Wunused-result */ }
|
||||||
|
|
||||||
chsrc_warn2 ("旧版源配置文件中使用了 CDROM 源,已删除(但备份)该配置文件,重新配置");
|
chsrc_warn2 ("旧版源配置文件中使用了 CDROM 源,已删除(但备份)该配置文件,重新配置");
|
||||||
|
@ -116,7 +116,7 @@ os_archlinuxcn_prelude ()
|
|||||||
chef_prep_this (os_archlinuxcn, gs);
|
chef_prep_this (os_archlinuxcn, gs);
|
||||||
|
|
||||||
chef_set_created_on (this, "2023-09-05");
|
chef_set_created_on (this, "2023-09-05");
|
||||||
chef_set_last_updated (this, "2025-08-10");
|
chef_set_last_updated (this, "2025-09-12");
|
||||||
chef_set_sources_last_updated (this, "2024-07-03");
|
chef_set_sources_last_updated (this, "2024-07-03");
|
||||||
|
|
||||||
chef_set_chef (this, NULL);
|
chef_set_chef (this, NULL);
|
||||||
@ -133,7 +133,7 @@ os_archlinuxcn_prelude ()
|
|||||||
|
|
||||||
|
|
||||||
def_sources_begin()
|
def_sources_begin()
|
||||||
{&UpstreamProvider, "https://repo.archlinuxcn.org/", DelegateToUpstream},
|
{&UpstreamProvider, "https://repo.archlinuxcn.org/", DelegateToUpstream},
|
||||||
{&Ali, "https://mirrors.aliyun.com/archlinuxcn/", DelegateToMirror},
|
{&Ali, "https://mirrors.aliyun.com/archlinuxcn/", DelegateToMirror},
|
||||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/archlinuxcn/", DelegateToMirror},
|
{&Bfsu, "https://mirrors.bfsu.edu.cn/archlinuxcn/", DelegateToMirror},
|
||||||
{&Ustc, "https://mirrors.ustc.edu.cn/archlinuxcn/", DelegateToMirror},
|
{&Ustc, "https://mirrors.ustc.edu.cn/archlinuxcn/", DelegateToMirror},
|
||||||
@ -157,7 +157,6 @@ os_archlinuxcn_getsrc (char *option)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @consult https://mirrors.tuna.tsinghua.edu.cn/help/archlinuxcn/
|
* @consult https://mirrors.tuna.tsinghua.edu.cn/help/archlinuxcn/
|
||||||
* @update 2025-05-24
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
os_archlinuxcn_setsrc (char *option)
|
os_archlinuxcn_setsrc (char *option)
|
||||||
@ -172,7 +171,7 @@ os_archlinuxcn_setsrc (char *option)
|
|||||||
|
|
||||||
/* 检查是否已存在 archlinuxcn 配置段 */
|
/* 检查是否已存在 archlinuxcn 配置段 */
|
||||||
char *check_cmd = "grep -q '\\[archlinuxcn\\]' " OS_Pacman_ArchLinuxCN_MirrorList;
|
char *check_cmd = "grep -q '\\[archlinuxcn\\]' " OS_Pacman_ArchLinuxCN_MirrorList;
|
||||||
int ret = system(check_cmd);
|
int ret = xy_run_get_status (check_cmd);
|
||||||
|
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
{
|
{
|
||||||
|
@ -12,7 +12,7 @@ wr_homebrew_prelude ()
|
|||||||
chef_prep_this (wr_homebrew, gs);
|
chef_prep_this (wr_homebrew, gs);
|
||||||
|
|
||||||
chef_set_created_on (this, "2023-09-10");
|
chef_set_created_on (this, "2023-09-10");
|
||||||
chef_set_last_updated (this, "2025-08-09");
|
chef_set_last_updated (this, "2025-09-12");
|
||||||
chef_set_sources_last_updated (this, "2025-07-13");
|
chef_set_sources_last_updated (this, "2025-07-13");
|
||||||
|
|
||||||
chef_set_chef (this, NULL);
|
chef_set_chef (this, NULL);
|
||||||
@ -39,7 +39,7 @@ wr_homebrew_prelude ()
|
|||||||
void
|
void
|
||||||
wr_homebrew_getsrc (char *option)
|
wr_homebrew_getsrc (char *option)
|
||||||
{
|
{
|
||||||
int status = system (RAWSTR_wr_homebrew_read_config_cmd);
|
int status = xy_run_get_status (RAWSTR_wr_homebrew_read_config_cmd);
|
||||||
if (status != 0) { xy_noop(); }
|
if (status != 0) { xy_noop(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user