22 * SPDX-License-Identifier: GPL-3.0-or-later
33 * -------------------------------------------------------------
44 * File Authors : Heng Guo <[email protected] > 5- * Contributors : Aoran Zeng <[email protected] > 65 * | happy game <[email protected] > 6+ * Contributors : Aoran Zeng <[email protected] > 7+ * |
78 * Created On : <2023-09-26>
89 * Last Modified : <2024-11-04>
910 *
1516 */
1617static SourceInfo
1718os_fedora_sources [] = {
18- {& Upstream , "http://download.example/pub/fedora/linux" },
19+ {& Upstream , "http://download.example/pub/fedora/linux" },
1920 {& Ali , "https://mirrors.aliyun.com/fedora" },
2021 {& Bfsu , "https://mirrors.bfsu.edu.cn/fedora" },
2122 {& Ustc , "https://mirrors.ustc.edu.cn/fedora" },
@@ -36,6 +37,8 @@ def_sources_n(os_fedora);
3637void
3738os_fedora_setsrc (char * option )
3839{
40+ char * setsrc_type = xy_streql (option , SetsrcType_Reset ) ? SetsrcType_Reset : SetsrcType_Auto ;
41+
3942 chsrc_ensure_root ();
4043
4144 chsrc_yield_source_and_confirm (os_fedora );
@@ -45,16 +48,17 @@ os_fedora_setsrc (char *option)
4548 chsrc_backup ("/etc/yum.repos.d/fedora.repo" );
4649 chsrc_backup ("/etc/yum.repos.d/fedora-updates.repo" );
4750
48- // 取消注释 baseurl
51+ // 取消对 baseurl 的注释
4952 char * cmd = xy_strjoin (5 , "sed " ,
5053 "-i 's|^#baseurl=|baseurl=" ,
5154 "|g' " ,
5255 "/etc/yum.repos.d/fedora.repo " ,
5356 "/etc/yum.repos.d/fedora-updates.repo" );
5457 chsrc_run (cmd , RunOpt_Default );
5558
56- // fedora的换源涉及 /etc/yum.repos.d/fedora.repo和 /etc/yum.repos.d/fedora-updates.repo
57- // 需要替换 baseurl=source.url/releases/... 和 baseurl=source.url/releases/...
59+ // 替换
60+ // (1) baseurl=<<URL>>/releases/...
61+ // (2) baseurl=<<URL>>/updates/...
5862 cmd = xy_strjoin (7 , "sed " ,
5963 "-i -E 's!^baseurl=.*?/(releases|updates)/!baseurl=" ,
6064 source .url ,
@@ -69,25 +73,31 @@ os_fedora_setsrc (char *option)
6973 chsrc_log2 ("(2) /etc/yum.repos.d/fedora-updates.repo" );
7074
7175 chsrc_run ("dnf makecache" , RunOpt_No_Last_New_Line );
72- chsrc_conclude (& source , SetsrcType_Auto );
76+
77+ chsrc_conclude (& source , setsrc_type );
7378}
7479
7580
81+ void
82+ os_fedora_resetsrc (char * option )
83+ {
84+ os_fedora_setsrc (SetsrcType_Reset );
85+ }
86+
7687
7788FeatInfo
7889os_fedora_feat (char * option )
7990{
8091 FeatInfo f = {0 };
8192
8293 f .can_get = false;
83- f .can_reset = false ;
94+ f .can_reset = true ;
8495
8596 f .cap_locally = CanNot ;
86- f .can_english = true ;
97+ f .can_english = false ;
8798 f .can_user_define = true;
8899
89100 return f ;
90101}
91102
92103def_target_sf (os_fedora );
93-
0 commit comments