File: make_gpt_dist

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 (233 lines) | stat: -rwxr-xr-x 5,757 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
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
#! /usr/bin/env perl

use Cwd;
use Getopt::Long;

my ($gtar_location, $gunzip_location, $verbose, $version, $help, 
    $man);
my $startdir = cwd();

my $tarconf="$startdir/tarfiles/gpt_tarfiles.conf";

GetOptions( 
           'tarconf=s' => \$tarconf,
          );

# determine gpt version number

open (CFG, 'packaging_tools/configure.ac');

die "ERROR: Need to set \$GPT_LOCATION \n" if ! defined $ENV{'GPT_LOCATION'};

my $version;
for (<CFG>) {
  if (m!AC_INIT\(\w+,([^,\)]+)!) {
    $version = $1;
    $version =~ s!\s+!!g;
    last;
  }
}

die "ERROR: Cannot determine GPT version from packaging_tools/configure.ac\n"
  if ! defined $version;

my @includes = (
                'packaging_tools',
                'build_gpt',
                'make_gpt_dist',
                'setup_gpt_dist',
                'tools',
                'CHANGES',
                'LICENSE',
                'INSTALL',
                'README',
               );



$newdir = "gpt-$version";

$newdirname = $newdir;
$newpkgname = "$ {newdir}-src";
$newdistname = "$ {newdir}-dist";
$tmpdirname = $newdirname;

push @INC, "$startdir/packaging_tools/perl/GPT";

require PkgMngmt::Inform;

my $log = new Grid::GPT::PkgMngmt::Inform(
                                          verbose => $verbose,
                                          name => "make_gpt_dist",
                                         );

for my $f ("./$tmpdirname", 
           "./$newpkgname.tar",
           "./$newpkgname.tar.gz") {

  if ( -e $f )
    {
      $log->announce("Removing existing $f\n");
      system ("rm -rf $f");
    }

}

if (! -f "$ENV{'GPT_LOCATION'}/newautotools/bin/autoconf") {
  $log->announce("Install autotools to bootstrap packaging_tools");

  if (! -d "./support") {
    my $result = $log->action("./setup_gpt_dist");
  }

  my $gpt_location = $ENV{'GPT_LOCATION'};
  my @instructions = ("PATH=$gpt_location/newautotools/bin:$ENV{'PATH'}; export PATH;GPT_LOCATION=$gpt_location; export GPT_LOCATION; ./configure --prefix=$gpt_location/newautotools", 
                      "make", 
                      "make install  > /dev/null 2>&1");

  @INC = ("./tools", @INC);


  require DistGPT;
  my $dist = new DistGPT(
                         topdir => cwd(),
                         building => 1,
                        );

  $dist->match_srcdirs('needautotools');

  for my $tool('autoconf', 'automake', 'libtool') {
    my $dir = $dist->{'srcdirs'}->{$tool};
    chdir $dir;
    for my $i (@instructions) {
      $log->action($i);
    }
    chdir $startdir;
  }



}

#
# prep the source directory by creating a temp directory containing all of the
# required files.
#

$log->announce("Copying files into source directory...\n");

$log->action("mkdir $tmpdirname")==0 or 
  die "Unable to create $tmpdirname: $?";

for my $c (@includes, tarfiles) {

print "Copying $c\n";

$log->action("cp -rf $c $tmpdirname")==0 or 
  die "Unable to copy $c into $tmpdirname: $?";

}

#
# change into the temp directory
#

chdir("./$tmpdirname");

#
# create any necessary directories
#

$log->action("./setup_gpt_dist -tarconf=$tarconf");


opendir SUPPORT, "support";

my @raw = readdir SUPPORT;

closedir SUPPORT;

my @gnu = map {"support/" . $_ } grep { (m!auto! or m!libtool!) 
                   and $_ ne $tmpdirname } @raw;

my @gpttar = map {"support/" . $_ } grep { ! (m!auto! or m!libtool!) 
                   and $_ ne $tmpdirname and ! m!\.$!} @raw;

push @gpttar, @includes;

@gnu = map {"$tmpdirname/" . $_ } @gnu;
@gpttar = map {"$tmpdirname/" . $_ } @gpttar;

#
# remove any 'unnecessary' files from the source directory.
#

$log->announce("pruning source directory of extraneous files...\n");
$log->action("find . -name CVS -print | xargs rm -rf ")==0 or die "Unable to remove cvs directories: $?";

$log->action('find . -name "*~" -print | xargs rm -rf ');

#
# run the standard development tools to get the necessary derived files.
#

my $distdir = cwd();

print "Preparing: $distdir/packaging_tools\n";

chdir("$distdir/packaging_tools") or die "Unable to cd to packaging_tools: $?";

# the existence of a Makefile suggests that make distclean needs to be run
# since the distclean target will remove the Makefile.

$rc = ! $log->action("make distclean");

die("make distclean of '$distdir/packaging_tools' failed\n") if ! $rc;

#
# bootstrap the code in each of these directories
#

$rc = 1;
$rc = ! $log->action("PATH=$ENV{'GPT_LOCATION'}/newautotools/bin:$ENV{'PATH'}; export PATH; ./bootstrap");

die("bootstrapping of '$distdir/packaging_tools' failed\n") if (!$rc);

chdir($startdir);

@INC = ("./tools", @INC);

require DistGPT;

my $dist = new DistGPT(
                       gtar => $gtar_location,
                       gunzip => $gunzip_location,
                       topdir => "$startdir",
                      );

printf("Creating $newpkgname.tar.gz ...");
my $gpt_contents = join(" ", @gpttar);
$log->action("$dist->{'gtar_location'} czf $newpkgname.tar.gz $gpt_contents")==0
  or die "Unable to create $newpkgname.tar.gz: $?";
printf("done.\n");

printf("Creating gnu-autotools-for-$newpkgname.tar.gz ...");
my $gnu_contents = join(" ", @gnu);
$log->action("$dist->{'gtar_location'} czf gnu-autotools-for-$newpkgname.tar.gz $gnu_contents")==0 
  or die "Unable to create gnu-autotools-for-$newpkgname.tar.gz: $?";
printf("done.\n");

printf("Creating $newdistname.tar.gz ...");
my $dist_contents = "$gpt_contents $gnu_contents $tmpdirname/tarfiles";
$log->action("$dist->{'gtar_location'} czf $newdistname.tar.gz $dist_contents")==0
  or die "Unable to create $newpkgname.tar.gz: $?";
printf("done.\n");

printf("Cleaning up ...");
$log->action("rm -rf $tmpdirname")==0 or die "Unable to remove $tmpdirname: $?";

printf("done.\n");


exit;