| 1 | 1 | ▶ | use FileHandle (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | requires.PL - work out which RPMs are being used by Link_Controller. | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | Based on the bundle file this works out the list of RPMs that are | ||||||||||||||||||||||||||||
| 10 | required to install Link_Controller | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | =head1 BUGS | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | This is rather carless about running RPM on systems which don't have | ||||||||||||||||||||||||||||
| 15 | it but should result in an empty output file anyway. | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | =cut | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 1 | ▶ | END { | ||||||||||||||||||||||||||
|
Subroutine
END: called CC=2 SCAR=10.5
| |||||||||||||||||||||||||||||
| 21 | 1 | ▶ | $? && do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | 0 | print STDERR <<EOF; | |||||||||||||||||||||||||||
| 23 | requires.PL tried to give non zero exit status: $?. Exiting zero | ||||||||||||||||||||||||||||
| 24 | instead. This allows build to proceed even if RPM isn't present. You | ||||||||||||||||||||||||||||
| 25 | probably don't need to worry about this unless you were trying to | ||||||||||||||||||||||||||||
| 26 | build an RPM of this software | ||||||||||||||||||||||||||||
| 27 | EOF | ||||||||||||||||||||||||||||
| 28 | 0 | $? = 0; | |||||||||||||||||||||||||||
| 29 | }; | ||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 1 | $found=0; | |||||||||||||||||||||||||||
| 33 | 1 | DIRCHECK: foreach (split /:/, $ENV{"PATH"}) { | |||||||||||||||||||||||||||
| 34 | 10 | ▶ | -x $_ . '/' . 'cdbmake' && do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 0 | $found=1; | |||||||||||||||||||||||||||
| 36 | 0 | last DIRCHECK; | |||||||||||||||||||||||||||
| 37 | }; | ||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | 1 | ▶ | unless ($found) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 1 | ▶ | print STDERR <<EOF unless $found; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | No rpm program found so we won't try to generate dependency file | ||||||||||||||||||||||||||||
| 42 | EOF | ||||||||||||||||||||||||||||
| 43 | 1 | exit 0; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | #It would be nice to implement this using the functions from CPAN | ||||||||||||||||||||||||||||
| 47 | #which read the contents of a bundle but they don't seem to be | ||||||||||||||||||||||||||||
| 48 | #stable. | ||||||||||||||||||||||||||||
| 49 | # | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 0 | $bfile="lib/Bundle/Link_Controller.pm"; | |||||||||||||||||||||||||||
| 52 | 0 | $verbose=0; | |||||||||||||||||||||||||||
| 53 | 0 | @result=(); | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 0 | my $fh = FileHandle->new; | |||||||||||||||||||||||||||
| 56 | 0 | ▶ | open($fh,$bfile) or die "Could not open '$bfile': $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | #straight from CPAN module | ||||||||||||||||||||||||||||
| 59 | 0 | ▶ | while (<$fh>) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | 0 | ▶ | $inpod = m/^=(?!head1\s+CONTENTS)/ ? 0 : | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 61 | m/^=head1\s+CONTENTS/ ? 1 : $inpod; | ||||||||||||||||||||||||||||
| 62 | 0 | ▶ | next unless $inpod; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | 0 | ▶ | next if /^=/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | 0 | ▶ | next if /^\s+$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | 0 | chomp; | |||||||||||||||||||||||||||
| 66 | 0 | push @result, (split " ", $_, 2)[0]; | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | 0 | close $fh; | |||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 0 | $rfile = "pkg-data-rpm/requires"; | |||||||||||||||||||||||||||
| 71 | 0 | my $rfh = FileHandle->new; | |||||||||||||||||||||||||||
| 72 | 0 | ▶ | open($rfh,"> $rfile") or die "Could not open '$bfile': $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 0 | my @foundrpm=(); | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 0 | MOD: foreach my $mod (@result) { | |||||||||||||||||||||||||||
| 77 | 0 | $mod=~ s,::,/,g; | |||||||||||||||||||||||||||
| 78 | 0 | $mod .= ".pm"; | |||||||||||||||||||||||||||
| 79 | 0 | foreach my $ldir (@INC) { | |||||||||||||||||||||||||||
| 80 | 0 | my $modf=$ldir . '/' . $mod; | |||||||||||||||||||||||||||
| 81 | 0 | ▶ | print "try $modf\n" if $verbose & 8; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | 0 | ▶ | -e $modf or next; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 83 | 0 | my $pkg = `rpm -qf $modf`; | |||||||||||||||||||||||||||
| 84 | 0 | chomp $pkg; | |||||||||||||||||||||||||||
| 85 | 0 | ▶ | $pkg =~ m/\s/ and do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | 0 | warn "didn't expect a space from rpm"; | |||||||||||||||||||||||||||
| 87 | 0 | ▶ | print "rpm gave $pkg\n" if $verbose & 2; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | 0 | next; | |||||||||||||||||||||||||||
| 89 | }; | ||||||||||||||||||||||||||||
| 90 | 0 | ▶ | print "was in $pkg\n" if $verbose & 2; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | 0 | $pkg =~ s/-[^-]+-[^-]+$//; | |||||||||||||||||||||||||||
| 92 | 0 | ▶ | $pkg && ( push @foundrpm, $pkg ) or | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$pkg and push @foundrpm, $pkg
MC/DC0%0/2
$pkg and push @foundrpm, $pkg
$pkg
push @foundrpm, $pkg
Truth table0%0/3
A and B
A= $pkgB= push @foundrpm, $pkg
| |||||||||||||||||||||||||||||
| 93 | warn "File $modf doesn't belong to an rpm"; | ||||||||||||||||||||||||||||
| 94 | 0 | next MOD; | |||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 0 | push @foundrpm, | |||||||||||||||||||||||||||
| 99 | "cdb"; | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 0 | my @reqrpm=sort @foundrpm; | |||||||||||||||||||||||||||
| 102 | 0 | push @reqrpm, ""; #terminator | |||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 0 | ▶ | for(my $i=0; $i < $#reqrpm; $i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 105 | 0 | my $reps=1; | |||||||||||||||||||||||||||
| 106 | 0 | ▶ | $reps++ while ( $reqrpm[$i] eq $reqrpm[$i+$reps] ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 107 | 0 | splice (@reqrpm, $i+1, ($reps - 1) ); | |||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 0 | print $rfh join("\n", @reqrpm ); | |||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||