mirror of
https://github.com/RubyMetric/chsrc
synced 2025-12-24 11:32:01 +08:00
Split arch out
This commit is contained in:
90
src/chsrc.c
90
src/chsrc.c
@@ -635,95 +635,7 @@ os_msys2_setsrc (char *option)
|
||||
|
||||
|
||||
|
||||
#define OS_Pacman_MirrorList "/etc/pacman.d/mirrorlist"
|
||||
void
|
||||
os_arch_getsrc (char *option)
|
||||
{
|
||||
chsrc_view_file (OS_Pacman_MirrorList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 参考:
|
||||
* 1. https://mirrors.tuna.tsinghua.edu.cn/help/archlinux/
|
||||
* 2. https://mirrors.tuna.tsinghua.edu.cn/help/archlinuxarm/
|
||||
*/
|
||||
void
|
||||
os_arch_setsrc (char *option)
|
||||
{
|
||||
chsrc_ensure_root ();
|
||||
|
||||
SourceInfo source;
|
||||
chsrc_yield_source (os_arch);
|
||||
chsrc_confirm_source (&source);
|
||||
|
||||
chsrc_backup (OS_Pacman_MirrorList);
|
||||
|
||||
bool is_x86 = false;
|
||||
char *to_write = NULL;
|
||||
char *arch = chsrc_get_cpuarch ();
|
||||
|
||||
if (strncmp(arch, "x86_64", 6)==0)
|
||||
{
|
||||
is_x86 = true;
|
||||
to_write = xy_strjoin (3, "Server = ", source.url, "/$repo/os/$arch");
|
||||
}
|
||||
else
|
||||
{
|
||||
is_x86 = false;
|
||||
to_write = xy_strjoin (3, "Server = ", source.url, "arm/$arch/$repo");
|
||||
}
|
||||
|
||||
// 越前面的优先级越高
|
||||
chsrc_prepend_to_file (to_write, OS_Pacman_MirrorList);
|
||||
|
||||
if (is_x86)
|
||||
{
|
||||
chsrc_run ("pacman -Syyu", RunOpt_No_Last_New_Line);
|
||||
}
|
||||
else
|
||||
{
|
||||
chsrc_run ("pacman -Syy", RunOpt_No_Last_New_Line);
|
||||
}
|
||||
chsrc_say_lastly (&source, ChsrcTypeUntested);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
os_archlinuxcn_getsrc (char *option)
|
||||
{
|
||||
chsrc_view_file (OS_Pacman_MirrorList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 参考 https://mirrors.tuna.tsinghua.edu.cn/help/archlinuxcn/
|
||||
*/
|
||||
void
|
||||
os_archlinuxcn_setsrc (char *option)
|
||||
{
|
||||
chsrc_ensure_root ();
|
||||
|
||||
SourceInfo source;
|
||||
chsrc_yield_source (os_archlinuxcn);
|
||||
chsrc_confirm_source (&source);
|
||||
|
||||
chsrc_backup (OS_Pacman_MirrorList);
|
||||
|
||||
bool arch_flag = false;
|
||||
char *arch = chsrc_get_cpuarch ();
|
||||
|
||||
char *towrite = xy_strjoin (3, "[archlinuxcn]\nServer = ", source.url, "$arch");
|
||||
// 越前面的优先级越高
|
||||
chsrc_prepend_to_file (towrite, OS_Pacman_MirrorList);
|
||||
|
||||
chsrc_run ("pacman-key --lsign-key \"farseerfc@archlinux.org\"", RunOpt_Dont_Abort_On_Failure);
|
||||
chsrc_run ("pacman -Sy archlinuxcn-keyring", RunOpt_Default);
|
||||
|
||||
chsrc_run ("pacman -Syy", RunOpt_No_Last_New_Line);
|
||||
chsrc_say_lastly (&source, ChsrcTypeUntested);
|
||||
}
|
||||
#undef OS_Pacman_MirrorList
|
||||
|
||||
|
||||
#include "recipe/os/arch.c"
|
||||
#include "recipe/os/gentoo.c"
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user