Skip to content

ARM 下 reset Ubuntu 报错 #334

Closed
Closed

Description

@usernameisnull

你操作了什么?

在reset ubuntu的时候好像sed语句不对?

#0 6.207 [chsrc 运行] sed -E -i 's@https?://.*/ubuntu-ports/?@http://archive.ubuntu.com/ubuntu/-ports@g' /etc/apt/sources.list

版本

root@30347b3ef331:/opt/hadoop# /opt/tools/chsrc --version
chsrc v0.2.4 (2025/12/31)

Copyright (C) 2023-2025 曾奥然, 郭恒
许可证 GPLv3+:GNU GPL 第 3 版或更高版本 <https://gnu.org/licenses/gpl.html>
这是自由软件:您可以自由修改和分发它。
在法律允许的最大范围内,本软件按'原样'提供,不作任何明示或暗示的保证。

由作者:曾奥然、郭恒,协作者:Mikachu2333、Happy Game 以及各位贡献者开发。(详见 chsrc-main.c, 或 `chsrc ls <target>`)

发生了什么?

reset ubuntu失败

本应该怎么样?

期望应该能够reset成功

chsrc 版本

v0.2.4 (2025/12/31)

你使用的是哪个操作系统?

Linux

OS 版本 / OS 发行版

Ubuntu 22.04.4 LTS

Log 输出

