mirror of
https://github.com/RubyMetric/chsrc
synced 2026-03-05 22:00:06 +08:00
Qualify os family name
This commit is contained in:
44
src/recipe/os/YUM/AlmaLinux.c
Normal file
44
src/recipe/os/YUM/AlmaLinux.c
Normal file
@@ -0,0 +1,44 @@
|
||||
/** ------------------------------------------------------------
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* -------------------------------------------------------------
|
||||
* File Authors : Aoran Zeng <ccmywish@qq.com>
|
||||
* Contributors : Nil Null <nil@null.org>
|
||||
* Created On : <2024-06-12>
|
||||
* Last Modified : <2024-08-16>
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @time 2024-06-12 更新
|
||||
*/
|
||||
static SourceInfo
|
||||
os_almalinux_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Ali, "https://mirrors.aliyun.com/almalinux"},
|
||||
{&Volcengine, "https://mirrors.volces.com/almalinux"},
|
||||
{&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/almalinux"},
|
||||
{&Zju, "https://mirrors.zju.edu.cn/almalinux"},
|
||||
{&Nju, "https://mirror.nju.edu.cn/almalinux"},
|
||||
};
|
||||
def_sources_n(os_almalinux);
|
||||
|
||||
/**
|
||||
* 参考: https://developer.aliyun.com/mirror/almalinux
|
||||
*/
|
||||
void
|
||||
os_almalinux_setsrc (char *option)
|
||||
{
|
||||
chsrc_ensure_root ();
|
||||
|
||||
SourceInfo source;
|
||||
chsrc_yield_source (os_almalinux);
|
||||
chsrc_confirm_source (&source);
|
||||
|
||||
char *cmd = xy_strjoin (3,
|
||||
"sed -e 's|^mirrorlist=|#mirrorlist=|g' -e 's|^#\\s*baseurl=https://repo.almalinux.org/almalinux|baseurl=", source.url, "|g' -i.bak /etc/yum.repos.d/almalinux*.repo");
|
||||
|
||||
chsrc_run (cmd, RunOpt_Default);
|
||||
chsrc_run ("dnf makecache", RunOpt_No_Last_New_Line);
|
||||
chsrc_say_lastly (&source, ChsrcTypeAuto);
|
||||
}
|
||||
|
||||
def_target_s(os_almalinux);
|
||||
44
src/recipe/os/YUM/Anolis-OS.c
Normal file
44
src/recipe/os/YUM/Anolis-OS.c
Normal file
@@ -0,0 +1,44 @@
|
||||
/** ------------------------------------------------------------
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* -------------------------------------------------------------
|
||||
* File Authors : Aoran Zeng <ccmywish@qq.com>
|
||||
* Contributors : Nil Null <nil@null.org>
|
||||
* Created On : <2023-09-24>
|
||||
* Last Modified : <2024-08-16>
|
||||
*
|
||||
* Anolis OS 为这个操作系统的名字,OpenAnolis(龙蜥社区) 只是社区名
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @time 2024-06-12 更新
|
||||
*/
|
||||
static SourceInfo
|
||||
os_anolis_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Ali, "https://mirrors.aliyun.com/anolis"},
|
||||
{&Hust, "https://mirrors.hust.edu.cn/anolis"}
|
||||
};
|
||||
def_sources_n(os_anolis);
|
||||
|
||||
|
||||
/**
|
||||
* 参考: https://mirrors.hust.edu.cn/docs/anolis
|
||||
*/
|
||||
void
|
||||
os_anolis_setsrc (char *option)
|
||||
{
|
||||
chsrc_ensure_root ();
|
||||
|
||||
SourceInfo source;
|
||||
chsrc_yield_source (os_anolis);
|
||||
chsrc_confirm_source (&source);
|
||||
|
||||
char *cmd = xy_strjoin (3, "sed -i.bak -E 's|https?://(mirrors\\.openanolis\\.cn/anolis)|", source.url, "|g' /etc/yum.repos.d/*.repo");
|
||||
chsrc_run (cmd, RunOpt_Default);
|
||||
|
||||
chsrc_run ("dnf makecache", RunOpt_Default);
|
||||
chsrc_run ("dnf update", RunOpt_No_Last_New_Line);
|
||||
chsrc_say_lastly (&source, ChsrcTypeUntested);
|
||||
}
|
||||
|
||||
def_target_s(os_anolis);
|
||||
68
src/recipe/os/YUM/Fedora-Linux.c
Normal file
68
src/recipe/os/YUM/Fedora-Linux.c
Normal file
@@ -0,0 +1,68 @@
|
||||
/** ------------------------------------------------------------
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* -------------------------------------------------------------
|
||||
* File Authors : Heng Guo <2085471348@qq.com>
|
||||
* Contributors : Nil Null <nil@null.org>
|
||||
* Created On : <2023-09-26>
|
||||
* Last Modified : <2024-08-16>
|
||||
*
|
||||
* 名称为 Fedora Linux
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @time 2023-09-02 更新
|
||||
* @note 源并不完整,且未经测试是否有效
|
||||
*/
|
||||
static SourceInfo
|
||||
os_fedora_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Ali, "https://mirrors.aliyun.com/fedora"},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/fedora"},
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn/fedora"},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/fedora"},
|
||||
{&Tencent, "https://mirrors.tencent.com/fedora"},
|
||||
{&Netease, "https://mirrors.163.com/fedora"},
|
||||
{&Sohu, "https://mirrors.sohu.com/fedora"}
|
||||
};
|
||||
def_sources_n(os_fedora);
|
||||
|
||||
|
||||
/**
|
||||
* @note fedora 29 及以下版本暂不支持
|
||||
*/
|
||||
void
|
||||
os_fedora_setsrc (char *option)
|
||||
{
|
||||
chsrc_ensure_root ();
|
||||
|
||||
SourceInfo source;
|
||||
chsrc_yield_source (os_fedora);
|
||||
chsrc_confirm_source (&source);
|
||||
|
||||
chsrc_note2 ("Fedora 29 及以下版本暂不支持");
|
||||
|
||||
chsrc_backup ("/etc/yum.repos.d/fedora.repo");
|
||||
chsrc_backup ("/etc/yum.repos.d/fedora-updates.repo");
|
||||
|
||||
char* cmd = xy_strjoin (9, "sed -e 's|^metalink=|#metalink=|g' ",
|
||||
"-e 's|^#baseurl=http://download.example/pub/fedora/linux/|baseurl=",
|
||||
source.url,
|
||||
"|g' ",
|
||||
"-i.bak ",
|
||||
"/etc/yum.repos.d/fedora.repo ",
|
||||
"/etc/yum.repos.d/fedora-modular.repo ",
|
||||
"/etc/yum.repos.d/fedora-updates.repo ",
|
||||
"/etc/yum.repos.d/fedora-updates-modular.repo");
|
||||
|
||||
chsrc_run (cmd, RunOpt_Default);
|
||||
|
||||
chsrc_log2 ("已替换文件 /etc/yum.repos.d/fedora.repo");
|
||||
chsrc_log2 ("已新增文件 /etc/yum.repos.d/fedora-modular.repo");
|
||||
chsrc_log2 ("已替换文件 /etc/yum.repos.d/fedora-updates.repo");
|
||||
chsrc_log2 ("已新增文件 /etc/yum.repos.d/fedora-updates-modular.repo");
|
||||
|
||||
chsrc_run ("dnf makecache", RunOpt_No_Last_New_Line);
|
||||
chsrc_say_lastly (&source, ChsrcTypeAuto);
|
||||
}
|
||||
|
||||
def_target_s(os_fedora);
|
||||
50
src/recipe/os/YUM/Rocky-Linux.c
Normal file
50
src/recipe/os/YUM/Rocky-Linux.c
Normal file
@@ -0,0 +1,50 @@
|
||||
/** ------------------------------------------------------------
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* -------------------------------------------------------------
|
||||
* File Authors : Aoran Zeng <ccmywish@qq.com>
|
||||
* Contributors : Nil Null <nil@null.org>
|
||||
* Created On : <2023-09-24>
|
||||
* Last Modified : <2024-08-16>
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @time 2024-06-12 更新
|
||||
*/
|
||||
static SourceInfo
|
||||
os_rockylinux_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Ali, "https://mirrors.aliyun.com/rockylinux"},
|
||||
{&Volcengine, "https://mirrors.volces.com/rockylinux"},
|
||||
{&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/rocky"},
|
||||
{&Sustech, "https://mirrors.sustech.edu.cn/rocky-linux"},
|
||||
{&Zju, "https://mirrors.zju.edu.cn/rocky"},
|
||||
{&Lzuoss, "https://mirror.lzu.edu.cn/rocky"},
|
||||
{&Sohu, "https://mirrors.sohu.com/Rocky"},
|
||||
{&Netease, "https://mirrors.163.com/rocky"}
|
||||
};
|
||||
def_sources_n(os_rockylinux);
|
||||
|
||||
|
||||
/**
|
||||
* 参考: https://help.mirrors.cernet.edu.cn/rocky/
|
||||
*/
|
||||
void
|
||||
os_rockylinux_setsrc (char *option)
|
||||
{
|
||||
chsrc_ensure_root ();
|
||||
|
||||
SourceInfo source;
|
||||
chsrc_yield_source (os_rockylinux);
|
||||
chsrc_confirm_source (&source);
|
||||
|
||||
char *cmd = xy_strjoin (3,
|
||||
"sed -e 's|^mirrorlist=|#mirrorlist=|g' "
|
||||
"-e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=", source.url, "|g' "
|
||||
"-i.bak /etc/yum.repos.d/rocky-extras.repo /etc/yum.repos.d/rocky.repo"
|
||||
);
|
||||
chsrc_run (cmd, RunOpt_Default);
|
||||
chsrc_run ("dnf makecache", RunOpt_No_Last_New_Line);
|
||||
chsrc_say_lastly (&source, ChsrcTypeUntested);
|
||||
}
|
||||
|
||||
def_target_s(os_rockylinux);
|
||||
13
src/recipe/os/YUM/common.h
Normal file
13
src/recipe/os/YUM/common.h
Normal file
@@ -0,0 +1,13 @@
|
||||
/** ------------------------------------------------------------
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* -------------------------------------------------------------
|
||||
* File Authors : Aoran Zeng <ccmywish@qq.com>
|
||||
* Contributors : Nil Null <nil@null.org>
|
||||
* Created On : <2024-08-16>
|
||||
* Last Modified : <2024-08-16>
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
// #define OS_Yum_SourceList "/etc/yum.repos"
|
||||
#define OS_Yum_SourceList_D "/etc/yum.repos.d/"
|
||||
|
||||
#define OS_openEuler_SourceList "openEuler.repo"
|
||||
51
src/recipe/os/YUM/openEuler.c
Normal file
51
src/recipe/os/YUM/openEuler.c
Normal file
@@ -0,0 +1,51 @@
|
||||
/** ------------------------------------------------------------
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* -------------------------------------------------------------
|
||||
* File Authors : Heng Guo <2085471348@qq.com>
|
||||
* Contributors : Nil Null <nil@null.org>
|
||||
* Created On : <2023-09-06>
|
||||
* Last Modified : <2024-08-16>
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @time 2023-09-06 更新
|
||||
* @note 源并不完整,且未经测试是否有效
|
||||
*/
|
||||
static SourceInfo
|
||||
os_openeuler_sources[] = {
|
||||
{&Upstream, NULL},
|
||||
{&Ali, "https://mirrors.aliyun.com/openeuler/"},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/openeuler/"},
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn/openeuler/"},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/openeuler/"},
|
||||
{&Tencent, "https://mirrors.tencent.com/openeuler/"},
|
||||
{&Netease, "https://mirrors.163.com/openeuler/"},
|
||||
{&Sohu, "https://mirrors.sohu.com/openeuler/"}
|
||||
};
|
||||
def_sources_n(os_openeuler);
|
||||
|
||||
/**
|
||||
* HELP: 未经测试
|
||||
*/
|
||||
void
|
||||
os_openeuler_setsrc (char *option)
|
||||
{
|
||||
chsrc_ensure_root ();
|
||||
|
||||
SourceInfo source;
|
||||
chsrc_yield_source (os_openeuler);
|
||||
chsrc_confirm_source (&source);
|
||||
|
||||
chsrc_backup (OS_openEuler_SourceList);
|
||||
|
||||
char *towrite = xy_strjoin (3, "s#http://repo.openeuler.org#",
|
||||
source.url,
|
||||
"#\'< /etc/yum.repos.d/openEuler.repo.bak");
|
||||
|
||||
chsrc_overwrite_file (towrite, OS_openEuler_SourceList);
|
||||
|
||||
chsrc_run ("dnf makecache", RunOpt_No_Last_New_Line);
|
||||
chsrc_say_lastly (&source, ChsrcTypeAuto);
|
||||
}
|
||||
|
||||
def_target_s(os_openeuler);
|
||||
Reference in New Issue
Block a user