From df1c4fae11cc4c69aa3a3dc28fbef3d4dd6961cb Mon Sep 17 00:00:00 2001 From: Aoran Zeng Date: Wed, 21 Jan 2026 15:26:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=20`chef=5Fset=5Fsource=5Furl?= =?UTF-8?q?`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/framework/chef.c | 29 ++++++++++++++++++++++++++--- src/recipe/os/APT/Ubuntu.c | 5 +++-- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/framework/chef.c b/src/framework/chef.c index 82a768f..cbee5c0 100644 --- a/src/framework/chef.c +++ b/src/framework/chef.c @@ -2,10 +2,10 @@ * SPDX-License-Identifier: GPL-3.0-or-later * ------------------------------------------------------------- * File Name : chef.c - * File Authors : 曾奥然 - * Contributors : BingChunMoLi + * File Authors : @ccmywish + * Contributors : @BingChunMoLi * Created On : <2025-08-09> - * Last Modified : <2025-10-27> + * Last Modified : <2026-01-21> * * chef DSL: for chefs (recipe makers) to define a target * ------------------------------------------------------------*/ @@ -156,6 +156,29 @@ chef_set_sources_speed_measure_url_with_postfix (Target_t *target, char *postfix } +/** + * @brief 修改 或 补充 某个镜像站的换源链接 + * + * @example 见 os_ubuntu_resetsrc() 中对非 x86_64 架构源地址的修改 + */ +void +chef_set_source_url (Target_t *target, SourceProvider_t *provider, char *url) +{ + for (int i=0; i < target->sources_n; i++) + { + Source_t *src = &target->sources[i]; + SourceProvider_t *p = src->provider; + if (p == provider) + { + src->url = xy_strdup (url); + return; + } + } + + xy_unreached(); +} + + /** * @note 用于: 组中的 item target 在 standalone 模式时正确填充源信息 */ diff --git a/src/recipe/os/APT/Ubuntu.c b/src/recipe/os/APT/Ubuntu.c index cfb279d..641fbcb 100644 --- a/src/recipe/os/APT/Ubuntu.c +++ b/src/recipe/os/APT/Ubuntu.c @@ -152,8 +152,9 @@ os_ubuntu_resetsrc (char *option) char *arch = chsrc_get_cpuarch (); if (strncmp (arch, "x86_64", 6)!=0) { - // ubuntu arm的源地址和x86_64不一样 - this->sources[0].url = "http://ports.ubuntu.com/ubuntu"; + // Ubuntu 非 x86_64 架构的源地址有所不同 + chef_set_source_url (this, &UpstreamProvider, "http://ports.ubuntu.com/ubuntu"); + // this->sources[0].url = "http://ports.ubuntu.com/ubuntu"; } os_ubuntu_setsrc (option); }