This file is indexed.

/usr/sbin/gpt-query 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
#! /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 Config;
use Cwd;

my $version;

#
# Do a perl check for version >= 5.005.
#

if ( ! ( defined eval "require 5.005" ) )
{
    die "GPT requires at least Perl version 5.005";
}

system("$sbindir/gpt_version") == 0
         or die "GPT died due to Version mismatch.  Check PATH and GPT_LOCATION\n" ;


if ( ! ( defined eval "require Grid::GPT::GPTObject" ) )
{
    die("$prefix does not appear to hold a valid GPT installation\n");
}

#
# standard includes
#

use Getopt::Long;


require Pod::Usage;
require Grid::GPT::V1::Bundle;

#
# argument specification
#


my %queryargs = ();
# sub pod2usage {
#   print "gpt-query [-name=Name -flavor=Flavor -pkgtype=Type --help -sdk -deps=<run|sdk>] [-file=Name] [pkgname-flavor-pkgtype+] \n";
#   exit shift;
# }

my ($deps, $help, $man, $lookupfile, $bundle, $whatBundles, $location, 
    $verBndl, $bndlPack, $bndl_style, $tmpdir);

GetOptions(
		
		'name|pkgname=s' =>
                sub
                {
                    my ($optname, $optval) = @_;


                   if ( defined($optval) && ( length($optval) > 0 ) )
                    {
                        $queryargs{'pkgname'} = $optval;
                    }
		  
                },
            'flavor|flavour=s' =>
                sub
                {
                    my ($optname, $optval) = @_;

                    if ( defined($optval) && ( length($optval) > 0 ) )
                    {
                        $queryargs{'flavor'} = $optval;
                    }
		   
                },
            'type|pkgtype=s' =>
                sub
                {
                    my ($optname, $optval) = @_;

                   if ( defined($optval) && ( length($optval) > 0 ) )
                    {
                        $queryargs{'pkgtype'} = $optval;
                    }
		 
                },

           'file=s'            => \$lookupfile,
           'help|?'            => \$help,
           'man'               => \$man,
           'deps=s'            => \$deps,
           'version'           => \$version,
           'bundle'            => \$bundle,
           'what-bundles'      => \$whatBundles,
           'location=s'        => \$location,
           'tmpdir=s'        => \$tmpdir,
           'verify-bundle=s'   => \$verBndl,
           'bundle-style'      => \$bndl_style,
           'bundle-packages=s' => \$bndlPack
          )
  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::Query;
require Grid::GPT::Installation;
require Grid::GPT::PkgFileName;
require Grid::GPT::BundleInstallation;
require Grid::GPT::Locations;

my $locations = new Grid::GPT::Locations(
                                         installdir => $location,
                                         tmpdir => $tmpdir,
                                        );
my $namematch = new Grid::GPT::PkgFileName(
                                           locations => $locations,
                                          );
$locations->create_dirs(mode => 'tmp');

main(\%queryargs, @ARGV);

###print_pkgs($i_pkg)
sub print_pkgs
{
  my ($i_pkg) = @_;
 printf("packages found that matched your query \n");
 for my $i (@$i_pkg)
 {
   if (defined $deps) {
     print $i->printnode(pretty=>1), "\n";
   } else {
     printf("\t");
     print $i->label(full=>1), "\n";
   }
 }
  $locations->cleantmp();
exit;
}

### main( $queryargs )
#
# query the installed base to get the matching packages against the passed query arguments
#

sub main
{
    my ($queryargs, @ARGS) = @_;
    my $installation = 
      new Grid::GPT::Installation( locations      => $locations,
                                   with_filelists => 1 );
  my $bndlinst     = 
    new Grid::GPT::BundleInstallation( locations => $locations );

if( defined( $bundle ) )
{
  my $bndl1 = new Grid::GPT::V1::Bundle( tmpdir => $locations->{'tmpdir'} ); 

  $bndl1->read_bundle_from_tar( file => $ARGS[0] );

  if( defined( $ARGS[1] ) )
  {
    my $bndl2 = new Grid::GPT::V1::Bundle( tmpdir => $locations->{'tmpdir'} ); 

    $bndl2->read_bundle_from_tar( file => $ARGS[1] );
    $bndl1->compare_bundle_2_bundle( bundle => $bndl2 );
  }
  else
  {
    $bndl1->compare_bundle_2_installation( inst => $installation );
  }
  $locations->cleantmp();
  exit;
}

if( defined( $whatBundles ) )
{
  print "System Bundles\n"; 
  for my $b (@{$bndlinst->what_bundles()})
  {
    print "\t$b\n";
  }
  $locations->cleantmp();
 exit;
}

if( defined($verBndl) )
{
  $bndlinst->check_bundle_integrity( bundle => $verBndl, 
                                     inst   => $installation );
}

if( defined($bndlPack) )
{
  my @bp = $bndlinst->list_packages_for_bundle( bundle => $bndlPack );
  
  print "Packages in Bundle $bndlPack:\n";
  for my $p (@bp)
  {
    print "\t$p\n";
  }
  $locations->cleantmp();

  exit;
}

if( defined($bndl_style) )
{
  my $bndl = $bndlinst->find_bundle( bundle => $ARGS[0] );
  if( $bndl->{'BundleVersion'} eq 'EMPTY' || 
      !defined($bndl->{'BundleVersion'}) )
  {
    print "Bundle $bndl->{'Name'} is an old style bundle.\n";
  }
  else
  {
    print "Bundle $bndl->{'Name'} is a new style bundle.\n";
  }
  $locations->cleantmp();
  exit;
}

my $globus_path = $locations->{'installdir'};

    if (defined $lookupfile) {
      $lookupfile =~ s!^$globus_path!!;
      $lookupfile =~ s!^([^/])!/$1!;


      if (! -f "$globus_path/$lookupfile") {
  $locations->cleantmp();
        die "$globus_path/$lookupfile does not exist\n";
      }
      my $pkg = $installation->find_file($lookupfile);
      if (defined $pkg) {
        print "$lookupfile is owned by ", $pkg->label(), "\n";
  $locations->cleantmp();
        exit 0;
      } else {
  $locations->cleantmp();
        die "$lookupfile is not owned by anyone\n";
      }
    }


    if (defined $deps) {
      $installation->set_depenv($deps eq 'sdk' ? 'Build' : 'RuntimeandSetup');
    }

    my $installed_pkgs = $installation->query(%$queryargs) if keys %$queryargs or ! @ARGS;

    for my $l (@ARGS)
    {
      my $parsed = $namematch->parse_name($l);
      my $pkgs = $installation->query(
                                      pkgname => $parsed->{'pkgname'},
                                      flavor => $parsed->{'flavor'},
                                      pkgtype => $parsed->{'pkgtype'},
                                     );
      push @$installed_pkgs, @$pkgs;
    }

    my $num = scalar(@$installed_pkgs);

    if ($num == 0)
    {
        printf("No packages were found that matched your query.\n");
  $locations->cleantmp();
        exit;
    }

    if ($num == 1)
    {
        printf("1 package was found in $globus_path that matched your query:\n");
    }
    else
    {
        printf("$num packages were found in $globus_path that matched your query:\n");
    }

    printf("\n");

print_pkgs($installed_pkgs);


}


