forked from ScoopInstaller/Scoop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
01fa31e
commit 7382e17
Showing
17 changed files
with
228 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,53 @@ | ||
$bucketsdir = "$scoopdir\buckets" | ||
|
||
function bucketdir($name) { | ||
if(!$name) { return relpath "..\bucket" } # main bucket | ||
if(!$name) { return relpath "..\bucket" } # main bucket | ||
|
||
"$bucketsdir\$name" | ||
"$bucketsdir\$name" | ||
} | ||
|
||
function known_bucket_repo($name) { | ||
$dir = versiondir 'scoop' 'current' | ||
$json = "$dir\buckets.json" | ||
$buckets = gc $json -raw | convertfrom-json -ea stop | ||
$buckets.$name | ||
$dir = versiondir 'scoop' 'current' | ||
$json = "$dir\buckets.json" | ||
$buckets = gc $json -raw | convertfrom-json -ea stop | ||
$buckets.$name | ||
} | ||
|
||
function apps_in_bucket($dir) { | ||
gci $dir | ? { $_.name.endswith('.json') } | % { $_ -replace '.json$', '' } | ||
gci $dir | ? { $_.name.endswith('.json') } | % { $_ -replace '.json$', '' } | ||
} | ||
|
||
function buckets { | ||
$buckets = @() | ||
if(test-path $bucketsdir) { | ||
gci $bucketsdir | % { $buckets += $_.name } | ||
} | ||
$buckets | ||
$buckets = @() | ||
if(test-path $bucketsdir) { | ||
gci $bucketsdir | % { $buckets += $_.name } | ||
} | ||
$buckets | ||
} | ||
|
||
function find_manifest($app) { | ||
@($null) + @(buckets) | % { # null for main bucket | ||
$manifest = manifest $app $_ | ||
if($manifest) { return $manifest, $_ } | ||
} | ||
@($null) + @(buckets) | % { # null for main bucket | ||
$manifest = manifest $app $_ | ||
if($manifest) { return $manifest, $_ } | ||
} | ||
} | ||
|
||
<# | ||
# convert an object to a hashtable | ||
function hashtable($obj) { | ||
$h = @{ } | ||
$obj.psobject.properties | % { | ||
$h[$_.name] = hashtable_val($_.value); | ||
} | ||
return $h | ||
$h = @{ } | ||
$obj.psobject.properties | % { | ||
$h[$_.name] = hashtable_val($_.value); | ||
} | ||
return $h | ||
} | ||
function hashtable_val($obj) { | ||
if($obj -is [object[]]) { | ||
return $_.value | % { hashtable_val($_) } | ||
} | ||
if($obj.gettype().name -eq 'pscustomobject') { # -is is unreliable | ||
return hashtable($obj) | ||
} | ||
return $obj # assume primitive | ||
if($obj -is [object[]]) { | ||
return $_.value | % { hashtable_val($_) } | ||
} | ||
if($obj.gettype().name -eq 'pscustomobject') { # -is is unreliable | ||
return hashtable($obj) | ||
} | ||
return $obj # assume primitive | ||
} | ||
#> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
function 7zip_installed { | ||
try { gcm 7z -ea stop } catch { return $false } | ||
$true | ||
try { gcm 7z -ea stop } catch { return $false } | ||
$true | ||
} | ||
|
||
function requires_7zip($fname) { | ||
$fname -match '(\.gz)|(\.tar)|(\.lzma)|(\.7z)$' | ||
$fname -match '(\.gz)|(\.tar)|(\.lzma)|(\.7z)$' | ||
} | ||
|
||
function extract_7zip($path, $to, $recurse) { | ||
if(!$recurse) { write-host "extracting..." -nonewline } | ||
$output = 7z x "$path" -o"$to" -y | ||
if($lastexitcode -ne 0) { abort "exit code was $lastexitcode" } | ||
if(!$recurse) { write-host "extracting..." -nonewline } | ||
$output = 7z x "$path" -o"$to" -y | ||
if($lastexitcode -ne 0) { abort "exit code was $lastexitcode" } | ||
|
||
# recursively extract files, e.g. for .tar.gz | ||
$output | sls '^Extracting\s+(.*)$' | % { | ||
$fname = $_.matches[0].groups[1].value | ||
if(requires_7zip $fname) { extract_7zip "$to\$fname" $to $true } | ||
} | ||
# recursively extract files, e.g. for .tar.gz | ||
$output | sls '^Extracting\s+(.*)$' | % { | ||
$fname = $_.matches[0].groups[1].value | ||
if(requires_7zip $fname) { extract_7zip "$to\$fname" $to $true } | ||
} | ||
|
||
rm $path | ||
if(!$recurse) { write-host "done" } | ||
rm $path | ||
if(!$recurse) { write-host "done" } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.