mirror of
https://github.com/ScoopInstaller/Scoop.git
synced 2025-12-13 11:36:04 +00:00
* makes changes to almost all main repo files to be in accordance with .editorconfig * some files in "test\fixtures\..." were left alone to avoid breaking tests * NOTE: whitespace changes *only* (`git diff -b` shows no changes)
25 lines
741 B
PowerShell
25 lines
741 B
PowerShell
function 7zip_installed { cmd_available '7z' }
|
|
|
|
function requires_7zip($manifest, $architecture) {
|
|
foreach($dlurl in @(url $manifest $architecture)) {
|
|
if(file_requires_7zip $dlurl) { return $true }
|
|
}
|
|
}
|
|
|
|
function file_requires_7zip($fname) {
|
|
$fname -match '\.((gz)|(tar)|(tgz)|(lzma)|(bz)|(7z)|(rar)|(iso)|(xz))$'
|
|
}
|
|
|
|
function extract_7zip($path, $to, $recurse) {
|
|
$output = 7z x "$path" -o"$to" -y
|
|
if($lastexitcode -ne 0) { abort "exit code was $lastexitcode" }
|
|
|
|
# check for tar
|
|
$tar = (split-path $path -leaf) -replace '\.[^\.]*$', ''
|
|
if($tar -match '\.tar$') {
|
|
if(test-path "$to\$tar") { extract_7zip "$to\$tar" $to $true }
|
|
}
|
|
|
|
if($recurse) { rm $path } # clean up intermediate files
|
|
}
|