travis/cleanup-bintray: use dpkg --compare-versions (#2453)
…instead of lexicographically sorting strings, which fails for the
following situation:
4.12-96-g086276b
4.12-97-g59c070b
4.12-108-gb850cfb
This bug resulted in new packages being built and uploaded, then
immediately deleted.
Thanks to eeemsi for reporting the issue.
Michael Stapelberg authored 7 years ago
GitHub committed 7 years ago
24 | 24 | my $resp = $client->get($apiurl); |
25 | 25 | die "Getting versions failed: HTTP status $resp->{status} (content: $resp->{content})" unless $resp->{success}; |
26 | 26 | my $decoded = decode_json($resp->{content}); |
27 | my @versions = reverse sort @{$decoded->{versions}}; | |
27 | my @versions = reverse sort { | |
28 | (system("/usr/bin/dpkg", "--compare-versions", "$a", "gt", "$b") == 0) ? 1 : -1 | |
29 | } @{$decoded->{versions}}; | |
28 | 30 | |
29 | 31 | # Keep the most recent 5 versions. |
30 | 32 | splice(@versions, 0, 5); |