Skip to content

Commit

Permalink
Merge pull request #2342 from dgalbraith/sqlite-tools-64-bit-update
Browse files Browse the repository at this point in the history
(sqlite) Handle updated filenames and 64-bit tools
  • Loading branch information
JPRuskin authored Jun 13, 2024
2 parents e7c16c9 + f3e5431 commit 22dc35d
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 33 deletions.
10 changes: 10 additions & 0 deletions automatic/sqlite/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,13 @@ This package also installs sqlite tools by default - sqldiff, sqlite3, sqlite3_a
- `/NoTools` - Do not install sqlite tools

Example: `choco install sqlite --params "/NoTools"`

## Notes

- Beginning with v3.44.0 only 64-bit tools are available. If support for 32-bit
is required use the legacy version [sqlite 3.43.2](https://chocolatey.org/packages/sqlite/3.43.2).

```powershell
choco install sqlite --version='3.43.2'
choco pin add --name='sqlite' --version='3.43.2'
```
4 changes: 2 additions & 2 deletions automatic/sqlite/legal/VERIFICATION.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Package can be verified like this:

x32: https://sqlite.org/2023/sqlite-dll-win32-x86-3430200.zip
x64: https://sqlite.org/2023/sqlite-dll-win64-x64-3430200.zip
Toolsx32: https://sqlite.org/2023/sqlite-tools-win32-x86-3430200.zip
Toolsx64: https://sqlite.org/2023/sqlite-tools-win32-x86-3430200.zip

to download the files.

Expand All @@ -19,7 +19,7 @@ Package can be verified like this:

checksum32: 0B64B189CB41D065F9355DE93CE2F41C40865429801BEC3A555B30ACA839058C
checksum64: FA8981F39524F25FCC546C45A87FF4C1EEFD81FDC22F55A9BBE249155CDAF62E
checksumTools32: FAE9EFCCF4469CA69BE5D418FC088593CDB86E07A1B211BDB85463591A923B02
checksumTools64: FAE9EFCCF4469CA69BE5D418FC088593CDB86E07A1B211BDB85463591A923B02

File 'license.txt' is obtained from the following URL (and converted to markdown):
http://www.sqlite.org/copyright.html
19 changes: 16 additions & 3 deletions automatic/sqlite/sqlite.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<title>SQLite</title>
<owners>chocolatey-community</owners>
<authors>D. Richard Hipp, SQLite contributors</authors>
<licenseUrl>http://www.sqlite.org/copyright.html</licenseUrl>
<projectUrl>http://www.sqlite.org</projectUrl>
<licenseUrl>https://www.sqlite.org/copyright.html</licenseUrl>
<projectUrl>https://www.sqlite.org</projectUrl>
<iconUrl>https://cdn.jsdelivr.net/gh/chocolatey-community/chocolatey-packages@edba4a5849ff756e767cba86641bea97ff5721fe/icons/sqlite.svg</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description><![CDATA[SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine.
Expand Down Expand Up @@ -37,14 +37,27 @@ This package also installs sqlite tools by default - sqldiff, sqlite3, sqlite3_a
- `/NoTools` - Do not install sqlite tools
Example: `choco install sqlite --params "/NoTools"`
## Notes
- Beginning with v3.44.0 only 64-bit tools are available. If support for 32-bit
is required use the legacy version [sqlite 3.43.2](https://chocolatey.org/packages/sqlite/3.43.2).
```powershell
choco install sqlite --version='3.43.2'
choco pin add --name='sqlite' --version='3.43.2'
```
]]></description>
<summary>A DLL for the SQLite SQL database engine installed in your user path.</summary>
<tags>sql sqlite db database embedded foss cross-platform</tags>
<packageSourceUrl>https://github.com/chocolatey-community/chocolatey-packages/tree/master/automatic/sqlite</packageSourceUrl>
<projectSourceUrl>http://www.sqlite.org/src</projectSourceUrl>
<projectSourceUrl>https://www.sqlite.org/src</projectSourceUrl>
<bugTrackerUrl>https://www.sqlite.org/src/rptview?rn=1</bugTrackerUrl>
<docsUrl>https://sqlite.org/docs.html</docsUrl>
<mailingListUrl>https://sqlite.org/forum/forum</mailingListUrl>
<releaseNotes>https://sqlite.org/changes.html</releaseNotes>
<copyright>None - SQLite has been dedicated to the public domain</copyright>
<dependencies>
<dependency id="chocolatey-core.extension" version="1.3.3" />
</dependencies>
Expand Down
17 changes: 9 additions & 8 deletions automatic/sqlite/tools/chocolateyInstall.ps1
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
$ErrorActionPreference = 'Stop'

$toolsDir = Split-Path $MyInvocation.MyCommand.Definition
$embedded_path = if ((Get-OSArchitectureWidth 64) -and $env:chocolateyForceX86 -ne 'true') {
Write-Host "Installing 64 bit version"; Get-Item "$toolsDir\*dll*win64*.zip"
} else { Write-Host "Installing 32 bit version"; Get-Item "$toolsDir\*dll*win32*.zip" }

$packageArgs = @{
PackageName = 'sqlite'
FileFullPath = $embedded_path
Destination = $toolsDir
PackageName = 'sqlite'
FileFullPath = "$toolsDir\sqlite-dll-win-x86-3430200.zip"
FileFullPath64 = "$toolsDir\sqlite-dll-win-x64-3430200.zip"
Destination = $toolsDir
}
Get-ChildItem $toolsDir\* | Where-Object { $_.PSISContainer } | Remove-Item -Recurse -Force #remove older package dirs
Get-ChocolateyUnzip @packageArgs

