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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
|
#! @PERL@
@GPT_PERL_INITIALIZER@
use strict;
use Getopt::Long;
use Config;
#
# Do a perl check for version >= 5.005.
#
if ( ! ( defined eval "require 5.005" ) )
{
die "GPT requires at least Perl version 5.005";
}
my $verbose = 0;
if ( ! ( defined eval "require Grid::GPT::GPTObject" ) )
{
die("$prefix does not appear to hold a valid GPT installation\n");
}
require Pod::Usage;
# test for the existance of a local file sorting module
my $filelistclass;
if (-f "MyFilelists.pm") {
require MyFilelists;
$filelistclass = "MyFilelists";
} else {
require Grid::GPT::MyFilelists;
$filelistclass = "Grid::GPT::MyFilelists";
}
use Cwd;
my $VERSION = 0.01;
my $srcdir = cwd();
my $flavor;
my ($help, $man, $pkgfile);
# sub pod2usage {
# my $ex = shift;
# print "gpt_sort_file [-verbose -help] -flavor=build_flavor -pkgfile=pkg_data_src.gpt master_filelist\n";
# exit $ex;
# }
GetOptions( "flavor=s" => \$flavor,
'pkg=s' => \$pkgfile,
'verbose=i' => \$verbose, 'help' => \$help)
or Pod::Usage::pod2usage(1);
Pod::Usage::pod2usage(0) if $help;
my $masterlist = shift;
my $static = shift;
if (!defined($masterlist)) {
print STDERR "ERROR: Need master filelist filename \n";
Pod::Usage::pod2usage(1);
}
if (!defined($flavor)) {
print STDERR "ERROR: Need build flavor \n";
Pod::Usage::pod2usage(1);
}
require Grid::GPT::PackageFactory;
require Grid::GPT::V1::Package;
require Grid::GPT::V1::Definitions;
my $mangling = 1;
if (defined $pkgfile) {
my $factory = new Grid::GPT::PackageFactory;
my $pkg = $factory->type_of_package($pkgfile);
$pkg->read_metadata_file($pkgfile);
if (defined $pkg->ColocateLibraries()) {
$mangling = $pkg->ColocateLibraries() ne 'no' ? 1 : undef;
}
}
open (MASTER, $masterlist) or die "ERROR: Could not read $masterlist\n";
require Grid::GPT::Locations;
my $locations = new Grid::GPT::Locations();
my $prefix = $locations->{'installdir'};
# The filelist won't include the installation directory,
# but the pkgdir value will. Strip it out so we can inspect
# the filelists later.
my $pkgdatasubdir = "$locations->{'pkgdir'}";
$pkgdatasubdir =~ s!\Q$prefix\E/!!;
my $altpkgdatasubdir = "$locations->{'altpkgdir'}";
$altpkgdatasubdir =~ s!\Q$prefix\E/!!;
my @list;
for my $line (<MASTER>) {
$line =~ s!^.*\Q$prefix\E!!;
push @list, $line;
# print $line;
}
if ($masterlist =~ m!^(.+)/[^/]+$!) {
$prefix = $1;
} else {
$prefix =".";
}
my $sort = new $filelistclass(list => \@list, flavor => $flavor,
mangling => $mangling,
);
my %funcs = ("data", sub{ $sort->data_files()},
"dev", sub {$sort->dev_files()},
"doc", sub {$sort->doc_files()},
"pgm", sub {$sort->pgm_files()},
"pgm_static", sub {$sort->pgm_static_files()},
"rtl", sub {$sort->rtl_files()});
for my $typ (sort keys %funcs) {
next if ( ( $typ eq "pgm" ) && ( $static eq "static" ) );
next if ( ( $typ eq "pgm_static" ) && ( $static eq "shared" ) );
my $outlines = &{$funcs{$typ}}();
if (@$outlines) {
my $type_flavor = $flavor;
$type_flavor = "noflavor"
if defined ($Grid::GPT::V1::Definitions::noflavor_pkg_types{$typ});
# If this filelist only has package metadata, don't write it!
my @notpkgdata;
@notpkgdata = grep { ! m!\Q$pkgdatasubdir\E!}
grep { ! m!\Q$altpkgdatasubdir\E!} @$outlines;
next if (! @notpkgdata );
my $out = "$prefix/$ {type_flavor}_$ {typ}.filelist";
open (OUT, ">$out") or die "ERROR: could not open $out\n";
for (@$outlines) {
print OUT "$_\n";
}
close OUT;
}
}
__END__
|