Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Provide version comparison function for PkPackage

Đang mở
#826 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
12/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
c
Lĩnh vực
api

Hướng nghiên cứu

Start with the PkPackage object and pk_package_get_version(), which the issue says return backend-specific version strings. The proposed pk_package_compare_version() would need a backend hook set when each PkPackage is created, so the apt and dnf backends are the places where the comparison would differ. The issue leaves open whether to add a virtual function or normalise versions, and it has been idle for about 590 days, so a maintainer decision on the design comes first. Done would mean an agreed API plus per-backend comparison.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

tl;dr: Please provide a int pk_package_compare_version (PkPackage *self, const char *other_version) API, which calls a backend-specific version comparison algorithm for that PkPackage.


As I understand it, the version returned by pk_package_get_version() is in a numbering format defined by the backend it comes from, and the format is not documented in the PackageKit documentation (as far as I can tell). So the apt backend will return versions using the Debian versioning scheme while the dnf backend will return versions using the Fedora versioning scheme (or other RPM vendors’ version schemes).

This makes it problematic for PackageKit clients to compare the versions of two PkPackages to try and work out which one is newer. So algorithms like Appstream’s version comparison algorithm were invented, which try and work for all versioning schemes. But they have corner cases and can’t work perfectly. This leads to problems like https://gitlab.gnome.org/GNOME/gnome-software/-/issues/2273.

I think there are two ways to fix this:

  1. Define a single versioning format which is used by PackageKit, and require PackageKit backends to convert packages’ versions to this format when creating a PkPackage. I don’t think this is a good idea, because it means the version numbers the user sees might not correspond to what the distro tooling/website/command line clients use. It might also lead to loss of precision depending on how the conversion was implemented.
  2. Provide a version comparison virtual function on PkPackage, which is provided by the backend when it creates the PkPackage, and can be used by clients to compare the versions of any two PkPackages from that backend. So the dnf backend would provide a comparison function following the relevant dnf versioning scheme, the apt backend would provide an implementation of Debian version comparison, etc. and the client code doesn’t have to worry about the difference.

I hope I haven’t misunderstood the history or semantics of any of the PackageKit functionality here. I would be very happy to be told I’ve got it all wrong and either (1) or (2) is already implemented.

Ngôn ngữ chính
C
Star
360
Fork
196
Merge trung bình
4 ngày 24 phút
Pull request đã merge (30 ngày)
6

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của PackageKit/PackageKit

Tất cả issue của PackageKit/PackageKit

Issue tương tự

Thêm issue về C

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.