Skip to content

Commit e76e50a

Browse files
author
Taois
committed
feat:完美
1 parent 3ab817b commit e76e50a

File tree

6 files changed

+163
-33
lines changed

6 files changed

+163
-33
lines changed

mediaProxy/build_goproxy.bat

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
@echo off
2+
setlocal
3+
4+
echo [1/2] Building Android 32-bit (ARM)...
5+
set CGO_ENABLED=0
6+
set GOOS=linux
7+
set GOARCH=arm
8+
set GOARM=7
9+
go build -trimpath -ldflags="-w -s" -o goProxy/goProxy-arm proxy.go
10+
if %errorlevel% neq 0 (
11+
echo Failed to build goProxy-arm
12+
exit /b %errorlevel%
13+
)
14+
echo Success: goProxy/goProxy-arm
15+
upx --best --lzma goProxy/goProxy-arm >nul 2>&1
16+
if %errorlevel% equ 0 (
17+
echo Compressed goProxy-arm with UPX
18+
) else (
19+
echo UPX compression skipped for goProxy-arm
20+
)
21+
22+
echo [2/2] Building Android 64-bit (ARM64)...
23+
set CGO_ENABLED=0
24+
set GOOS=linux
25+
set GOARCH=arm64
26+
go build -trimpath -ldflags="-w -s" -o goProxy/goProxy-arm64 proxy.go
27+
if %errorlevel% neq 0 (
28+
echo Failed to build goProxy-arm64
29+
exit /b %errorlevel%
30+
)
31+
echo Success: goProxy/goProxy-arm64
32+
upx --best --lzma goProxy/goProxy-arm64 >nul 2>&1
33+
if %errorlevel% equ 0 (
34+
echo Compressed goProxy-arm64 with UPX
35+
) else (
36+
echo UPX compression skipped for goProxy-arm64
37+
)
38+
39+
echo All builds completed successfully!
40+
endlocal

mediaProxy/build_goproxy.ps1

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Write-Host "[1/2] Building Android 32-bit (ARM)..."
2+
$env:CGO_ENABLED="0"
3+
$env:GOOS="linux"
4+
$env:GOARCH="arm"
5+
$env:GOARM="7"
6+
go build -trimpath -ldflags="-w -s" -o goProxy/goProxy-arm proxy.go
7+
if ($LASTEXITCODE -ne 0) {
8+
Write-Error "Failed to build goProxy-arm"
9+
exit $LASTEXITCODE
10+
}
11+
Write-Host "Success: goProxy/goProxy-arm" -ForegroundColor Green
12+
try {
13+
upx --best --lzma goProxy/goProxy-arm 2>$null
14+
Write-Host "Compressed goProxy-arm with UPX" -ForegroundColor Green
15+
} catch {
16+
Write-Host "UPX compression skipped for goProxy-arm" -ForegroundColor Yellow
17+
}
18+
19+
Write-Host "[2/2] Building Android 64-bit (ARM64)..."
20+
$env:CGO_ENABLED="0"
21+
$env:GOOS="linux"
22+
$env:GOARCH="arm64"
23+
go build -trimpath -ldflags="-w -s" -o goProxy/goProxy-arm64 proxy.go
24+
if ($LASTEXITCODE -ne 0) {
25+
Write-Error "Failed to build goProxy-arm64"
26+
exit $LASTEXITCODE
27+
}
28+
Write-Host "Success: goProxy/goProxy-arm64" -ForegroundColor Green
29+
try {
30+
upx --best --lzma goProxy/goProxy-arm64 2>$null
31+
Write-Host "Compressed goProxy-arm64 with UPX" -ForegroundColor Green
32+
} catch {
33+
Write-Host "UPX compression skipped for goProxy-arm64" -ForegroundColor Yellow
34+
}
35+
36+
Write-Host "All builds completed successfully!" -ForegroundColor Green

