forked from duzyn/scoop-cn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.ps1
136 lines (101 loc) · 6.48 KB
/
update.ps1
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# 删除已有的文件
Remove-Item -Path .\bucket -Recurse -Force
Remove-Item -Path .\scripts -Recurse -Force
# 将克隆的最新的文件拷贝到待处理的文件夹
New-Item -ItemType Directory -Path .\bucket
New-Item -ItemType Directory -Path .\scripts
# Scoop 官方的十个库
Copy-Item -Path .\Main\bucket\* -Destination .\bucket -Recurse -Force
Copy-Item -Path .\Extras\bucket\* -Destination .\bucket -Recurse -Force
Copy-Item -Path .\Versions\bucket\* -Destination .\bucket -Recurse -Force
Copy-Item -Path .\Nonportable\bucket\* -Destination .\bucket -Recurse -Force
Copy-Item -Path .\Java\bucket\* -Destination .\bucket -Recurse -Force
Copy-Item -Path .\PHP\bucket\* -Destination .\bucket -Recurse -Force
Copy-Item -Path .\scoop-nirsoft\bucket\* -Destination .\bucket -Recurse -Force
Copy-Item -Path .\scoop-nerd-fonts\bucket\* -Destination .\bucket -Recurse -Force
Copy-Item -Path .\scoop-games\bucket\* -Destination .\bucket -Recurse -Force
Copy-Item -Path .\scoop-sysinternals\bucket\* -Destination .\bucket -Recurse -Force
Copy-Item -Path .\Main\scripts\* -Destination .\scripts -Recurse -Force
Copy-Item -Path .\Extras\scripts\* -Destination .\scripts -Recurse -Force
Copy-Item -Path .\Versions\scripts\* -Destination .\scripts -Recurse -Force
Copy-Item -Path .\Nonportable\scripts\* -Destination .\scripts -Recurse -Force
Copy-Item -Path .\scoop-games\scripts\* -Destination .\scripts -Recurse -Force
# 复制完后,删掉克隆的文件夹
Remove-Item -Path .\Main -Recurse -Force
Remove-Item -Path .\Extras -Recurse -Force
Remove-Item -Path .\Versions -Recurse -Force
Remove-Item -Path .\Nonportable -Recurse -Force
Remove-Item -Path .\Java -Recurse -Force
Remove-Item -Path .\PHP -Recurse -Force
Remove-Item -Path .\scoop-nirsoft -Recurse -Force
Remove-Item -Path .\scoop-nerd-fonts -Recurse -Force
Remove-Item -Path .\scoop-games -Recurse -Force
Remove-Item -Path .\scoop-sysinternals -Recurse -Force
# 设置 GitHub 代理地址
# $githubProxy = "https://github.whrstudio.top"
. .\ghproxy.ps1
Get-ChildItem -Recurse -Path .\bucket | ForEach-Object -Process {
$content = Get-Content $_.FullName
# 使用变量进行替换
$content = $content -replace '(https?://github\.com/.+/releases/.*download)', "$githubProxy/`$1"
$content = $content -replace '(https?://github\.com/.+/archive/)', "$githubProxy/`$1"
$content = $content -replace '(https?://gist.github\.com/.+/)', "$githubProxy/`$1"
$content = $content -replace '(https?://raw\.githubusercontent\.com)', "$githubProxy/`$1"
$content = $content -replace '(https?://github\.com/.+/raw/)', "$githubProxy/`$1"
# DBeaver,not debaver-ea
$content = $content -replace 'https?://dbeaver\.io/files/([\d\.]+)/', "$githubProxy/https://github.com/dbeaver/dbeaver/releases/download/`$1/"
# FastCopy
$content = $content -replace 'https?://fastcopy\.jp/archive', "$githubProxy/https://raw.githubusercontent.com/FastCopyLab/FastCopyDist2/main"
# OBS Studio
$content = $content -replace 'https?://cdn-fastly\.obsproject\.com/downloads/OBS-Studio-(.+)-Windows\.zip', "$githubProxy/https://github.com/obsproject/obs-studio/releases/download/`$1/OBS-Studio-`$1-Windows.zip"
# OBS Studio 2.7
$content = $content -replace 'https?://cdn-fastly\.obsproject\.com/downloads/OBS-Studio-(.+)-Full', "$githubProxy/https://github.com/obsproject/obs-studio/releases/download/`$1/OBS-Studio-`$1-Full"
# Strawberry
$content = $content -replace 'https?://files\.jkvinge\.net/packages/strawberry/StrawberrySetup-(.+)-mingw-x', "$githubProxy/https://github.com/strawberrymusicplayer/strawberry/releases/download/`$1/StrawberrySetup-`$1-mingw-x"
# KDE Apps
# $content = $content -replace 'download\.kde\.org', 'mirrors.nju.edu.cn/kde'
# 7-Zip
$content = $content -replace 'www\.7-zip\.org/a', 'mirrors.nju.edu.cn/7-zip'
# Blender
$content = $content -replace 'download\.blender\.org', 'mirrors.tuna.tsinghua.edu.cn/blender'
# Cygwin
$content = $content -replace '//.*/cygwin/', '//mirrors.tuna.tsinghua.edu.cn/cygwin/'
# GIMP
$content = $content -replace 'download\.gimp\.org/mirror/pub', 'mirrors.nju.edu.cn/gimp'
# Go
$content = $content -replace 'dl\.google\.com/go', 'mirrors.nju.edu.cn/golang'
# Gradle
$content = $content -replace 'services\.gradle\.org/distributions', 'mirror.nju.edu.cn/gradle'
# Inkscape
$content = $content -replace 'media\.inkscape\.org/dl/resources/file', 'mirrors.nju.edu.cn/inkscape'
# Kodi
$content = $content -replace 'mirrors\.kodi\.tv', 'mirrors.tuna.tsinghua.edu.cn/kodi'
# LaTeX, MiKTeX
$content = $content -replace '(miktex\.org/download/ctan)|(mirrors.+/CTAN)', 'mirrors.tuna.tsinghua.edu.cn/CTAN'
# Node
$content = $content -replace 'nodejs\.org/dist', 'mirrors.tuna.tsinghua.edu.cn/nodejs-release'
# Python
$content = $content -replace 'www\.python\.org/ftp/python', 'mirrors.nju.edu.cn/python'
# Vim
$content = $content -replace 'ftp\.nluug\.nl/pub/vim/pc', 'mirrors.nju.edu.cn/vim/pc'
# VirtualBox
$content = $content -replace 'download\.virtualbox\.org/virtualbox', 'mirrors.tuna.tsinghua.edu.cn/virtualbox'
# VLC
$content = $content -replace 'download\.videolan\.org/pub', 'mirrors.tuna.tsinghua.edu.cn/videolan-ftp'
# Wireshark
$content = $content -replace 'www\.wireshark\.org/download', 'mirrors.tuna.tsinghua.edu.cn/wireshark'
# Lunacy
$content = $content -replace 'lun-eu\.icons8\.com/s/', 'lcdn.icons8.com/'
# Tor Browser, Tor
# mirror list: https://raw.githubusercontent.com/torproject/torbrowser-launcher/refs/heads/main/share/torbrowser-launcher/mirrors.txt
$content = $content -replace 'archive\.torproject\.org/tor-package-archive', 'tor.calyxinstitute.org/dist'
# Typora
$content = $content -replace 'download\.typora\.io', 'download2.typoraio.cn'
# Scripts
$content = $content -replace '(bucketsdir\\\\).+(\\\\scripts)', '$1scoop-cn$2'
# 将 suggest 路径改为 scoop-cn
$content = $content -replace '\"main/|\"extras/|\"versions/|\"nirsoft/|\"sysinternals/|\"php/|\"nerd-fonts/|\"nonportable/|\"java/|\"games/', '"scoop-cn/'
# 将 depends 路径改为 scoop-cn
$content = $content -replace '\"depends\":\s*\"(scoop\-cn/)?', '"depends": "scoop-cn/'
Set-Content -Path $_.FullName -Value $content
}