$pp = Get-PackageParameters
if (!$pp.NoTools) {
if ((Get-OSArchitectureWidth -Compare 32) -or ($env:chocolateyForceX86 -eq 'true')) {
Write-Error -Message "The 32-bit version of sqlite tools is not available after version 3.43.2" -Category ResourceUnavailable
}
Write-Host "Installing tools"
$packageArgs.FileFullPath = Get-Item "$toolsDir\*tools*win32*.zip"
$packageArgs.FileFullPath64 = "$toolsDir\sqlite-tools-win-x86-3430200.zip"
Get-ChocolateyUnzip @packageArgs
}

Remove-Item $toolsDir\*.zip -ea 0
Remove-Item $toolsDir\*.zip -ea 0
61 changes: 41 additions & 20 deletions automatic/sqlite/update.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,25 @@ function global:au_SearchReplace {
".\legal\VERIFICATION.txt" = @{
"(?i)(\s+x32:).*" = "`${1} $($Latest.URL32)"
"(?i)(\s+x64:).*" = "`${1} $($Latest.URL64)"
"(?i)(\s+Toolsx32:).*" = "`${1} $($Latest.URLTools32)"
"(?i)(\s+Toolsx64:).*" = "`${1} $($Latest.URLTools64)"
"(?i)(checksum32:).*" = "`${1} $($Latest.Checksum32)"
"(?i)(checksum64:).*" = "`${1} $($Latest.Checksum64)"
"(?i)(checksumTools32:).*" = "`${1} $($Latest.ChecksumTools32)"
"(?i)(checksumTools64:).*" = "`${1} $($Latest.ChecksumTools64)"
}
".\tools\chocolateyInstall.ps1" = @{
"sqlite-dll-win-x86.+\.zip" = "$($Latest.Filename32)"
"sqlite-dll-win-x64.+\.zip" = "$($Latest.Filename64)"
"sqlite-tools-win-x.+\.zip" = "$($Latest.FilenameTools64)"
}
}
}

function global:au_BeforeUpdate {
Get-RemoteFiles -Purge -NoSuffix
$tools_name = $Latest.URLTools32 -split '/' | Select-Object -Last 1
Invoke-WebRequest $Latest.URLTools32 -OutFile tools\$tools_name
$Latest.ChecksumTools32 = Get-FileHash tools\$tools_name | ForEach-Object Hash
$tools_name = $Latest.URLTools64 -split '/' | Select-Object -Last 1
Invoke-WebRequest $Latest.URLTools64 -OutFile tools\$tools_name
$Latest.FilenameTools64 = $tools_name
$Latest.ChecksumTools64 = Get-FileHash tools\$tools_name | ForEach-Object Hash
}

function global:au_GetLatest {
Expand All @@ -30,35 +36,50 @@ function global:au_GetLatest {
}

function url_exists( [string] $Url ) {
try { ([System.Net.WebRequest]::Create($Url)).GetResponse().Close(); return $true } catch { return $false }
try {
([System.Net.WebRequest]::Create($Url)).GetResponse().Close()
return $true
} catch {
return $false
}
}

$download_page = Invoke-WebRequest -Uri $releases
$version32 = get_version 32
$version64 = get_version 64

$re = '\-win\d\d\-.+\.zip'
$url = $download_page.links | Where-Object href -match $re | ForEach-Object { 'https://sqlite.org/' + $_.href }
$url32 = $url -like '*dll*win32*' | Select-Object -First 1
$url64 = $url -like '*dll*win64*' | Select-Object -First 1
$urlTools32 = $url -like '*tools*win32*'| Select-Object -First 1
$re = '\-win-x\d\d\-.+\.zip'
$urls = $download_page.links | Where-Object href -match $re | ForEach-Object { 'https://sqlite.org/' + $_.href }
$url32 = $urls -like '*dll*win-x86*' | Select-Object -First 1
$url64 = $urls -like '*dll*win-x64*' | Select-Object -First 1
$urlTools64 = $urls -like '*tools*win-x64*' | Select-Object -First 1

# https://github.com/chocolatey/chocolatey-coreteampackages/issues/733
if ($version32 -eq $version64) { $Version = $version32 }
else {
if ($version32 -eq $version64) {
$Version = $version32
} else {
$u32 = $url64 -replace 'win-x64', 'win-x86'
$u64 = $url64 -replace 'win-x86', 'win-x64'

$u32 = $url64 -replace 'win64', 'win32'
$u64 = $url64 -replace 'win32', 'win64'

if (url_exists $u32) { $Version = $version64; $url32 = $u32 }
elseif (url_exists $64) { $Version = $version32; $url64 = $u64 }
else {
if (url_exists $u32) {
$version = $version64
$url32 = $u32
} elseif (url_exists $64) {
$version = $version32
$url64 = $u64
} else {
Write-Host "Can't find common version for x32 and x64 architecture."
return 'ignore'
}
}

@{ Version = $version; URL32 = $url32; URL64 = $url64; URLTools32 = $urlTools32; PackageName = 'SQLite' }
@{
Version = $version
URL32 = $url32
URL64 = $url64
URLTools64 = $urlTools64
PackageName = 'SQLite'
}
}

update -ChecksumFor none

0 comments on commit 22dc35d

Please sign in to comment.