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

Windows update script fails to account for milestone builds in current version check #1397

Open
j-vaughn opened this issue Jun 10, 2022 · 1 comment

Comments

@j-vaughn
Copy link

j-vaughn commented Jun 10, 2022

When the current version of OpenHAB is a milestone build, the milestone is not added back to to the concatenation of the reconstructed $CurrentVersion. This causes the script to prompt for reinstallation vs updating if you're updating from the x.y.z.M1 build to the x.y.z build.

image

This example is taken from 3.2.0.M1 with the following version.properties

openHAB Distribution Version Information
----------------------------------------
build-no        : Milestone Build
online-repo     : https://openhab.jfrog.io/openhab/libs-milestone

Repository        Version
----------------------------------------
openhab-distro  : 3.2.0.M1
openhab-core    : 3.2.0.M1
openhab-addons  : 3.2.0.M1
karaf           : 4.3.2

$CurrentVersion = $parts[0] + "." + $parts[1] + "." + $parts[2]

    if ($parts[2].EndsWith("-SNAPSHOT", "CurrentCultureIgnoreCase")) {
        $CurrentVersion = $parts[0] + "." + $parts[1] + "." + $parts[2].Substring(0, $parts[2].Length - "-SNAPSHOT".Length);
    }
    else {
        $CurrentVersion = $parts[0] + "." + $parts[1] + "." + $parts[2]
    }
    Write-Host -ForegroundColor Yellow "The current version is $CurrentVersion" 
@j-vaughn
Copy link
Author

j-vaughn commented Jun 10, 2022

I modified the concatenation of CurrentVersion to include the milestone:

    if ($parts[2].EndsWith("-SNAPSHOT", "CurrentCultureIgnoreCase")) {
        $CurrentVersion = $parts[0] + "." + $parts[1] + "." + $parts[2].Substring(0, $parts[2].Length - "-SNAPSHOT".Length);
    }
    else {
        $CurrentVersion = $parts[0] + "." + $parts[1] + "." + $parts[2]
        if($parts.length -eq 4) {
		$CurrentVersion = $CurrentVersion + "." + $parts[3]
	}
    }
    Write-Host -ForegroundColor Yellow "The current version is $CurrentVersion"   

The addition of the milestone to the CurrentVersion variable results in NormalizeVersionNumber rejecting it for not being 3 parts

$parts = $VersionNumber.Split(".")
if ($parts.Length -eq 2) {
    $parts += "0"
}
if ($parts.Length -ne 3) {
    throw "$VersionNumber is not formatted correctly (d.d.d)"
}

Modifying this (probably impacts other parts of the script yet to be seen) to be if( -not ($parts.Length -eq 3 -or $parts.Length -eq 4) gets the script to progress and the script now prompts for a downgrade due to "3.2.0" -lt "3.2.0.M1" being $True. Proceeding with the "downgrade" is successful and upgraded 3.2.0.M1 to 3.2.0.

I went back and looked and it appears the reinstallation warning ("Current version is equal to specified version ($OHVersionName). If you continue, you will REINSTALL $OHVersionName rather than upgrade.") is just a warning and actually has no impact. This made me think the way forward would be to just proceed as a "reinstallation" without all of the other modifications above, but there are other implications (such as the temporary backup being stored as 3.2.0 instead of 3.2.0.M1 which seem less than ideal)

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

No branches or pull requests

1 participant