juhp / pkgtreediff

Tool for comparing rpm package trees
https://hackage.haskell.org/package/pkgtreediff
GNU General Public License v3.0
5 stars 2 forks source link

Confusion when repo. has multiple versions of packages #3

Closed james-antill closed 4 years ago

james-antill commented 4 years ago

If you look at the difference between two repos. which contain multiple versions of the same package) pkgtreediff gets confused about versions and what to report. Eg.

pkgtreediff  -p yum\* \
  http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages \
  http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/Packages

...gives this output:

yum.noarch: 4.2.7-6.el8 -> 4.2.17-3.el8
yum.noarch: 4.2.7-7.el8_1 -> 4.2.7-6.el8
+ yum.noarch  4.2.7-7.el8_1
yum-utils.noarch: 4.0.8-3.el8 -> 4.0.12-1.el8
+ yum-utils.noarch  4.0.8-3.el8

Looking at the repos. directly we see (currently):

8:

yum-4.2.7-6.el8.noarch.rpm
yum-4.2.7-7.el8_1.noarch.rpm
yum-utils-4.0.8-3.el8.noarch.rpm

8-stream:

yum-4.2.7-6.el8.noarch.rpm
yum-4.2.7-7.el8_1.noarch.rpm
yum-4.2.17-3.el8.noarch.rpm
yum-utils-4.0.8-3.el8.noarch.rpm
yum-utils-4.0.12-1.el8.noarch.rpm

...expected/desired output would be just:

+ yum.noarch  4.2.17-3.el8
+ yum-utils.noarch  4.0.12-1.el8
juhp commented 4 years ago

Aha thanks for reporting this - yeah I think there is an implicit assumption of no package duplicates... I need to think how to address this. Is that expected for centos or a transient thing?

james-antill commented 4 years ago

That's probably expected for stream, at least in the short term.

One thing that would make it much easier is if you could sort using a variant of "version sort" (https://www.gnu.org/software/coreutils/manual/html_node/Details-about-version-sort.html), rpmvercmp isn't exactly the same but it's much closer than lexical sort.

juhp commented 4 years ago

Yeah, thanks you are right that sort -V basically does close to the right thing.

Edit: I found this reference more helpful here than this detailed algorithm.

juhp commented 4 years ago

Finally had time to look into this and pretty happy with the result. I will release 0.4 soon and push it to my copr repo. But do let me know if works for you or if you have more feedback, thanks.

juhp commented 4 years ago

I released 0.4 today and updated my copr repo.