-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Expand file tree
/
Copy pathbuild_linux_arm64.ps1
More file actions
122 lines (105 loc) · 3.28 KB
/
build_linux_arm64.ps1
File metadata and controls
122 lines (105 loc) · 3.28 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
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
# Requires PowerShell 3.0+
# Script Directory
$scriptDir = $PSScriptRoot
$staticDir = Join-Path $scriptDir 'clash_core\linux-arm64\static'
$mainDir = Join-Path $scriptDir 'main'
$logoFile = Join-Path $scriptDir 'logo.ico'
$outputDir = Join-Path $scriptDir 'output'
$outWinDir = Join-Path $outputDir 'cfw-linux-arm64'
Write-Host 'Checking environment...'
# Checking static
if (-not (Test-Path $staticDir)) {
Write-Error 'Failed! "static" folder not found!'
Read-Host 'Press Enter to exit'
exit 1
}
# Checking main
if (-not (Test-Path $mainDir)) {
Write-Error 'Failed! "main" folder not found!'
Read-Host 'Press Enter to exit'
exit 1
}
# Checking logo.ico
if (-not (Test-Path $logoFile)) {
Write-Error 'Failed! "logo.ico" not found!'
Read-Host 'Press Enter to exit'
exit 1
}
# Checking npm
& npm --version > $null 2>&1
if ($LASTEXITCODE -eq 0) {
Write-Host 'npm is detected...'
} else {
Write-Error 'Failed! No npm command!'
Write-Host 'Install Node.js might fix this.'
Read-Host 'Press Enter to exit'
exit 1
}
# Checking electron-packager
& npx electron-packager --version > $null 2>&1
if ($LASTEXITCODE -eq 0) {
Write-Host 'electron-packager is detected...'
} else {
Write-Warning 'Failed! No electron-packager command!'
Write-Host 'But npm is detected!'
Read-Host 'Press Enter to install electron-packager or Ctrl+C to exit'
npm install -g electron-packager
}
# Checking asar
& npx asar --version > $null 2>&1
if ($LASTEXITCODE -eq 0) {
Write-Host 'asar is detected...'
} else {
Write-Warning 'Failed! No asar command!'
Write-Host 'But npm is detected!'
Read-Host 'Press Enter to install asar or Ctrl+C to exit'
npm install -g asar
}
Write-Host 'Success!'
# Clear old output
if (Test-Path $outWinDir) {
Write-Host 'Detected old output!'
Read-Host 'Press Enter to delete and rebuild'
Remove-Item -Recurse -Force $outWinDir
Write-Host 'Success!'
}
# Make sure output dir is existed
if (-not (Test-Path $outputDir)) {
New-Item -ItemType Directory -Path $outputDir | Out-Null
}
# Start packaging
Write-Host 'Starting electron-packager...'
& npx electron-packager `
"`"$mainDir`"" "cfw" `
--platform=linux --arch=arm64 --electron-version=34.0.0 `
--icon="`"$logoFile`"" --out="`"$outputDir`"" --prune=true --asar
if ($LASTEXITCODE -ne 0) {
Write-Error 'electron-packager Failed!'
exit 1
}
Write-Host 'Waiting app building...'
Write-Host 'Note: If wait too long, it may mean that the execution has failed. Press Ctrl+C to terminate.'
# Wait for the program
$exePath = Join-Path $outWinDir 'cfw'
while (-not (Test-Path $exePath)) {
Start-Sleep -Seconds 5
}
Write-Host 'Success!'
# Adding files
Write-Host 'Adding proxy core files...'
Start-Sleep -Seconds 1
$destStatic = Join-Path $outWinDir 'resources\static'
# Make sure resources dir is existed
$resourcesDir = Split-Path $destStatic -Parent
if (-not (Test-Path $resourcesDir)) {
New-Item -ItemType Directory -Path $resourcesDir | Out-Null
}
# Make sure static dir is existed
if (-not (Test-Path $destStatic)) {
New-Item -ItemType Directory -Path $destStatic | Out-Null
}
# Then copy it
Copy-Item -Path "$staticDir\*" -Destination $destStatic -Recurse -Force
Write-Host 'Success!'
Write-Host 'Finish!'
Read-Host 'Press Enter to exit'