File: gpt-file-remove

package info (click to toggle)
grid-packaging-tools 3.2globus2-5
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 4,816 kB
  • ctags: 1,621
  • sloc: perl: 19,536; sh: 3,047; makefile: 320; exp: 89
file content (126 lines) | stat: -rwxr-xr-x 2,610 bytes parent folder | download
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
#! perl

#
# Do a perl check for version >= 5.005.  See 'gpt-translate-interpreter' should you
# need to alter the invocation path to a valid perl interpreter in the GPT front-end
# programs.
#

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 $gpt_path = $ENV{GPT_LOCATION};
my $globus_path = $ENV{GLOBUS_LOCATION};
my $gpath;

if ( !defined($gpt_path) )
{
    $gpt_path = "/usr";
}

if ( !defined($globus_path) )
{
    $globus_path = "/usr";
}

if ( !defined($gpt_path) && !defined($globus_path) )
{
    die("GPT_LOCATION or GLOBUS_LOCATION needs to be set before running this script");
}

if ( defined($gpt_path) )
{
    $gpath = $gpt_path;
}

if ( defined($globus_path) && !defined($gpath) )
{
    $gpath = $globus_path;
}

if ( ! -d "$globus_path/share/globus/packages" )
{
    die("Can't find a globus/packages directory to work on in your GLOBUS_LOCATION!\n");
}

#
# standard includes
#

use strict;
use Config;
use Getopt::Long;

@INC = ("$gpath/lib/perl", "$gpath/lib/perl/$Config{'archname'}", @INC);

my( $action, $verbose, $help, $version );

my $actions = [ "both", "file", "filelist", "disk" ];

GetOptions( 'action:s' => \$action,
            'verbose!' => \$verbose,
            'help' => \$help,
            'version' => \$version,
          ) or Pod::Usage::pod2usage(1);

Pod::Usage::pod2usage(0) if $help;
require Grid::GPT::GPTIdentity;
Grid::GPT::GPTIdentity::print_gpt_version() if defined $version;

require Grid::GPT::Installation;

#
# begin main execution
#

if (!defined($action))
{
    $action = "both";
}

if ( !grep(/^$action$/, @$actions) )
{
    die("ERROR: bad action specified");
}

my @files = map
            {
                my $x = $_;
                $x =~ s:/+:/:g;
                $x =~ s:^\s+|\s+$::g;
                $x =~ s:^\./::g;
                $x =~ s:^/::g;
                $x;
            } @ARGV;

if ( ($action eq "both") or ($action eq "filelist") )
{
    my $installation = new Grid::GPT::Installation(
                              pkgdir => "$globus_path/share/globus/packages",
                              with_filelists => 1,
                              );

    for my $path (@files)
    {
        $installation->removeFilePath( path => $path );
    }

    $installation->saveFilelist();
}

if ( ($action eq "both") or ($action eq "disk") or ($action eq "file") )
{
    for my $path (@files)
    {
        my $fullPath = "$globus_path/$path";
        $fullPath =~ s:/+:/:g;
        system("rm $fullPath");
    }
}