Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Expand-DarkArchive and some other dependency features #3450

Merged
merged 5 commits into from
May 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions lib/core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
26 changes: 26 additions & 0 deletions lib/decompress.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 36 additions & 1 deletion lib/depends.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 = @()

Expand All @@ -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
}
15 changes: 15 additions & 0 deletions libexec/scoop-checkup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down