From 9d7a121947c125ba888c54b0dbd84c803659ec97 Mon Sep 17 00:00:00 2001 From: Aoran Zeng Date: Fri, 16 Aug 2024 04:31:48 +0800 Subject: [PATCH] Split texlive out --- include/source.h | 21 ---------- src/chsrc.c | 65 +--------------------------- src/recipe/catalog.c | 1 - src/recipe/ware/TeX-Live.c | 86 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 87 insertions(+), 86 deletions(-) create mode 100644 src/recipe/ware/TeX-Live.c diff --git a/include/source.h b/include/source.h index f047d79..c43eeee 100644 --- a/include/source.h +++ b/include/source.h @@ -151,29 +151,8 @@ pl_dotnet_sources[] = { {&Huawei, "https://mirrors.huaweicloud.com/repository/nuget/v3"} }; - - -/** - * @time 2023-09-10 更新 - */ -static SourceInfo -wr_tex_sources[] = { - {&Upstream, NULL}, - {&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/ctan/systems/texlive/tlnet"}, - {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet"}, - {&Bfsu, "https://mirrors.bfsu.edu.cn/CTAN/systems/texlive/tlnet"}, - {&Lzuoss, "https://mirror.lzu.edu.cn/CTAN/systems/texlive/tlnet"}, - {&Jlu, "https://mirrors.jlu.edu.cn/CTAN/systems/texlive/tlnet"}, - {&Sustech, "https://mirrors.sustech.edu.cn/CTAN/systems/texlive/tlnet"} -}; - - - #define def_sources_n(t) const size_t t##_sources_n = xy_arylen(t##_sources) def_sources_n(pl_clojure); def_sources_n(pl_dotnet); - -def_sources_n(wr_tex); - diff --git a/src/chsrc.c b/src/chsrc.c index a16770b..d69d08a 100644 --- a/src/chsrc.c +++ b/src/chsrc.c @@ -112,70 +112,7 @@ pl_clojure_setsrc (char *option) #include "recipe/os/BSD/OpenBSD.c" - - - -void -wr_tex_check_cmd (bool *tlmgr_exist, bool *mpm_exist) -{ - *tlmgr_exist = chsrc_check_program ("tlmgr"); - *mpm_exist = chsrc_check_program ("mpm"); - - if (!*tlmgr_exist && !*mpm_exist) - { - chsrc_error ("未找到 tlmgr 或 mpm 命令,请检查是否存在(其一)"); - exit(1); - } -} - -void -wr_tex_getsrc (char *option) -{ - bool tlmgr_exist, mpm_exist; - wr_tex_check_cmd (&tlmgr_exist, &mpm_exist); - - if (tlmgr_exist) - { - chsrc_run("tlmgr option repository", RunOpt_Default); - } - if (mpm_exist) - { - chsrc_run("mpm --get-repository", RunOpt_Default); - } -} - -/** - * 参考 https://help.mirrors.cernet.edu.cn/CTAN/ - */ -void -wr_tex_setsrc (char *option) -{ - bool tlmgr_exist, mpm_exist; - wr_tex_check_cmd (&tlmgr_exist, &mpm_exist); - - SourceInfo source; - chsrc_yield_source (wr_tex); - chsrc_confirm_source (&source); - - char *cmd = NULL; - - if (tlmgr_exist) - { - cmd = xy_2strjoin ("tlmgr option repository ", source.url); - chsrc_run (cmd, RunOpt_Default); - } - - if (mpm_exist) - { - char *miktex_url = xy_2strjoin (xy_str_delete_suffix (source.url, "texlive/tlnet"), "win32/miktex/tm/packages/"); - cmd = xy_2strjoin ("mpm --set-repository=", miktex_url); - chsrc_run (cmd, RunOpt_Default); - } - - chsrc_say_lastly (&source, ChsrcTypeUntested); -} - - +#include "recipe/ware/TeX-Live.c" #include "recipe/ware/emacs.c" #include "recipe/ware/WinGet.c" #include "recipe/ware/Homebrew.c" diff --git a/src/recipe/catalog.c b/src/recipe/catalog.c index 9f0d0fb..02419fd 100644 --- a/src/recipe/catalog.c +++ b/src/recipe/catalog.c @@ -91,7 +91,6 @@ static const char os_freebsd, os_netbsd, os_openbsd, }; -def_target(wr_tex); static const char *wr_winget [] = {"winget", NULL, t(&wr_winget_target)}, diff --git a/src/recipe/ware/TeX-Live.c b/src/recipe/ware/TeX-Live.c new file mode 100644 index 0000000..2003c67 --- /dev/null +++ b/src/recipe/ware/TeX-Live.c @@ -0,0 +1,86 @@ +/** ------------------------------------------------------------ + * SPDX-License-Identifier: GPL-3.0-or-later + * ------------------------------------------------------------- + * File Authors : Aoran Zeng + * Contributors : Nil Null + * Created On : <2023-09-10> + * Last Modified : <2024-08-15> + * ------------------------------------------------------------*/ + +/** + * @time 2023-09-10 更新 + */ +static SourceInfo +wr_tex_sources[] = { + {&Upstream, NULL}, + {&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/ctan/systems/texlive/tlnet"}, + {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet"}, + {&Bfsu, "https://mirrors.bfsu.edu.cn/CTAN/systems/texlive/tlnet"}, + {&Lzuoss, "https://mirror.lzu.edu.cn/CTAN/systems/texlive/tlnet"}, + {&Jlu, "https://mirrors.jlu.edu.cn/CTAN/systems/texlive/tlnet"}, + {&Sustech, "https://mirrors.sustech.edu.cn/CTAN/systems/texlive/tlnet"} +}; +def_sources_n(wr_tex); + + +void +wr_tex_check_cmd (bool *tlmgr_exist, bool *mpm_exist) +{ + *tlmgr_exist = chsrc_check_program ("tlmgr"); + *mpm_exist = chsrc_check_program ("mpm"); + + if (!*tlmgr_exist && !*mpm_exist) + { + chsrc_error ("未找到 tlmgr 或 mpm 命令,请检查是否存在(其一)"); + exit(1); + } +} + +void +wr_tex_getsrc (char *option) +{ + bool tlmgr_exist, mpm_exist; + wr_tex_check_cmd (&tlmgr_exist, &mpm_exist); + + if (tlmgr_exist) + { + chsrc_run("tlmgr option repository", RunOpt_Default); + } + if (mpm_exist) + { + chsrc_run("mpm --get-repository", RunOpt_Default); + } +} + +/** + * 参考 https://help.mirrors.cernet.edu.cn/CTAN/ + */ +void +wr_tex_setsrc (char *option) +{ + bool tlmgr_exist, mpm_exist; + wr_tex_check_cmd (&tlmgr_exist, &mpm_exist); + + SourceInfo source; + chsrc_yield_source (wr_tex); + chsrc_confirm_source (&source); + + char *cmd = NULL; + + if (tlmgr_exist) + { + cmd = xy_2strjoin ("tlmgr option repository ", source.url); + chsrc_run (cmd, RunOpt_Default); + } + + if (mpm_exist) + { + char *miktex_url = xy_2strjoin (xy_str_delete_suffix (source.url, "texlive/tlnet"), "win32/miktex/tm/packages/"); + cmd = xy_2strjoin ("mpm --set-repository=", miktex_url); + chsrc_run (cmd, RunOpt_Default); + } + + chsrc_say_lastly (&source, ChsrcTypeUntested); +} + +def_target(wr_tex);