-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Outdated apps are not considered outdated by Scoop #4489
Comments
@niheaven could you take a look at this? |
The lastest version of While checking outdated apps, ffmpeg is NOT marked as outdated, the problem is before Maybe we should optimize the |
not familiar with pwsh, but try to make a quick & dirty fix class VersionPoc {
[string] $Main
[string] $Sub
}
function GetVersion( $ver ) {
$arr = $ver -split '[-_]'
$v = New-Object VersionPoc
$v.Main = $arr[0]
if ($arr.count -gt 1) {
$v.Sub = $arr[1]
}
return $v
}
function version($ver) {
$ver -split '[\.]' | ForEach-Object {
$num = $_ -as [int]
if($num) { $num } else { $_ }
}
}
function compare_versions($a, $b) {
$ver_a = @(version $a)
$ver_b = @(version $b)
for($i=0;$i -lt $ver_a.length;$i++) {
if($i -gt $ver_b.length) { return 1; }
# don't try to compare int to string
if($ver_b[$i] -is [string] -and $ver_a[$i] -isnot [string]) {
$ver_a[$i] = "$($ver_a[$i])"
}
if($ver_a[$i] -gt $ver_b[$i]) { return 1; }
if($ver_a[$i] -lt $ver_b[$i]) { return -1; }
}
if($ver_b.length -gt $ver_a.length) { return -1 }
return 0
}
function cmpver($a, $b) {
$res = compare_versions GetVersion($a).Main, GetVersion($b).Main
if ($res -ne 0) { return $res }
return compare_versions GetVersion($a).Sub, GetVersion($b).Sub
}
cmpver 4.4.1-2 4.4-190
cmpver '5.1.10_1' '5.1.9_1' execution result:
However, the version number is very variable, sometimes even git commit sha would appears. I think we should do a well-rounded review on version numbers in scoop manifests, then we will know how to cover more cases. |
data from main, extra and dorado bucket. do not include versions full of digit,
|
@batkiz Nice try, but it still only handles Scoop is a system that tries to "receive" all software out there. It is impossible to create ONE algorithm that describes version comparison for every single app. What I'm thinking of is that, Scoop should decide to support one versioning scheme (e.g. semver), and allow bucket maintainer to convert any non-standard version to this scheme. The conversion could be arbitrary, as long as it's ordered. For example, suppose we have wezterm's two versions: If it's so weird, like zeronet's If the version is already standard, obviously no conversion is needed. |
It's confusing if the scoop version is different with the official version for users, if in this way, maybe an internal version field should be introduced to scoop. I'm thinking maybe we could add version compare field to manifest, like |
The version I mentioned is internal. I was thinking of a new "version_conversion" field in the manifest that defines a function, where Scoop would call this function with the $version (which is public to user) as input and use the output for comparison (which could never be shown to user). The Later, Scoop could even pre-define some common conversion function, like "convert arbitrary string-like version to Basically what you said, but instead of |
that's what I thought, I meant it's value would be powershell script like pre_install. |
Ref: #3721 Please wait a moment for this PR being merged 😢 |
@niheaven I see the PR is merged. However, if I test |
The PR was merged into |
No worry. I'm using main branch. I just want to chime in before it goes main. I see there are many test cases, but it bounds to miss some, like |
@CrendKing Fixed in ae89213 |
Thank you for the quick fix. However, may I suggest that instead of comparing "_8" against "_9", compare "_10" against "_9", because the latter would fail if the function is a ASCII comparison (like before)? It would catch more potential bugs and regressions. |
Added it, thanks. Any other problem or this should be closed 😄 |
I believe you. Thanks! |
I have kicad-lite installed from the Extras bucket. Currently the latest version is
5.1.10_1
, while my installed version is5.1.9_1
.scoop update
doesn't update anything. Upon digging, I found that thecompare_versions
function is the culprit.To reproduce, simply run
compare_versions '5.1.10_1' '5.1.9_1'
and you will get result -1, which means NOT outdated, which is wrong. The problem is basically'10_1' -gt '9_1'
is false and'10_1 -lt '9_1'
is true. Maybe we should pad "0"s in the front before comparing, such asI can create a pull request if this is OK.
The text was updated successfully, but these errors were encountered: