forked from cms-sw/pkgtools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aptDeps.pl
executable file
·68 lines (52 loc) · 1.08 KB
/
aptDeps.pl
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
#!/usr/bin/env perl
#
#
#
# David Lange, LLNL.
#
use strict;
my $path=$ENV{'PATH'};
my @sp0=split(':',$path);
my $aptcacheInPath=0;
foreach my $p (@sp0) {
if ( -e "${p}/apt-cache" ) {
$aptcacheInPath=1;
last;
}
}
if ( $aptcacheInPath == 0 ) {
print "can not find apt-cache in PATH. Do you need to setup apt?\n";
exit;
}
my $narg=@ARGV;
if ( $narg == 0 ) {
print "usage: aptDeps.pl <rpm name1> .... <rpm nameN>\n";
print " returns the list of rpms that would be installed by apt\n";
}
my %deps;
my $nrpm=0;
foreach my $rpm (@ARGV) {
$deps{$rpm}=1;
$nrpm++;
}
my $nrpmlast=0;
while ( $nrpmlast != $nrpm ) {
$nrpmlast=$nrpm;
foreach my $rpm (keys %deps) {
my $newpacks=`apt-cache depends $rpm | grep Depends`;
my @sp1=split('\n',$newpacks);
foreach my $line (@sp1) {
if ( $line =~ /lcg\+/ || $line =~ /cms\+/ || $line =~ /external\+/ ) {
my @sp2=split(' ',$line);
my $newrpm=$sp2[1];
if ( !($deps{$newrpm}) ) {
$nrpm++;
$deps{$newrpm}=1;
}
}
}
}
}
foreach my $rpm (sort keys %deps) {
print "$rpm\n";
}