Update FreeBSD

This commit is contained in:
Aoran Zeng 2023-09-24 21:56:03 +08:00
parent e93020e9d2
commit d2bc0d2441
2 changed files with 55 additions and 26 deletions

69
chsrc.c
View File

@ -12,7 +12,7 @@
* GPLv3 LICENSE.txt
* ------------------------------------------------------------*/
#define Chsrc_Version "v0.1.0-20230924"
#define Chsrc_Version "v0.1.1-20230924"
#include "chsrc.h"
@ -1507,7 +1507,14 @@ os_openkylin_setsrc (char* option)
/**
* HELP: , sources of freebsd are different from each other.
* : https://book.bsdcn.org/di-3-zhang-ruan-jian-yuan-ji-bao-guan-li-qi/di-3.2-jie-freebsd-huan-yuan-fang-shi.html
*
* @ykla,
* FreeBSD pkgportsportsnapupdate portsnap FreeBSD 14
*
* update源 pkg ports
*
* HELP:
*/
void
os_freebsd_setsrc (char* option)
@ -1524,40 +1531,58 @@ os_freebsd_setsrc (char* option)
source_info source = os_freebsd_sources[index];
chsrc_say_selection(&source);
xy_info("chsrc: 1. 添加 freebsd-pkg 源 (二进制安装包)");
char* pkg_mkdir = "mkdir -p /usr/local/etc/pkg/repos";
char* pkg_createconf = "ee /usr/local/etc/pkg/repos/bjtu.conf";
char* pkg_createconf = xy_strjoin(3, "ee /usr/local/etc/pkg/repos/", source.mirror->code, ".conf");
chsrc_runcmd(pkg_mkdir);
chsrc_runcmd(pkg_createconf);
char* pkg_content = xy_strjoin(3,"bjtu: { \
url: \"pkg+=http://",source.url,"/freebsd-pkg/${ABI}/latest\",\
char* pkg_content = xy_strjoin(4,
source.mirror->code, ": { \
url: \"pkg+=http://", source.url, "/freebsd-pkg/${ABI}/latest\",\
mirror_type: \"srv\",\
signature_type: \"none\",\
fingerprints: \"/usr/share/keys/pkg\",\
enabled: yes\
}");
char* pkg_cmd;
pkg_cmd = xy_strjoin(3,
"cat ",
pkg_content,
"> /usr/local/etc/pkg/repos/bjtu.conf");
char* pkg_cmd = xy_strjoin(3, "cat ", pkg_content, "> /usr/local/etc/pkg/repos/", source.mirror->code , ".conf");
chsrc_runcmd(pkg_cmd);
xy_info("chsrc: 若要使用HTTPS源,请先安装securtiy/ca_root_ns,并将 'http' 改成 'https' ,最后使用 'pkg update -f' 刷新缓存即可");
xy_warn("chsrc: 若要使用HTTPS源,请先安装securtiy/ca_root_ns,并将 'http' 改成 'https' ,最后使用 'pkg update -f' 刷新缓存即可\n");
xy_info("chsrc: 2. 修改 freebsd-ports 源");
bool git_exist = does_the_program_exist (xy_str_to_quietcmd("git version"), "git");
if (git_exist) {
char* git_cmd = xy_strjoin(3, "git clone --depth 1 https://", source.url, "/freebsd-ports/ports.git /usr/ports");
chsrc_runcmd(git_cmd);
} else {
char* fetch = xy_strjoin(3, "fetch https://", source.url, "/freebsd-ports/ports.tar.gz"); // 70多MB
char* unzip = "tar -zxvf ports.tar.gz -C /usr/ports";
char* delete = "rm ports.tar.gz";
chsrc_runcmd(fetch);
chsrc_runcmd(unzip);
chsrc_runcmd(delete);
}
/* https://help.mirrors.cernet.edu.cn/FreeBSD-ports/ 的换源方法 */
/*
char* ports_cp="cp -f /etc/make.conf /etc/make.conf.bak";
chsrc_runcmd(ports_cp);
char* ports_cmd =xy_strjoin(3,"cat MASTER_SITE_OVERRIDE?=http://",
source.url,
"/freebsd-ports/ >> /etc/make.conf");
char* ports_cmd =xy_strjoin(3, "cat MASTER_SITE_OVERRIDE?=http://",
source.url,
"/freebsd-ports/ >> /etc/make.conf");
chsrc_runcmd(ports_cmd);
*/
xy_info("chsrc: ports sources changed.");
/* 不再换 portsnap */
/*
char* portsnap_cp="cp -f /etc/portsnap.conf /etc/portsnap.conf.bak";
chsrc_runcmd(portsnap_cp);
@ -1567,9 +1592,15 @@ os_freebsd_setsrc (char* option)
chsrc_runcmd(portsnap_cmd);
xy_info("chsrc: portsnap sources changed.");
xy_info("chsrc: portsnap sources changed");
xy_info("chsrc: 获取portsnap更新使用此命令: 'portsnap fetch extract'");
*/
// HELP: 暂时似乎没有源提供
/*
xy_info("chsrc: 3. 修改 freebsd-update 源");
char* update_cp="cp -f /etc/freebsd-update.conf /etc/freebsd-update.conf.bak";
chsrc_runcmd(update_cp);
@ -1578,7 +1609,7 @@ os_freebsd_setsrc (char* option)
source.url,
"@g < /etc/freebsd-update.conf.bak | cat > /etc/freebsd-update.conf");
chsrc_runcmd(update_cmd);
xy_info("chsrc: freebsd-update sources changed.");
*/
chsrc_say_thanks(&source);
}

View File

@ -540,18 +540,16 @@ os_void_sources[] = {
/**
* 2023-09-17
* 2023-09-24
*
* TODO: 1.
* @note FreeBSD
*
* @ccmywish: [2023-09-24] USTC, NJU, Netease freebsd-pkg freebsd-ports
*/
os_freebsd_sources[] = {
{&Ali, "mirrors.aliyun.com"},
{&Bfsu, "mirrors.bfsu.edu.cn"},
{&Ustc, "mirrors.ustc.edu.cn"},
{&Tuna, "mirrors.tuna.tsinghua.edu.cn"},
{&Tencent, "mirrors.tencent.com"},
{&Nju, "mirror.nju.edu.cn"},
{&Netease, "mirrors.163.com"},
{&Sohu, "mirrors.sohu.com"}
},