54 lines
1.9 KiB
Batchfile
54 lines
1.9 KiB
Batchfile
@echo off
|
|||
|
|
:: This script extracts winCodeSign archive and handles symlink errors
|
||
|
|
:: It's called automatically by the build process
|
||
|
|
|
||
|
|
setlocal ENABLEDELAYEDEXPANSION
|
||
|
|
|
||
|
|
:: Wait for the archive to be downloaded (check every second for up to 30 seconds)
|
||
|
|
set MAX_WAIT=30
|
||
|
|
set WAIT_COUNT=0
|
||
|
|
set ARCHIVE_FOUND=0
|
||
|
|
|
||
|
|
echo Waiting for winCodeSign archive to download...
|
||
|
|
|
||
|
|
:WAIT_LOOP
|
||
|
|
timeout /T 1 >nul 2>&1
|
||
|
|
set /a WAIT_COUNT+=1
|
||
|
|
|
||
|
|
:: Find the most recent .7z file in the winCodeSign cache
|
||
|
|
for /f "delims=" %%f in ('dir /b /o-d "%LOCALAPPDATA%\electron-builder\Cache\winCodeSign\*.7z" 2^>nul') do (
|
||
|
|
set ARCHIVE_PATH=%LOCALAPPDATA%\electron-builder\Cache\winCodeSign\%%f
|
||
|
|
set ARCHIVE_FOUND=1
|
||
|
|
goto :EXTRACT
|
||
|
|
)
|
||
|
|
|
||
|
|
if !WAIT_COUNT! LSS !MAX_WAIT! goto :WAIT_LOOP
|
||
|
|
|
||
|
|
if !ARCHIVE_FOUND! EQU 0 (
|
||
|
|
echo Archive not found, skipping extraction fix...
|
||
|
|
exit /b 0
|
||
|
|
)
|
||
|
|
|
||
|
|
:EXTRACT
|
||
|
|
echo Found archive: !ARCHIVE_PATH!
|
||
|
|
|
||
|
|
:: Extract using PowerShell which handles symlinks better
|
||
|
|
powershell -ExecutionPolicy Bypass -Command ^
|
||
|
|
"$archive = '!ARCHIVE_PATH!'; ^
|
||
|
|
$output = Split-Path $archive -Parent; ^
|
||
|
|
$output = Join-Path $output ([System.IO.Path]::GetFileNameWithoutExtension($archive)); ^
|
||
|
|
if (-not (Test-Path $output)) { New-Item -ItemType Directory -Path $output -Force | Out-Null }; ^
|
||
|
|
Add-Type -AssemblyName System.IO.Compression.FileSystem; ^
|
||
|
|
try { [System.IO.Compression.ZipFile]::ExtractToDirectory($archive, $output) } catch { }; ^
|
||
|
|
$symlinks = @('darwin\10.12\lib\libcrypto.dylib', 'darwin\10.12\lib\libssl.dylib'); ^
|
||
|
|
foreach ($sl in $symlinks) { ^
|
||
|
|
$path = Join-Path $output $sl; ^
|
||
|
|
$dir = Split-Path $path -Parent; ^
|
||
|
|
if (-not (Test-Path $dir)) { New-Item -ItemType Directory -Path $dir -Force | Out-Null }; ^
|
||
|
|
if (-not (Test-Path $path)) { New-Item -ItemType File -Path $path -Force | Out-Null } ^
|
||
|
|
}; ^
|
||
|
|
Write-Host 'Extraction completed with symlink workaround'"
|
||
|
|
|
||
|
|
exit /b 0
|
||
|
|
|