Skip to content

Commit

Permalink
fix dependency matching, correcting ordering for concurrent installat…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
rivy committed May 30, 2016
1 parent 2321afd commit 3263c0a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
16 changes: 16 additions & 0 deletions lib/core.ps1
Expand Up @@ -689,3 +689,19 @@ function app($name, $bucket, $variant) {
if ($null -ne $variant) { $result = "$result@$variant" }
$result
}

function matching_apps($apps, $app) {
# trace "matching_apps(): () = [$apps], $app"
$matches = @()
$app_name = app_name( $app )
# trace "matching_apps(): appname('$app') = $app_name"
if ($null -ne $apps) { foreach ($a in $apps) {
# trace "matching_apps(): a = $a"
$n = app_name($a)
# trace "matching_apps(): app_name($a) = $n"
if ( $n -ieq $app_name ) { $matches += $a }
# trace "matching_apps(): [$a] => [$matches]"
}}
# trace "matching_apps():DONE: [$matches]"
$matches
}
11 changes: 9 additions & 2 deletions lib/depends.ps1
@@ -1,3 +1,5 @@
. "$($MyInvocation.MyCommand.Path | Split-Path | Split-Path)\lib\core.ps1"

# resolve dependencies for the supplied apps, and sort into the correct order
function install_order($apps, $arch) {
# trace "install_order(): () = [$apps], $arch"
Expand All @@ -7,9 +9,14 @@ function install_order($apps, $arch) {
$deps = @( deps $app $arch )
# trace "install_order(): deps = [$deps]"
if ($null -ne $deps) { foreach ($dep in $deps) {
if($res -notcontains $dep) { $res += $dep }
$app_variant = @( matching_apps $apps $dep )[0];
# trace "install_order(): app_variant = $app_variant"
if ($null -ne $app_variant) { $dep = $app_variant }
# trace "install_order(): dep = $dep"
if (-not ( matching_apps $res $dep )) { $res += @( install_order $dep $arch ) }
}}
if($res -notcontains $app) { $res += $app }
if (-not ( matching_apps $res $app )) { $res += $app }
# trace "install_order(): [app=$app] res = [$res]"
}}
$res
# trace "install_order():DONE: res = [$res]"
Expand Down
6 changes: 3 additions & 3 deletions libexec/scoop-install.ps1
Expand Up @@ -56,12 +56,12 @@ if($global -and !(is_admin)) {
ensure_none_failed $apps $global
warn_installed $apps $global

# trace "1:apps = $apps"
trace "1:apps = $apps"
$apps = install_order $apps $architecture # adds dependencies
# trace "2:apps = $apps"
trace "2:apps = $apps"
ensure_none_failed $apps $global
$apps = prune_installed $apps $global # removes dependencies that are already installed
# trace "3:apps = $apps"
trace "3:apps = $apps"

$apps | foreach-object { install_app $_ $architecture $global }

Expand Down

0 comments on commit 3263c0a

Please sign in to comment.