From bbfb6d54016b48bafc8b9f876c1ac905bb6d0c74 Mon Sep 17 00:00:00 2001 From: Aoran Zeng Date: Fri, 16 Aug 2024 04:11:38 +0800 Subject: [PATCH] Split winget out --- include/source.h | 15 +----------- src/chsrc.c | 31 +------------------------ src/recipe/catalog.c | 1 - src/recipe/ware/WinGet.c | 49 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 45 deletions(-) create mode 100644 src/recipe/ware/WinGet.c diff --git a/include/source.h b/include/source.h index 381912a..25d4087 100644 --- a/include/source.h +++ b/include/source.h @@ -153,21 +153,10 @@ pl_dotnet_sources[] = { -/** - * @time 2024-06-07 更新 - * @note 目前仅有一个源 - */ -static SourceInfo -wr_winget_sources[] = { - {&Upstream, "https://cdn.winget.microsoft.com/cache"}, - {&Ustc, "https://mirrors.ustc.edu.cn/winget-source"}, -}, - - - /** * @time 2024-06-08 更新 */ +static SourceInfo wr_cocoapods_sources[] = { {&Upstream, NULL}, {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git"}, @@ -248,8 +237,6 @@ wr_tex_sources[] = { def_sources_n(pl_clojure); def_sources_n(pl_dotnet); - -def_sources_n(wr_winget); def_sources_n(wr_cocoapods); def_sources_n(wr_flathub); diff --git a/src/chsrc.c b/src/chsrc.c index c84097a..b4d9ef4 100644 --- a/src/chsrc.c +++ b/src/chsrc.c @@ -177,36 +177,7 @@ wr_tex_setsrc (char *option) #include "recipe/ware/emacs.c" - - -void -wr_winget_getsrc (char *option) -{ - chsrc_run ("winget source list", RunOpt_Default); -} - -/* 参考:https://mirrors.ustc.edu.cn/help/winget-source.html */ -void -wr_winget_setsrc (char *option) -{ - SourceInfo source; - chsrc_yield_source (wr_winget); - chsrc_confirm_source (&source); - - chsrc_run ("winget source remove winget", RunOpt_Default); - chsrc_run (xy_2strjoin ("winget source add winget ", source.url), RunOpt_Default); - - chsrc_say_lastly (&source, ChsrcTypeAuto); -} - -void -wr_winget_resetsrc (char *option) -{ - chsrc_run ("winget source reset winget", RunOpt_Default); - chsrc_say_lastly (NULL, ChsrcTypeAuto); -} - - +#include "recipe/ware/WinGet.c" #include "recipe/ware/Homebrew.c" /** diff --git a/src/recipe/catalog.c b/src/recipe/catalog.c index 3ee769e..6b51e06 100644 --- a/src/recipe/catalog.c +++ b/src/recipe/catalog.c @@ -92,7 +92,6 @@ static const char }; -def_target_full(wr_winget); def_target_noget (wr_cocoapods); def_target_noget (wr_flathub); def_target_noget (wr_nix); diff --git a/src/recipe/ware/WinGet.c b/src/recipe/ware/WinGet.c new file mode 100644 index 0000000..59272be --- /dev/null +++ b/src/recipe/ware/WinGet.c @@ -0,0 +1,49 @@ +/** ------------------------------------------------------------ + * SPDX-License-Identifier: GPL-3.0-or-later + * ------------------------------------------------------------- + * File Authors : Aoran Zeng + * Contributors : Nil Null + * Created On : <2024-06-07> + * Last Modified : <2024-08-15> + * ------------------------------------------------------------*/ + +/** + * @time 2024-06-07 更新 + * @note 目前仅有一个源 + */ +static SourceInfo +wr_winget_sources[] = { + {&Upstream, "https://cdn.winget.microsoft.com/cache"}, + {&Ustc, "https://mirrors.ustc.edu.cn/winget-source"}, +}; +def_sources_n(wr_winget); + + +void +wr_winget_getsrc (char *option) +{ + chsrc_run ("winget source list", RunOpt_Default); +} + +/* 参考:https://mirrors.ustc.edu.cn/help/winget-source.html */ +void +wr_winget_setsrc (char *option) +{ + SourceInfo source; + chsrc_yield_source (wr_winget); + chsrc_confirm_source (&source); + + chsrc_run ("winget source remove winget", RunOpt_Default); + chsrc_run (xy_2strjoin ("winget source add winget ", source.url), RunOpt_Default); + + chsrc_say_lastly (&source, ChsrcTypeAuto); +} + +void +wr_winget_resetsrc (char *option) +{ + chsrc_run ("winget source reset winget", RunOpt_Default); + chsrc_say_lastly (NULL, ChsrcTypeAuto); +} + +def_target_full(wr_winget);