@@ -216,6 +216,16 @@ function Complete-ConfigChange {
216216 }
217217 }
218218 }
219+
220+ if ($Name -eq ' use_sqlite_cache' -and $Value -eq $true ) {
221+ if ((Get-DefaultArchitecture ) -eq ' arm64' ) {
222+ abort ' SQLite cache is not supported on ARM64 platform.'
223+ }
224+ . " $PSScriptRoot \..\lib\database.ps1"
225+ . " $PSScriptRoot \..\lib\manifest.ps1"
226+ info ' Initializing SQLite cache in progress... This may take a while, please wait.'
227+ Set-ScoopDB
228+ }
219229}
220230
221231function setup_proxy () {
@@ -314,10 +324,6 @@ function Invoke-GitLog {
314324# helper functions
315325function coalesce ($a , $b ) { if ($a ) { return $a } $b }
316326
317- function format ($str , $hash ) {
318- $hash.keys | ForEach-Object { set-variable $_ $hash [$_ ] }
319- $executionContext.invokeCommand.expandString ($str )
320- }
321327function is_admin {
322328 $admin = [security.principal.windowsbuiltinrole ]::administrator
323329 $id = [security.principal.windowsidentity ]::getcurrent()
@@ -399,7 +405,22 @@ function currentdir($app, $global) {
399405function persistdir ($app , $global ) { " $ ( basedir $global ) \persist\$app " }
400406function usermanifestsdir { " $ ( basedir) \workspace" }
401407function usermanifest ($app ) { " $ ( usermanifestsdir) \$app .json" }
402- function cache_path ($app , $version , $url ) { " $cachedir \$app #$version #$ ( $url -replace ' [^\w\.\-]+' , ' _' ) " }
408+ function cache_path ($app , $version , $url ) {
409+ $underscoredUrl = $url -replace ' [^\w\.\-]+' , ' _'
410+ $filePath = " $cachedir \$app #$version #$underscoredUrl "
411+
412+ # NOTE: Scoop cache files migration. Remove this 6 months after the feature ships.
413+ if (Test-Path $filePath ) {
414+ return $filePath
415+ }
416+
417+ $urlStream = [System.IO.MemoryStream ]::new([System.Text.Encoding ]::UTF8.GetBytes($url ))
418+ $sha = (Get-FileHash - Algorithm SHA256 - InputStream $urlStream ).Hash.ToLower().Substring(0 , 7 )
419+ $extension = [System.IO.Path ]::GetExtension($url )
420+ $filePath = $filePath -replace " $underscoredUrl " , " $sha$extension "
421+
422+ return $filePath
423+ }
403424
404425# apps
405426function sanitary_path ($path ) { return [regex ]::replace($path , " [/\\?:*<>|]" , " " ) }
@@ -477,7 +498,7 @@ function Get-HelperPath {
477498 [OutputType ([String ])]
478499 param (
479500 [Parameter (Mandatory = $true , Position = 0 , ValueFromPipeline = $true )]
480- [ValidateSet (' Git' , ' 7zip' , ' Lessmsi' , ' Innounp' , ' Dark' , ' Aria2' , ' Zstd ' )]
501+ [ValidateSet (' Git' , ' 7zip' , ' Lessmsi' , ' Innounp' , ' Dark' , ' Aria2' )]
481502 [String ]
482503 $Helper
483504 )
@@ -491,20 +512,24 @@ function Get-HelperPath {
491512 if ($internalgit ) {
492513 $HelperPath = $internalgit
493514 } else {
494- $HelperPath = (Get-Command git - ErrorAction Ignore).Source
515+ $HelperPath = (Get-Command git - CommandType Application - TotalCount 1 - ErrorAction Ignore).Source
495516 }
496517 }
497518 ' 7zip' { $HelperPath = Get-AppFilePath ' 7zip' ' 7z.exe' }
498519 ' Lessmsi' { $HelperPath = Get-AppFilePath ' lessmsi' ' lessmsi.exe' }
499- ' Innounp' { $HelperPath = Get-AppFilePath ' innounp' ' innounp.exe' }
520+ ' Innounp' {
521+ $HelperPath = Get-AppFilePath ' innounp-unicode' ' innounp.exe'
522+ if ([String ]::IsNullOrEmpty($HelperPath )) {
523+ $HelperPath = Get-AppFilePath ' innounp' ' innounp.exe'
524+ }
525+ }
500526 ' Dark' {
501527 $HelperPath = Get-AppFilePath ' wixtoolset' ' wix.exe'
502528 if ([String ]::IsNullOrEmpty($HelperPath )) {
503529 $HelperPath = Get-AppFilePath ' dark' ' dark.exe'
504530 }
505531 }
506532 ' Aria2' { $HelperPath = Get-AppFilePath ' aria2' ' aria2c.exe' }
507- ' Zstd' { $HelperPath = Get-AppFilePath ' zstd' ' zstd.exe' }
508533 }
509534
510535 return $HelperPath
@@ -551,7 +576,7 @@ function Test-HelperInstalled {
551576 [CmdletBinding ()]
552577 param (
553578 [Parameter (Mandatory = $true , Position = 0 , ValueFromPipeline = $true )]
554- [ValidateSet (' 7zip' , ' Lessmsi' , ' Innounp' , ' Dark' , ' Aria2' , ' Zstd ' )]
579+ [ValidateSet (' 7zip' , ' Lessmsi' , ' Innounp' , ' Dark' , ' Aria2' )]
555580 [String ]
556581 $Helper
557582 )
@@ -1013,19 +1038,20 @@ function shim($path, $global, $name, $arg) {
10131038 warn_on_overwrite " $shim .cmd" $path
10141039 @ (
10151040 " @rem $resolved_path " ,
1016- " @cd /d $ ( Split-Path $resolved_path - Parent) "
1017- " @java -jar `" $resolved_path `" $arg %*"
1041+ " @pushd $ ( Split-Path $resolved_path - Parent) " ,
1042+ " @java -jar `" $resolved_path `" $arg %*" ,
1043+ " @popd"
10181044 ) -join " `r`n " | Out-UTF8File " $shim .cmd"
10191045
10201046 warn_on_overwrite $shim $path
10211047 @ (
10221048 " #!/bin/sh" ,
10231049 " # $resolved_path " ,
1024- " if [ `$ (echo `$ WSL_DISTRO_NAME) ]" ,
1050+ " if [ `$ WSL_INTEROP ]" ,
10251051 ' then' ,
10261052 " cd `$ (wslpath -u '$ ( Split-Path $resolved_path - Parent) ')" ,
10271053 ' else' ,
1028- " cd `" $ ( (Split-Path $resolved_path - Parent).Replace( ' \ ' , ' / ' ) ) `" " ,
1054+ " cd `$ (cygpath -u ' $ ( Split-Path $resolved_path - Parent) ') " ,
10291055 ' fi' ,
10301056 " java.exe -jar `" $resolved_path `" $arg `" $@`" "
10311057 ) -join " `n " | Out-UTF8File $shim - NoNewLine
@@ -1038,22 +1064,30 @@ function shim($path, $global, $name, $arg) {
10381064
10391065 warn_on_overwrite $shim $path
10401066 @ (
1041- " #!/bin/sh" ,
1067+ ' #!/bin/sh' ,
10421068 " # $resolved_path " ,
10431069 " python.exe `" $resolved_path `" $arg `" $@`" "
10441070 ) -join " `n " | Out-UTF8File $shim - NoNewLine
10451071 } else {
10461072 warn_on_overwrite " $shim .cmd" $path
10471073 @ (
10481074 " @rem $resolved_path " ,
1049- " @bash `" $resolved_path `" $arg %*"
1075+ " @bash `"`$ (wslpath -u '$resolved_path ')`" $arg %* 2>nul" ,
1076+ ' @if %errorlevel% neq 0 (' ,
1077+ " @bash `"`$ (cygpath -u '$resolved_path ')`" $arg %* 2>nul" ,
1078+ ' )'
10501079 ) -join " `r`n " | Out-UTF8File " $shim .cmd"
10511080
10521081 warn_on_overwrite $shim $path
10531082 @ (
1054- " #!/bin/sh" ,
1083+ ' #!/bin/sh' ,
10551084 " # $resolved_path " ,
1056- " `" $resolved_path `" $arg `" $@`" "
1085+ " if [ `$ WSL_INTEROP ]" ,
1086+ ' then' ,
1087+ " `"`$ (wslpath -u '$resolved_path ')`" $arg `" $@`" " ,
1088+ ' else' ,
1089+ " `"`$ (cygpath -u '$resolved_path ')`" $arg `" $@`" " ,
1090+ ' fi'
10571091 ) -join " `n " | Out-UTF8File $shim - NoNewLine
10581092 }
10591093}
@@ -1172,7 +1206,7 @@ function applist($apps, $global) {
11721206}
11731207
11741208function parse_app ([string ]$app ) {
1175- if ($app -match ' ^(?:(?<bucket>[a-zA-Z0-9-_.]+)/)?(?<app>.*\.json$ |[a-zA-Z0-9-_.]+)(?:@(?<version>.*))?$' ) {
1209+ if ($app -match ' ^(?:(?<bucket>[a-zA-Z0-9-_.]+)/)?(?<app>.*\.json|[a-zA-Z0-9-_.]+)(?:@(?<version>.*))?$' ) {
11761210 return $Matches [' app' ], $Matches [' bucket' ], $Matches [' version' ]
11771211 } else {
11781212 return $app , $null , $null
0 commit comments