/
findaurdups
executable file
·44 lines (36 loc) · 1023 Bytes
/
findaurdups
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/perl
use warnings 'FATAL' => 'all';
use strict;
use HTTP::Tiny;
use JSON;
my @corepkgs;
open my $distfh, 'cat core.dists | ./dist2pkg |' or die "open: $!";
@corepkgs = sort map { (split)[0] } <$distfh>;
close $distfh;
my $httpc = HTTP::Tiny->new;
my $url = "http://juster.us/aurpc/packages/perl-*";
my @aurpkgs;
while($url){
print STDERR $url, "\n";
my $resp = $httpc->get($url);
die $resp->{'reason'} unless($resp->{'success'});
$resp = decode_json($resp->{'content'});
push @aurpkgs,
map { [ $_->{'name'}, $_->{'version'}, $_->{'author'} ] }
@{$resp->{'matches'}};
$url = $resp->{'next_url'};
}
@aurpkgs = sort { $a->[0] cmp $b->[0] } @aurpkgs;
# Go through the two sorted lists, akin to 'uniq -d'.
my($i, $j) = (0, 0);
while($i < @corepkgs && $j < @aurpkgs){
if($corepkgs[$i] lt $aurpkgs[$j][0]){
$i++;
}elsif($corepkgs[$i] gt $aurpkgs[$j][0]){
$j++;
}else{
print "@{$aurpkgs[$j]}\n";
$i++;
$j++;
}
}