Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kekylin opened this issue Mar 23, 2025 · 6 comments
Open

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

kekylin opened this issue Mar 23, 2025 · 6 comments
Assignees
Labels
Linux Linux相关 os_target os target Release Release
Milestone

Comments

@kekylin
Copy link

kekylin commented Mar 23, 2025

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

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

@ccmywish
Copy link
Contributor

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

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

分别采用两种解决方法:

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

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

@kekylin
Copy link
Author

kekylin commented Mar 23, 2025

安装使用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:~#

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

@ccmywish
Copy link
Contributor

ccmywish commented Mar 23, 2025

疑似安装过程需要使用到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 这个项目帮助解决燃眉之急

@kekylin
Copy link
Author

kekylin commented Mar 23, 2025

抱歉哈,目前能力无法做出贡献。我不太懂编程,只是有这个业余爱好。
在玩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:~#

@happy-game
Copy link
Collaborator

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

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

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

ccmywish added a commit that referenced this issue Mar 25, 2025
ccmywish added a commit that referenced this issue Mar 25, 2025
ccmywish added a commit that referenced this issue Mar 25, 2025
@ccmywish ccmywish self-assigned this Mar 25, 2025
@ccmywish ccmywish added this to the v0.2.1 milestone Mar 25, 2025
@ccmywish ccmywish added os_target os target Release Release Linux Linux相关 labels Mar 25, 2025
@ccmywish
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Linux Linux相关 os_target os target Release Release
Projects
None yet
Development

No branches or pull requests

3 participants