6 #############################################################################
10 thirdParty
=> "$ENV{WM_PROJECT_INST_DIR}/ThirdParty",
11 project
=> ( $ENV{WM_PROJECT
} || '' ) . "-"
12 . ( $ENV{WM_PROJECT_VERSION
} || '' ),
18 url
=> "http://www.cmake.org/files/v2.6/cmake-2.6.0.tar.gz",
23 url
=> "http://www.lam-mpi.org/download/files/lam-7.1.4.tar.bz2",
29 "https://wci.llnl.gov/codes/visit/3rd_party/libccmio-2.6.1.tar.gz",
34 "http://www.open-mpi.org/software/ompi/v1.2/downloads/openmpi-1.2.6.tar.bz2",
39 "http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/metis-5.0pre2.tar.gz"
43 url
=> "http://www.mico.org/mico-2.3.12.tar.gz",
48 url
=> "ftp://ftp.mcs.anl.gov/pub/mpi/old/mpich-1.2.4.tar.gz",
53 "http://glaros.dtc.umn.edu/gkhome/fetch/sw/parmetis/ParMetis-3.1.tar.gz",
58 "http://www-users.cs.umn.edu/~moulitsa/download/ParMGridGen-1.0.tar.gz",
61 zlib
=> { url
=> "http://www.zlib.net/zlib-1.2.3.tar.gz", },
66 "http://www.cs.umass.edu/%7Eemery/hoard/hoard-3.7.1/hoard-371.tar.gz"
69 ## # this really doesn't work well, but code needs minor patching anyhow:
72 ## "http://www.freebsd.org/cgi/cvsweb.cgi/~checkout~/src/lib/libc/stdlib/malloc.c?rev=1.171",
79 ############################################################################
81 ( my $Script = $0 ) =~ s{^.*/}{};
83 # --------------------------------------------------------------------------
87 for ( sort keys %packages ) {
88 if ( $packages{$_}{-opt
} ) {
100 $Script [OPTION] [package1 .. packageN]
104 -status show status [default]
105 -list list versions and resource locations
106 -version list versions only
107 -dir list unpack directory
108 -reldir list unpack directory relative to cwd
109 -get get packages as required (uses curl)
110 -unpack unpack packages where required and possible
112 Simple management of 3rd party software for '$config{project}'
120 -status -get -unpack number of missing packages or errors
125 # --------------------------------------------------------------------------
128 # default action is -status
129 @ARGV or $opt{status
}++;
132 "help", "status", "list", "version", "dir",
133 "reldir", "get", "unpack",
137 $opt{help
} and usage
;
139 -d
$config{thirdParty
} or usage
"ERROR: no '$config{thirdParty}' dir";
142 # complete the config
144 if ( not exists $config{sources
} ) {
145 $config{sources
} = "$config{thirdParty}/sources";
146 -d
$config{sources
} or mkdir $config{sources
};
150 # cleanup the packages table
152 for my $name ( keys %packages ) {
153 my $href = $packages{$name};
155 if ( not $href->{url
} ) {
156 warn "$name without url\n";
157 delete $packages{$name};
161 if ( not exists $href->{file
} ) {
162 ( $href->{file
} = $href->{url
} ) =~ s{^.*/|\?.*$}{}g;
165 if ( not exists $href->{dir
} ) {
166 ( $href->{dir
} = $href->{file
} ) =~ s{\.(zip|tar(\.(gz|bz2))?)$}{};
171 # check for names in the packages
177 while ( @_ and $_[0] =~ /^-/ ) {
179 if ( $opt =~ /^-req/ ) {
185 my ( %seen, @reject );
187 next if $seen{$name}++;
188 if ( exists $packages{$name} ) {
196 usage
"unknown package(s): @reject" if @reject;
200 grep { not $req or not $packages{$_}{-opt
} } sort keys %packages;
203 @names or usage
"no packages";
209 # list the current status
211 if ( $opt{status
} ) {
212 my @names = selectNames
@ARGV;
216 for my $name (@names) {
217 my $href = $packages{$name};
218 my ( $dir, $file, $url ) = @
$href{qw( dir file url )};
221 if ( -e
"$config{sources}/$file" ) {
222 push @status, " packed: $config{sources}/$file";
225 if ( -d
"$config{thirdParty}/$dir" ) {
226 push @status, "unpacked: $config{thirdParty}/$dir";
235 printf "%-16s %-16s %s", $name, $dir, $_;
237 if ( $href->{-opt
} ) {
248 # show an overview of the versions and the resource locations
251 my @names = selectNames
@ARGV;
253 for my $name (@names) {
254 my $href = $packages{$name};
255 my ( $dir, $file, $url ) = @
$href{qw( dir file url )};
257 printf "%-16s %-16s %s", $name, $dir, $url;
258 if ( $href->{-opt
} ) {
269 # show the version (directory name) only
271 if ( $opt{version
} ) {
272 my @names = selectNames
@ARGV;
274 for my $name (@names) {
275 my $href = $packages{$name};
276 my ( $dir, $file, $url ) = @
$href{qw( dir file url )};
285 # show the unpack directory name
287 if ( $opt{dir
} or $opt{reldir
} ) {
288 my @names = selectNames
@ARGV;
289 my $base = $config{thirdParty
};
291 if ( $opt{reldir
} ) {
292 $base = File
::Spec
->abs2rel($base);
293 length $base or $base = '.';
296 for my $name (@names) {
297 my $href = $packages{$name};
298 my ( $dir, $file, $url ) = @
$href{qw( dir file url )};
300 print File
::Spec
->catfile( $base, $dir ), "\n";
307 # get and/or unpack packages as required and possible
308 # avoid getting/unpacking optional packages
310 if ( $opt{get
} or $opt{unpack} ) {
311 my @names = selectNames
-required
=> @ARGV;
315 for my $name (@names) {
316 my $href = $packages{$name};
317 my ( $dir, $file, $url ) = @
$href{qw( dir file url )};
320 if ( $href->{-opt
} ) {
321 $flags .= "[optional]";
324 warn '-' x
70, "\n", "$name ($dir) $flags\n";
326 if ( -d
"$config{thirdParty}/$dir" ) {
327 warn "unpacked: $config{thirdParty}/$dir\n";
332 if ( -e
"$config{sources}/$file" ) {
333 warn " packed: $config{sources}/$file\n";
336 my $fetch = "curl -k -o $file";
338 # curl seems to hang on anonymous ftp?
339 if ( $url =~ /^ftp:/ ) {
343 system "set -x; cd $config{sources} && $fetch $url";
345 if ( not -e
"$config{sources}/$file" ) {
347 warn " download failed!?\n";
353 if ( $opt{unpack} ) {
354 if ( -e
"$config{sources}/$file" ) {
356 if ( $file =~ m{\.zip$} ) {
359 elsif ( $file =~ m{\.tar$} ) {
362 elsif ( $file =~ m{\.tar\.bz2$} ) {
363 $unpack = "tar -xjf";
365 elsif ( $file =~ m{\.(tgz|tar\.gz)$} ) {
366 $unpack = "tar -xzf";
370 warn " no unpack defined for $file\n";
375 "set -x; cd $config{thirdParty} && $unpack $config{sources}/$file";
377 # catch isolated cases where it unpacks without a version number
378 if ( -d
"$config{thirdParty}/$name"
379 and not -d
"$config{thirdParty}/$dir" )
381 rename "$config{thirdParty}/$name",
382 "$config{thirdParty}/$dir";
385 unless ( -d
"$config{thirdParty}/$dir" ) {
387 warn "unpack failed!?\n";
394 warn '-' x
70, "\n\n";
398 # --------------------------------------------------------------------------