This repository was archived by the owner on Mar 23, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.sh
More file actions
56 lines (50 loc) · 2.83 KB
/
update.sh
File metadata and controls
56 lines (50 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash
# Exit on error. Append "|| true" if you expect an error.
set -o errexit
# Exit on error inside any functions or subshells.
set -o errtrace
# Do not allow use of undefined vars. Use ${VAR:-} to use an undefined VAR
set -o nounset
# Catch the error in case mysqldump fails (but gzip succeeds) in `mysqldump | gzip`
set -o pipefail
# Turn on traces, useful while debugging but commented out by default.
: "${DEBUG:="false"}"
if [[ "$DEBUG" == "true" ]]; then
set -o xtrace
fi
SCRIPT_DIR="$(dirname "$(readlink -f "${0}")")"
cd "$SCRIPT_DIR" || exit 1
: "${TEST:="false"}"
if [[ "$TEST" == "true" ]]; then
git clone --depth 1 https://mirror.ghproxy.com/https://github.com/Homebrew/homebrew-core
git clone --depth 1 https://mirror.ghproxy.com/https://github.com/Homebrew/homebrew-cask
fi
rm -rf ./Formula ./Casks ./Aliases
mkdir -p ./Formula ./Casks ./Aliases
cp -r ./homebrew-core/Formula/* ./Formula/
cp -r ./homebrew-core/Aliases/* ./Aliases/
cp -r ./homebrew-cask/Casks/* ./Casks/
rm -rf ./homebrew-core ./homebrew-cask
for file in ./Formula/**/*.rb ./Casks/**/*.rb; do
perl -pi -e 's#(github\.com/.+/releases/download)#mirror.ghproxy.com/https://\1#g;
s#(raw\.githubusercontent\.com)#mirror.ghproxy.com/https://\1#g;
s#(github\.com/.+/raw)#mirror.ghproxy.com/https://\1#g;
s#(github\.com/.+/archive)#mirror.ghproxy.com/https://\1#g;
s#(downloads\.sourceforge\.net/.*)"#\1?use_mirror=jaist"#g;
s#download\.kde\.org#mirrors.ustc.edu.cn/kde#g;
s#(www\.)?7-zip\.org/a#mirror.nju.edu.cn/7-zip#g;
s#mirror\.ctan\.org#mirrors.aliyun.com/CTAN#g;
s#nodejs\.org/dist#npmmirror.com/mirrors/node#g;
s#www\.python\.org/ftp/python#npmmirror.com/mirrors/python#g;
s#go\.dev/dl#mirrors.aliyun.com/golang#g;
s#download\.videolan\.org#mirrors.aliyun.com/videolan#g;
s#media\.inkscape\.org/dl/resources/file#mirror.nju.edu.cn/inkscape#g;
s#dbeaver\.io/files#mirror.ghproxy.com/https://github.com/dbeaver/dbeaver/releases/download#g;
s#cdn-fastly\.obsproject\.com/downloads/obs-studio-(.+)-macos#mirrors.nju.edu.cn/github-release/obsproject/obs-studio/OBS%20Studio%20\1/obs-studio-\1-macos#g;
s#download\.gimp\.org/gimp#mirrors.aliyun.com/gimp/gimp#g;
s#download\.blender\.org#mirrors.aliyun.com/blender#g;
s#download\.virtualbox\.org/virtualbox#mirror.nju.edu.cn/virtualbox/#g;
s#www\.wireshark\.org/download#mirror.nju.edu.cn/wireshark/#g;
s#archive\.torproject\.org/tor-package-archive#tor.ybti.net/dist#g;
s#download\.calibre-ebook\.com/#mirror.ghproxy.com/https://github.com/kovidgoyal/calibre/releases/download/v#g' "$file"
done