The all-platform universal source replacement tool and framework chsrc
aims to support as many operating system environments as possible such as Linux, Windows (MSYS2, Cygwin), macOS, BSD, etc., and as many CPUs as possible such as Loongson, Feiteng, and RISC-V .
We use C99 to accomplish the above goals. We do not use interpreted languages such as Python or JS because a simple source-changing tool should not force users to have a huge interpreter and dozens or hundreds of MB of other files.
This software is free software , and the SDPX software license is GPL-3.0-or-later and MIT
Note
chsrc
can replace source 60+ targets. Everyone only contributes and maintains the parts they are familiar with, and in return gets help from experts in all other fields . People who are unfamiliar with GitHub and Gitee collaboration are welcome to take this opportunity to learn and contribute. Any programming beginner is welcome to contribute. The author @ccmywish can provide certain contribution guidance.
Tip
chsrc
is not only a command line tool, but also a source replacement framework. It even enables you to write new source replacement methods (recipes) without knowing the C language.
Instantly add a source change method for a new software! Write A Recipe Even If You Don't Know C
Challenge list:
[HELP] Provide the default source address, such as the default source URL of Ubuntu, Debian, Go, etc., to help us perform chsrc reset
[Challenge] Writing unified installation shell and PowerShell scripts: Completed by @Efterklang and @xuan
[Challenge] CentOS (Stream) Recipe
https://github.com/RubyMetric/chsrc/wiki
https://github.com/RubyMetric/chsrc/discussions
Important
If installed through the following manual method, it will be downloaded to the current directory and can be run directly through ./chsrc
Installable via scoop
, thanks to @Gn3po4g and @niheaven
$ scoop install chsrc
Download the latest version of the binary file with one click through a PowerShell
script
$ iwr -useb "https://chsrc.run/windows" | iex
Or manually download the binary file. This is the latest version, which is often newer than what scoop
provides. It is suitable for timely use after fixing bugs, adding new features, and when scoop
is not installed.
# x64curl -L https://gitee.com/RubyMetric/chsrc/releases/download/pre/chsrc-x64-windows.exe -o chsrc.exe # x86curl -L https://gitee.com/RubyMetric/chsrc/ releases/download/pre/chsrc-x86-windows.exe -o chsrc.exe
Supports AUR
, installable via yay
, thanks to @Jerry-Terrasse
# AUR$ yay -S chsrc-bin # Binary from GitHub Release$ yay -S chsrc-git # Build from the latest main branch (stable)$ yay -S chsrc # Build from GitHub Release
The latest version can be installed with one click through shell
script, thanks to @Efterklang and @xuan (to be tested by users, please provide feedback in issue#98 on GitHub)
# Non-root users are installed to ~/.local/bin$ by default curl https:/chsrc.run/posix | bash # Root users are installed to /usr/local/bin$ by default curl https:/chsrc.run/posix | sudo bash # Use -d to specify the directory to install $ curl https:/chsrc.run/posix | bash -s -- -d ./# Use -l en to output English $ curl https:/chsrc.run/posix | bash -s -- -l en
Binary files can be manually downloaded and installed
# x64curl -L https://gitee.com/RubyMetric/chsrc/releases/download/pre/chsrc-x64-linux -o chsrc; chmod +x ./chsrc# aarch64curl -L https://gitee.com/RubyMetric /chsrc/releases/download/pre/chsrc-aarch64-linux -o chsrc; chmod +x ./chsrc# riscv64curl -L https://gitee.com/RubyMetric/chsrc/releases/download/pre/chsrc-riscv64- linux -o chsrc; chmod +x ./chsrc# armv7curl -L https://gitee.com/RubyMetric/chsrc/releases/download/pre/chsrc-armv7-linux -o chsrc; chmod +x ./chsrc
Can be installed via homebrew
, thanks to @Aaron-212 and @chenrui333
$ brew install chsrc
The latest version can be installed through shell
script, thanks to @Efterklang and @xuan (to be tested by macOS users, please provide feedback in issue#98 on GitHub)
# Non-root users are installed to ~/.local/bin$ by default curl https:/chsrc.run/posix | bash # Root users are installed to /usr/local/bin$ by default curl https:/chsrc.run/posix | sudo bash # Use -d to specify the directory to install $ curl https:/chsrc.run/posix | bash -s -- -d ./# Use -l en to output English $ curl https:/chsrc.run/posix | bash -s -- -l en
Or manually download the binary file. This is the latest version, which is often newer than that provided by homebrew
. It is suitable for timely use after fixing bugs and adding new features.
# arm64/aarch64curl -L https://gitee.com/RubyMetric/chsrc/releases/download/pre/chsrc-aarch64-macos -o chsrc; chmod +x ./chsrc# x64curl -L https://gitee.com /RubyMetric/chsrc/releases/download/pre/chsrc-x64-macos -o chsrc; chmod +x ./chsrc
$ git clone https://gitee.com/RubyMetric/chsrc.git; cd chsrc $ clang -Iinclude src/chsrc-main.c -o chsrc
Use: chsrc[options] [target] [mirror]help # Print this help, or h, -h, --helpissue # View related issuelist (or ls, or l) # List available mirror sources, and available Replacement source target list mirror/target # List available mirror sources, or replaceable source target list os/lang/ware # List the operating systems/programming languages/software of replaceable sources measure # Measure the speed of all sources of the target cesu list # Check the available sources and supported functions of the target get # Check the current source usage of the target set # Change the source and select the fastest source after automatic speed measurement set first # Change the source, use the source with the highest speed measured by the maintenance team set # Change the source, specify to use a mirror station (view through the list command) set https://url # Change the source, user-defined Source URLreset #Reset, using the source options used by upstream by default: -dry # Dry Run, simulates the source change process, the command only prints and does not run -local # Only change sources for a certain project rather than globally (only some software such as bundler and pdm support) -ipv6 # Use IPv6 speed measurement -en(glish) # Use English output -no-color # No color output
Automatically measure speed, find the fastest, change source $ chsrc set ruby If you don’t want to automatically measure the speed, you can use the fastest mirror station tested by the maintenance team $ chsrc set ruby first First list the available mirror sites, and then select one, such as using RubyChina as the mirror site $ chsrc ls ruby $ chsrc set ruby rubychina If you have your own mirror address, use a custom URL $ chsrc set ruby https://gems.ruby-china.com/ For targets that support *project-level* resourcing, you can avoid global (*system-level* or *user-level*) resourcing $ chsrc set -local bundler $ chsrc set -local pdm
chsrc set ruby|rb|gem|bundler|rubygems chsrc set python | py | pypi # Change the three package managers pip, poetry and pdm at the same time, or you can change the sources independently chsrc set pip chsrc set poetry chsrc set pdm chsrc set node | nodejs # Change the three package managers npm, yarn and pnpm at the same time, or you can change the sources independently chsrc set npm chsrc set yarn chsrc set pnpm chsrc set nvm chsrc set bun chsrc set perl | cpan chsrc set php | composer chsrc set lua | luarocks chsrc set rust | cargo | crate chsrc set rustup chsrc set go chsrc set java | maven | mvn | gradle chsrc set clojure | clojars chsrc set dart | pub chsrc set flutter chsrc set haskell | hackage | cabal | stack chsrc set ocaml | opam# will also change the source of bioconductor chsrc set r | cran chsrc set julia
sudo chsrc set ubuntu sudo chsrc set linuxmint | mint sudo chsrc set debian sudo chsrc set fedora sudo chsrc set suse | opensuse sudo chsrc set kali sudo chsrc set arch sudo chsrc set archlinuxcn sudo chsrc set manjaro sudo chsrc set gentoo sudo chsrc set rocky | rockylinux sudo chsrc set alma | almalinux sudo chsrc set alpine sudo chsrc set void | voidlinux sudo chsrc set solus sudo chsrc set ros | ros2 sudo chsrc set trisquel sudo chsrc set lite | linuxlite sudo chsrc set raspi | raspberrypi sudo chsrc set armbian sudo chsrc set openwrt sudo chsrc set openeuler sudo chsrc set openanolis | anolis sudo chsrc set openkylin sudo chsrc set deepin chsrc set msys2 | msys# BSDsudo chsrc set freebsd sudo chsrc set openbsd sudo chsrc set netbsd
chsrc set winget chsrc set brew | homebrew chsrc set cocoapods | cocoa | pod chsrc set dockerhub | docker chsrc set flathub | flatpak chsrc set nix chsrc setguix chsrc set emacs | elpa chsrc set tex | ctan | latex | texlive | miktex chsrc set conda | anaconda
Please install gcc
or clang
, make
and curl
# Use the dev branch to develop git clone https://gitee.com/RubyMetric/chsrc.git -b dev make # By default, use cc to compile make CC=clang # Use clang to compile make CC=gcc # Use gcc to compile make test # Test command make test-xy # Test xy.hmake clean
The chsrc
main program adopts GPL-3.0-or-later
license to ensure the permanent freedom of the software
xy.h
uses MIT
license to ensure that the library can be reused in as many situations as possible
Thanks to various mirror sites for providing high-quality free mirror services
source.h contains general mirror site information
Dedicated mirror stations defined within each recipe
Special thanks to the following organizations or projects:
MirrorZ Education Network Mirror Station
Tsinghua University Tuna
Shanghai Jiao Tong University Software Source Mirror Service
University of Science and Technology of China Linux Users Association
Thanks Mirror project by @eryajf
Did you save time and effort by using chsrc
or whatever?