[pacman-dev] List packages from a given repo
Xavier
shiningxc at gmail.com
Fri May 9 13:44:55 EDT 2008
Dan McGee wrote:
>
> dmcgee at dublin /tmp
> $ time ./repopkg.orig testing | wc -l
> 28
>
> real 0m13.195s
> user 0m9.166s
> sys 0m3.343s
>
> dmcgee at dublin /tmp
> $ time ./repopkg testing | wc -l
> 28
>
> real 0m6.445s
> user 0m4.523s
> sys 0m1.203s
>
I still wasn't happy with the performance, so I tried to do it in perl
as you suggested. This is my first perl script so it wouldn't surprise
me if it was poorly written.
Also, I don't have testing repo enabled so I am not perfectly sure the
script works correctly, but it works fine with normal repos and the
performance difference is huge.
$ time ./repolist.sh extra | wc -l
372
real 0m4.739s
user 0m4.260s
sys 0m0.440s
$ time ./repolist.pl extra | wc -l
372
real 0m0.100s
user 0m0.070s
sys 0m0.020s
#!/usr/bin/perl
%count = ();
$output = `pacman -Sl $ARGV[0]`;
@sync = split(/\n/, $output);
foreach $pkg (@sync) {
@info = split(/ /, $pkg);
$pkg = @info[1] . " " . @info[2];
$count{$pkg}++;
}
$output = `pacman -Q`;
@local = split(/\n/, $output);
foreach $pkg (@local) {
$count{$pkg}++;
}
foreach $element (keys %count) {
if ($count{$element} == 2) {
push @{ \@intersection }, $element;
}
}
@intersection = sort @intersection;
foreach $pkg (@intersection) {
print $pkg . "\n";
}
Maybe someone can rewrite this in two lines? :D
More information about the pacman-dev
mailing list