mirror of
https://github.com/RubyMetric/chsrc
synced 2025-08-13 15:59:32 +08:00
Fix os recipes
This commit is contained in:
parent
097097c664
commit
0ecd128f8f
@ -86,6 +86,47 @@
|
||||
#include "recipe/lang/NuGet.c"
|
||||
#include "recipe/lang/Clojure.c"
|
||||
|
||||
#include "recipe/os/rawstr4c.h"
|
||||
#include "recipe/os/APT/common.h"
|
||||
// Debian-based
|
||||
#include "recipe/os/APT/Debian.c"
|
||||
#include "recipe/os/APT/Ubuntu.c"
|
||||
#include "recipe/os/APT/Kali-Linux.c"
|
||||
#include "recipe/os/APT/Raspberry-Pi-OS.c"
|
||||
// Ubuntu-based
|
||||
#include "recipe/os/APT/Linux-Mint.c"
|
||||
#include "recipe/os/APT/Trisquel.c"
|
||||
#include "recipe/os/APT/Linux-Lite.c"
|
||||
// Debian-based and Ubuntu-based
|
||||
#include "recipe/os/APT/Armbian.c"
|
||||
// Independent
|
||||
#include "recipe/os/APT/ROS.c"
|
||||
#include "recipe/os/APT/Termux.c"
|
||||
#include "recipe/os/APT/openKylin.c"
|
||||
#include "recipe/os/APT/deepin.c"
|
||||
|
||||
#include "recipe/os/YUM/common.h"
|
||||
#include "recipe/os/YUM/Fedora-Linux.c"
|
||||
#include "recipe/os/YUM/AlmaLinux.c"
|
||||
#include "recipe/os/YUM/Rocky-Linux.c"
|
||||
#include "recipe/os/YUM/openEuler.c"
|
||||
#include "recipe/os/YUM/Anolis-OS.c"
|
||||
|
||||
#include "recipe/os/pacman/Arch-Linux.c"
|
||||
#include "recipe/os/pacman/Manjaro-Linux.c"
|
||||
#include "recipe/os/pacman/MSYS2.c"
|
||||
|
||||
#include "recipe/os/openSUSE.c"
|
||||
#include "recipe/os/Alpine-Linux.c"
|
||||
#include "recipe/os/Gentoo-Linux.c"
|
||||
#include "recipe/os/Void-Linux.c"
|
||||
#include "recipe/os/Solus.c"
|
||||
#include "recipe/os/OpenWrt.c"
|
||||
|
||||
#include "recipe/os/BSD/FreeBSD.c"
|
||||
#include "recipe/os/BSD/NetBSD.c"
|
||||
#include "recipe/os/BSD/OpenBSD.c"
|
||||
|
||||
#include "rawstr4c.h"
|
||||
|
||||
|
||||
|
@ -64,7 +64,7 @@ os_armbian_setsrc (char *option)
|
||||
{
|
||||
chsrc_ensure_root ();
|
||||
|
||||
chsrc_yield_source_and_confirm (os_armbian);
|
||||
use_this_source(os_armbian);
|
||||
|
||||
chsrc_backup (OS_Armbian_SourceList);
|
||||
|
||||
|
@ -89,7 +89,7 @@ os_debian_does_old_sourcelist_use_cdrom (void)
|
||||
void
|
||||
os_debian_setsrc_for_deb822 (char *option)
|
||||
{
|
||||
chsrc_yield_source_and_confirm (os_debian);
|
||||
use_this_source(os_debian);
|
||||
|
||||
chsrc_backup (OS_Debian_SourceList_DEB822);
|
||||
|
||||
@ -150,7 +150,7 @@ os_debian_setsrc (char *option)
|
||||
}
|
||||
}
|
||||
|
||||
chsrc_yield_source_and_confirm (os_debian);
|
||||
use_this_source(os_debian);
|
||||
|
||||
chsrc_alert2 ("如果遇到无法拉取 HTTPS 源的情况,请手动运行:");
|
||||
say ("apt install apt-transport-https ca-certificates");
|
||||
|
@ -51,7 +51,7 @@ os_kali_setsrc (char *option)
|
||||
{
|
||||
chsrc_ensure_root ();
|
||||
|
||||
chsrc_yield_source_and_confirm (os_kali);
|
||||
use_this_source(os_kali);
|
||||
|
||||
chsrc_backup (OS_Apt_SourceList);
|
||||
|
||||
|
@ -49,7 +49,7 @@ os_linuxlite_setsrc (char *option)
|
||||
{
|
||||
chsrc_ensure_root ();
|
||||
|
||||
chsrc_yield_source_and_confirm (os_linuxlite);
|
||||
use_this_source(os_linuxlite);
|
||||
|
||||
chsrc_backup (OS_Apt_SourceList);
|
||||
|
||||
|
@ -61,7 +61,7 @@ os_linuxmint_setsrc (char *option)
|
||||
{
|
||||
chsrc_ensure_root ();
|
||||
|
||||
chsrc_yield_source_and_confirm (os_linuxmint);
|
||||
use_this_source(os_linuxmint);
|
||||
|
||||
chsrc_backup (OS_LinuxMint_SourceList);
|
||||
|
||||
|
@ -59,7 +59,7 @@ os_ros_setsrc (char *option)
|
||||
{
|
||||
chsrc_ensure_root ();
|
||||
|
||||
chsrc_yield_source_and_confirm (os_ros);
|
||||
use_this_source(os_ros);
|
||||
|
||||
chsrc_backup (OS_ROS_SourceList);
|
||||
|
||||
|
@ -53,7 +53,7 @@ os_raspberrypi_setsrc (char *option)
|
||||
{
|
||||
chsrc_ensure_root(); // HELP: 不确定是否需要
|
||||
|
||||
chsrc_yield_source_and_confirm (os_raspberrypi);
|
||||
use_this_source(os_raspberrypi);
|
||||
|
||||
chsrc_backup (OS_RaspberryPi_SourceList);
|
||||
|
||||
|
@ -61,7 +61,7 @@ os_termux_setsrc (char *option)
|
||||
|
||||
// chsrc_ensure_root (); Termux下禁止使用root
|
||||
|
||||
chsrc_yield_source_and_confirm (os_termux);
|
||||
use_this_source(os_termux);
|
||||
|
||||
char *cmd = xy_strjoin (3, "sed -i 's@^\\(deb.*stable main\\)$@#\\1\\ndeb ",
|
||||
source.url, "apt/termux-main stable main@' " OS_Termux_SourceList);
|
||||
|
@ -53,7 +53,7 @@ os_trisquel_setsrc (char *option)
|
||||
{
|
||||
chsrc_ensure_root ();
|
||||
|
||||
chsrc_yield_source_and_confirm (os_trisquel);
|
||||
use_this_source(os_trisquel);
|
||||
|
||||
chsrc_backup (OS_Apt_SourceList);
|
||||
|
||||
|
@ -79,7 +79,7 @@ os_ubuntu_getsrc (char *option)
|
||||
void
|
||||
os_ubuntu_setsrc_for_deb822 (char *option)
|
||||
{
|
||||
chsrc_yield_source_and_confirm (os_ubuntu);
|
||||
use_this_source(os_ubuntu);
|
||||
|
||||
chsrc_backup (OS_Ubuntu_SourceList_DEB822);
|
||||
|
||||
@ -122,7 +122,7 @@ os_ubuntu_setsrc (char *option)
|
||||
|
||||
bool sourcelist_exist = ensure_debian_or_ubuntu_old_sourcelist (OS_Is_Ubuntu);
|
||||
|
||||
chsrc_yield_source_and_confirm (os_ubuntu);
|
||||
use_this_source(os_ubuntu);
|
||||
|
||||
/* 不存在的时候,用的是我们生成的无效文件,不要备份 */
|
||||
if (sourcelist_exist)
|
||||
|
@ -56,7 +56,7 @@ os_deepin_setsrc (char *option)
|
||||
{
|
||||
chsrc_ensure_root();
|
||||
|
||||
chsrc_yield_source_and_confirm (os_deepin);
|
||||
use_this_source(os_deepin);
|
||||
|
||||
chsrc_backup (OS_Apt_SourceList);
|
||||
|
||||
|
@ -47,7 +47,7 @@ os_openkylin_setsrc (char *option)
|
||||
{
|
||||
chsrc_ensure_root();
|
||||
|
||||
chsrc_yield_source_and_confirm (os_openkylin);
|
||||
use_this_source(os_openkylin);
|
||||
|
||||
chsrc_backup (OS_Apt_SourceList);
|
||||
|
||||
|
@ -57,8 +57,7 @@ os_alpine_setsrc (char *option)
|
||||
{
|
||||
// chsrc_ensure_root(); // HELP: 不确定是否需要root
|
||||
|
||||
use_this(os_alpine);
|
||||
Source_t source = chsrc_yield_source_and_confirm (this, option);
|
||||
use_this_source(os_alpine);
|
||||
|
||||
char* cmd = xy_strjoin (3,
|
||||
"sed -i 's#https\\?://dl-cdn.alpinelinux.org/alpine#", source.url, "#g' /etc/apk/repositories"
|
||||
|
@ -23,8 +23,9 @@ os_freebsd_prelude ()
|
||||
chef_forbid_english(this);
|
||||
chef_forbid_user_define(this);
|
||||
|
||||
chef_set_note ("2023-09-24: 以下三个USTC, NJU, Netease 均维护了 freebsd-pkg freebsd-ports\n2023-09-27: 请务必保持Nju前面有至少一个镜像,原因请查看 freebsd 的换源函数", NULL);
|
||||
|
||||
// 2023-09-24: 以下三个USTC, NJU, Netease 均维护了 freebsd-pkg freebsd-ports
|
||||
// 2023-09-27: 请务必保持Nju前面有至少一个镜像,原因请查看 freebsd 的换源函数
|
||||
def_sources_begin()
|
||||
{&upstream, NULL, DelegateToUpstream},
|
||||
{&Ustc, "mirrors.ustc.edu.cn", DelegateToMirror},
|
||||
@ -47,10 +48,11 @@ os_freebsd_setsrc (char *option)
|
||||
// 据 @ykla,FreeBSD不自带sudo,但是我们依然要保证是root权限
|
||||
chsrc_ensure_root ();
|
||||
|
||||
int index = use_specific_mirror_or_auto_select (option, os_freebsd);
|
||||
use_this(os_freebsd);
|
||||
int index = use_specific_mirror_or_auto_select (option, this);
|
||||
|
||||
Source_t source = os_freebsd_sources[index];
|
||||
chsrc_confirm_source();
|
||||
Source_t source = this->sources[index];
|
||||
chsrc_confirm_source(&source);
|
||||
|
||||
chsrc_log2 ("1. 添加 freebsd-pkg 源 (二进制安装包)");
|
||||
chsrc_ensure_dir ("/usr/local/etc/pkg/repos");
|
||||
@ -80,11 +82,11 @@ os_freebsd_setsrc (char *option)
|
||||
{
|
||||
if (xy_streql("nju",source.mirror->code))
|
||||
{
|
||||
source = os_freebsd_sources[index-1]; // 使用NJU的前一个源,即USTC源
|
||||
source = this->sources[index-1]; // 使用NJU的前一个源,即USTC源
|
||||
}
|
||||
char *git_cmd = xy_strjoin (3, "git clone --depth 1 https://", source.url, "/freebsd-ports/ports.git /usr/ports");
|
||||
chsrc_run (git_cmd, RunOpt_Default);
|
||||
source = os_freebsd_sources[index]; // 恢复至选中的源
|
||||
source = this->sources[index]; // 恢复至选中的源
|
||||
chsrc_alert2 ("下次更新请使用 git -C /usr/ports pull 而非使用 gitup");
|
||||
}
|
||||
else
|
||||
|
@ -24,8 +24,6 @@ os_netbsd_prelude ()
|
||||
chef_forbid_english(this);
|
||||
chef_forbid_user_define(this);
|
||||
|
||||
chef_set_note ("根据 @ykla: NetBSD 默认状态下没有 pkgsrc,用户可能安装了也可能没安装", NULL);
|
||||
|
||||
def_sources_begin()
|
||||
{&upstream, NULL, DelegateToUpstream},
|
||||
{&MirrorZ, "https://mirrors.cernet.edu.cn/pkgsrc/packages/NetBSD/", DelegateToMirror},
|
||||
@ -62,7 +60,7 @@ os_netbsd_setsrc (char *option)
|
||||
{
|
||||
chsrc_ensure_root ();
|
||||
|
||||
chsrc_yield_source_and_confirm (os_netbsd);
|
||||
use_this_source(os_netbsd);
|
||||
|
||||
chsrc_backup ("/usr/pkg/etc/pkgin/repositories.conf");
|
||||
|
||||
|
@ -59,7 +59,7 @@ os_openbsd_setsrc (char *option)
|
||||
{
|
||||
chsrc_ensure_root ();
|
||||
|
||||
chsrc_yield_source_and_confirm (os_openbsd);
|
||||
use_this_source(os_openbsd);
|
||||
|
||||
chsrc_backup ("/etc/installurl");
|
||||
chsrc_overwrite_file (source.url, "/etc/installurl");
|
||||
|
@ -45,8 +45,7 @@ os_gentoo_setsrc (char *option)
|
||||
{
|
||||
chsrc_ensure_root ();
|
||||
|
||||
use_this(os_gentoo);
|
||||
Source_t source = chsrc_yield_source_and_confirm (this, option);
|
||||
use_this_source(os_gentoo);
|
||||
|
||||
chsrc_backup ("/etc/portage/repos.conf/gentoo.conf");
|
||||
|
||||
|
@ -61,8 +61,7 @@ os_openwrt_setsrc (char *option)
|
||||
{
|
||||
chsrc_ensure_root ();
|
||||
|
||||
use_this(os_openwrt);
|
||||
Source_t source = chsrc_yield_source_and_confirm (this, option);
|
||||
use_this_source(os_openwrt);
|
||||
|
||||
chsrc_backup (OS_OpenWRT_SourceConfig);
|
||||
|
||||
|
@ -43,8 +43,7 @@ os_solus_setsrc (char *option)
|
||||
{
|
||||
chsrc_ensure_root ();
|
||||
|
||||
use_this(os_solus);
|
||||
Source_t source = chsrc_yield_source_and_confirm (this, option);
|
||||
use_this_source(os_solus);
|
||||
|
||||
char *cmd = xy_2strjoin ("eopkg add-repo Solus ", source.url);
|
||||
chsrc_run (cmd, RunOpt_Default);
|
||||
|
@ -52,8 +52,7 @@ os_voidlinux_setsrc (char *option)
|
||||
{
|
||||
chsrc_ensure_root ();
|
||||
|
||||
use_this(os_voidlinux);
|
||||
Source_t source = chsrc_yield_source_and_confirm (this, option);
|
||||
use_this_source(os_voidlinux);
|
||||
|
||||
chsrc_ensure_dir ("/etc/xbps.d");
|
||||
char *cmd = "cp /usr/share/xbps.d/*-repository-*.conf /etc/xbps.d/";
|
||||
|
@ -46,8 +46,7 @@ os_almalinux_setsrc (char *option)
|
||||
{
|
||||
chsrc_ensure_root ();
|
||||
|
||||
use_this(os_almalinux);
|
||||
Source_t source = chsrc_yield_source_and_confirm (this, option);
|
||||
use_this_source(os_almalinux);
|
||||
|
||||
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");
|
||||
|
@ -41,8 +41,7 @@ os_anolis_setsrc (char *option)
|
||||
{
|
||||
chsrc_ensure_root ();
|
||||
|
||||
use_this(os_anolis);
|
||||
Source_t source = chsrc_yield_source_and_confirm (this, option);
|
||||
use_this_source(os_anolis);
|
||||
|
||||
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);
|
||||
|
@ -55,8 +55,7 @@ os_fedora_setsrc (char *option)
|
||||
{
|
||||
chsrc_ensure_root ();
|
||||
|
||||
use_this(os_fedora);
|
||||
Source_t source = chsrc_yield_source_and_confirm (this, option);
|
||||
use_this_source(os_fedora);
|
||||
|
||||
chsrc_alert2 ("Fedora 38 及以下版本暂不支持");
|
||||
|
||||
|
@ -49,7 +49,7 @@ os_rockylinux_setsrc (char *option)
|
||||
{
|
||||
chsrc_ensure_root ();
|
||||
|
||||
chsrc_yield_source_and_confirm (os_rockylinux);
|
||||
use_this_source(os_rockylinux);
|
||||
|
||||
char *version_str = xy_run ("sed -nr 's/ROCKY_SUPPORT_PRODUCT_VERSION=\"(.*)\"/\\1/p' " ETC_OS_RELEASE, 0);
|
||||
double version = atof (version_str);
|
||||
|
@ -66,8 +66,7 @@ os_openeuler_setsrc (char *option)
|
||||
{
|
||||
chsrc_ensure_root ();
|
||||
|
||||
use_this(os_openeuler);
|
||||
Source_t source = chsrc_yield_source_and_confirm (this, option);
|
||||
use_this_source(os_openeuler);
|
||||
|
||||
chsrc_backup (OS_openEuler_SourceList);
|
||||
|
||||
@ -97,11 +96,3 @@ os_openeuler_resetsrc (char *option)
|
||||
{
|
||||
os_openeuler_setsrc (option);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* chsrc ls openeuler
|
||||
*/
|
||||
chef_allow_get();
|
||||
chef_allow_reset();
|
||||
def_target(os_openeuler);
|
||||
|
@ -46,8 +46,7 @@ os_opensuse_setsrc (char *option)
|
||||
{
|
||||
// chsrc_ensure_root ();
|
||||
|
||||
use_this(os_opensuse);
|
||||
Source_t source = chsrc_yield_source_and_confirm (this, option);
|
||||
use_this_source(os_opensuse);
|
||||
|
||||
while (1) {
|
||||
chsrc_note2 ("请选择你的操作系统为:");
|
||||
|
@ -28,7 +28,9 @@ os_arch_prelude ()
|
||||
chef_forbid_english(this);
|
||||
chef_forbid_user_define(this);
|
||||
|
||||
chef_set_note ("可额外使用 chsrc set archlinuxcn 来更换 Arch Linux CN Repository 源", "You can additionally use chsrc set archlinuxcn to change Arch Linux CN Repository source");
|
||||
chef_set_note (this,
|
||||
"可额外使用 chsrc set archlinuxcn 来更换 Arch Linux CN Repository 源",
|
||||
"You can additionally use chsrc set archlinuxcn to change Arch Linux CN Repository source");
|
||||
|
||||
/**
|
||||
* @note 不要给后面加 / ,因为ARM情况下,还要额外加一个 arm 后缀
|
||||
@ -68,7 +70,7 @@ os_arch_setsrc (char *option)
|
||||
{
|
||||
chsrc_ensure_root ();
|
||||
|
||||
chsrc_yield_source_and_confirm (os_arch);
|
||||
use_this_source(os_arch);
|
||||
|
||||
chsrc_backup (OS_Pacman_MirrorList);
|
||||
|
||||
@ -115,6 +117,7 @@ void
|
||||
os_archlinuxcn_prelude ()
|
||||
{
|
||||
use_this(os_archlinuxcn);
|
||||
chef_allow_gs(os_archlinuxcn);
|
||||
|
||||
chef_set_created_on (this, "2023-09-05");
|
||||
chef_set_last_updated (this, "2025-08-10");
|
||||
@ -126,14 +129,13 @@ os_archlinuxcn_prelude ()
|
||||
chef_set_contributors (this, 1,
|
||||
"happy game", "happygame1024@gmail.com");
|
||||
|
||||
chef_allow_get();
|
||||
chef_allow_set();
|
||||
|
||||
chef_allow_local_mode (this, CanNot, NULL, NULL);
|
||||
chef_forbid_english(this);
|
||||
chef_forbid_user_define(this);
|
||||
|
||||
chef_set_note ("可额外使用 chsrc set arch 来更换 Arch Linux 源", "You can additionally use chsrc set arch to change Arch Linux source");
|
||||
chef_set_note (this,
|
||||
"可额外使用 chsrc set arch 来更换 Arch Linux 源",
|
||||
"You can additionally use chsrc set arch to change Arch Linux source");
|
||||
|
||||
|
||||
def_sources_begin()
|
||||
@ -167,7 +169,7 @@ os_archlinuxcn_setsrc (char *option)
|
||||
{
|
||||
chsrc_ensure_root ();
|
||||
|
||||
chsrc_yield_source_and_confirm (os_archlinuxcn);
|
||||
use_this_source(os_archlinuxcn);
|
||||
|
||||
chsrc_backup (OS_Pacman_ArchLinuxCN_MirrorList);
|
||||
|
||||
|
@ -46,7 +46,7 @@ os_msys2_prelude ()
|
||||
void
|
||||
os_msys2_setsrc (char *option)
|
||||
{
|
||||
chsrc_yield_source_and_confirm (os_msys2);
|
||||
use_this_source(os_msys2);
|
||||
|
||||
chsrc_backup ("/etc/pacman.d/mirrorlist.mingw32");
|
||||
chsrc_backup ("/etc/pacman.d/mirrorlist.mingw64");
|
||||
|
Loading…
x
Reference in New Issue
Block a user