-
Notifications
You must be signed in to change notification settings - Fork 8
/
sabayon-detectobsolete
executable file
·65 lines (59 loc) · 1.65 KB
/
sabayon-detectobsolete
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/perl
# mudler <[email protected]>
# this tool requires querypkg
use Getopt::Long;
use strict;
use warnings;
my $arch;
my $verbose;
my $overlay;
GetOptions(
"arch=s" => \$arch,
"overlay=s" => \$overlay,
"verbose" => \$verbose
) or die("Error in command line arguments\n");
die("You should at least supply an overlay with --overlay") if !$overlay;
# Input: Overlay absolute path
# Output: array with package names (category/name)
sub get_packages {
keys %{
{ map {
s/$overlay\/|\.ebuild//g;
$_ = join( '/', ( split( /\//, $_ ) )[ 0, 1 ] );
$_ => 1
} glob( $_[0] . "/*/*/*.ebuild" )
}
};
}
# Input: package (category/name)
# Output: returns 1 if obsolete and can be removed
sub obsolete_package($$) {
my $package = $_[0];
my $arch = $_[1];
my $l_arch = ( defined $arch and $arch ne "" ? "--arch $arch" : "" );
print "querypkg -q $l_arch $package --show spm_repo\n" if $verbose;
my @out = `querypkg -q $l_arch $package --show spm_repo`;
chomp(@out);
return 1 if "@out" eq "";
foreach my $l (@out) {
print " >> $l\n" if $verbose;
return 1 if ( $l =~ /$package.*\{spm_repo\:gent.*/ );
}
return 0;
}
my @packages = get_packages($overlay);
my @obsoletes;
foreach my $p (@packages) {
print "[$p] Checking if there is a version in the repositories.... ";
print "\n" if $verbose;
if ( obsolete_package( $p, $arch ) ) {
print " OBSOLETE! \n";
push( @obsoletes, $p );
}
else {
print " ok \n";
}
}
print "\n";
print "Obsoletes found:\n\n";
print "$_\n" for @obsoletes;