diff --git a/include/source.h b/include/source.h index c5eaf36..18fc525 100644 --- a/include/source.h +++ b/include/source.h @@ -8,7 +8,7 @@ * Contributors : Shengwei Chen <414685209@qq.com> * | * Created on : <2023-08-29> - * Last modified : <2024-07-24> + * Last modified : <2024-08-09> * * 镜像站与换源信息 * ------------------------------------------------------------*/ @@ -833,27 +833,6 @@ wr_cocoapods_sources[] = { {&Bfsu, "https://mirrors.bfsu.edu.cn/git/CocoaPods/Specs.git"} }, -/** - * 2024-07-24 更新 - * - * @note USTC 与 SJTUG 于 2024-06-06 停止支持 DockerHub - * @note NJU 于 2024-06-07 停止支持 DockerHub - * - * 参考:https://gist.github.com/y0ngb1n/7e8f16af3242c7815e7ca2f0833d3ea6 - */ -wr_dockerhub_sources[] = { - {&Upstream, NULL}, - // {&Ustc, "https://docker.mirrors.ustc.edu.cn/"}, - - // https://github.com/DaoCloud/public-image-mirror - {&DaoCloud, "https://docker.m.daocloud.io"}, - {&Fit2Cloud, "https://docker.1panel.live"}, - - // 暂时加入,未来若国内镜像恢复,将删除 - // https://huecker.io/en/use.html#unbanned - {&Huecker, "https://huecker.io"} -}, - /** @@ -972,7 +951,7 @@ def_sources_n(os_anolis); def_sources_n(wr_winget); def_sources_n(wr_brew); def_sources_n(wr_cocoapods); -def_sources_n(wr_dockerhub); + def_sources_n(wr_flathub); def_sources_n(wr_nix); def_sources_n(wr_guix); def_sources_n(wr_tex); def_sources_n(wr_emacs); diff --git a/src/chsrc.c b/src/chsrc.c index 362c184..8e6aa14 100644 --- a/src/chsrc.c +++ b/src/chsrc.c @@ -2123,59 +2123,7 @@ wr_nix_setsrc (char *option) } - -void -wr_dockerhub_getsrc (char *option) -{ - if (xy_on_linux || xy_on_bsd) - { - chsrc_view_file ("/etc/docker/daemon.json"); - } - else - { - chsrc_note2 ("请打开Docker Desktop设置"); - chsrc_note2 ("选择“Docker Engine”选项卡,在该选项卡中找到“registry-mirrors”一栏查看"); - } -} - -/** - * 参考: - * 1. https://mirrors.ustc.edu.cn/help/dockerhub.html - * 2. https://www.cnblogs.com/yuzhihui/p/17461781.html - */ -void -wr_dockerhub_setsrc (char *option) -{ - SourceInfo source; - chsrc_yield_source (wr_dockerhub); - chsrc_confirm_source (&source); - - if (xy_on_linux || xy_on_bsd) - { - char *to_add = xy_strjoin (3, "{\n" - " \"registry-mirrors\": [\"", source.url, "\"]\n" - "}"); - chsrc_note2 ("请向 /etc/docker/daemon.json 中添加下述内容:"); - puts (to_add); - if (xy_on_linux) - { - chsrc_note2 ("然后请运行:"); - puts ("sudo systemctl restart docker"); - } - else - { - chsrc_note2 ("然后请手动重启 docker 服务"); - } - } - else - { - chsrc_note2 ("请打开Docker Desktop设置"); - chsrc_note2 ("选择“Docker Engine”选项卡,在该选项卡中找到“registry-mirrors”一栏,添加镜像地址:"); - puts (source.url); - } - chsrc_say_lastly (&source, ChsrcTypeManual); -} - +#include "recipe/ware/docker.c" /** @@ -2363,7 +2311,6 @@ static const char def_target_full(wr_winget); def_target(wr_brew); def_target_noget (wr_cocoapods); -def_target(wr_dockerhub); def_target_noget (wr_flathub); def_target_noget (wr_nix); def_target_noget (wr_guix); diff --git a/src/recipe/ware/docker.c b/src/recipe/ware/docker.c new file mode 100644 index 0000000..e2bc9a4 --- /dev/null +++ b/src/recipe/ware/docker.c @@ -0,0 +1,87 @@ +/** ------------------------------------------------------------ + * SPDX-License-Identifier: GPL-3.0-or-later + * ------------------------------------------------------------- + * Contributors : Aoran Zeng + * Created on : <2024-06-08> + * Last modified : <2024-08-09> + * ------------------------------------------------------------*/ + +/** + * 2024-07-24 更新 + * + * @note USTC 与 SJTUG 于 2024-06-06 停止支持 DockerHub + * @note NJU 于 2024-06-07 停止支持 DockerHub + * + * 参考:https://gist.github.com/y0ngb1n/7e8f16af3242c7815e7ca2f0833d3ea6 + */ + +static SourceInfo +wr_dockerhub_sources[] = { + {&Upstream, NULL}, + // {&Ustc, "https://docker.mirrors.ustc.edu.cn/"}, + + // https://github.com/DaoCloud/public-image-mirror + {&DaoCloud, "https://docker.m.daocloud.io"}, + {&Fit2Cloud, "https://docker.1panel.live"}, + + // 暂时加入,未来若国内镜像恢复,将删除 + // https://huecker.io/en/use.html#unbanned + {&Huecker, "https://huecker.io"} +}; + +def_sources_n(wr_dockerhub); + +void +wr_dockerhub_getsrc (char *option) +{ + if (xy_on_linux || xy_on_bsd) + { + chsrc_view_file ("/etc/docker/daemon.json"); + } + else + { + chsrc_note2 ("请打开Docker Desktop设置"); + chsrc_note2 ("选择“Docker Engine”选项卡,在该选项卡中找到“registry-mirrors”一栏查看"); + } +} + +/** + * 参考: + * 1. https://mirrors.ustc.edu.cn/help/dockerhub.html + * 2. https://www.cnblogs.com/yuzhihui/p/17461781.html + */ +void +wr_dockerhub_setsrc (char *option) +{ + SourceInfo source; + chsrc_yield_source (wr_dockerhub); + chsrc_confirm_source (&source); + + if (xy_on_linux || xy_on_bsd) + { + char *to_add = xy_strjoin (3, "{\n" + " \"registry-mirrors\": [\"", source.url, "\"]\n" + "}"); + chsrc_note2 ("请向 /etc/docker/daemon.json 中添加下述内容:"); + puts (to_add); + if (xy_on_linux) + { + chsrc_note2 ("然后请运行:"); + puts ("sudo systemctl restart docker"); + } + else + { + chsrc_note2 ("然后请手动重启 docker 服务"); + } + } + else + { + chsrc_note2 ("请打开Docker Desktop设置"); + chsrc_note2 ("选择“Docker Engine”选项卡,在该选项卡中找到“registry-mirrors”一栏,添加镜像地址:"); + puts (source.url); + } + chsrc_say_lastly (&source, ChsrcTypeManual); +} + + +def_target(wr_dockerhub);