Skip to content

Conversation

@benprew
Copy link

@benprew benprew commented May 10, 2025

Fixes #129

Previous and after my change
Screenshot from 2025-05-08 20-12-12
Screenshot from 2025-05-08 20-12-46

src/Package.vala Outdated
} else if (a_num > b_num) {
return 1;
}
return 0;

Choose a reason for hiding this comment

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

for the strings "32.17.3" and "32.17.10" the method will return 0 and this is the culprit. Remove it and add a if(i == length-1) like in the original code

src/Package.vala Outdated
string[] aparts = aver.split (".");
string[] bparts = bver.split (".");

int length = int.max (aparts.length, bparts.length);

Choose a reason for hiding this comment

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

this is not a problem coincidentally because you have return 0, but if you do it correctly it will cause out of array error, replace it with int.min and do the length comparison as above

src/Package.vala Outdated
bool b_is_num = int.try_parse(bparts[i], out b_num);

if (a_is_num && b_is_num) {
if (a_num < b_num) {

Choose a reason for hiding this comment

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

if(a_num != b_num)
return a_num - b_num;

is also faster for cpu than comparisons

@camilajenny
Copy link

We should diligently adhere to the version comparison specification, as described on the Debian site, see https://www.debian.org/doc/debian-policy/ch-controlfields.html#version. It's not only about the upstream version split by . which you tried to implement, but also about epochs. I'm working on it, I will create a pull request to your code @benprew when I'm ready!

Copy link

@camilajenny camilajenny left a comment

Choose a reason for hiding this comment

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

I will create a pr to your code when I'm ready

src/Package.vala Outdated
}
return 0;
} else {
return strcmp (aparts[i], bparts[i]);

Choose a reason for hiding this comment

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

this changes the contract as strcmp doesn't have to return either -1, or 1 but any negative or positive number (cmp. below)

src/Package.vala Outdated

int rc = compare_versions (package.get_version (), version);
int rc = compare_versions (package.get_version (), version);
if (rc == 1) {

Choose a reason for hiding this comment

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

see above

@camilajenny
Copy link

@benprew Thank you for your effort contributing to this project. As it turns out, the version problem annoyed me as well. Let's improve it together. I created a pull request improving your solution, please let me know what you think! benprew#1

@benprew
Copy link
Author

benprew commented Jul 7, 2025

Update to support different debian version schemes, with tests! Thanks camilajenny!

@benprew
Copy link
Author

benprew commented Jul 7, 2025

@donadigo Are you able to review this PR? Are you still supporting eddy?

Thanks

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.

Unexpected downgrade prompt opening newer version of .deb

2 participants