Skip to content

Commit 4a31bd3

Browse files
authored
chore(release): Bump to version 0.2.4
2 parents 80b52e3 + 5b5daa5 commit 4a31bd3

12 files changed

+104
-35
lines changed

CHANGELOG.md

+22
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
## [v0.2.4](https://github.com/ScoopInstaller/Scoop/compare/v0.2.3...v0.2.4) - 2022-08-08
2+
3+
### Features
4+
5+
- **core:** Create no window by default in `Invoke-ExternalCommand` ([#5066](https://github.com/ScoopInstaller/Scoop/issues/5066))
6+
- **core:** Improve argument concatenation in `Invoke-ExternalCommand` ([#5065](https://github.com/ScoopInstaller/Scoop/issues/5065))
7+
- **install:** Show bucket name while installing an app ([#5075](https://github.com/ScoopInstaller/Scoop/issues/5075))
8+
- **scoop-status:** Add flag to disable remote checking ([#5073](https://github.com/ScoopInstaller/Scoop/issues/5073))
9+
- **scoop-update:** Add support for `pre_uninstall` and `post_uninstall` ([#5085](https://github.com/ScoopInstaller/Scoop/issues/5085))
10+
11+
### Bug Fixes
12+
13+
- **core:** Avoid deadlock in `Invoke-ExternalCommand` ([#5064](https://github.com/ScoopInstaller/Scoop/issues/5064))
14+
- **core:** Use 'System.Nullable<bool>' for param 'global' ([#5088](https://github.com/ScoopInstaller/Scoop/issues/5088))
15+
- **install:** Move from cache when `--no-cache` is specified ([#5039](https://github.com/ScoopInstaller/Scoop/issues/5039))
16+
- **scoop-status:** Correct formatting of `Info` output ([#5047](https://github.com/ScoopInstaller/Scoop/issues/5047))
17+
18+
### Builds
19+
20+
- **checkver:** Load page content before running 'script' ([#5080](https://github.com/ScoopInstaller/Scoop/issues/5080))
21+
- **json:** Update Newtonsoft.Json.Schema to 3.0.15-beta2 ([#5053](https://github.com/ScoopInstaller/Scoop/issues/5053))
22+
123
## [v0.2.3](https://github.com/ScoopInstaller/Scoop/compare/v0.2.2...v0.2.3) - 2022-07-07
224

325
### Features

bin/checkver.ps1

+5-3
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ while ($in_progress -gt 0) {
218218
$regexp = $state.regex
219219
$jsonpath = $state.jsonpath
220220
$xpath = $state.xpath
221+
$script = $json.checkver.script
221222
$reverse = $state.reverse
222223
$replace = $state.replace
223224
$expected_ver = $json.version
@@ -234,11 +235,12 @@ while ($in_progress -gt 0) {
234235
continue
235236
}
236237

237-
if ($json.checkver.script) {
238-
$page = Invoke-Command ([scriptblock]::Create($json.checkver.script -join "`r`n"))
239-
} else {
238+
if ($url) {
240239
$page = (Get-Encoding($wc)).GetString($ev.SourceEventArgs.Result)
241240
}
241+
if ($script) {
242+
$page = Invoke-Command ([scriptblock]::Create($script -join "`r`n"))
243+
}
242244

243245
if ($jsonpath) {
244246
# Return only a single value if regex is absent

lib/core.ps1

+41-12
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ function cache_path($app, $version, $url) { "$cachedir\$app#$version#$($url -rep
225225

226226
# apps
227227
function sanitary_path($path) { return [regex]::replace($path, "[/\\?:*<>|]", "") }
228-
function installed($app, $global) {
229-
if (-not $PSBoundParameters.ContainsKey('global')) {
228+
function installed($app, [Nullable[bool]]$global) {
229+
if ($null -eq $global) {
230230
return (installed $app $false) -or (installed $app $true)
231231
}
232232
# Dependencies of the format "bucket/dependency" install in a directory of form
@@ -507,34 +507,63 @@ function Invoke-ExternalCommand {
507507
}
508508
$Process = New-Object System.Diagnostics.Process
509509
$Process.StartInfo.FileName = $FilePath
510-
$Process.StartInfo.Arguments = ($ArgumentList | Select-Object -Unique) -join ' '
511510
$Process.StartInfo.UseShellExecute = $false
512511
if ($LogPath) {
513-
if ($FilePath -match '(^|\W)msiexec($|\W)') {
514-
$Process.StartInfo.Arguments += " /lwe `"$LogPath`""
512+
if ($FilePath -match '^msiexec(.exe)?$') {
513+
$ArgumentList += "/lwe `"$LogPath`""
515514
} else {
515+
$redirectToLogFile = $true
516516
$Process.StartInfo.RedirectStandardOutput = $true
517517
$Process.StartInfo.RedirectStandardError = $true
518518
}
519519
}
520520
if ($RunAs) {
521521
$Process.StartInfo.UseShellExecute = $true
522522
$Process.StartInfo.Verb = 'RunAs'
523+
} else {
524+
$Process.StartInfo.CreateNoWindow = $true
525+
}
526+
if ($FilePath -match '^((cmd|cscript|wscript|msiexec)(\.exe)?|.*\.(bat|cmd|js|vbs|wsf))$') {
527+
$Process.StartInfo.Arguments = $ArgumentList -join ' '
528+
} elseif ($Process.StartInfo.ArgumentList.Add) {
529+
# ArgumentList is supported in PowerShell 6.1 and later (built on .NET Core 2.1+)
530+
# ref-1: https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processstartinfo.argumentlist?view=net-6.0
531+
# ref-2: https://docs.microsoft.com/en-us/powershell/scripting/whats-new/differences-from-windows-powershell?view=powershell-7.2#net-framework-vs-net-core
532+
$ArgumentList | ForEach-Object { $Process.StartInfo.ArgumentList.Add($_) }
533+
} else {
534+
# escape arguments manually in lower versions, refer to https://docs.microsoft.com/en-us/previous-versions/17w5ykft(v=vs.85)
535+
$escapedArgs = $ArgumentList | ForEach-Object {
536+
# escape N consecutive backslash(es), which are followed by a double quote, to 2N consecutive ones
537+
$s = $_ -replace '(\\+)"', '$1$1"'
538+
# escape N consecutive backslash(es), which are at the end of the string, to 2N consecutive ones
539+
$s = $s -replace '(\\+)$', '$1$1'
540+
# escape double quotes
541+
$s = $s -replace '"', '\"'
542+
# quote the argument
543+
"`"$s`""
544+
}
545+
$Process.StartInfo.Arguments = $escapedArgs -join ' '
523546
}
524547
try {
525-
$Process.Start() | Out-Null
548+
[void]$Process.Start()
526549
} catch {
527550
if ($Activity) {
528551
Write-Host "error." -ForegroundColor DarkRed
529552
}
530553
error $_.Exception.Message
531554
return $false
532555
}
533-
if ($LogPath -and ($FilePath -notmatch '(^|\W)msiexec($|\W)')) {
534-
Out-UTF8File -FilePath $LogPath -Append -InputObject $Process.StandardOutput.ReadToEnd()
535-
Out-UTF8File -FilePath $LogPath -Append -InputObject $Process.StandardError.ReadToEnd()
556+
if ($redirectToLogFile) {
557+
# we do this to remove a deadlock potential
558+
# ref: https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.process.standardoutput?view=netframework-4.5#remarks
559+
$stdoutTask = $Process.StandardOutput.ReadToEndAsync()
560+
$stderrTask = $Process.StandardError.ReadToEndAsync()
536561
}
537562
$Process.WaitForExit()
563+
if ($redirectToLogFile) {
564+
Out-UTF8File -FilePath $LogPath -Append -InputObject $stdoutTask.Result
565+
Out-UTF8File -FilePath $LogPath -Append -InputObject $stderrTask.Result
566+
}
538567
if ($Process.ExitCode -ne 0) {
539568
if ($ContinueExitCodes -and ($ContinueExitCodes.ContainsKey($Process.ExitCode))) {
540569
if ($Activity) {
@@ -604,12 +633,12 @@ function movedir($from, $to) {
604633
$proc.StartInfo.RedirectStandardError = $true
605634
$proc.StartInfo.UseShellExecute = $false
606635
$proc.StartInfo.WindowStyle = [System.Diagnostics.ProcessWindowStyle]::Hidden
607-
$proc.Start()
608-
$out = $proc.StandardOutput.ReadToEnd()
636+
[void]$proc.Start()
637+
$stdoutTask = $proc.StandardOutput.ReadToEndAsync()
609638
$proc.WaitForExit()
610639

611640
if($proc.ExitCode -ge 8) {
612-
debug $out
641+
debug $stdoutTask.Result
613642
throw "Could not find '$(fname $from)'! (error $($proc.ExitCode))"
614643
}
615644

lib/decompress.ps1

+8-8
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ function Expand-7zipArchive {
2828
$7zPath = Get-HelperPath -Helper 7zip
2929
}
3030
$LogPath = "$(Split-Path $Path)\7zip.log"
31-
$ArgList = @('x', "`"$Path`"", "-o`"$DestinationPath`"", '-y')
31+
$ArgList = @('x', $Path, "-o$DestinationPath", '-y')
3232
$IsTar = ((strip_ext $Path) -match '\.tar$') -or ($Path -match '\.t[abgpx]z2?$')
3333
if (!$IsTar -and $ExtractDir) {
34-
$ArgList += "-ir!`"$ExtractDir\*`""
34+
$ArgList += "-ir!$ExtractDir\*"
3535
}
3636
if ($Switches) {
3737
$ArgList += (-split $Switches)
@@ -53,7 +53,7 @@ function Expand-7zipArchive {
5353
}
5454
if ($IsTar) {
5555
# Check for tar
56-
$Status = Invoke-ExternalCommand $7zPath @('l', "`"$Path`"") -LogPath $LogPath
56+
$Status = Invoke-ExternalCommand $7zPath @('l', $Path) -LogPath $LogPath
5757
if ($Status) {
5858
# get inner tar file name
5959
$TarFile = (Select-String -Path $LogPath -Pattern '[^ ]*tar$').Matches.Value
@@ -97,7 +97,7 @@ function Expand-ZstdArchive {
9797
$LogPath = Join-Path (Split-Path $Path) 'zstd.log'
9898
$DestinationPath = $DestinationPath.TrimEnd('\')
9999
ensure $DestinationPath | Out-Null
100-
$ArgList = @('-d', "`"$Path`"", '--output-dir-flat', "`"$DestinationPath`"", '-f', '-v')
100+
$ArgList = @('-d', $Path, '--output-dir-flat', $DestinationPath, '-f', '-v')
101101

102102
if ($Switches) {
103103
$ArgList += (-split $Switches)
@@ -148,10 +148,10 @@ function Expand-MsiArchive {
148148
}
149149
if ((get_config MSIEXTRACT_USE_LESSMSI)) {
150150
$MsiPath = Get-HelperPath -Helper Lessmsi
151-
$ArgList = @('x', "`"$Path`"", "`"$DestinationPath\\`"")
151+
$ArgList = @('x', $Path, "$DestinationPath\")
152152
} else {
153153
$MsiPath = 'msiexec.exe'
154-
$ArgList = @('/a', "`"$Path`"", '/qn', "TARGETDIR=`"$DestinationPath\\SourceDir`"")
154+
$ArgList = @('/a', "`"$Path`"", '/qn', "TARGETDIR=`"$DestinationPath\SourceDir`"")
155155
}
156156
$LogPath = "$(Split-Path $Path)\msi.log"
157157
if ($Switches) {
@@ -200,7 +200,7 @@ function Expand-InnoArchive {
200200
$Removal
201201
)
202202
$LogPath = "$(Split-Path $Path)\innounp.log"
203-
$ArgList = @('-x', "-d`"$DestinationPath`"", "`"$Path`"", '-y')
203+
$ArgList = @('-x', "-d$DestinationPath", $Path, '-y')
204204
switch -Regex ($ExtractDir) {
205205
'^[^{].*' { $ArgList += "-c{app}\$ExtractDir" }
206206
'^{.*' { $ArgList += "-c$ExtractDir" }
@@ -267,7 +267,7 @@ function Expand-DarkArchive {
267267
$Removal
268268
)
269269
$LogPath = "$(Split-Path $Path)\dark.log"
270-
$ArgList = @('-nologo', "-x `"$DestinationPath`"", "`"$Path`"")
270+
$ArgList = @('-nologo', '-x', $DestinationPath, $Path)
271271
if ($Switches) {
272272
$ArgList += (-split $Switches)
273273
}

lib/install.ps1

+6-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function install_app($app, $architecture, $global, $suggested, $use_cache = $tru
4343
return
4444
}
4545
}
46-
write-output "Installing '$app' ($version) [$architecture]"
46+
Write-Output "Installing '$app' ($version) [$architecture]$(if ($bucket) { " from $bucket bucket" })"
4747

4848
$dir = ensure (versiondir $app $version $global)
4949
$original_dir = $dir # keep reference to real (not linked) directory
@@ -90,7 +90,11 @@ function dl_with_cache($app, $version, $url, $to, $cookies = $null, $use_cache =
9090
} else { write-host "Loading $(url_remote_filename $url) from cache"}
9191

9292
if (!($null -eq $to)) {
93-
Copy-Item $cached $to
93+
if ($use_cache) {
94+
Copy-Item $cached $to
95+
} else {
96+
Move-Item $cached $to -Force
97+
}
9498
}
9599
}
96100

libexec/scoop-status.ps1

+14-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Usage: scoop status
22
# Summary: Show status and check for new app versions
3+
# Help: Options:
4+
# -l, --local Checks the status for only the locally installed apps,
5+
# and disables remote fetching/checking for Scoop and buckets
36

47
. "$PSScriptRoot\..\lib\manifest.ps1" # 'manifest' 'parse_json' "install_info"
58
. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion'
@@ -9,6 +12,8 @@ $currentdir = fullpath $(versiondir 'scoop' 'current')
912
$needs_update = $false
1013
$bucket_needs_update = $false
1114
$script:network_failure = $false
15+
$no_remotes = $args[0] -eq '-l' -or $args[0] -eq '--local'
16+
if (!(Get-Command git -ErrorAction SilentlyContinue)) { $no_remotes = $true }
1217
$list = @()
1318
if (!(Get-FormatData ScoopStatus)) {
1419
Update-FormatData "$PSScriptRoot\..\supporting\formats\ScoopTypes.Format.ps1xml"
@@ -27,18 +32,21 @@ function Test-UpdateStatus($repopath) {
2732
}
2833
}
2934

30-
$needs_update = Test-UpdateStatus $currentdir
31-
foreach ($bucket in Get-LocalBucket) {
32-
if (Test-UpdateStatus (Find-BucketDirectory $bucket -Root)) {
33-
$bucket_needs_update = $true
35+
if (!$no_remotes) {
36+
$needs_update = Test-UpdateStatus $currentdir
37+
foreach ($bucket in Get-LocalBucket) {
38+
if (Test-UpdateStatus (Find-BucketDirectory $bucket -Root)) {
39+
$bucket_needs_update = $true
40+
break
41+
}
3442
}
3543
}
3644

3745
if ($needs_update) {
3846
warn "Scoop out of date. Run 'scoop update' to get the latest changes."
3947
} elseif ($bucket_needs_update) {
4048
warn "Scoop bucket(s) out of date. Run 'scoop update' to get the latest changes."
41-
} elseif (!$script:network_failure) {
49+
} elseif (!$script:network_failure -and !$no_remotes) {
4250
success 'Scoop is up to date.'
4351
}
4452

@@ -57,7 +65,7 @@ $true, $false | ForEach-Object { # local and global apps
5765
$item.'Installed Version' = $status.version
5866
$item.'Latest Version' = if ($status.outdated) { $status.latest_version } else { "" }
5967
$item.'Missing Dependencies' = $status.missing_deps -Split ' ' -Join ' | '
60-
$info = $()
68+
$info = @()
6169
if ($status.failed) { $info += 'Install failed' }
6270
if ($status.hold) { $info += 'Held package' }
6371
if ($status.removed) { $info += 'Manifest removed' }

libexec/scoop-update.ps1

+4
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ function update($app, $global, $quiet = $false, $independent, $suggested, $use_c
243243
$dir = versiondir $app $old_version $global
244244
$persist_dir = persistdir $app $global
245245

246+
Invoke-HookScript -HookType 'pre_uninstall' -Manifest $old_manifest -Arch $architecture
247+
246248
#region Workaround for #2952
247249
if (test_running_process $app $global) {
248250
return
@@ -272,6 +274,8 @@ function update($app, $global, $quiet = $false, $independent, $suggested, $use_c
272274
}
273275
}
274276

277+
Invoke-HookScript -HookType 'post_uninstall' -Manifest $old_manifest -Arch $architecture
278+
275279
if ($bucket) {
276280
# add bucket name it was installed from
277281
$app = "$bucket/$app"
Binary file not shown.
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
b624949df8b0e3a6153fdfb730a7c6f4990b6592ee0d922e1788433d276610f3 *Newtonsoft.Json.dll
2-
cff8fc4ce358d7daff84ab47129a776797a4ec819c1586a15bd5e63144f5b73f *Newtonsoft.Json.Schema.dll
2+
9abb57d73d82a2d77008321a85aff2b62e5ac68bebb54ece8668c96cc112e36b *Newtonsoft.Json.Schema.dll
33
0318c8221ce4d44806f8def619bcc02886be0902aab80080e6251c50c6ca53a9 *Scoop.Validator.dll
44
40a70bee96d108701f8f2e81392f9b79fd003f1cb4e1653ad2429753153fd7ee *validator.exe
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
2fdf035661f349206f58ea1feed8805b7f9517a21f9c113e7301c69de160f184c774350a12a710046e3ff6baa37345d319b6f47fd24fbba4e042d54014bee511 *Newtonsoft.Json.dll
2-
298d3d0b656acbb1fe5ed0c3abb49a640c47889184ab7bd4b594e51a7d7f829d5c8685edbd10a286fd56bfd8d601b9f187da463a5a9c8509365eddaea280642f *Newtonsoft.Json.Schema.dll
2+
855ab2e30c9d523c9f321ae861c5969244185f660fa47e05cec96df8e2970d19843dbd3d89a0fca845544641915d1adf4b4a2145ef568dd99da7791e5064d70e *Newtonsoft.Json.Schema.dll
33
338793e6127330c0b05728291fcf18441127ffb56e1bd5c0f0588cd7436605f4b852f4bb622f655896a7eb7b1262add142b200fd5f37391b47d1401becb6b81c *Scoop.Validator.dll
44
d497c27b48f44f4cff270d3c8801b0cecc74108f8786a4a7c40e57541308ae33a69f5456cfc43ae1ce4214038d20da9fbeac1bcf76cc58d972863b58dab18401 *validator.exe

supporting/validator/packages.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net45" />
4-
<package id="Newtonsoft.Json.Schema" version="3.0.14" targetFramework="net45" />
4+
<package id="Newtonsoft.Json.Schema" version="3.0.15-beta2" targetFramework="net45" />
55
<package id="Microsoft.Net.Compilers.Toolset" version="4.2.0" targetFramework="net45" developmentDependency="true" />
66
</packages>

supporting/validator/validator.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<Private>True</Private>
2020
</Reference>
2121
<Reference Include="Newtonsoft.Json.Schema, Version=3.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
22-
<HintPath>packages\Newtonsoft.Json.Schema.3.0.14\lib\net45\Newtonsoft.Json.Schema.dll</HintPath>
22+
<HintPath>packages\Newtonsoft.Json.Schema.3.0.15-beta2\lib\net45\Newtonsoft.Json.Schema.dll</HintPath>
2323
<Private>True</Private>
2424
</Reference>
2525
<Reference Include="System" />

0 commit comments

Comments
 (0)