mirror of
https://github.com/RubyMetric/chsrc.git
synced 2024-12-03 23:37:07 +08:00
parent
5a225c4e12
commit
0373e8149e
|
@ -6,7 +6,7 @@
|
|||
* Contributors : Shengwei Chen <414685209@qq.com>
|
||||
* |
|
||||
* Created On : <2023-08-29>
|
||||
* Last Modified : <2024-10-09>
|
||||
* Last Modified : <2024-11-04>
|
||||
*
|
||||
* 通用镜像站与换源信息
|
||||
* ------------------------------------------------------------*/
|
||||
|
@ -192,8 +192,10 @@ typedef struct TargetInfo_t {
|
|||
|
||||
|
||||
#define def_target_inner_s(t) NULL, t##_setsrc, NULL, NULL
|
||||
#define def_target_inner_gs(t) t##_getsrc, t##_setsrc, NULL, NULL
|
||||
#define def_target_inner_sr(t) NULL, t##_setsrc, t##_resetsrc, NULL
|
||||
#define def_target_inner_sf(t) NULL, t##_setsrc, NULL, t##_feat
|
||||
#define def_target_inner_srf(t) NULL, t##_setsrc, t##_resetsrc, t##_feat
|
||||
#define def_target_inner_gs(t) t##_getsrc, t##_setsrc, NULL, NULL
|
||||
#define def_target_inner_gsr(t) t##_getsrc, t##_setsrc, t##_resetsrc, NULL
|
||||
#define def_target_inner_gsf(t) t##_getsrc, t##_setsrc, NULL, t##_feat
|
||||
#define def_target_inner_gsrf(t) t##_getsrc, t##_setsrc, t##_resetsrc, t##_feat
|
||||
|
@ -202,9 +204,11 @@ typedef struct TargetInfo_t {
|
|||
|
||||
// 大部分target还不支持reset,所以暂时先默认设置为NULL来过渡
|
||||
#define def_target(t) TargetInfo t##_target = {def_target_inner_gs(t),def_target_sourcesn(t)}
|
||||
#define def_target_gs(t) TargetInfo t##_target = {def_target_inner_gs(t),def_target_sourcesn(t)}
|
||||
#define def_target_s(t) TargetInfo t##_target = {def_target_inner_s(t),def_target_sourcesn(t)}
|
||||
#define def_target_sr(t) TargetInfo t##_target = {def_target_inner_sr(t),def_target_sourcesn(t)}
|
||||
#define def_target_sf(t) TargetInfo t##_target = {def_target_inner_sf(t),def_target_sourcesn(t)}
|
||||
#define def_target_srf(t) TargetInfo t##_target = {def_target_inner_srf(t),def_target_sourcesn(t)}
|
||||
#define def_target_gs(t) TargetInfo t##_target = {def_target_inner_gs(t),def_target_sourcesn(t)}
|
||||
#define def_target_gsr(t) TargetInfo t##_target = {def_target_inner_gsr(t),def_target_sourcesn(t)}
|
||||
#define def_target_gsf(t) TargetInfo t##_target = {def_target_inner_gsf(t),def_target_sourcesn(t)}
|
||||
#define def_target_gsrf(t) TargetInfo t##_target = {def_target_inner_gsrf(t),def_target_sourcesn(t)}
|
||||
#define def_target_s(t) TargetInfo t##_target = {def_target_inner_s(t),def_target_sourcesn(t)}
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* -------------------------------------------------------------
|
||||
* File Authors : Heng Guo <2085471348@qq.com>
|
||||
* Contributors : Aoran Zeng <ccmywish@qq.com>
|
||||
* | happy game <happygame1024@gmail.com>
|
||||
* Contributors : Aoran Zeng <ccmywish@qq.com>
|
||||
* |
|
||||
* Created On : <2023-09-26>
|
||||
* Last Modified : <2024-11-04>
|
||||
*
|
||||
|
@ -15,7 +16,7 @@
|
|||
*/
|
||||
static SourceInfo
|
||||
os_fedora_sources[] = {
|
||||
{&Upstream, "http://download.example/pub/fedora/linux"},
|
||||
{&Upstream, "http://download.example/pub/fedora/linux"},
|
||||
{&Ali, "https://mirrors.aliyun.com/fedora"},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/fedora"},
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn/fedora"},
|
||||
|
@ -36,6 +37,8 @@ def_sources_n(os_fedora);
|
|||
void
|
||||
os_fedora_setsrc (char *option)
|
||||
{
|
||||
char *setsrc_type = xy_streql (option, SetsrcType_Reset) ? SetsrcType_Reset : SetsrcType_Auto;
|
||||
|
||||
chsrc_ensure_root ();
|
||||
|
||||
chsrc_yield_source_and_confirm (os_fedora);
|
||||
|
@ -45,7 +48,7 @@ os_fedora_setsrc (char *option)
|
|||
chsrc_backup ("/etc/yum.repos.d/fedora.repo");
|
||||
chsrc_backup ("/etc/yum.repos.d/fedora-updates.repo");
|
||||
|
||||
// 取消注释 baseurl
|
||||
// 取消对 baseurl 的注释
|
||||
char* cmd = xy_strjoin (5, "sed ",
|
||||
"-i 's|^#baseurl=|baseurl=",
|
||||
"|g' ",
|
||||
|
@ -53,8 +56,9 @@ os_fedora_setsrc (char *option)
|
|||
"/etc/yum.repos.d/fedora-updates.repo");
|
||||
chsrc_run (cmd, RunOpt_Default);
|
||||
|
||||
// fedora的换源涉及 /etc/yum.repos.d/fedora.repo和 /etc/yum.repos.d/fedora-updates.repo
|
||||
// 需要替换 baseurl=source.url/releases/... 和 baseurl=source.url/releases/...
|
||||
// 替换
|
||||
// (1) baseurl=<<URL>>/releases/...
|
||||
// (2) baseurl=<<URL>>/updates/...
|
||||
cmd = xy_strjoin (7, "sed ",
|
||||
"-i -E 's!^baseurl=.*?/(releases|updates)/!baseurl=",
|
||||
source.url,
|
||||
|
@ -69,10 +73,17 @@ os_fedora_setsrc (char *option)
|
|||
chsrc_log2 ("(2) /etc/yum.repos.d/fedora-updates.repo");
|
||||
|
||||
chsrc_run ("dnf makecache", RunOpt_No_Last_New_Line);
|
||||
chsrc_conclude (&source, SetsrcType_Auto);
|
||||
|
||||
chsrc_conclude (&source, setsrc_type);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
os_fedora_resetsrc (char *option)
|
||||
{
|
||||
os_fedora_setsrc (SetsrcType_Reset);
|
||||
}
|
||||
|
||||
|
||||
FeatInfo
|
||||
os_fedora_feat (char *option)
|
||||
|
@ -80,14 +91,13 @@ os_fedora_feat (char *option)
|
|||
FeatInfo f = {0};
|
||||
|
||||
f.can_get = false;
|
||||
f.can_reset = false;
|
||||
f.can_reset = true;
|
||||
|
||||
f.cap_locally = CanNot;
|
||||
f.can_english = true;
|
||||
f.can_english = false;
|
||||
f.can_user_define = true;
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
def_target_sf(os_fedora);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user