@@ -50,9 +50,10 @@ function install_app($app, $architecture, $global, $suggested, $use_cache = $tru
5050 $persist_dir = persistdir $app $global
5151
5252 $fname = Invoke-ScoopDownload $app $version $manifest $bucket $architecture $dir $use_cache $check_hash
53+ Invoke-Extraction - Path $dir - Name $fname - Manifest $manifest - ProcessorArchitecture $architecture
5354 Invoke-HookScript - HookType ' pre_install' - Manifest $manifest - Arch $architecture
5455
55- run_installer $fname $manifest $architecture $dir $global
56+ run_installer @ ( $fname )[ -1 ] $manifest $architecture $dir $global
5657 ensure_install_dir_not_in_path $dir $global
5758 $dir = link_current $dir
5859 create_shims $manifest $dir $global $architecture
@@ -539,21 +540,12 @@ function Invoke-ScoopDownload ($app, $version, $manifest, $bucket, $architecture
539540 # we only want to show this warning once
540541 if (! $use_cache ) { warn ' Cache is being ignored.' }
541542
542- # can be multiple urls: if there are, then installer should go last,
543- # so that $fname is set properly
543+ # can be multiple urls: if there are, then installer should go last to make 'installer.args' section work
544544 $urls = @ (script:url $manifest $architecture )
545545
546546 # can be multiple cookies: they will be used for all HTTP requests.
547547 $cookies = $manifest.cookie
548548
549- $fname = $null
550-
551- # extract_dir and extract_to in manifest are like queues: for each url that
552- # needs to be extracted, will get the next dir from the queue
553- $extract_dirs = @ (extract_dir $manifest $architecture )
554- $extract_tos = @ (extract_to $manifest $architecture )
555- $extracted = 0
556-
557549 # download first
558550 if (Test-Aria2Enabled ) {
559551 Invoke-CachedAria2Download $app $version $manifest $architecture $dir $cookies $use_cache $check_hash
@@ -587,44 +579,7 @@ function Invoke-ScoopDownload ($app, $version, $manifest, $bucket, $architecture
587579 }
588580 }
589581
590- foreach ($url in $urls ) {
591- $fname = url_filename $url
592-
593- $extract_dir = $extract_dirs [$extracted ]
594- $extract_to = $extract_tos [$extracted ]
595-
596- # work out extraction method, if applicable
597- $extract_fn = $null
598- if ($manifest.innosetup ) {
599- $extract_fn = ' Expand-InnoArchive'
600- } elseif ($fname -match ' \.zip$' ) {
601- # Use 7zip when available (more fast)
602- if (((get_config USE_EXTERNAL_7ZIP) -and (Test-CommandAvailable 7z)) -or (Test-HelperInstalled - Helper 7zip)) {
603- $extract_fn = ' Expand-7zipArchive'
604- } else {
605- $extract_fn = ' Expand-ZipArchive'
606- }
607- } elseif ($fname -match ' \.msi$' ) {
608- $extract_fn = ' Expand-MsiArchive'
609- } elseif (Test-ZstdRequirement - Uri $fname ) {
610- # Zstd first
611- $extract_fn = ' Expand-ZstdArchive'
612- } elseif (Test-7zipRequirement - Uri $fname ) {
613- # 7zip
614- $extract_fn = ' Expand-7zipArchive'
615- }
616-
617- if ($extract_fn ) {
618- Write-Host ' Extracting ' - NoNewline
619- Write-Host $fname -f Cyan - NoNewline
620- Write-Host ' ... ' - NoNewline
621- & $extract_fn - Path " $dir \$fname " - DestinationPath " $dir \$extract_to " - ExtractDir $extract_dir - Removal
622- Write-Host ' done.' -f Green
623- $extracted ++
624- }
625- }
626-
627- $fname # returns the last downloaded file
582+ return $urls.ForEach ({ url_filename $_ })
628583}
629584
630585function cookie_header ($cookies ) {
@@ -710,7 +665,7 @@ function run_installer($fname, $manifest, $architecture, $dir, $global) {
710665 return
711666 }
712667 if ($installer ) {
713- $prog = " $dir \$ ( coalesce $installer.file " $fname " ) "
668+ $prog = " $dir \$ ( coalesce $installer.file $fname ) "
714669 if (! (is_in_dir $dir $prog )) {
715670 abort " Error in manifest: Installer $prog is outside the app directory."
716671 }
0 commit comments