=head1 NAME

B<gpt-query> - Queries an installation for packages

=head1 SYNOPSIS

gpt-query [-name=Name -flavor=Flavor -pkgtype=Type --help -file=name -man -deps=run|sdk] [pkgname-flavor-pkgtype+]

=head1 DESCRIPTION

B<gpt-query> searches installed packages for matches to the query.
I<Name> is the name of the package. I<Flavor> is the
information about linking and compile options used on package.  
I<Type> is the type of the package. I<?> will alow the use to
access system help.

The user may enter a value for any of the options.  These options
can be used in combination or not at all.  The script will take the
options being used and try to find all matching items.


An alternate form is to use the pkgname-flavor-pkgtype tuples.
Multiple of instances of these tuples can be used in a query.

=head1 OPTIONS

=over 4

=item B<-name=NAME>

 Returns all of the packages matching NAME.

=item B<-flavor=FLAVOR>

Returns all of the packages matching FLAVOR.

=item B<-pkgtype=TYPE>

Returns all of the packages matching TYPE.

=item B<-file=FILE>

Returns the package owning the FILE.  FILE needs to be either an
absolute path or referenced to $GLOBUS_LOCATION.

=item B<-deps=run|sdk>

Returns the runtime or build dependencies of a package.

=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<-what-bundles>

Prints a list of the installed bundles. 

=item B<-verify-bundle=BUNDLE>

Takes a bundle defintion and checks to see if it matches the installation.

=item B<-bundle-packages=BUNDLE>

List the packages that belong to the desired bundle.

=item B<-bundle BUNDLE 1 [BUNDLE 2]>

If two bundles are given, the bundles will be compared to one another
for equality.  If only one bundle is given, the bundle will be checked
against the installation.  This command works on tar bundles.

=back

=head1 EXAMPLES

  gpt-query

Returns a listing of all of the installed packages.

  gpt-query -name=foo

Returns all flavors and package types with the name "foo".

 gpt-query foo

Also returns all flavors and package types with the name "foo".

  gpt-query 'foo-*-*'

A third way of typing the same query.  Note the single quotes.

  gpt-query '*-noflavor-*'

List all of the packages with a 'noflavor' build flavor.

  gpt-query -file=libexec/globus-build-env-gcc32.sh

Returns "/libexec/globus-build-env-gcc32.sh is owned by globus_core-gcc32-rtl"

  gpt-query -file=$GLOBUS_LOCATION/libexec/globus-build-env-gcc32.sh

Returns the same.

  gpt-query -file=globus-build-env-gcc32.sh

Returns an error because the path is incorrect.

=head1 OUTPUT

Here is an example output:

   gpt-query '*-noflavor-*'

 4 packages were found in /home/mbletzin/work/install that matched your query:

 packages found that matched your query 
        globus_core-noflavor-data ver: 2.1 cmp id: 2.1.0
        globus_core_setup-noflavor-pgm ver: 2.0 cmp id: 2.0.0
        globus_ssl_utils-noflavor-data ver: 2.1 cmp id: 2.1.0
        kca_setup-noflavor-pgm ver: 3.0.2p1 cmp id: 1.0.0

For each package name, flavor, package type, version, and the
compatibility identifier is return.  The compatibility identifier is
what is used to resolve dependencies.

=head1 SEE ALSO

gpt-install(8) gpt-uninstall(8) gpt-verify(8) gpt-postinstall(8)

=head1 AUTHOR

Michael Bletzinger E<lt>mbletzin.ncsa.uiuc.eduE<gt> and Eric Blau
E<lt>eblau.ncsa.uiuc.eduE<gt>

=cut