/usr/sbin/gpt-postinstall is in grid-packaging-tools 3.6.7-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 | #! /usr/bin/perl
my ($prefix, $globus_prefix, $exec_prefix, $bindir, $sbindir, $libdir);
my ($datarootdir, $datadir, $perlmoduledir, $gptdatadir);
my ($gptexecsharedir, $amdir, $pkg_confdir, $aclocaldir);
if (exists $ENV{GPT_LOCATION})
{
$prefix = $ENV{GPT_LOCATION};
}
else
{
$prefix = "/usr";
}
if (exists $ENV{GLOBUS_LOCATION})
{
$globus_prefix = $ENV{GLOBUS_LOCATION};
}
else
{
$globus_prefix = "/usr";
}
$exec_prefix = "${prefix}";
$bindir = "${exec_prefix}/bin";
$sbindir = "${exec_prefix}/sbin";
$libdir = "${exec_prefix}/lib";
$datarootdir = "${prefix}/share";
$datadir = "${prefix}/share";
$perlmoduledir = "/usr/share/perl5";
$gptdatadir = "${datadir}/globus/gpt";
$gptexecsharedir = "${datadir}/globus/gpt";
$amdir = "${datadir}/globus/amdir";
$pkg_confdir = "${datadir}/globus/gpt";
$aclocaldir = "${datadir}/globus/aclocal";
unshift(@INC, "${perlmoduledir}");
use strict;
use Carp;
use Getopt::Long;
use Cwd;
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";
}
#
# dig the globus and gpt paths out of the user's environment variables
#
my $verbose;
if ( ! -d "$datadir/globus/packages" )
{
die("Can't find a globus/packages directory to work on in your GLOBUS_LOCATION!\n");
}
if ( ! ( defined eval "require Grid::GPT::GPTObject" ) )
{
die("$prefix does not appear to hold a valid GPT installation\n");
}
require Pod::Usage;
my($force, $error, $version, $help, $man, $location, $debug);
GetOptions( 'force' => \$force,
'debug' => \$debug,
'verbose' => \$verbose,
'version' => \$version,
'help|?' => \$help,
'location=s' => \$prefix,
'man' => \$man)
or Pod::Usage::pod2usage(0);
Pod::Usage::pod2usage(1) if $help;
Pod::Usage::pod2usage(-verbose => 2) if $man;
require Grid::GPT::GPTIdentity;
Grid::GPT::GPTIdentity::print_gpt_version() if defined $version;
require Grid::GPT::Installation;
require Grid::GPT::SetupInstallation;
require Grid::GPT::PackageFactory;
require Grid::GPT::Algorithms;
require Grid::GPT::PkgMngmt::Inform;
my @pkg_queries = @ARGV;
my $all = @pkg_queries < 1;
my $log = new Grid::GPT::PkgMngmt::Inform(
verbose => $verbose,
debug => $debug
);
my $locations = new Grid::GPT::Locations( installdir => $prefix);
my $list;
my $installation =
new Grid::GPT::Installation(locations => $locations,
log => $log);
if (! $all) {
require Grid::GPT::Algorithms;
my $checks =
new Grid::GPT::Algorithms(
log => $log,
locations => $locations,
);
$list = $checks->sort_input_patterns(inputs => \@pkg_queries);
$list = find_pkgs($list);
} else {
$list = $installation->setup_pkgs();
}
my $msg .= "The following setup packages were found:\n" if @$list;
for my $p (@$list) {
$msg .= "\t" .$p->label() ." ver: " .
$p->version_label() . "\n";
}
$log->debug($msg);
my @postpkgs;
my %postcommands;
my $setupinstallation =
new Grid::GPT::SetupInstallation(locations => $locations,
log => $log);
@$list = grep {$_->pkgtype() =~ m!pgm! } @$list;
if ( !defined($force) )
{
my $needs = $setupinstallation->check_for_setup_needs(pkgs => $list);
if (defined $verbose or defined $debug or ! $all) {
for my $p (@$list) {
next if grep {$_->is_same($p)} @$needs;
$log->inform($p->label() . " is already set up",1);
}
}
$list = $needs;
}
$msg .= "The following packages need to be set up:\n" if @$list;
for my $p (@$list) {
$msg .= "\t" .$p->label() ." ver: " .
$p->version_label() . "\n";
}
$log->debug($msg);
my @setupcommands;
my $setupcmd;
my $depnode;
my $pkgset = new Grid::GPT::PkgSet;
#
# our first pass checks for collisions against the post install program. it
# only adds packages to our package set that require post install programs which
# we haven't seen yet be run.
#
for my $l (@$list)
{
# $l->printnode();
$setupcmd = trimSetupCommand($l->{'depnode'}->{'Post_Install_Program'});
if ( ! grep(/^$setupcmd$/, @setupcommands) )
{
$depnode = $l->{'depnode'};
push(@setupcommands, $setupcmd);
$pkgset->add_package(pkg => $depnode);
}
}
#
# print out the unsorted commands (for debugging)
#
# printf("\nunsorted commands\n");
# for my $s (@setupcommands)
# {
# printf("command = '%s'\n", $s);
# }
#
# prep the package set and sort
#
$pkgset->set_depenv('Setup');
#open (OUT, ">./deptable.html");
#select(OUT);
#print "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">
#<html>
# <head>
# <title>Globus Packages</title>
# </head>
# <body>
# <h1>Installation Dependency Tree</h1>\n";
#$pkgset->printtablehtml();
#print " </body>
#</html>
#";
$pkgset->sort_pkgs();
#
# zero out our list of setup commands
#
@setupcommands = ();
#
# grab the packages that have been sorted and add them onto setup commands
#
for my $p (@{$pkgset->sorted()})
{
$setupcmd = trimSetupCommand($p->{'depnode'}->{'Post_Install_Program'});
$setupcmd = formatSetupCommand($setupcmd);
if (length($setupcmd) > 0)
{
push(@setupcommands, $setupcmd);
}
}
# printf("\nsorted commands\n");
# for my $s (@setupcommands)
# {
# printf("command = '%s'\n", $s);
# }
if ( (scalar(@setupcommands) == 0)
&& !defined($error) && $all)
{
printf("All of the packages in your GLOBUS_LOCATION are already set up.\n");
exit;
}
else
{
runSetupCommands(@setupcommands);
}
#verifying that scripts have completed.
$setupinstallation =
new Grid::GPT::SetupInstallation(locations => $locations,
log => $log);
$list = $setupinstallation->check_for_setup_needs(pkgs => $pkgset->{'pkgs'});
my @bad;
for my $p (@$list) {
next if ! grep {$_->is_same($p)} @{$pkgset->{'pkgs'}};
push @bad, $p->label();
}
exit 0 if ! @bad;
print "WARNING: The following packages were not set up correctly:\n";
for my $l (@bad) {
print "\t$l\n";
}
print "Check the package documentation or run postinstall -verbose to see what happened\n";
exit;
### getFileLocation( $entity )
#
# given an entity in the form of a unix-style path, remove the trailing entry
# and return its parent directory.
#
sub getFileLocation
{
my($entity) = @_;
my($dir);
$dir = $entity;
$dir =~ s:/+:/:g; # remove consecutive slashes
$dir =~ s:/$::g; # remove trailing slash (just in case)
$dir =~ s:/[^/]*$::; # remove trailing filename
return $dir;
}
### runSetupCommands
#
# given a list of setup commands, run them (in order)
#
sub runSetupCommands
{
my (@setupcommands) = @_;
my $olddir;
for my $s (@setupcommands)
{
printf("running %s..", $s);
print "\n" if defined $verbose or defined $debug;
action($s, getFileLocation($s));
printf("..Done\n") if ! defined $verbose and ! defined $debug;
}
}
### formatSetupCommand( $setupcmd )
#
# prepend the setup path to the setup command
#
sub formatSetupCommand
{
my($setupcmd) = @_;
my($newcmd, $tmpcmd1, $tmpcmd2);
#
# first check in $GL/setup/globus/ to maintain backwards compatibility
#
$tmpcmd1 = "$prefix/setup/globus/$setupcmd";
if ( -x $tmpcmd1 )
{
$newcmd = $tmpcmd1;
return $newcmd;
}
#
# otherwise check in $GL/setup/ to support new-style paths
#
$tmpcmd2 = "$prefix/setup/$setupcmd";
if ( -x $tmpcmd2 )
{
$newcmd = $tmpcmd2;
return $newcmd;
}
#
# warn that we can't find a match for $setupcmd
#
printf("WARNING: cannot locate an executable file at either\n");
printf("\t'$tmpcmd1'\n");
printf("or\n");
printf("\t'$tmpcmd2'\n");
printf("...giving up.\n");
$error = 1;
return "";
}
### trimSetupCommand( $setupcmd )
#
# given a string, trim extraneous characters off of it
#
sub trimSetupCommand
{
my ($setupcmd) = @_;
$setupcmd =~ s:\n+::g;
$setupcmd =~ s:^[\s]+|[\s]+$::g;
$setupcmd =~ s:\s+: :g;
return $setupcmd;
}
### action( $command, $dir )
#
# perform some command and inform the user
#
sub action
{
my ($command, $dir) = @_;
my $pwd;
if (defined $dir) {
$pwd = cwd();
$log->inform("[ Changing to $dir ]",1);
chdir($dir);
}
my $result =
system(
"GLOBUS_LOCATION=$locations->{'installdir'}; \\
export GLOBUS_LOCATION; \\
GPT_LOCATION=$locations->{'installdir'}; \\
export GPT_LOCATION; \\
$command 2>&1");
if ($result or $?)
{
# results are bad print them out.
die("ERROR: Command failed\n");
}
if (defined $dir)
{
$log->inform("[ Changing to $pwd ]");
chdir($pwd);
}
}
sub find_pkgs {
my ($queries) = @_;
my @bad;
my @pkgs;
for my $q (@$queries) {
my $cands = $installation->query(%$q);
my $input = "$q->{'pkgname'}-$q->{'flavor'}-$q->{'pkgtype'}";
$input =~ s!ANY!*!g;
# Complain about pattern if it does not come from a bundle.
if (! defined $cands) {
push @bad, $input;
next;
}
my $msg = "Query: $input found the following setup packages:\n";
for my $c (@$cands) {
next if ! defined $c->setupname();
$msg .= "\t" . $c->label() . "\n";
push @pkgs, $c;
}
$log->debug($msg);
}
if (@bad) {
print "ERROR: The following does not match any packages:\n";
for my $b (@bad) {
print "\t$b->{'pkgname'}-$b->{'flavor'}-$b->{'pkgtype'}\n";
}
exit 1;
}
return \@pkgs;
}
=head1 NAME
B<gpt-postinstall> - Searches for post install scripts and executes them
=head1 SYNOPSIS
gpt-postinstall [-help -force -version -man -location ]
=head1 DESCRIPTION
B<gpt-postinstall> Searches an installation for post-install scripts
that have not been run yet and executes them. These scripts are
installed by Setup packages and are designed to localize an
installation. The I<-force> flag can be used to re-run all of the
setup scripts.
=head1 OPTIONS
=over 8
=item B<-force>
forces all action to be taken, regardless of state.
=item B<-help>
Print a brief help message and exits.
=item B<-man>
Prints the manual page and exits.
=item B<-version>
Prints the version of GPT and exits.
=item B<-location>
Location indicates the path to the Globus installation that will be used.
=back
=head1 SEE ALSO
gpt-install(1) gpt-uninstall(1) gpt-verify(1)
=head1 AUTHOR
Michael Bletzinger E<lt>mbletzin.ncsa.uiuc.eduE<gt> and Eric Blau
E<lt>eblau.ncsa.uiuc.eduE<gt>
=cut
|