From 6ab4e548346c1c8176b783d848f429892bc4f0e9 Mon Sep 17 00:00:00 2001 From: David Peng Date: Fri, 1 Nov 2024 10:43:41 +0800 Subject: [PATCH] Github Proxy use ghp.ci --- .vscode/settings.json | 2 +- README.md | 6 +++--- install.ps1 | 26 ++++++++++++++------------ update.ps1 | 18 +++++++++--------- 4 files changed, 27 insertions(+), 25 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 1c118b6ee2..2a9d7d6ec5 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,7 @@ { "json.schemas": [ { - "url": "https://mirror.ghproxy.com/https://raw.githubusercontent.com/ScoopInstaller/Scoop/master/schema.json", + "url": "https://ghp.ci/https://raw.githubusercontent.com/ScoopInstaller/Scoop/master/schema.json", "fileMatch": [ "bucket/**/*.json" ] diff --git a/README.md b/README.md index 352c773d2f..23e10679c2 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Scoop 是一个很优秀的软件包管理工具,官方的安装说明也简 ## 本应用库介绍 -本应用库为了解决上述问题,把各个环节的下载地址替换成了国内可加速访问的地址。本应用库使用的是 [GitHub Proxy](https://mirror.ghproxy.com/) 和 [GitHub Actions](https://github.com/features/actions) 。 +本应用库为了解决上述问题,把各个环节的下载地址替换成了国内可加速访问的地址。本应用库使用的是 [GitHub Proxy](https://ghp.ci/) 和 [GitHub Actions](https://github.com/features/actions) 。 特性有: @@ -53,7 +53,7 @@ Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser 此方法会把安装 Scoop 过程中的地址都换成中国可快速访问的地址,并设置好 Scoop,添加本仓库。打开 PowerShell,输入以下命令下载安装 Scoop: ```powershell -irm https://mirror.ghproxy.com/https://raw.githubusercontent.com/duzyn/scoop-cn/master/install.ps1 | iex +irm https://ghp.ci/https://raw.githubusercontent.com/duzyn/scoop-cn/master/install.ps1 | iex ``` 或使用 jsDelivr 的地址: @@ -71,7 +71,7 @@ irm https://cdn.jsdelivr.net/gh/duzyn/scoop-cn/install.ps1 | iex 1. 添加本仓库,运行命令 ```powershell - scoop bucket add scoop-cn https://mirror.ghproxy.com/https://github.com/duzyn/scoop-cn + scoop bucket add scoop-cn https://ghp.ci/https://github.com/duzyn/scoop-cn ``` 2. 把已经安装的 app 改为使用 scoop-cn 来更新。每个 app 安装后在 app 的 current 路径下有个 install.json,里面的 bucket 项的值改为 scoop-cn,这样就把已安装的 app 换到 scoop-cn 了。可以运行 scoop list 来检查替换成功。如果要批量修改,可以借助 grepWin 来写个正则表达式搜索替换这个值。 diff --git a/install.ps1 b/install.ps1 index 8b354f3045..2259b53de1 100644 --- a/install.ps1 +++ b/install.ps1 @@ -4,11 +4,13 @@ # 需先以管理员权限打开系统自带的 Powershell,设置脚本运行权限 # Set-Executionpolicy -ExecutionPolicy RemoteSigned -Scope Currentuser +$GITHUB_PROXY = https://ghp.ci + # 安装 Scoop -(Invoke-RestMethod https://mirror.ghproxy.com/https://raw.githubusercontent.com/scoopinstaller/install/master/install.ps1).Replace('"https://github.com', '"https://mirror.ghproxy.com/https://github.com') | Invoke-Expression +(Invoke-RestMethod $GITHUB_PROXY/https://raw.githubusercontent.com/scoopinstaller/install/master/install.ps1).Replace('"https://github.com', '"$GITHUB_PROXY/https://github.com') | Invoke-Expression # 将 Scoop 的仓库源替换为代理的 -scoop config scoop_repo https://mirror.ghproxy.com/https://github.com/ScoopInstaller/Scoop +scoop config scoop_repo $GITHUB_PROXY/https://github.com/ScoopInstaller/Scoop # 如果有设环境变量,就按环境变量来 $SCOOP_DIR = $ScoopDir, $env:SCOOP, "$env:USERPROFILE\scoop" | Where-Object { -not [String]::IsNullOrEmpty($_) } | Select-Object -First 1 @@ -18,14 +20,14 @@ New-Item -ItemType "directory" -Path "$SCOOP_DIR\buckets\scoop-cn\bucket" New-Item -ItemType "directory" -Path "$SCOOP_DIR\buckets\scoop-cn\scripts\7-zip" New-Item -ItemType "directory" -Path "$SCOOP_DIR\buckets\scoop-cn\scripts\git" -Invoke-RestMethod -Uri https://mirror.ghproxy.com/https://raw.githubusercontent.com/duzyn/scoop-cn/master/bucket/7zip.json -OutFile "$SCOOP_DIR\buckets\scoop-cn\bucket\7zip.json" -Invoke-RestMethod -Uri https://mirror.ghproxy.com/https://raw.githubusercontent.com/duzyn/scoop-cn/master/scripts/7-zip/install-context.reg -OutFile "$SCOOP_DIR\buckets\scoop-cn\scripts\7-zip\install-context.reg" -Invoke-RestMethod -Uri https://mirror.ghproxy.com/https://raw.githubusercontent.com/duzyn/scoop-cn/master/scripts/7-zip/uninstall-context.reg -OutFile "$SCOOP_DIR\buckets\scoop-cn\scripts\7-zip\uninstall-context.reg" -Invoke-RestMethod -Uri https://mirror.ghproxy.com/https://raw.githubusercontent.com/duzyn/scoop-cn/master/bucket/git.json -OutFile "$SCOOP_DIR\buckets\scoop-cn\bucket\git.json" -Invoke-RestMethod -Uri https://mirror.ghproxy.com/https://raw.githubusercontent.com/duzyn/scoop-cn/master/scripts/git/install-context.reg -OutFile "$SCOOP_DIR\buckets\scoop-cn\scripts\git\install-context.reg" -Invoke-RestMethod -Uri https://mirror.ghproxy.com/https://raw.githubusercontent.com/duzyn/scoop-cn/master/scripts/git/uninstall-context.reg -OutFile "$SCOOP_DIR\buckets\scoop-cn\scripts\git\uninstall-context.reg" -Invoke-RestMethod -Uri https://mirror.ghproxy.com/https://raw.githubusercontent.com/duzyn/scoop-cn/master/scripts/git/install-file-associations.reg -OutFile "$SCOOP_DIR\buckets\scoop-cn\scripts\git\install-file-associations.reg" -Invoke-RestMethod -Uri https://mirror.ghproxy.com/https://raw.githubusercontent.com/duzyn/scoop-cn/master/scripts/git/uninstall-file-associations.reg -OutFile "$SCOOP_DIR\buckets\scoop-cn\scripts\git\uninstall-file-associations.reg" +Invoke-RestMethod -Uri $GITHUB_PROXY/https://raw.githubusercontent.com/duzyn/scoop-cn/master/bucket/7zip.json -OutFile "$SCOOP_DIR\buckets\scoop-cn\bucket\7zip.json" +Invoke-RestMethod -Uri $GITHUB_PROXY/https://raw.githubusercontent.com/duzyn/scoop-cn/master/scripts/7-zip/install-context.reg -OutFile "$SCOOP_DIR\buckets\scoop-cn\scripts\7-zip\install-context.reg" +Invoke-RestMethod -Uri $GITHUB_PROXY/https://raw.githubusercontent.com/duzyn/scoop-cn/master/scripts/7-zip/uninstall-context.reg -OutFile "$SCOOP_DIR\buckets\scoop-cn\scripts\7-zip\uninstall-context.reg" +Invoke-RestMethod -Uri $GITHUB_PROXY/https://raw.githubusercontent.com/duzyn/scoop-cn/master/bucket/git.json -OutFile "$SCOOP_DIR\buckets\scoop-cn\bucket\git.json" +Invoke-RestMethod -Uri $GITHUB_PROXY/https://raw.githubusercontent.com/duzyn/scoop-cn/master/scripts/git/install-context.reg -OutFile "$SCOOP_DIR\buckets\scoop-cn\scripts\git\install-context.reg" +Invoke-RestMethod -Uri $GITHUB_PROXY/https://raw.githubusercontent.com/duzyn/scoop-cn/master/scripts/git/uninstall-context.reg -OutFile "$SCOOP_DIR\buckets\scoop-cn\scripts\git\uninstall-context.reg" +Invoke-RestMethod -Uri $GITHUB_PROXY/https://raw.githubusercontent.com/duzyn/scoop-cn/master/scripts/git/install-file-associations.reg -OutFile "$SCOOP_DIR\buckets\scoop-cn\scripts\git\install-file-associations.reg" +Invoke-RestMethod -Uri $GITHUB_PROXY/https://raw.githubusercontent.com/duzyn/scoop-cn/master/scripts/git/uninstall-file-associations.reg -OutFile "$SCOOP_DIR\buckets\scoop-cn\scripts\git\uninstall-file-associations.reg" # 安装时注意顺序是 7-Zip, Git scoop install scoop-cn/7zip @@ -34,12 +36,12 @@ scoop install scoop-cn/git # 将 Scoop 的 main 仓库源替换为代理的 if (Test-Path -Path "$SCOOP_DIR\buckets\main") { scoop bucket rm main } Write-Host "Adding main bucket..." -scoop bucket add main https://mirror.ghproxy.com/https://github.com/ScoopInstaller/Main +scoop bucket add main $GITHUB_PROXY/https://github.com/ScoopInstaller/Main # scoop-cn 库还不是 Git 仓库,删掉后,重新添加 Git 仓库 if (Test-Path -Path "$SCOOP_DIR\buckets\scoop-cn") { scoop bucket rm scoop-cn } Write-Host "Adding scoop-cn bucket..." -scoop bucket add scoop-cn https://mirror.ghproxy.com/https://github.com/duzyn/scoop-cn +scoop bucket add scoop-cn $GITHUB_PROXY/https://github.com/duzyn/scoop-cn # Set-Location "$SCOOP_DIR\buckets\scoop-cn" # git config pull.rebase true diff --git a/update.ps1 b/update.ps1 index 19008b5c37..cb67fc9321 100644 --- a/update.ps1 +++ b/update.ps1 @@ -40,14 +40,14 @@ Remove-Item -Path .\scoop-sysinternals -Recurse -Force Get-ChildItem -Recurse -Path .\bucket | ForEach-Object -Process { # GitHub Releases - (Get-Content $_.FullName) -replace '(github\.com/.+/releases/.*download)', 'mirror.ghproxy.com/https://$1' | Set-Content -Path $_.FullName + (Get-Content $_.FullName) -replace '(github\.com/.+/releases/.*download)', 'ghp.ci/https://$1' | Set-Content -Path $_.FullName # GitHub Archive - (Get-Content $_.FullName) -replace '(github\.com/.+/archive/)', 'mirror.ghproxy.com/https://$1' | Set-Content -Path $_.FullName + (Get-Content $_.FullName) -replace '(github\.com/.+/archive/)', 'ghp.ci/https://$1' | Set-Content -Path $_.FullName # GitHub Raw - (Get-Content $_.FullName) -replace '(raw\.githubusercontent\.com)', 'mirror.ghproxy.com/https://$1' | Set-Content -Path $_.FullName - (Get-Content $_.FullName) -replace '(github\.com/.+/raw/)', 'mirror.ghproxy.com/https://$1' | Set-Content -Path $_.FullName + (Get-Content $_.FullName) -replace '(raw\.githubusercontent\.com)', 'ghp.ci/https://$1' | Set-Content -Path $_.FullName + (Get-Content $_.FullName) -replace '(github\.com/.+/raw/)', 'ghp.ci/https://$1' | Set-Content -Path $_.FullName # SourceForge # Use jaist @@ -84,18 +84,18 @@ Get-ChildItem -Recurse -Path .\bucket | ForEach-Object -Process { (Get-Content $_.FullName) -replace 'media\.inkscape\.org/dl/resources/file', 'mirrors.nju.edu.cn/inkscape' | Set-Content -Path $_.FullName # DBeaver - (Get-Content $_.FullName) -replace 'dbeaver\.io/files', 'mirror.ghproxy.com/https://github.com/dbeaver/dbeaver/releases/download' | Set-Content -Path $_.FullName + (Get-Content $_.FullName) -replace 'dbeaver\.io/files', 'ghp.ci/https://github.com/dbeaver/dbeaver/releases/download' | Set-Content -Path $_.FullName # Or # (Get-Content $_.FullName) -replace 'dbeaver\.io/files', 'mirrors.nju.edu.cn/github-release/dbeaver/dbeaver' | Set-Content -Path $_.FullName # OBS Studio - (Get-Content $_.FullName) -replace 'cdn-fastly\.obsproject\.com/downloads/OBS-Studio-(.+)-Windows\.zip', 'mirror.ghproxy.com/https://github.com/obsproject/obs-studio/releases/download/$1/OBS-Studio-$1-Windows.zip' | Set-Content -Path $_.FullName + (Get-Content $_.FullName) -replace 'cdn-fastly\.obsproject\.com/downloads/OBS-Studio-(.+)-Windows\.zip', 'ghp.ci/https://github.com/obsproject/obs-studio/releases/download/$1/OBS-Studio-$1-Windows.zip' | Set-Content -Path $_.FullName # Or # (Get-Content $_.FullName) -replace 'cdn-fastly\.obsproject\.com/downloads/OBS-Studio-(.+)-Windows\.zip', 'mirrors.nju.edu.cn/github-release/obsproject/obs-studio/OBS%20Studio%20$1/OBS-Studio-$1-Windows.zip' | Set-Content -Path $_.FullName # (Get-Content $_.FullName) -replace 'cdn-fastly\.obsproject\.com/downloads/OBS-Studio-(.+)-Windows\.zip', 'mirrors.tuna.tsinghua.edu.cn/github-release/obsproject/obs-studio/OBS%20Studio%20$1/OBS-Studio-$1-Windows.zip' | Set-Content -Path $_.FullName # OBS Studio 2.7 - (Get-Content $_.FullName) -replace 'cdn-fastly\.obsproject\.com/downloads/OBS-Studio-(.+)-Full', 'mirror.ghproxy.com/https://github.com/obsproject/obs-studio/releases/download/$1/OBS-Studio-$1-Full' | Set-Content -Path $_.FullName + (Get-Content $_.FullName) -replace 'cdn-fastly\.obsproject\.com/downloads/OBS-Studio-(.+)-Full', 'ghp.ci/https://github.com/obsproject/obs-studio/releases/download/$1/OBS-Studio-$1-Full' | Set-Content -Path $_.FullName # GIMP (Get-Content $_.FullName) -replace 'download\.gimp\.org/mirror/pub', 'mirrors.aliyun.com/gimp' | Set-Content -Path $_.FullName @@ -113,7 +113,7 @@ Get-ChildItem -Recurse -Path .\bucket | ForEach-Object -Process { (Get-Content $_.FullName) -replace 'lun-eu\.icons8\.com/s/', 'lcdn.icons8.com/' | Set-Content -Path $_.FullName # Strawberry - (Get-Content $_.FullName) -replace 'files\.jkvinge\.net/packages/strawberry/StrawberrySetup-(.+)-mingw-x', 'mirror.ghproxy.com/https://github.com/strawberrymusicplayer/strawberry/releases/download/$1/StrawberrySetup-$1-mingw-x' | Set-Content -Path $_.FullName + (Get-Content $_.FullName) -replace 'files\.jkvinge\.net/packages/strawberry/StrawberrySetup-(.+)-mingw-x', 'ghp.ci/https://github.com/strawberrymusicplayer/strawberry/releases/download/$1/StrawberrySetup-$1-mingw-x' | Set-Content -Path $_.FullName # SumatraPDF (Get-Content $_.FullName) -replace 'files\.sumatrapdfreader\.org/file/kjk-files/software/sumatrapdf/rel', 'www.sumatrapdfreader.org/dl/rel' | Set-Content -Path $_.FullName @@ -138,7 +138,7 @@ Get-ChildItem -Recurse -Path .\bucket | ForEach-Object -Process { (Get-Content $_.FullName) -replace 'archive\.torproject\.org/tor-package-archive', 'tor.ybti.net/dist' | Set-Content -Path $_.FullName # FastCopy - (Get-Content $_.FullName) -replace 'fastcopy\.jp/archive', 'mirror.ghproxy.com/https://raw.githubusercontent.com/FastCopyLab/FastCopyDist2/main' | Set-Content -Path $_.FullName + (Get-Content $_.FullName) -replace 'fastcopy\.jp/archive', 'ghp.ci/https://raw.githubusercontent.com/FastCopyLab/FastCopyDist2/main' | Set-Content -Path $_.FullName # Kodi (Get-Content $_.FullName) -replace 'mirrors\.kodi\.tv', 'mirrors.tuna.tsinghua.edu.cn/kodi' | Set-Content -Path $_.FullName