#25 [linux/arm64 9/9] RUN /opt/tools/chsrc reset ubuntu
#0 0.769 
#0 0.770 WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
#0 0.770 
#0 1.815 Get:1 https://deb.nodesource.com/node_20.x nodistro InRelease [12.1 kB]
#0 2.121 Ign:2 http://archive.ubuntu.com/ubuntu/-ports jammy InRelease
#0 2.416 Ign:3 http://archive.ubuntu.com/ubuntu/-ports jammy-updates InRelease
#0 2.712 Ign:4 http://archive.ubuntu.com/ubuntu/-ports jammy-backports InRelease
#0 3.009 Ign:5 http://archive.ubuntu.com/ubuntu/-ports jammy-security InRelease
#0 3.307 Err:6 http://archive.ubuntu.com/ubuntu/-ports jammy Release
#0 3.307   404  Not Found [IP: 185.125.190.83 80]
#0 3.600 Err:7 http://archive.ubuntu.com/ubuntu/-ports jammy-updates Release
#0 3.600   404  Not Found [IP: 185.125.190.83 80]
#0 3.896 Err:8 http://archive.ubuntu.com/ubuntu/-ports jammy-backports Release
#0 3.896   404  Not Found [IP: 185.125.190.83 80]
#0 4.192 Err:9 http://archive.ubuntu.com/ubuntu/-ports jammy-security Release
#0 4.192   404  Not Found [IP: 185.125.190.83 80]
#0 5.574 Get:10 https://deb.nodesource.com/node_20.x nodistro/main arm64 Packages [13.8 kB]
#0 5.980 Reading package lists...
#0 6.194 E: The repository 'http://archive.ubuntu.com/ubuntu/-ports jammy Release' does not have a Release file.
#0 6.194 E: The repository 'http://archive.ubuntu.com/ubuntu/-ports jammy-updates Release' does not have a Release file.
#0 6.194 E: The repository 'http://archive.ubuntu.com/ubuntu/-ports jammy-backports Release' does not have a Release file.
#0 6.194 E: The repository 'http://archive.ubuntu.com/ubuntu/-ports jammy-security Release' does not have a Release file.
#0 6.194 W: https://deb.nodesource.com/node_20.x/dists/nodistro/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
#0 6.206 chsrc: 关键错误,强制结束
#0 6.207 [chsrc 检查] x 文件 /etc/apt/sources.list.d/ubuntu.sources 不存在
#0 6.207 [chsrc 提醒] 将基于旧格式(非DEB822)换源
#0 6.207 [chsrc 检查] ✓ 文件 /etc/apt/sources.list 存在
#0 6.207 选中镜像站: Upstream (upstream)
#0 6.207 --------------------------------
#0 6.207 [chsrc 备份] /etc/apt/sources.list -> /etc/apt/sources.list.bak
#0 6.207 [chsrc 运行] sed -E -i 's@https?://.*/ubuntu-ports/?@http://archive.ubuntu.com/ubuntu/-ports@g' /etc/apt/sources.list
#0 6.207 [chsrc 运行] ✓ 命令执行成功
#0 6.207 
`
#0 6.207 [chsrc 运行] apt update
#0 6.207 [chsrc 运行] x 命令执行失败,退出状态: 25600
#25 ...
#24 [linux/amd64 9/9] RUN /opt/tools/chsrc reset ubuntu
#24 8.357 Get:10 http://archive.ubuntu.com/ubuntu jammy/restricted amd64 Packages [164 kB]
#24 8.435 Get:11 http://archive.ubuntu.com/ubuntu jammy-updates/multiverse amd64 Packages [69.2 kB]
#24 8.459 Get:12 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 Packages [1,600 kB]
 5 warnings found (use --debug to expand):

防止重复问题

  • 我已在项目中搜索过类似的 issue

Activity

  1. usernameisnull commented on Jan 19, 2026

    @usernameisnull
    ContributorAuthor

    在我本地跑没问题, 但是在gitlab的流水线里跑就有问题,镜像都是一样的,挺奇怪的...

  2. ccmywish commented on Jan 19, 2026

    @ccmywish
    Contributor

    @usernameisnull

    在我本地跑没问题, 但是在gitlab的流水线里跑就有问题,镜像都是一样的

    你在 GitLab 的服务器是 arm64, 本地服务器是 x86 的。chsrc 换源的代码走向了不同分支。

    https://github.com/RubyMetric/chsrc/blob/main/src/recipe/os/APT/Ubuntu.c#L84-L91

  3. added this to the v0.2.5 milestone on Jan 19, 2026
  4. added
    os_dish
    Linux
    on Jan 19, 2026
  5. ccmywish commented on Jan 19, 2026

    @ccmywish
    Contributor

    代码的问题可能是:

    https://github.com/RubyMetric/chsrc/blob/main/src/recipe/os/APT/Ubuntu.c#L28-L29

    这两行提供的换源路径多了一个 /,你能在服务器上编译chsrc吗?(只要有 gcc 和 make 就行,我们在 Gitee 上也有仓库,服务器可以直接从 Gitee 的仓库拉代码),可以修改后运行试试看。如果没问题可以向我们提交PR。

    不方便的话,就我来修改,然后发布新版本。

  6. usernameisnull commented on Jan 19, 2026

    @usernameisnull
    ContributorAuthor

    代码的问题可能是:

    https://github.com/RubyMetric/chsrc/blob/main/src/recipe/os/APT/Ubuntu.c#L28-L29

    这两行提供的换源路径多了一个 /,你能在服务器上编译chsrc吗?(只要有 gcc 和 make 就行,我们在 Gitee 上也有仓库,服务器可以直接从 Gitee 的仓库拉代码),可以修改后运行试试看。如果没问题可以向我们提交PR。

    不方便的话,就我来修改,然后发布新版本。

    我试试

  7. linked a pull request that will close this issue修复ubuntu arm64下reset的问题 #335on Jan 21, 2026
  8. ccmywish commented on Jan 21, 2026

    @ccmywish
    Contributor

    @usernameisnull 👍👍👍

    额外提取了一个API出来,用来运行时修改换源链接: chef_set_repoURL()

    void
    os_ubuntu_resetsrc (char *option)
    {
    chef_use_this (os_ubuntu);
    char *arch = chsrc_get_cpuarch ();
    if (strncmp (arch, "x86_64", 6)!=0)
    {
    // Ubuntu 非 x86_64 架构的源地址有所不同
    chef_set_repoURL (this, &UpstreamProvider, "http://ports.ubuntu.com/ubuntu");
    // this->sources[0].url = "http://ports.ubuntu.com/ubuntu";
    }
    os_ubuntu_setsrc (option);
    }

    已发布 v0.2.4.1, 可使用安装脚本下载试用,若无问题,可随时关闭此 issue.

  9. ccmywish commented on Jan 21, 2026

    @ccmywish
    Contributor

    发布了 v0.2.4.2,换了个位置,这段逻辑直接放在 prelude() 最后,这样有两个好处:

    1. chsrc ls ubuntu 的时候就可以看到默认源地址是否是根据架构变化的
    2. 测速的时候也会使用这个正确的默认源地址下的资源

    def_sources_begin()
    {&UpstreamProvider, "http://archive.ubuntu.com/ubuntu", FeedByPrelude}, /* 不支持https */
    {&MirrorZ, "https://mirrors.cernet.edu.cn/ubuntu",FeedByPrelude},
    {&Ali, "https://mirrors.aliyun.com/ubuntu",FeedByPrelude},
    {&Volcengine, "https://mirrors.volces.com/ubuntu",FeedByPrelude},
    {&Bfsu, "https://mirrors.bfsu.edu.cn/ubuntu",FeedByPrelude},
    {&Ustc, "https://mirrors.ustc.edu.cn/ubuntu",FeedByPrelude},
    {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/ubuntu",FeedByPrelude},
    {&Tencent, "https://mirrors.tencent.com/ubuntu", FeedByPrelude},
    // {&Tencent_Intra, "https://mirrors.tencentyun.com/ubuntu",FeedByPrelude},
    {&Huawei, "https://mirrors.huaweicloud.com/ubuntu",FeedByPrelude}
    /* 不启用原因:过慢 */
    // {&Netease, "https://mirrors.163.com/ubuntu", FeedByPrelude},
    /* 不启用原因:过慢 */
    // {&Sohu, "https://mirrors.sohu.com/ubuntu", FeedByPrelude}
    def_sources_end()
    char *arch = chsrc_get_cpuarch ();
    // Ubuntu 非 x86_64 架构的默认源地址有所不同
    if (strncmp (arch, "x86_64", 6)!=0)
    {
    chef_set_repoURL (this, &UpstreamProvider, "http://ports.ubuntu.com/ubuntu");
    }
    chef_set_rest_smURL_with_postfix (this, "/dists/noble/Contents-amd64.gz");
    }

  10. changed the title [-]reset ubuntu好像sed语句不对[/-] [+]`ARM` 下 `reset` `Ubuntu` 报错[/+] on Jan 21, 2026
  11. usernameisnull commented on Jan 22, 2026

    @usernameisnull
    ContributorAuthor

    我用v0.2.4.2在arm上试了,是ok的

    root@iZ2vcbv67xusmcl6d7fuogZ:/etc/apt# arch
    aarch64
    root@iZ2vcbv67xusmcl6d7fuogZ:/etc/apt# chsrc --version
    chsrc v0.2.4.2 (2026/01/21)
    
    Copyright (C) 2023-2026 曾奥然, 郭恒
    许可证 GPLv3+:GNU GPL 第 3 版或更高版本 <https://gnu.org/licenses/gpl.html>
    这是自由软件:您可以自由修改和分发它。
    在法律允许的最大范围内,本软件按'原样'提供,不作任何明示或暗示的保证。
    
    由作者:曾奥然、郭恒,协作者:Mikachu2333、Happy Game 以及各位贡献者开发。(详见 chsrc-main.c, 或 `chsrc ls <target>`)
    root@iZ2vcbv67xusmcl6d7fuogZ:/etc/apt# chsrc reset ubuntu
    [chsrc 检查] x 文件 /etc/apt/sources.list.d/ubuntu.sources 不存在
    [chsrc 提醒] 将基于旧格式(非DEB822)换源
    [chsrc 检查] ✓ 文件 /etc/apt/sources.list 存在
    选中镜像站: Upstream (upstream)
    --------------------------------
    [chsrc 备份] /etc/apt/sources.list -> /etc/apt/sources.list.bak
    [chsrc 运行] sed -E -i 's@https?://.*/ubuntu-ports/?@http://ports.ubuntu.com/ubuntu-ports@g' /etc/apt/sources.list
    [chsrc 运行] ✓ 命令执行成功
    
    [chsrc 运行] apt-get update
    Get:1 http://ports.ubuntu.com/ubuntu-ports jammy InRelease [270 kB]
    Get:2 http://ports.ubuntu.com/ubuntu-ports jammy-updates InRelease [128 kB]
    Get:3 http://ports.ubuntu.com/ubuntu-ports jammy-backports InRelease [127 kB]
    Get:4 http://ports.ubuntu.com/ubuntu-ports jammy-security InRelease [129 kB]
    Get:5 http://ports.ubuntu.com/ubuntu-ports jammy/main arm64 Packages [1,369 kB]
    Get:6 http://ports.ubuntu.com/ubuntu-ports jammy/main Translation-en [510 kB]
    Get:7 http://ports.ubuntu.com/ubuntu-ports jammy/main arm64 c-n-f Metadata [29.8 kB]
    Get:8 http://ports.ubuntu.com/ubuntu-ports jammy/restricted arm64 Packages [19.6 kB]
    Get:9 http://ports.ubuntu.com/ubuntu-ports jammy/restricted Translation-en [18.6 kB]
    Get:10 http://ports.ubuntu.com/ubuntu-ports jammy/restricted arm64 c-n-f Metadata [372 B]
    Get:11 http://ports.ubuntu.com/ubuntu-ports jammy/universe arm64 Packages [13.9 MB]
    Get:12 http://ports.ubuntu.com/ubuntu-ports jammy/universe Translation-en [5,652 kB]
    Get:13 http://ports.ubuntu.com/ubuntu-ports jammy/universe arm64 c-n-f Metadata [277 kB]
    Get:14 http://ports.ubuntu.com/ubuntu-ports jammy/multiverse arm64 Packages [184 kB]
    Get:15 http://ports.ubuntu.com/ubuntu-ports jammy/multiverse Translation-en [112 kB]
    Get:16 http://ports.ubuntu.com/ubuntu-ports jammy/multiverse arm64 c-n-f Metadata [7,064 B]
    Get:17 http://ports.ubuntu.com/ubuntu-ports jammy-updates/main arm64 Packages [2,993 kB]
    Get:18 http://ports.ubuntu.com/ubuntu-ports jammy-updates/main Translation-en [485 kB]
    Get:19 http://ports.ubuntu.com/ubuntu-ports jammy-updates/main arm64 c-n-f Metadata [18.8 kB]
    Get:20 http://ports.ubuntu.com/ubuntu-ports jammy-updates/restricted arm64 Packages [4,875 kB]
    Get:21 http://ports.ubuntu.com/ubuntu-ports jammy-updates/restricted Translation-en [944 kB]
    Get:22 http://ports.ubuntu.com/ubuntu-ports jammy-updates/restricted arm64 c-n-f Metadata [496 B]
    Get:23 http://ports.ubuntu.com/ubuntu-ports jammy-updates/universe arm64 Packages [1,274 kB]
    Get:24 http://ports.ubuntu.com/ubuntu-ports jammy-updates/universe Translation-en [311 kB]
    Get:25 http://ports.ubuntu.com/ubuntu-ports jammy-updates/universe arm64 c-n-f Metadata [26.9 kB]
    Get:26 http://ports.ubuntu.com/ubuntu-ports jammy-updates/multiverse arm64 Packages [38.6 kB]
    Get:27 http://ports.ubuntu.com/ubuntu-ports jammy-updates/multiverse Translation-en [13.2 kB]
    Get:28 http://ports.ubuntu.com/ubuntu-ports jammy-updates/multiverse arm64 c-n-f Metadata [336 B]
    Get:29 http://ports.ubuntu.com/ubuntu-ports jammy-backports/main arm64 Packages [69.0 kB]
    Get:30 http://ports.ubuntu.com/ubuntu-ports jammy-backports/main Translation-en [11.5 kB]
    Get:31 http://ports.ubuntu.com/ubuntu-ports jammy-backports/main arm64 c-n-f Metadata [412 B]
    Get:32 http://ports.ubuntu.com/ubuntu-ports jammy-backports/restricted arm64 c-n-f Metadata [116 B]
    Get:33 http://ports.ubuntu.com/ubuntu-ports jammy-backports/universe arm64 Packages [30.1 kB]
    Get:34 http://ports.ubuntu.com/ubuntu-ports jammy-backports/universe Translation-en [16.9 kB]
    Get:35 http://ports.ubuntu.com/ubuntu-ports jammy-backports/universe arm64 c-n-f Metadata [604 B]
    Get:36 http://ports.ubuntu.com/ubuntu-ports jammy-backports/multiverse arm64 c-n-f Metadata [116 B]
    Get:37 http://ports.ubuntu.com/ubuntu-ports jammy-security/main arm64 Packages [2,743 kB]
    Get:38 http://ports.ubuntu.com/ubuntu-ports jammy-security/main Translation-en [419 kB]
    Get:39 http://ports.ubuntu.com/ubuntu-ports jammy-security/main arm64 c-n-f Metadata [13.7 kB]
    Get:40 http://ports.ubuntu.com/ubuntu-ports jammy-security/restricted arm64 Packages [4,723 kB]
    Get:41 http://ports.ubuntu.com/ubuntu-ports jammy-security/restricted Translation-en [917 kB]
    Get:42 http://ports.ubuntu.com/ubuntu-ports jammy-security/restricted arm64 c-n-f Metadata [508 B]
    Get:43 http://ports.ubuntu.com/ubuntu-ports jammy-security/universe arm64 Packages [1,043 kB]
    Get:44 http://ports.ubuntu.com/ubuntu-ports jammy-security/universe Translation-en [222 kB]
    Get:45 http://ports.ubuntu.com/ubuntu-ports jammy-security/universe arm64 c-n-f Metadata [19.8 kB]
    Get:46 http://ports.ubuntu.com/ubuntu-ports jammy-security/multiverse arm64 Packages [33.6 kB]
    Get:47 http://ports.ubuntu.com/ubuntu-ports jammy-security/multiverse Translation-en [10.5 kB]
    Get:48 http://ports.ubuntu.com/ubuntu-ports jammy-security/multiverse arm64 c-n-f Metadata [296 B]
    Fetched 44.0 MB in 8s (5,294 kB/s)
    Reading package lists... Done
    [chsrc 运行] ✓ 命令执行成功
    --------------------------------
    chsrc: 已重置为上游默认源
    食源检查: 2026-01-21  食谱更新: 2026-01-21  后厨人数: 4  (详查 chsrc ls ubuntu)
    root@iZ2vcbv67xusmcl6d7fuogZ:/etc/apt#
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Linuxos_dish

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions