Skip to content

功能请求:增加初始无软件源系统换源功能 #185

Closed

Description

@kekylin

原因:
因Debian安装系统过程中安全源更新在国内速度异常缓慢,一般情况下我采用完整镜像包用离线模式安装系统。
系统安装完成后,默认是无软件源的。也因为是最小化安装,系统初始环境无curl工具,只有wget工具。
无软件源+无curl工具,导致无法正常使用chsrc,无法享受换源的便利性。

期望:
如果可以,请求增加初始无软件源系统换源功能,谢谢!

Activity

  1. ccmywish commented on Mar 23, 2025

    @ccmywish
    Contributor

    了解你的需求,不存在 curl,只有 wget。这涉及到两个环节:

    1. 安装 chsrc 时
    2. 使用 chsrc 时

    分别采用两种解决方法:

    1. 安装的时候不用 curl,用 wget 把 https://chsrc.run/posix 这个脚本下载下来再运行
    2. 直接使用 chsrc set debian tuna 直接换到清华源,或者 set first 换到维护团队测速的最快源

    第二步可以避开测速过程,因而避开了使用 curl。

  2. kekylin commented on Mar 23, 2025

    @kekylin
    Author

    安装使用chsrc需要经过三个步骤:
    1、下载安装脚本【已解决】
    可通过wget工具下载。
    wget https://chsrc.run/posix | bash

    2、安装chsrc【未解决】
    因为系统没有curl工具,实际上第一步操作执行后,只能完成安装脚本文件的下载,无法正常运行脚本并完成chsrc的安装。
    疑似安装过程需要使用到curl工具。

    3、使用chsrc【已解决】
    直接使用chsrc set debian tuna直接换到清华源,或者set first换到维护团队测速的最快源,避开curl测速。

    4、手动下载二进制文件安装【安装成功,换源报错】
    通过手动下载二进制文件安装,也未成功换源,操作流程如下。
    手动下载安装:

    root@debian:~# wget https://gitee.com/RubyMetric/chsrc/releases/download/pre/chsrc-x64-linux -O chsrc && \
    chmod +x chsrc && \
    ./chsrc
    --2025-03-23 15:03:30--  https://gitee.com/RubyMetric/chsrc/releases/download/pre/chsrc-x64-linux
    Resolving gitee.com (gitee.com)... 180.76.198.225, 180.76.198.77, 180.76.199.13
    Connecting to gitee.com (gitee.com)|180.76.198.225|:443... connected.
    HTTP request sent, awaiting response... 302 Found
    Location: https://gitee.com/RubyMetric/chsrc/attach_files/2096424/download/chsrc-x64-linux [following]
    --2025-03-23 15:03:31--  https://gitee.com/RubyMetric/chsrc/attach_files/2096424/download/chsrc-x64-linux
    Reusing existing connection to gitee.com:443.
    HTTP request sent, awaiting response... 302 Found
    Location: https://foruda.gitee.com/attach_file/1742194070384800506/chsrc-x64-linux.bin?token=36fabcf4aba2bfecbf7ebdfaa026e176&ts=1742713411&attname=chsrc-x64-linux [following]
    --2025-03-23 15:03:31--  https://foruda.gitee.com/attach_file/1742194070384800506/chsrc-x64-linux.bin?token=36fabcf4aba2bfecbf7ebdfaa026e176&ts=1742713411&attname=chsrc-x64-linux
    Resolving foruda.gitee.com (foruda.gitee.com)... 180.76.198.77, 180.76.199.13
    Connecting to foruda.gitee.com (foruda.gitee.com)|180.76.198.77|:443... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 1078088 (1.0M) [application/x-executable]
    Saving to: ‘chsrc’
    
    chsrc                      100%[========================================>]   1.03M   553KB/s    in 1.9s
    
    2025-03-23 15:03:33 (553 KB/s) - ‘chsrc’ saved [1078088/1078088]
    
    chsrc: Change Source (GPLv3+) v0.2.0.1-2025/03/17 by RubyMetric
    
    使用: chsrc <command> [options] [target] [mirror]
    help                      打印此帮助,或 h, -h, --help
    issue                     查看相关issue
    
    list (或 ls, 或 l)        列出可用镜像源,和可换源目标
    list mirror/target        列出可用镜像源,或可换源目标
    list os/lang/ware         列出可换源的操作系统/编程语言/软件
    
    measure <target>          对该目标所有源测速
    cesu    <target>
    
    list <target>             查看该目标可用源与支持功能
    get  <target>             查看该目标当前源的使用情况
    
    set  <target>             换源,自动测速后挑选最快源
    set  <target>  first      换源,使用维护团队测速第一的源
    set  <target> <mirror>    换源,指定使用某镜像站 (通过list <target>查看)
    set  <target> https://url 换源,用户自定义源URL
    reset <target>            重置,使用上游默认使用的源
    
    选项:
    -dry                      Dry Run,模拟换源过程,命令仅打印并不运行
    -local                    仅对本项目而非全局换源 (通过ls <target>查看支持情况)
    -ipv6                     使用IPv6测速
    -en(glish)                使用英文输出
    -no-color                 无颜色输出
    
    镜像站状态: <https://github.com/RubyMetric/chsrc/wiki>
    维护: <https://github.com/RubyMetric/chsrc>
    

    执行换源:

    root@debian:~# ./chsrc set debian tuna
    [chsrc 检查] x 文件 /etc/apt/sources.list.d/debian.sources 不存在
    [chsrc 检查] ✓ 文件 /etc/apt/sources.list 存在
    选中镜像站: TUNA (tuna)
    --------------------------------
    [chsrc 提示] 如果遇到无法拉取 HTTPS 源的情况,我们会使用 HTTP 源并需要您运行:
    apt install apt-transport-https ca-certificates
    [chsrc 备份] /etc/apt/sources.list -> /etc/apt/sources.list.bak
    [chsrc 运行] sed -E -i 's@https?://.*/debian/?@https://mirrors.tuna.tsinghua.edu.cn/debian@g' /etc/apt/sources.list
    [chsrc 运行] ✓ 命令执行成功
    
    [chsrc 运行] apt update
    Ign:1 cdrom://[Debian GNU/Linux 12.9.0 _Bookworm_ - Official amd64 DVD Binary-1 with firmware 20250111-10:55] bookworm InRelease
    Err:2 cdrom://[Debian GNU/Linux 12.9.0 _Bookworm_ - Official amd64 DVD Binary-1 with firmware 20250111-10:55] bookworm Release
      Please use apt-cdrom to make this CD-ROM recognized by APT. apt-get update cannot be used to add new CD-ROMs
    Reading package lists... Done
    E: The repository 'cdrom://[Debian GNU/Linux 12.9.0 _Bookworm_ - Official amd64 DVD Binary-1 with firmware 20250111-10:55] bookworm Release' does not have a Release file.
    N: Updating from such a repository can't be done securely, and is therefore disabled by default.
    N: See apt-secure(8) manpage for repository creation and user configuration details.
    [chsrc 运行] x 命令执行失败,退出状态: 25600
    chsrc: 关键错误,强制结束
    root@debian:~#

    期望是能直接通过脚本完成安装,而不是手动安装模式,谢谢!

  3. ccmywish commented on Mar 23, 2025

    @ccmywish
    Contributor

    疑似安装过程需要使用到curl工具

    没注意到这个依赖项。是这样的。如果你有兴趣,可以参与贡献,帮助修改安装脚本

    https://github.com/RubyMetric/chsrc/blob/main/tool/installer.sh#L242


    Please use apt-cdrom to make this CD-ROM recognized by APT. apt-get update cannot be used to add new CD-ROMs

    我们在 Debian 的换源recipe中好像没有处理过这种情况。你可否复制粘贴现在的 /etc/apt/sources.list 让我们看下?

    另外你可以试试 https://github.com/SuperManito/LinuxMirrors 这个项目帮助解决燃眉之急

  4. kekylin commented on Mar 23, 2025

    @kekylin
    Author

    抱歉哈,目前能力无法做出贡献。我不太懂编程,只是有这个业余爱好。
    在玩NAS过程中偶然发现这个项目,想搭个换源便车,不是刚需,大佬方便就整上。
    手动换源是熟悉的,只是发现这个项目在具备基础条件下,换源更加方便快速。

    /etc/apt/sources.list文件内容如下:

    root@debian:~# cat /etc/apt/sources.list
    deb cdrom:[Debian GNU/Linux 12.9.0 _Bookworm_ - Official amd64 DVD Binary-1 with firmware 20250111-10:55]/ bookworm contrib main non-free-firmware
    root@debian:~#
    
  5. happy-game commented on Mar 24, 2025

    @happy-game
    Collaborator

    没注意到这个依赖项。是这样的。如果你有兴趣,可以参与贡献,帮助修改安装脚本

    可以判断系统中存在 curl 和 wget 来决定使用哪个。

    这个需求感觉不是很急迫,要不新建一个 good first issue 给想参与贡献的用户。

  6. self-assigned this
    on Mar 25, 2025
  7. added this to the v0.2.1 milestone on Mar 25, 2025
  8. added theissue type on Mar 25, 2025
  9. ccmywish commented on Mar 25, 2025

    @ccmywish
    Contributor

    @happy-game 没事,这个是小问题,刚好我要手动合并现有的那个修改installer.sh的PR。现在已经修改好了

  10. ccmywish commented on Apr 13, 2025

    @ccmywish
    Contributor

    @kekylin

    已修复。现在的方式是:chsrc 检查你的源配置文件,如果是像你所装系统这样的,用 cdrom 的,将会删除这个配置文件,重新给你生成一个新的源配置文件。

    可试用最新版 v0.2.1。

  11. kekylin commented on Apr 13, 2025

    @kekylin
    Author

    @kekylin

    已修复。现在的方式是:chsrc 检查你的源配置文件,如果是像你所装系统这样的,用 cdrom 的,将会删除这个配置文件,重新给你生成一个新的源配置文件。

    可试用最新版 v0.2.1。

    非常感谢!通过Debian系统测试,已达到预期需求。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions