Skip to content

Commit

Permalink
(sqlite) Handle updated filenames and 64-bit tools
Browse files Browse the repository at this point in the history
Package was failing to build due to updates in the filename format from
sqlite-dll-win32-3432000.zip to sqlite-dll-win-x86-3440000.zip.  The
tools package has also been modified from 32-bit to 64-bit.

Modified filename handling in the update script to correctly process the
new filename format and modified the install script to handle the 64-bit
tools package.
  • Loading branch information
dgalbraith committed Nov 4, 2023
1 parent c37769d commit 21cad2a
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 35 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
21 changes: 17 additions & 4 deletions automatic/sqlite/sqlite.nuspec
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. -->
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>SQLite</id>
<version>3.43.2</version>
<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 = (Get-Item "$toolsDir\*dll*win-x86*.zip")
FileFullPath64 = (Get-Item "$toolsDir\*dll*win-x64*.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 "32-bit version of sqlite tools not available after version 3.43.2" -Category ResourceUnavailable
}
Write-Host "Installing tools"
$packageArgs.FileFullPath = Get-Item "$toolsDir\*tools*win32*.zip"
$packageArgs.FileFullPath64 = Get-Item "$toolsDir\*tools*win-x64*.zip"
Get-ChocolateyUnzip @packageArgs
}

Remove-Item $toolsDir\*.zip -ea 0
Remove-Item $toolsDir\*.zip -ea 0
42 changes: 21 additions & 21 deletions automatic/sqlite/update.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,50 @@ $releases = 'https://sqlite.org/download.html'
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)(checksum32:).*" = "`${1} $($Latest.Checksum32)"
"(?i)(checksum64:).*" = "`${1} $($Latest.Checksum64)"
"(?i)(checksumTools32:).*" = "`${1} $($Latest.ChecksumTools32)"
"(?<=x32:\s).*" = "$($Latest.URL32)"
"(?<=\sx64:\s).*" = "$($Latest.URL64)"
"(?<=\sToolsx64:\s).*" = "$($Latest.URLTools64)"
"(?<=checksum32:).*" = "$($Latest.Checksum32)"
"(?<=checksum64:).*" = "$($Latest.Checksum64)"
"(?<=checksumTools64:\s).*" = "$($Latest.ChecksumTools64)"
}
}
}

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.ChecksumTools64 = Get-FileHash tools\$tools_name | ForEach-Object Hash
}

function global:au_GetLatest {
function get_version( [int]$Bit=32 ) {
$version = $download_page.AllElements | Where-Object tagName -eq 'td' | Where-Object InnerHtml -match "$Bit-bit DLL .+ for SQLite version" | ForEach-Object InnerHtml
$version -match '((?:\d+\.)+)' | out-null
$Matches[0] -replace '\.$'
$re = '(?<=,)(?<Version>.+),(?<Filename>\d*\/sqlite-dll-win-x{0}.+\.zip)' -f ((86, $Bit)[!($Bit -eq 32)])
$download_page.Content -match $re | Out-Null
$Matches.Version
}

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

$download_page = Invoke-WebRequest -Uri $releases
$download_page = Invoke-WebRequest -Uri $releases -UseBasicParsing
$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 = '(?<=,)\d{4}/sqlite-.+-win-x\d{2}-\d{7}\.zip'
$urls = $download_page.Content | Select-String -Pattern $re -AllMatches | ForEach-Object { $_.Matches } | ForEach-Object { 'https://sqlite.org/' + $_.Groups[0].Value}
$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 {

$u32 = $url64 -replace 'win64', 'win32'
$u64 = $url64 -replace 'win32', 'win64'
$u32 = $url64 -replace 'win-x64', 'win-x86'
$u64 = $url64 -replace 'win-x86', 'win-x64'

if (url_exists $u32) { $Version = $version64; $url32 = $u32 }
elseif (url_exists $64) { $Version = $version32; $url64 = $u64 }
Expand All @@ -58,7 +58,7 @@ function global:au_GetLatest {
}
}

@{ 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 21cad2a

Please sign in to comment.