From 71d6c68e11ad8f22f4d566b7ac0bf77f1470588f Mon Sep 17 00:00:00 2001 From: Aoran Zeng Date: Sat, 14 Dec 2024 22:10:40 +0800 Subject: [PATCH] Fix `OpenWrt` setsrc and add resetsrc [GitHub #153] Co-authored-by: happy game --- src/recipe/os/OpenWrt.c | 44 +++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/src/recipe/os/OpenWrt.c b/src/recipe/os/OpenWrt.c index 0ec7e4f..077b1c6 100644 --- a/src/recipe/os/OpenWrt.c +++ b/src/recipe/os/OpenWrt.c @@ -3,16 +3,17 @@ * ------------------------------------------------------------- * File Authors : Aoran Zeng * Contributors : Yangmoooo + * | * Created On : <2024-08-08> - * Last Modified : <2024-08-08> + * Last Modified : <2024-12-14> * ------------------------------------------------------------*/ /** - * @update 2024-08-08 + * @update 2024-12-14 */ static Source_t os_openwrt_sources[] = { - {&UpstreamProvider, "http://downloads.openwrt.org"}, + {&UpstreamProvider, "https://downloads.openwrt.org"}, {&MirrorZ, "https://mirrors.cernet.edu.cn/openwrt"}, {&Ali, "https://mirrors.aliyun.com/openwrt"}, {&Tencent, "https://mirrors.cloud.tencent.com/openwrt"}, @@ -36,7 +37,9 @@ os_openwrt_getsrc (char *option) } /** - * 参考: https://mirror.tuna.tsinghua.edu.cn/help/openwrt/ + * @consult + * 1. https://mirror.tuna.tsinghua.edu.cn/help/openwrt/ + * 2. https://github.com/RubyMetric/chsrc/issues/153#issuecomment-2543077933 */ void os_openwrt_setsrc (char *option) @@ -47,13 +50,38 @@ os_openwrt_setsrc (char *option) chsrc_backup (OS_OpenWRT_SourceConfig); - char *cmd = xy_strjoin (3, "sed -E -i 's@https?://.*downloads.openwrt.org@", source.url, "@g' " OS_OpenWRT_SourceConfig); + char *cmd = xy_strjoin (3, "sed -E -i 's@https?://.*/releases@", source.url, "@g' " OS_OpenWRT_SourceConfig); - chsrc_run ("apt update", RunOpt_No_Last_New_Line); + chsrc_run ("opkg update", RunOpt_No_Last_New_Line); - ProgMode_ChgType = ChgType_Auto; + ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto; chsrc_conclude (&source); } -def_target(os_openwrt); +void +os_openwrt_resetsrc (char *option) +{ + os_openwrt_setsrc (option); +} + + +Feature_t +os_openwrt_feat (char *option) +{ + Feature_t f = {0}; + + f.can_get = true; + f.can_reset = true; + + f.cap_locally = CanNot; + f.cap_locally_explain = NULL; + f.can_english = true; + f.can_user_define = true; + + f.note = NULL; + return f; +} + + +def_target_gsf(os_openwrt);