11# ==============================================================================
22# zapret2 Desktop GUI - Upstream Binaries Setup Script
33# ==============================================================================
4- # This script ensures that winws2.exe, WinDivert.dll, and WinDivert64.sys
5- # are properly present in the ./bin directory for local development and runtime.
6- # ==============================================================================
7-
84$ErrorActionPreference = " Stop"
95
106$BinDir = Join-Path $PSScriptRoot " ..\bin"
117if (-not (Test-Path $BinDir )) {
128 New-Item - ItemType Directory - Path $BinDir - Force | Out-Null
139}
1410
15- Write-Host " ==> Checking runtime binaries in $BinDir ..." - ForegroundColor Cyan
16-
17- $RequiredFiles = @ (" winws2.exe" , " WinDivert.dll" , " WinDivert64.sys" )
11+ $RequiredFiles = @ (" winws2.exe" , " winws.exe" , " WinDivert.dll" , " WinDivert64.sys" , " cygwin1.dll" )
1812$Missing = @ ()
1913
2014foreach ($File in $RequiredFiles ) {
@@ -25,22 +19,22 @@ foreach ($File in $RequiredFiles) {
2519}
2620
2721if ($Missing.Count -eq 0 ) {
28- Write-Host " [OK] All required binaries are present!" - ForegroundColor Green
22+ Write-Host " [OK] All required binaries are present in bin !" - ForegroundColor Green
2923 exit 0
3024}
3125
3226Write-Host " [!] Missing binaries: $ ( $Missing -join ' , ' ) " - ForegroundColor Yellow
33- Write-Host " ==> Looking for local releases or upstream archives ..." - ForegroundColor Cyan
27+ Write-Host " ==> Searching local developer paths ..." - ForegroundColor Cyan
3428
3529$SearchLocations = @ (
3630 (Join-Path $PSScriptRoot " ..\zapret2 releases\binaries\windows-x86_64" ),
3731 (Join-Path $PSScriptRoot " ..\zapret2-releases\binaries\windows-x86_64" ),
38- (Join-Path $PSScriptRoot " ..\zapret-discord-youtube-main\bin" )
32+ (Join-Path $PSScriptRoot " ..\zapret-discord-youtube-main\bin" ),
33+ (Join-Path $PSScriptRoot " .." )
3934)
4035
4136foreach ($Loc in $SearchLocations ) {
4237 if (Test-Path $Loc ) {
43- Write-Host " --> Found candidate directory: $Loc " - ForegroundColor Gray
4438 foreach ($File in $Missing ) {
4539 $CandidateFile = Join-Path $Loc $File
4640 if (Test-Path $CandidateFile ) {
@@ -51,4 +45,34 @@ foreach ($Loc in $SearchLocations) {
5145 }
5246}
5347
54- Write-Host " ==> Setup completed successfully!" - ForegroundColor Green
48+ # If still missing in CI environment, download upstream bundle
49+ $StillMissing = @ ()
50+ foreach ($File in $RequiredFiles ) {
51+ if (-not (Test-Path (Join-Path $BinDir $File ))) {
52+ $StillMissing += $File
53+ }
54+ }
55+
56+ if ($StillMissing.Count -gt 0 ) {
57+ Write-Host " ==> Downloading upstream runtime bundle from GitHub..." - ForegroundColor Cyan
58+ $ZipPath = Join-Path $env: TEMP " zapret-upstream.zip"
59+ $ExtractDir = Join-Path $env: TEMP " zapret-upstream-extracted"
60+
61+ $Url = " https://github.com/Flowseal/zapret-discord-youtube/releases/download/1.10.3/zapret-discord-youtube-1.10.3.zip"
62+ Invoke-WebRequest - Uri $Url - OutFile $ZipPath
63+ Expand-Archive - Path $ZipPath - DestinationPath $ExtractDir - Force
64+
65+ $FoundBin = Get-ChildItem - Path $ExtractDir - Recurse - Directory - Filter " bin" | Select-Object - First 1
66+ if ($FoundBin ) {
67+ Get-ChildItem - Path $FoundBin.FullName | ForEach-Object {
68+ Copy-Item - Path $_.FullName - Destination $BinDir - Force
69+ }
70+ }
71+
72+ # If winws2.exe was missing, ensure winws.exe is linked or copied
73+ if (-not (Test-Path (Join-Path $BinDir " winws2.exe" )) -and (Test-Path (Join-Path $BinDir " winws.exe" ))) {
74+ Copy-Item (Join-Path $BinDir " winws.exe" ) (Join-Path $BinDir " winws2.exe" ) - Force
75+ }
76+ }
77+
78+ Write-Host " ==> Runtime binaries verified successfully!" - ForegroundColor Green
0 commit comments