Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
227 dpurdie 1
#! perl
2
########################################################################
229 dpurdie 3
# Copyright (C) 2007 ERG Limited, All rights reserved
227 dpurdie 4
#
229 dpurdie 5
# Module name   : MakePackage.pl
227 dpurdie 6
# Module type   : Makefile system
7
# Compiler(s)   : n/a
8
# Environment(s): jats
9
#
229 dpurdie 10
# Description   : This script is invoked by the builder to:
11
#                   1) Perform sanity tests
12
#                   2) Package up jats
13
#                 This script is really used to 'release' JATS.
227 dpurdie 14
#
229 dpurdie 15
#                 This script must be executed within a JATS environment
16
#                 JATS required JATS to build itself.
17
#
227 dpurdie 18
# Usage:
19
#
20
#......................................................................#
21
 
22
require 5.6.1;
23
use strict;
24
use warnings;
25
use Cwd;
26
use Getopt::Long;
229 dpurdie 27
use Pod::Usage;
28
use File::Basename;
29
use File::Find;
30
use File::Path;
31
use File::Copy;
32
use JatsError;
33
use JatsSystem;
227 dpurdie 34
 
229 dpurdie 35
my $VERSION = "1.0.0";
36
my $opt_help = 0;
37
my $opt_manual = 0;
38
my $opt_buildname;
39
my $opt_buildversion;
40
my $opt_package;
41
my $opt_root;
42
my $opt_verbose = $ENV{'GBE_VERBOSE'};
43
my $opt_vargs;
227 dpurdie 44
 
45
#
46
#   Parse the user options
47
#
48
my $result = GetOptions (
229 dpurdie 49
                "help+"             => \$opt_help,
50
                "manual"            => \$opt_manual,
51
 
52
                "BuildName=s"       => \$opt_buildname,
53
                "BuildVersion=s"    => \$opt_buildversion,
54
                "PackageDir=s"      => \$opt_package,
55
                "BuildRoot=s"       => \$opt_root,
56
                "Verbose:s"         => \$opt_vargs,
57
 
227 dpurdie 58
                );
59
 
229 dpurdie 60
#
61
#   Process help and manual options
62
#
63
pod2usage(-verbose => 0, -message => "Version: $VERSION")  if ($opt_help == 1  || ! $result);
64
pod2usage(-verbose => 1)  if ($opt_help == 2 );
65
pod2usage(-verbose => 2)  if ($opt_manual || $opt_help > 2);
227 dpurdie 66
 
67
#
229 dpurdie 68
#   Init the error and message subsystem
227 dpurdie 69
#
229 dpurdie 70
$opt_verbose += 2 unless ( $opt_vargs eq '@' );
71
ErrorConfig( 'name'    => 'RELEASE_JATS',
72
             'verbose' => $opt_verbose );
227 dpurdie 73
 
229 dpurdie 74
SystemConfig ('ExitOnError' => 1 );
227 dpurdie 75
 