mediaProxy/calc_md5.ps1

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition
2+
$filePath = Join-Path -Path $scriptDir -ChildPath "custom_spider.jar"
3+
4+
if (Test-Path $filePath) {
5+
$md5 = (Get-FileHash -Path $filePath -Algorithm MD5).Hash.ToLower()
6+
Write-Host "文件: custom_spider.jar" -ForegroundColor Cyan
7+
Write-Host "MD5 : $md5" -ForegroundColor Green
8+
} else {
9+
Write-Host "未找到文件: $filePath" -ForegroundColor Red
10+
}
11+
12+
# 如果你在资源管理器中双击运行,这行代码可以让窗口保持打开状态方便查看结果
13+
Read-Host "按 Enter 键退出..."
4.13 MB
Binary file not shown.

mediaProxy/test_data.py

Lines changed: 0 additions & 33 deletions
This file was deleted.

mediaProxy/update_jar.ps1

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
param(
2+
[string]$JarPath = "custom_spider.jar",
3+
[string]$SourceDir = "goProxy"
4+
)
5+
6+
# Ensure 7z is available
7+
$7zCmd = Get-Command "7z" -ErrorAction SilentlyContinue
8+
if (-not $7zCmd) {
9+
Write-Error "Please ensure 7-Zip is installed and added to your system PATH."
10+
exit 1
11+
}
12+
13+
# Check if target file exists
14+
if (-not (Test-Path $JarPath)) {
15+
Write-Error "Target file not found: $JarPath"
16+
exit 1
17+
}
18+
19+
$ArmPath = Join-Path $SourceDir "goProxy-arm"
20+
$Arm64Path = Join-Path $SourceDir "goProxy-arm64"
21+
22+
if (-not (Test-Path $ArmPath) -or -not (Test-Path $Arm64Path)) {
23+
Write-Error "Compiled goProxy files not found. Please run build_goproxy.ps1 first."
24+
exit 1
25+
}
26+
27+
Write-Host "Updating assets directory in $JarPath..." -ForegroundColor Cyan
28+
29+
$TempAssetsDir = "temp_assets_for_jar\assets"
30+
New-Item -ItemType Directory -Force -Path $TempAssetsDir | Out-Null
31+
Copy-Item -Path $ArmPath -Destination $TempAssetsDir -Force
32+
Copy-Item -Path $Arm64Path -Destination $TempAssetsDir -Force
33+
34+
try {
35+
# 为了避免在 jar 中创建 temp_assets_for_jar 目录,我们需要进入到该目录后再执行打包
36+
# 使用 Push-Location 和 Pop-Location 来切换工作目录
37+
Push-Location "temp_assets_for_jar"
38+
39+
# 构造相对路径的 jar 文件路径,因为我们改变了工作目录
40+
$AbsoluteJarPath = Resolve-Path "..\$JarPath"
41+
$updateCmd = "7z u `"$AbsoluteJarPath`" `"assets\*`""
42+
43+
Invoke-Expression $updateCmd | Out-Null
44+
45+
if ($LASTEXITCODE -ne 0) {
46+
throw "7z command failed with exit code: $LASTEXITCODE"
47+
}
48+
49+
Pop-Location
50+
Write-Host "Successfully updated files to assets directory in $JarPath." -ForegroundColor Green
51+
} catch {
52+
if ((Get-Location).Path -like "*temp_assets_for_jar*") {
53+
Pop-Location
54+
}
55+
Write-Error "Failed to update jar file: $_"
56+
Remove-Item -Path "temp_assets_for_jar" -Recurse -Force -ErrorAction SilentlyContinue
57+
exit 1
58+
} finally {
59+
Remove-Item -Path "temp_assets_for_jar" -Recurse -Force -ErrorAction SilentlyContinue
60+
}
61+
62+
Write-Host "Calculating MD5 for $JarPath..." -ForegroundColor Cyan
63+
try {
64+
$md5Hash = (Get-FileHash -Path $JarPath -Algorithm MD5).Hash.ToLower()
65+
$Md5FilePath = "$JarPath.md5"
66+
$md5Hash | Out-File -FilePath $Md5FilePath -Encoding ascii
67+
Write-Host "MD5 Calculation complete: $md5Hash" -ForegroundColor Green
68+
Write-Host "MD5 written to file: $Md5FilePath" -ForegroundColor Green
69+
} catch {
70+
Write-Error "Failed to calculate MD5: $_"
71+
exit 1
72+
}
73+
74+
Write-Host "All operations completed successfully!" -ForegroundColor Green

0 commit comments

Comments
 (0)