diff --git a/lib/core.ps1 b/lib/core.ps1 index 7fd01aa3b0..3d5c6813e4 100644 --- a/lib/core.ps1 +++ b/lib/core.ps1 @@ -248,13 +248,26 @@ function Get-HelperPath { $Helper ) + $HelperPath = $null switch ($Helper) { - '7zip' { Get-AppFilePath '7zip' '7z.exe' } - 'Lessmsi' { Get-AppFilePath 'lessmsi' 'lessmsi.exe' } - 'Innounp' { Get-AppFilePath 'innounp' 'innounp.exe' } - 'Dark' { Get-AppFilePath 'dark' 'dark.exe' } - 'Aria2' { Get-AppFilePath 'aria2' 'aria2c.exe' } + '7zip' { + $HelperPath = Get-AppFilePath '7zip' '7z.exe' + if([String]::IsNullOrEmpty($HelperPath)) { + $HelperPath = Get-AppFilePath '7zip-zstd' '7z.exe' + } + } + 'Lessmsi' { $HelperPath = Get-AppFilePath 'lessmsi' 'lessmsi.exe' } + 'Innounp' { $HelperPath = Get-AppFilePath 'innounp' 'innounp.exe' } + 'Dark' { + $HelperPath = Get-AppFilePath 'dark' 'dark.exe' + if([String]::IsNullOrEmpty($HelperPath)) { + $HelperPath = Get-AppFilePath 'wixtoolset' 'dark.exe' + } + } + 'Aria2' { $HelperPath = Get-AppFilePath 'aria2' 'aria2c.exe' } } + + return $HelperPath } function Test-HelperInstalled { diff --git a/lib/decompress.ps1 b/lib/decompress.ps1 index 9198fee2bb..84600303a7 100644 --- a/lib/decompress.ps1 +++ b/lib/decompress.ps1 @@ -202,6 +202,32 @@ function Expand-ZipArchive { } } +function Expand-DarkArchive { + [CmdletBinding()] + param( + [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] + [String] + $Path, + [Parameter(Position = 1)] + [String] + $DestinationPath = (Split-Path $Path), + [Switch] + $Removal + ) + $LogLocation = "$(Split-Path $Path)\dark.log" + & (Get-HelperPath -Helper Dark) -nologo -x "$DestinationPath" "$Path" | Out-File $LogLocation + if ($LASTEXITCODE -ne 0) { + abort "Failed to extract files from $Path.`nLog file:`n $(friendly_path $LogLocation)" + } + if (Test-Path $LogLocation) { + Remove-Item $LogLocation -Force + } + if ($Removal) { + # Remove original archive file + Remove-Item $Path -Force + } +} + function extract_7zip($path, $to, $removal) { Show-DeprecatedWarning $MyInvocation 'Expand-7zipArchive' Expand-7zipArchive -Path $path -DestinationPath $to -Removal:$removal @args diff --git a/lib/depends.ps1 b/lib/depends.ps1 index 8567436f89..1ce3af7675 100644 --- a/lib/depends.ps1 +++ b/lib/depends.ps1 @@ -49,6 +49,31 @@ function runtime_deps($manifest) { if ($manifest.depends) { return $manifest.depends } } +function script_deps($script) { + $deps = @() + if($script -is [Array]) { + $script = $script -join "`n" + } + if([String]::IsNullOrEmpty($script)) { + return $deps + } + + if($script -like '*Expand-7zipArchive *' -or $script -like '*extract_7zip *') { + $deps += '7zip' + } + if($script -like '*Expand-MsiArchive *' -or $script -like '*extract_msi *') { + $deps += 'lessmsi' + } + if($script -like '*Expand-InnoArchive *' -or $script -like '*unpack_inno *') { + $deps += 'innounp' + } + if($script -like '*Expand-DarkArchive *') { + $deps += 'dark' + } + + return $deps +} + function install_deps($manifest, $arch) { $deps = @() @@ -61,6 +86,16 @@ function install_deps($manifest, $arch) { if (!(Test-HelperInstalled -Helper Innounp) -and $manifest.innosetup) { $deps += 'innounp' } + if (!(Test-HelperInstalled -Helper Dark)) { + $deps += 'dark' + } - return $deps + $pre_install = arch_specific 'pre_install' $manifest $arch + $installer = arch_specific 'installer' $manifest $arch + $post_install = arch_specific 'post_install' $manifest $arch + $deps += script_deps $pre_install + $deps += script_deps $installer.script + $deps += script_deps $post_install + + return $deps | Select-Object -Unique } diff --git a/libexec/scoop-checkup.ps1 b/libexec/scoop-checkup.ps1 index 877552d806..723df01f0c 100644 --- a/libexec/scoop-checkup.ps1 +++ b/libexec/scoop-checkup.ps1 @@ -13,6 +13,21 @@ $issues += !(check_windows_defender $true) $issues += !(check_main_bucket) $issues += !(check_long_paths) +if (!(Test-HelperInstalled -Helper 7zip)) { + error "'7-Zip' is not installed! It's required for unpacking most programs. Please Run 'scoop install 7zip' or 'scoop install 7zip-zstd'." + $issues++ +} + +if (!(Test-HelperInstalled -Helper Innounp)) { + error "'Inno Setup Unpacker' is not installed! It's required for unpacking InnoSetup files. Please run 'scoop install innounp'." + $issues++ +} + +if (!(Test-HelperInstalled -Helper Dark)) { + error "'dark' is not installed! It's require for unpacking installers created with the WiX Toolset. Please run 'scoop install dark' or 'scoop install wixtoolset'." + $issues++ +} + $globaldir = New-Object System.IO.DriveInfo($globaldir) if($globaldir.DriveFormat -ne 'NTFS') { error "Scoop requires an NTFS volume to work! Please point `$env:SCOOP_GLOBAL or 'globalPath' variable in '~/.config/scoop/config.json' to another Drive."