Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(mysql) Fix automatic MySQL update in update.ps1 #214

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lauxjpn
Copy link

@lauxjpn lauxjpn commented Sep 29, 2023

Description

  • Changes the defunct download URL to the currently used one.
  • Uses the GitHub tags page to get the latest release version number, instead of the download page of the MySQL site (an alternative would be to parse https://api.github.com/repos/mysql/mysql-server/tags instead).
  • Specifies the mainline version prefix, since there can be multiple maintained release lines by Oracle.

Motivation and Context

  • The currently used download URL is incorrect, because it was changed on the MySQL website.
  • It is currently not possible to get the latest version, because the MySQL website requires a JavaScript enabled browser.

How Has this Been Tested?

I ran the update script locally:

PS C:\Repositories\chocolatey-packages\automatic\mysql> .\update.ps1
mysql - checking updates using au version 2022.10.24

URL check
  https://cdn.mysql.com/Downloads/MySQL-8.0/mysql-8.0.34-winx64.zip
nuspec version: 8.0.31
remote version: 8.0.34
New version is available
Automatic checksum started
Adding 'C:\tools\mysql\current\bin' to the path and the current shell path
PATH environment variable does not have C:\tools\mysql\current\bin in it. Adding...
Using system proxy server ''.
Downloading chocolatey\mysql 64 bit
  from 'https://cdn.mysql.com/Downloads/MySQL-8.0/mysql-8.0.34-winx64.zip'
Using system proxy server ''.

Download of mysql-8.0.34-winx64.zip (231,68 MB) completed.
Package downloaded and hash calculated for 64 bit version
Setting package description from README.md
Updating files
  $Latest data:
    Checksum64                (String)     d0480039bceef97a558027bfb868b77be1717ec1097410c697db383315243895
    ChecksumType64            (String)     sha256
    FileType                  (String)     zip
    NuspecVersion             (String)     8.0.31
    PackageName               (String)     mysql
    URL64                     (String)     https://cdn.mysql.com/Downloads/MySQL-8.0/mysql-8.0.34-winx64.zip
    Version                   (String)     8.0.34
  mysql.nuspec
    setting id: mysql
    updating version: 8.0.31 -> 8.0.34
  tools\chocolateyInstall.ps1
    (^[$]checksumType\s*=\s*)('.*')     = $1'sha256'
    (^[$]url\s*=\s*)('.*')              = $1'https://cdn.mysql.com/Downloads/MySQL-8.0/mysql-8.0.34-winx64.zip'
    (^[$]checksum\s*=\s*)('.*')         = $1'd0480039bceef97a558027bfb868b77be1717ec1097410c697db383315243895'
Attempting to build package from 'mysql.nuspec'.
Successfully created package 'C:\Repositories\chocolatey-packages\automatic\mysql\mysql.8.0.34.nupkg'

Package updated

Path          : C:\Repositories\chocolatey-packages\automatic\mysql
Name          : mysql
Updated       : True
Pushed        : False
RemoteVersion : 8.0.34
NuspecVersion : 8.0.31
Result        : {mysql - checking updates using au version 2022.10.24, , URL check,   https://cdn.mysql.com/Downloads/MySQL-8.0/mysql-8.0.34-winx64.zip…}
Error         :
NuspecPath    : C:\Repositories\chocolatey-packages\automatic\mysql\mysql.nuspec
NuspecXml     : #document
Ignored       : False
IgnoreMessage :
StreamsPath   : C:\Repositories\chocolatey-packages\automatic\mysql\mysql.json
Streams       :

Screenshot (if appropriate, usually isn't needed):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Migrated package (a package has been migrated from another repository)

Checklist:

  • My code follows the code style of this repository.
  • My change requires a change to documentation (this usually means the notes in the description of a package).
  • I have updated the documentation accordingly (this usually means the notes in the description of a package).
  • I have updated the package description and it is less than 4000 characters.
  • All files are up to date with the latest Contributing Guidelines
  • The added/modified package passed install/uninstall in the chocolatey test environment.
  • The changes only affect a single package (not including meta package).

@AppVeyorBot
Copy link

✅ Package verification completed without issues. PR is now pending human review

Copy link
Owner

@mkevenaar mkevenaar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #215

@@ -1,6 +1,7 @@
import-module au

$releases = 'https://dev.mysql.com/downloads/mysql/'
$releases = 'https://github.com/mysql/mysql-server/tags'
$mainlineVersionPrefix = '8.0.'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as #215

@@ -15,11 +16,10 @@ function global:au_SearchReplace {
function global:au_GetLatest {
$download_page = Invoke-WebRequest -Uri $releases

$version = ($download_page.ParsedHtml.getElementsByTagName('h1') | Where-Object innerhtml -match "^MySQL Community Server ").innerhtml -replace "^MySQL Community Server "
$versiondata = Get-Version($version)
$versiondata = $download_page.Links.Href | Where-Object { $_ -match '^/mysql/mysql-server/releases/tag/mysql-(\d+\.\d+\.\d+)$' -and $Matches[1].StartsWith($mainlineVersionPrefix) } | ForEach-Object { Get-Version $_ } | Sort-Object -Property Version -Descending | Select-Object -First 1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as #215

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants