Skip to content

Commit

Permalink
chore(release): Bump to version 0.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
niheaven committed Aug 10, 2022
2 parents 80b52e3 + 5b5daa5 commit 4a31bd3
Show file tree
Hide file tree
Showing 12 changed files with 104 additions and 35 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
## [v0.2.4](https://github.com/ScoopInstaller/Scoop/compare/v0.2.3...v0.2.4) - 2022-08-08

### Features

- **core:** Create no window by default in `Invoke-ExternalCommand` ([#5066](https://github.com/ScoopInstaller/Scoop/issues/5066))
- **core:** Improve argument concatenation in `Invoke-ExternalCommand` ([#5065](https://github.com/ScoopInstaller/Scoop/issues/5065))
- **install:** Show bucket name while installing an app ([#5075](https://github.com/ScoopInstaller/Scoop/issues/5075))
- **scoop-status:** Add flag to disable remote checking ([#5073](https://github.com/ScoopInstaller/Scoop/issues/5073))
- **scoop-update:** Add support for `pre_uninstall` and `post_uninstall` ([#5085](https://github.com/ScoopInstaller/Scoop/issues/5085))

### Bug Fixes

- **core:** Avoid deadlock in `Invoke-ExternalCommand` ([#5064](https://github.com/ScoopInstaller/Scoop/issues/5064))
- **core:** Use 'System.Nullable<bool>' for param 'global' ([#5088](https://github.com/ScoopInstaller/Scoop/issues/5088))
- **install:** Move from cache when `--no-cache` is specified ([#5039](https://github.com/ScoopInstaller/Scoop/issues/5039))
- **scoop-status:** Correct formatting of `Info` output ([#5047](https://github.com/ScoopInstaller/Scoop/issues/5047))

### Builds

- **checkver:** Load page content before running 'script' ([#5080](https://github.com/ScoopInstaller/Scoop/issues/5080))
- **json:** Update Newtonsoft.Json.Schema to 3.0.15-beta2 ([#5053](https://github.com/ScoopInstaller/Scoop/issues/5053))

## [v0.2.3](https://github.com/ScoopInstaller/Scoop/compare/v0.2.2...v0.2.3) - 2022-07-07

### Features
Expand Down
8 changes: 5 additions & 3 deletions bin/checkver.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ while ($in_progress -gt 0) {
$regexp = $state.regex
$jsonpath = $state.jsonpath
$xpath = $state.xpath
$script = $json.checkver.script
$reverse = $state.reverse
$replace = $state.replace
$expected_ver = $json.version
Expand All @@ -234,11 +235,12 @@ while ($in_progress -gt 0) {
continue
}

if ($json.checkver.script) {
$page = Invoke-Command ([scriptblock]::Create($json.checkver.script -join "`r`n"))
} else {
if ($url) {
$page = (Get-Encoding($wc)).GetString($ev.SourceEventArgs.Result)
}
if ($script) {
$page = Invoke-Command ([scriptblock]::Create($script -join "`r`n"))
}

if ($jsonpath) {
# Return only a single value if regex is absent
Expand Down
53 changes: 41 additions & 12 deletions lib/core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ function cache_path($app, $version, $url) { "$cachedir\$app#$version#$($url -rep

# apps
function sanitary_path($path) { return [regex]::replace($path, "[/\\?:*<>|]", "") }
function installed($app, $global) {
if (-not $PSBoundParameters.ContainsKey('global')) {
function installed($app, [Nullable[bool]]$global) {
if ($null -eq $global) {
return (installed $app $false) -or (installed $app $true)
}
# Dependencies of the format "bucket/dependency" install in a directory of form
Expand Down Expand Up @@ -507,34 +507,63 @@ function Invoke-ExternalCommand {
}
$Process = New-Object System.Diagnostics.Process
$Process.StartInfo.FileName = $FilePath
$Process.StartInfo.Arguments = ($ArgumentList | Select-Object -Unique) -join ' '
$Process.StartInfo.UseShellExecute = $false
if ($LogPath) {
if ($FilePath -match '(^|\W)msiexec($|\W)') {
$Process.StartInfo.Arguments += " /lwe `"$LogPath`""
if ($FilePath -match '^msiexec(.exe)?$') {
$ArgumentList += "/lwe `"$LogPath`""
} else {
$redirectToLogFile = $true
$Process.StartInfo.RedirectStandardOutput = $true
$Process.StartInfo.RedirectStandardError = $true
}
}
if ($RunAs) {
$Process.StartInfo.UseShellExecute = $true
$Process.StartInfo.Verb = 'RunAs'
} else {
$Process.StartInfo.CreateNoWindow = $true
}
if ($FilePath -match '^((cmd|cscript|wscript|msiexec)(\.exe)?|.*\.(bat|cmd|js|vbs|wsf))$') {
$Process.StartInfo.Arguments = $ArgumentList -join ' '
} elseif ($Process.StartInfo.ArgumentList.Add) {
# ArgumentList is supported in PowerShell 6.1 and later (built on .NET Core 2.1+)
# ref-1: https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processstartinfo.argumentlist?view=net-6.0
# 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
$ArgumentList | ForEach-Object { $Process.StartInfo.ArgumentList.Add($_) }
} else {
# escape arguments manually in lower versions, refer to https://docs.microsoft.com/en-us/previous-versions/17w5ykft(v=vs.85)
$escapedArgs = $ArgumentList | ForEach-Object {
# escape N consecutive backslash(es), which are followed by a double quote, to 2N consecutive ones
$s = $_ -replace '(\\+)"', '$1$1"'
# escape N consecutive backslash(es), which are at the end of the string, to 2N consecutive ones
$s = $s -replace '(\\+)$', '$1$1'
# escape double quotes
$s = $s -replace '"', '\"'
# quote the argument
"`"$s`""
}
$Process.StartInfo.Arguments = $escapedArgs -join ' '
}
try {
$Process.Start() | Out-Null
[void]$Process.Start()
} catch {
if ($Activity) {
Write-Host "error." -ForegroundColor DarkRed
}
error $_.Exception.Message
return $false
}
if ($LogPath -and ($FilePath -notmatch '(^|\W)msiexec($|\W)')) {
Out-UTF8File -FilePath $LogPath -Append -InputObject $Process.StandardOutput.ReadToEnd()
Out-UTF8File -FilePath $LogPath -Append -InputObject $Process.StandardError.ReadToEnd()
if ($redirectToLogFile) {
# we do this to remove a deadlock potential
# ref: https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.process.standardoutput?view=netframework-4.5#remarks
$stdoutTask = $Process.StandardOutput.ReadToEndAsync()
$stderrTask = $Process.StandardError.ReadToEndAsync()
}
$Process.WaitForExit()
if ($redirectToLogFile) {
Out-UTF8File -FilePath $LogPath -Append -InputObject $stdoutTask.Result
Out-UTF8File -FilePath $LogPath -Append -InputObject $stderrTask.Result
}
if ($Process.ExitCode -ne 0) {
if ($ContinueExitCodes -and ($ContinueExitCodes.ContainsKey($Process.ExitCode))) {
if ($Activity) {
Expand Down Expand Up @@ -604,12 +633,12 @@ function movedir($from, $to) {
$proc.StartInfo.RedirectStandardError = $true
$proc.StartInfo.UseShellExecute = $false
$proc.StartInfo.WindowStyle = [System.Diagnostics.ProcessWindowStyle]::Hidden
$proc.Start()
$out = $proc.StandardOutput.ReadToEnd()
[void]$proc.Start()
$stdoutTask = $proc.StandardOutput.ReadToEndAsync()
$proc.WaitForExit()

if($proc.ExitCode -ge 8) {
debug $out
debug $stdoutTask.Result
throw "Could not find '$(fname $from)'! (error $($proc.ExitCode))"
}

Expand Down
16 changes: 8 additions & 8 deletions lib/decompress.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ function Expand-7zipArchive {
$7zPath = Get-HelperPath -Helper 7zip
}
$LogPath = "$(Split-Path $Path)\7zip.log"
$ArgList = @('x', "`"$Path`"", "-o`"$DestinationPath`"", '-y')
$ArgList = @('x', $Path, "-o$DestinationPath", '-y')
$IsTar = ((strip_ext $Path) -match '\.tar$') -or ($Path -match '\.t[abgpx]z2?$')
if (!$IsTar -and $ExtractDir) {
$ArgList += "-ir!`"$ExtractDir\*`""
$ArgList += "-ir!$ExtractDir\*"
}
if ($Switches) {
$ArgList += (-split $Switches)
Expand All @@ -53,7 +53,7 @@ function Expand-7zipArchive {
}
if ($IsTar) {
# Check for tar
$Status = Invoke-ExternalCommand $7zPath @('l', "`"$Path`"") -LogPath $LogPath
$Status = Invoke-ExternalCommand $7zPath @('l', $Path) -LogPath $LogPath
if ($Status) {
# get inner tar file name
$TarFile = (Select-String -Path $LogPath -Pattern '[^ ]*tar$').Matches.Value
Expand Down Expand Up @@ -97,7 +97,7 @@ function Expand-ZstdArchive {
$LogPath = Join-Path (Split-Path $Path) 'zstd.log'
$DestinationPath = $DestinationPath.TrimEnd('\')
ensure $DestinationPath | Out-Null
$ArgList = @('-d', "`"$Path`"", '--output-dir-flat', "`"$DestinationPath`"", '-f', '-v')
$ArgList = @('-d', $Path, '--output-dir-flat', $DestinationPath, '-f', '-v')

if ($Switches) {
$ArgList += (-split $Switches)
Expand Down Expand Up @@ -148,10 +148,10 @@ function Expand-MsiArchive {
}
if ((get_config MSIEXTRACT_USE_LESSMSI)) {
$MsiPath = Get-HelperPath -Helper Lessmsi
$ArgList = @('x', "`"$Path`"", "`"$DestinationPath\\`"")
$ArgList = @('x', $Path, "$DestinationPath\")
} else {
$MsiPath = 'msiexec.exe'
$ArgList = @('/a', "`"$Path`"", '/qn', "TARGETDIR=`"$DestinationPath\\SourceDir`"")
$ArgList = @('/a', "`"$Path`"", '/qn', "TARGETDIR=`"$DestinationPath\SourceDir`"")
}
$LogPath = "$(Split-Path $Path)\msi.log"
if ($Switches) {
Expand Down Expand Up @@ -200,7 +200,7 @@ function Expand-InnoArchive {
$Removal
)
$LogPath = "$(Split-Path $Path)\innounp.log"
$ArgList = @('-x', "-d`"$DestinationPath`"", "`"$Path`"", '-y')
$ArgList = @('-x', "-d$DestinationPath", $Path, '-y')
switch -Regex ($ExtractDir) {
'^[^{].*' { $ArgList += "-c{app}\$ExtractDir" }
'^{.*' { $ArgList += "-c$ExtractDir" }
Expand Down Expand Up @@ -267,7 +267,7 @@ function Expand-DarkArchive {
$Removal
)
$LogPath = "$(Split-Path $Path)\dark.log"
$ArgList = @('-nologo', "-x `"$DestinationPath`"", "`"$Path`"")
$ArgList = @('-nologo', '-x', $DestinationPath, $Path)
if ($Switches) {
$ArgList += (-split $Switches)
}
Expand Down
8 changes: 6 additions & 2 deletions lib/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function install_app($app, $architecture, $global, $suggested, $use_cache = $tru
return
}
}
write-output "Installing '$app' ($version) [$architecture]"
Write-Output "Installing '$app' ($version) [$architecture]$(if ($bucket) { " from $bucket bucket" })"

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

if (!($null -eq $to)) {
Copy-Item $cached $to
if ($use_cache) {
Copy-Item $cached $to
} else {
Move-Item $cached $to -Force
}
}
}

Expand Down
20 changes: 14 additions & 6 deletions libexec/scoop-status.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Usage: scoop status
# Summary: Show status and check for new app versions
# Help: Options:
# -l, --local Checks the status for only the locally installed apps,
# and disables remote fetching/checking for Scoop and buckets

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

$needs_update = Test-UpdateStatus $currentdir
foreach ($bucket in Get-LocalBucket) {
if (Test-UpdateStatus (Find-BucketDirectory $bucket -Root)) {
$bucket_needs_update = $true
if (!$no_remotes) {
$needs_update = Test-UpdateStatus $currentdir
foreach ($bucket in Get-LocalBucket) {
if (Test-UpdateStatus (Find-BucketDirectory $bucket -Root)) {
$bucket_needs_update = $true
break
}
}
}

if ($needs_update) {
warn "Scoop out of date. Run 'scoop update' to get the latest changes."
} elseif ($bucket_needs_update) {
warn "Scoop bucket(s) out of date. Run 'scoop update' to get the latest changes."
} elseif (!$script:network_failure) {
} elseif (!$script:network_failure -and !$no_remotes) {
success 'Scoop is up to date.'
}

Expand All @@ -57,7 +65,7 @@ $true, $false | ForEach-Object { # local and global apps
$item.'Installed Version' = $status.version
$item.'Latest Version' = if ($status.outdated) { $status.latest_version } else { "" }
$item.'Missing Dependencies' = $status.missing_deps -Split ' ' -Join ' | '
$info = $()
$info = @()
if ($status.failed) { $info += 'Install failed' }
if ($status.hold) { $info += 'Held package' }
if ($status.removed) { $info += 'Manifest removed' }
Expand Down
4 changes: 4 additions & 0 deletions libexec/scoop-update.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ function update($app, $global, $quiet = $false, $independent, $suggested, $use_c
$dir = versiondir $app $old_version $global
$persist_dir = persistdir $app $global

Invoke-HookScript -HookType 'pre_uninstall' -Manifest $old_manifest -Arch $architecture

#region Workaround for #2952
if (test_running_process $app $global) {
return
Expand Down Expand Up @@ -272,6 +274,8 @@ function update($app, $global, $quiet = $false, $independent, $suggested, $use_c
}
}

Invoke-HookScript -HookType 'post_uninstall' -Manifest $old_manifest -Arch $architecture

if ($bucket) {
# add bucket name it was installed from
$app = "$bucket/$app"
Expand Down
Binary file modified supporting/validator/bin/Newtonsoft.Json.Schema.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion supporting/validator/bin/checksum.sha256
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
b624949df8b0e3a6153fdfb730a7c6f4990b6592ee0d922e1788433d276610f3 *Newtonsoft.Json.dll
cff8fc4ce358d7daff84ab47129a776797a4ec819c1586a15bd5e63144f5b73f *Newtonsoft.Json.Schema.dll
9abb57d73d82a2d77008321a85aff2b62e5ac68bebb54ece8668c96cc112e36b *Newtonsoft.Json.Schema.dll
0318c8221ce4d44806f8def619bcc02886be0902aab80080e6251c50c6ca53a9 *Scoop.Validator.dll
40a70bee96d108701f8f2e81392f9b79fd003f1cb4e1653ad2429753153fd7ee *validator.exe
2 changes: 1 addition & 1 deletion supporting/validator/bin/checksum.sha512
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
2fdf035661f349206f58ea1feed8805b7f9517a21f9c113e7301c69de160f184c774350a12a710046e3ff6baa37345d319b6f47fd24fbba4e042d54014bee511 *Newtonsoft.Json.dll
298d3d0b656acbb1fe5ed0c3abb49a640c47889184ab7bd4b594e51a7d7f829d5c8685edbd10a286fd56bfd8d601b9f187da463a5a9c8509365eddaea280642f *Newtonsoft.Json.Schema.dll
855ab2e30c9d523c9f321ae861c5969244185f660fa47e05cec96df8e2970d19843dbd3d89a0fca845544641915d1adf4b4a2145ef568dd99da7791e5064d70e *Newtonsoft.Json.Schema.dll
338793e6127330c0b05728291fcf18441127ffb56e1bd5c0f0588cd7436605f4b852f4bb622f655896a7eb7b1262add142b200fd5f37391b47d1401becb6b81c *Scoop.Validator.dll
d497c27b48f44f4cff270d3c8801b0cecc74108f8786a4a7c40e57541308ae33a69f5456cfc43ae1ce4214038d20da9fbeac1bcf76cc58d972863b58dab18401 *validator.exe
2 changes: 1 addition & 1 deletion supporting/validator/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net45" />
<package id="Newtonsoft.Json.Schema" version="3.0.14" targetFramework="net45" />
<package id="Newtonsoft.Json.Schema" version="3.0.15-beta2" targetFramework="net45" />
<package id="Microsoft.Net.Compilers.Toolset" version="4.2.0" targetFramework="net45" developmentDependency="true" />
</packages>
2 changes: 1 addition & 1 deletion supporting/validator/validator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json.Schema, Version=3.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
<HintPath>packages\Newtonsoft.Json.Schema.3.0.14\lib\net45\Newtonsoft.Json.Schema.dll</HintPath>
<HintPath>packages\Newtonsoft.Json.Schema.3.0.15-beta2\lib\net45\Newtonsoft.Json.Schema.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
Expand Down

0 comments on commit 4a31bd3

Please sign in to comment.