-
-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
27 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
* Contributors : Shengwei Chen <[email protected]> | ||
* | | ||
* 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)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,9 @@ | |
* SPDX-License-Identifier: GPL-3.0-or-later | ||
* ------------------------------------------------------------- | ||
* File Authors : Heng Guo <[email protected]> | ||
* Contributors : Aoran Zeng <[email protected]> | ||
* | happy game <[email protected]> | ||
* Contributors : Aoran Zeng <[email protected]> | ||
* | | ||
* 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,16 +48,17 @@ 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' ", | ||
"/etc/yum.repos.d/fedora.repo ", | ||
"/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,25 +73,31 @@ 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) | ||
{ | ||
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); | ||
|