Subversion Repositories DevTools

Rev

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

Rev Author Line No. Line
227 dpurdie 1
#! perl
2
########################################################################
3
# Copyright (C) 2004 ERG Limited, All rights reserved
4
#
5
# Module name   : jats.sh
6
# Module type   : Makefile system
7
# Compiler(s)   : n/a
8
# Environment(s): jats
9
#
10
# Description:
11
#
12
# Usage:
13
#
14
# Version   Who      Date        Description
15
#     1.0   DDP      08-Sep-04   Created
16
#......................................................................#
17
 
18
require 5.6.1;
19
use strict;
20
use warnings;
21
use Cwd;
22
use Getopt::Long;
23
 
24
my $opt_help;
25
my $version;
26
 
27
#
28
#   Parse the user options
29
#
30
my $result = GetOptions (
31
                "help+"         => \$opt_help,
32
                );
33
help() if ( !$result || $opt_help );
34
help ("Expecting one command line argument" )
35
    if ( $#ARGV != 0);
36
 
37
$version = $ARGV[0];
38
$version =~ s~^JATS_~~;
39
help ("Bad format for package version. Need nn.nn.nn" )
40
    unless ( $version =~ m~^(\d+\.\d+\.\d+)$~ );
41
 
42
#
43
#   Ensure that the jats.pl file has the correct version information
44
#   The version number in this file is important as it is published as
45
#   the JATS version number
46
#
47
my $line = qx(grep \"my.*\$GBE_VERSION\" ../TOOLS/jats.pl);
48
Error ('Cannot locate GBE_VERSION in jats.pl' ) unless ( $line );
49
 
50
$line =~ s~['"](.*).cr['"]~~;
51
$line = $1;
52
Error ("GBE_VERSION definition in jats.pl Does not match released version.",
53
        "Expecting: $version",
54
        "Got      : $line") unless( $line eq $version );
55
 
56
#
57
#   Remove any existing package directory
58
#
59
if ( -d "./pkg" )
60
{
61
    print "Removing existing package image\n";
62
    system ("rm -rf ./pkg");
63
}
64
 
65
print "Create package image\n";
66
mkdir  ("./pkg");
67
mkdir  ("./pkg/core_devl");
68
 
69
#
70
#   Create a new format descpkg file
71
#
72
my $pkgfile = "./pkg/core_devl/descpkg";
73
my $BUILDNAME_PACKAGE = "core_devl";
74
my $BUILDNAME_VERSION = $version;
75
my $BUILDNAME_PROJECT= "cr",
76
my $CurrentTime = localtime;
77
my $USER = $ENV{'USER'};
78
my $Cwd = getcwd();
79
 
80
 
81
open( DESCPKG, ">$pkgfile" ) ||
82
    Error( "cannot create $pkgfile" );
83
 
84
print DESCPKG "Package Name: $BUILDNAME_PACKAGE\n";
85
print DESCPKG "Version:      $BUILDNAME_VERSION.$BUILDNAME_PROJECT\n";
86
print DESCPKG "Released By:  $USER\n";
87
print DESCPKG "Released On:  $CurrentTime\n";
88
print DESCPKG "Path:         $Cwd\n";
89
print DESCPKG "\n";
90
print DESCPKG "Build Dependencies:\n";
91
print DESCPKG "\n";
92
close DESCPKG;
93
 
94
for my $dir (glob ('../BIN.*' ))
95
{
96
    print "Copy in: $dir\n";
97
    system ("cp -r $dir ./pkg/core_devl")
98
}
99
 
100
for my $dir qw(CFG TEMPLATES TOOLS)
101
{
102
    print "Copy in: $dir\n";
103
    system ("cp -r ../$dir ./pkg/core_devl")
104
}
105
 
106
for my $dir qw(TOOLS/LOCAL)
107
{
108
    print "Remove in: $dir\n";
109
    system ("rm -rf ./pkg/core_devl/$dir")
110
}
111
 
112
for my $file qw(Readme.txt PostInstall.sh ChangeLog.txt)
113
{
114
    print "Copy in: $file\n";
115
    system ("cp -r ../$file ./pkg/core_devl")
116
}
117
 
118
#
119
#   Update version info in some files
120
#
121
foreach my $file qw( TOOLS/jats.sh TOOLS/jats.bat )
122
{
123
    print "Insert version into: $file\n";
124
    system "sed -i -e 's~VERSION_TAG~${version}.cr~' ./pkg/core_devl/$file";
125
    if ( $? )
126
    {
127
        Error("Failure in SED command. Result: $?");
128
    }
129
}
130
 
131
system ( "jats.bat -here create_dpkg" );
132
 
133
print "Removing existing package image\n";
134
system ("rm -rf ./pkg");
135
exit 0;
136
 
137
########################################################################
138
#
139
#   Give the user a clue
140
#
141
sub help
142
{
143
    if ( $#_ >= 0 )
144
    {
145
        print STDERR    '-' x 80 . "\n";
146
        print STDERR    "ERROR: @_\n";
147
        print STDERR    '-' x 80 . "\n\n";
148
    }
149
 
150
    print STDERR    "Package JATS ready for release\n";
151
    print STDERR    "\n";
152
    print STDERR    "Usage: perl MakePackage nn.nn.nn\n";
153
    print STDERR    "\n";
154
    print STDERR    "Where opts:\n";
155
    print STDERR    "   -h              - Help message\n";
156
    print STDERR    "\n";
157
    print STDERR    "Where arguments:\n";
158
    print STDERR    "   nn.nn.nn        - The version of the release\n";
159
    print STDERR    "                     This should be based on the \n";
160
    print STDERR    "                     label applied to the package\n";
161
    print STDERR    "\n";
162
    exit 1;
163
}
164
 
165
#-------------------------------------------------------------------------------
166
# Function        : Message
167
#                   Warning
168
#                   Error
169
#                   _Message ( Internal use only )
170
#
171
# Description     : Error, Warning and Message routines
172
#                   These routines will display a message to the user
173
#                   with the module name.
174
#
175
#                   Multiple arguments are displayed on their own line
176
#                   with suitable spacing.
177
#
178
# Inputs          : Lines of text to display
179
#
180
# Returns         : Error() does not return
181
#
182
sub _Message
183
{
184
    my $tag = shift;                # First argument is a tag
185
 
186
    my $prefix = "";
187
    my $count = 0;
188
 
189
    #
190
    #   Generate the message prefix
191
    #   This will only be used on the first line
192
    #   All other lines will have a space filled prefix
193
    #
194
    $prefix .= $tag;
195
 
196
    foreach my $nextline ( @_ )
197
    {
198
        chomp( my $line = $nextline );
199
        $prefix = ' ' x length($prefix)
200
            if ( $count eq 1 );
201
 
202
        print "$prefix $line\n";
203
        $count++;
204
    }
205
}
206
 
207
sub Error
208
{
209
    _Message '(E)', @_;
210
    exit 1;
211
}
212
 
213
 
214