76
#
229 dpurdie 77
#   Sanity Test arguments
227 dpurdie 78
#
229 dpurdie 79
Error ("Not expecting any command line arguments" )
80
    if ( $#ARGV >= 0);
227 dpurdie 81
 
229 dpurdie 82
#
83
#   Ensure we have all required parameters
84
#
85
Error ("No build name provided" ) unless ( $opt_buildname );
86
Error ("No build version provided" ) unless ( $opt_buildversion );
87
Error ("No package directory provided" ) unless ( $opt_package );
88
Error ("No build root provided" ) unless ( $opt_root );
89
Error ("Build root is not a directory " ) unless ( -d $opt_root );
227 dpurdie 90
 
91
#
229 dpurdie 92
#   Import Environment Variables
227 dpurdie 93
#
229 dpurdie 94
my $GBE_PERL = $ENV{GBE_PERL} || Error ("Environment variable GBE_PERL not set");
95
my $GBE_CORE = $ENV{GBE_CORE} || Error ("Environment variable GBE_CORE not set");
227 dpurdie 96
 
229 dpurdie 97
#
98
#   Remove any existing package directory
99
#
100
if ( -d $opt_package )
101
{
102
    Message ("Removing existing package image");
103
    rmtree( $opt_package);
104
}
227 dpurdie 105
 
229 dpurdie 106
Message "Create package image: $opt_package";
107
mkpath($opt_package, 0, 0775);
227 dpurdie 108
 
109
 
229 dpurdie 110
for my $dir (glob ("$opt_root/BIN.*" ))
227 dpurdie 111
{
229 dpurdie 112
    Message "Copy in: $dir";
113
    System ("cp -r $dir $opt_package")
227 dpurdie 114
}
115
 
116
for my $dir qw(CFG TEMPLATES TOOLS)
117
{
229 dpurdie 118
    Message "Copy in: $dir";
119
    System ("cp -r $opt_root/$dir $opt_package")
227 dpurdie 120
}
121
 
122
for my $dir qw(TOOLS/LOCAL)
123
{
229 dpurdie 124
    Message "Remove: $dir";
125
    rmtree( "$opt_package/$dir" );
227 dpurdie 126
}
127
 
128
for my $file qw(Readme.txt PostInstall.sh ChangeLog.txt)
129
{
229 dpurdie 130
    Message "Copy in: $file";
131
    System ("cp -r $opt_root/$file $opt_package")
227 dpurdie 132
}
133
 
134
#
135
#   Update version info in some files
136
#
229 dpurdie 137
foreach my $file qw( TOOLS/jats.sh TOOLS/jats.bat TOOLS/jats.pl )
227 dpurdie 138
{
229 dpurdie 139
    Message "Insert version into: $file";
140
    my @opts;
141
    push @opts, ( $file =~ m~\.bat$~ ? '-dos' : '-unix' );
142
    unlink "$opt_package/$file";
143
    System ( "$GBE_PERL", "$GBE_CORE/TOOLS/jats_transform_file.pl",
144
             "-infile=$opt_root/$file",
145
             "-outfile=$opt_package/$file",
146
             "-tag=VERSION_TAG,$opt_buildversion",
147
             "-tag=PACKAGE_TAG,$opt_buildname",
148
             "-tag=RELEASE_TAG,",
149
             @opts
150
            );
227 dpurdie 151
}
152
 
153
#
229 dpurdie 154
#   Ensure that the jats.pl file has the correct version information
155
#   inserted into it, by this tool
227 dpurdie 156
#
229 dpurdie 157
Message ("Validate version embedded into jats.pl" );
158
my $file = "$opt_package/TOOLS/jats.pl";
159
my $jversion;
160
open ( FH, '<', $file ) || Error ("Cannot open: $file", "Reason: $!");
161
while ( <FH> )
227 dpurdie 162
{
229 dpurdie 163
    next unless ( m~\s*my\s+\$GBE_VERSION\s+=\s+['"](.*)['"]~ );
164
    $jversion = $1;
165
    last;
227 dpurdie 166
 
167
}
229 dpurdie 168
close FH;
227 dpurdie 169
 
229 dpurdie 170
Error ("Cannot locate GBE_VERSION in jats.p" ) unless ( $jversion );
171
Error ("GBE_VERSION definition in jats.pl Does not match released version.",
172
        "Expecting: $opt_buildversion",
173
        "Got      : $jversion") unless( $jversion eq $opt_buildversion );
174
 
175
 
176
 
177
exit 0;
178
 
227 dpurdie 179
#-------------------------------------------------------------------------------
229 dpurdie 180
#   Documentation
227 dpurdie 181
#
182
 
229 dpurdie 183
=pod
227 dpurdie 184
 
229 dpurdie 185
=head1 NAME
227 dpurdie 186
 
229 dpurdie 187
MakePackage - Release Jats
227 dpurdie 188
 
229 dpurdie 189
=head1 SYNOPSIS
227 dpurdie 190
 
229 dpurdie 191
 MakePackage [options]
227 dpurdie 192
 
229 dpurdie 193
 Options:
194
    -help               - Brief help message
195
    -help -help         - Detailed help message
196
    -man                - Full documentation
197
    -BuildName=text     - Name of the package being built
198
    -BuildVersion=text  - Version of the package being built
199
    -PackageDir=path    - Path to the packaging target directory
200
    -BuildRoot=path     - Path to the root of the build
201
    -Verbose=text       - Verbosity control
202
 
227 dpurdie 203
 
229 dpurdie 204
=head1 OPTIONS
227 dpurdie 205
 
229 dpurdie 206
=over 8
207
 
208
=item B<-help>
209
 
210
Print a brief help message and exits.
211
 
212
=item B<-help -help>
213
 
214
Print a detailed help message with an explanation for each option.
215
 
216
=item B<-man>
217
 
218
Prints the manual page and exits.
219
 
220
=head1 DESCRIPTION
221
 
222
No user servicable parts in this script.
223
 
224
=cut
225
 
226