Subversion Repositories DevTools

Rev

Rev 6857 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6857 Rev 6861
Line 1... Line 1...
1
########################################################################
1
########################################################################
2
# Copyright (c) VIX TECHNOLOGY (AUST) LTD
2
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
3
#
3
#
4
# Module name   : jats.sh
4
# Module name   : jats.sh
5
# Module type   : Makefile system
5
# Module type   : Makefile system
6
# Compiler(s)   : n/a
6
# Compiler(s)   : n/a
7
# Environment(s): jats
7
# Environment(s): jats
Line 20... Line 20...
20
# Syntax        : MakeRpmPackage (<platforms>, Options+);
20
# Syntax        : MakeRpmPackage (<platforms>, Options+);
21
#                 Where Options may be one of:
21
#                 Where Options may be one of:
22
#                   --Script=PackagerScript             - Mandatory. Name of a the packaging script
22
#                   --Script=PackagerScript             - Mandatory. Name of a the packaging script
23
#                   --Name=Name                         - Redhat Package name(optional)
23
#                   --Name=Name                         - Redhat Package name(optional)
24
#                   --Variant=Text                      - Package Variant(optional)
24
#                   --Variant=Text                      - Package Variant(optional)
-
 
25
#                   --DeployMode                        - Ignored
-
 
26
#                   --NoDeployMode                      - Ignored
-
 
27
#                                                         Default for embedded devices
25
#                   --TarFile[=TemplateName]            - Create named .tgz file, of the data area [not Debian scripts]
28
#                   --TarFile[=TemplateName]            - Create named .tgz file, of the data area [not Debian scripts]
26
#                   --TarFile                           - Same as --TarFile=PACKAGE_VERSION_PLATFORM_TYPE or PACKAGE_VERSION_PLATFORM
29
#                   --TarFile                           - Same as --TarFile=PACKAGE_VERSION_PLATFORM_TYPE or PACKAGE_VERSION_PLATFORM
-
 
30
#                   --TarOnly                           - Suppress the Debian Build
27
#                   --NoArch                            - Marks the package as having no specific architecture
31
#                   --NoArch                            - Marks the package as having no specific architecture
28
#
32
#
29
#               Templates may contain:
33
#               Templates may contain:
30
#                   PACKAGE
34
#                   PACKAGE
31
#                   VARIANT
35
#                   VARIANT
Line 37... Line 41...
37
#......................................................................#
41
#......................................................................#
38
 
42
 
39
require 5.006_001;
43
require 5.006_001;
40
#use strict;
44
#use strict;
41
use warnings;
45
use warnings;
-
 
46
#use PackagerUtils;
42
 
47
 
43
#-------------------------------------------------------------------------------
48
#-------------------------------------------------------------------------------
44
# Function        : MakeRpmPackage
49
# Function        : MakeRpmPackage
45
#
50
#
46
# Description     : Create a Debian Package
51
# Description     : Create a Debian Package
Line 57... Line 62...
57
 
62
 
58
    my $build_name =  $::ScmBuildPackage;
63
    my $build_name =  $::ScmBuildPackage;
59
    my $build_version = $::ScmBuildVersionFull;
64
    my $build_version = $::ScmBuildVersionFull;
60
    my $build_variant = '';
65
    my $build_variant = '';
61
 
66
 
62
    my $script_set=0;
-
 
63
    my $name_set=0;
67
    my $name_set=0;
64
    my $variant_set=0;
68
    my $variant_set=0;
65
 
69
 
-
 
70
    my $tarOnly;
66
    my $tarFileName = '';
71
    my $tarFileName = '';
67
    my @outputFiles;
72
    my @outputFiles;
68
    my @optArgs;
73
    my @optArgs;
69
    my $noArch;
74
    my $noArch;
70
 
75
 
71
    #
-
 
72
    #   Take the project name and convert it into a full path
-
 
73
    #
-
 
74
    my $script;
76
    my $script;
75
 
77
 
76
    #
78
    #
77
    #   Collect user arguments
79
    #   Collect user arguments
78
    #   They are all processed within the toolset
80
    #   They are all processed within the toolset
79
    #
81
    #
80
    foreach ( @elements )
82
    foreach ( @elements )
81
    {
83
    {
82
        if ( m/^--Script=(.+)/i ) {
84
        if ( m/^--Script=(.+)/i ) {
-
 
85
            ReportError ("MakeRpmPackage: --Script. RPM script name already set") if $script;
83
            $script = $1;
86
            $script = $1;
84
            $script_set++;
-
 
85
 
87
 
-
 
88
        } elsif ( m/^--RpmScript=(.+)/i ) {
-
 
89
            ReportError ("MakeDebianPackage: --RpmScript. RPM script name already set") if $script;
-
 
90
            $script = $1;
86
        } elsif ( m/^--Name=(.+)/i ) {
91
        } elsif ( m/^--Name=(.+)/i ) {
87
            $build_name = $1;
92
            $build_name = $1;
88
            $name_set++;
93
            $name_set++;
89
 
94
 
90
        } elsif ( m/^--Variant=(.+)/i ) {
95
        } elsif ( m/^--Variant=(.+)/i ) {
91
            $build_variant = $1;
96
            $build_variant = $1;
92
            $variant_set++;
97
            $variant_set++;
93
 
98
 
-
 
99
        } elsif ( m/^--(No)?DeployMode/i ) {
-
 
100
 
94
        } elsif ( m/^--NoArch$/i ) {
101
        } elsif ( m/^--NoArch$/i ) {
95
            $noArch = 1;
102
            $noArch = 1;
96
 
103
 
-
 
104
        } elsif ( m/^--TarOnly$/i ) {
-
 
105
            $tarOnly = 1;
-
 
106
 
97
        } elsif ( m/^--TarFile(=(.*))?/i ) {
107
        } elsif ( m/^--TarFile(=(.*))?/i ) {
98
            $tarFileName = defined($1) ? $2 : 'DEFAULT';
108
            $tarFileName = defined($1) ? $2 : 'DEFAULT';
99
            
109
            
100
        } elsif ( m/^--/ ) {
110
        } elsif ( m/^--/ ) {
101
            Error("MakeRpmPackage. Unknown option: $_");
111
            ReportError("MakeRpmPackage. Unknown option: $_");
102
 
112
 
103
        } else {
113
        } else {
104
            Error("MakeRpmPackage. Unknown argument: $_");
114
            ReportError("MakeRpmPackage. Unknown argument: $_");
105
        }
115
        }
106
    }
116
    }
107
 
117
 
108
    #
118
    #
109
    #   Sanity test
119
    #   Sanity test
110
    #
120
    #
111
    Error ("MakeRpmPackage: Not supported on a GENERIC target") if ( $ScmPlatform eq 'GENERIC' );
121
    ReportError ("MakeRpmPackage: Not supported on a GENERIC target") if ( $ScmPlatform eq 'GENERIC' );
112
    Error ("MakeRpmPackage: Script name not defined") unless ( $script );
122
    ReportError ("MakeRpmPackage: Script name not defined") unless ( $script );
113
    Error ("MakeRpmPackage: --Script option can only be used once") if ( $script_set > 1 );
-
 
114
    Error ("MakeRpmPackage: --Name option can only be used once") if ( $name_set > 1 );
123
    ReportError ("MakeRpmPackage: --Name option can only be used once") if ( $name_set > 1 );
115
    Error ("MakeRpmPackage: --Variant option can only be used once") if ( $variant_set > 1 );
124
    ReportError ("MakeRpmPackage: --Variant option can only be used once") if ( $variant_set > 1 );
-
 
125
    ErrorDoExit();
116
 
126
 
117
    #
127
    #
-
 
128
    #   If the platform cannot generate a native installer then (silently) ignore the request
-
 
129
    #   unless the user has specified a --TarOnly
-
 
130
    #
-
 
131
    my $canGenerateInstaller = ActivePlatform('PKG_RPM');
-
 
132
    if ( !$canGenerateInstaller && !$tarOnly) {
-
 
133
        Verbose ("MakeRpmPackage: Installer not builadble for this platform");
-
 
134
        return;
-
 
135
    }
-
 
136
 
118
    #   Sanity check the package name and version
137
    #   Sanity check the package name and version
119
    #   RedHat has stricter requirements than JATS
138
    #   RedHat has stricter requirements than JATS
120
    #       Name:    Upper and Lower case letters (a-z), digits (0-9), plus (+) and minus (-) signs, and periods (.).
139
    #       Name:    Upper and Lower case letters (a-z), digits (0-9), plus (+) and minus (-) signs, and periods (.).
121
    #                '-' is used as a field seperator, although it is allowed in names
140
    #                '-' is used as a field seperator, although it is allowed in names
122
    #                Release Manager does not allow '.'
141
    #                Release Manager does not allow '.'
Line 126... Line 145...
126
    #       Whitespace   -> -
145
    #       Whitespace   -> -
127
    #       _           -> -
146
    #       _           -> -
128
    #       Remove multiple '-' characters
147
    #       Remove multiple '-' characters
129
    #       Lowercase all text
148
    #       Lowercase all text
130
    #
149
    #
131
    my $cvt = 0;
-
 
132
    $cvt = 3 if ( $build_name =~ s~\s~_~g );
-
 
133
    $cvt = 4 if ( $build_name =~ s~-~_~g );
-
 
134
    $cvt = 5 if ( $build_name =~ s~__+~-~g );
-
 
135
 
150
 
136
    Warning ("Package Name converted to RedHat friendly form: $build_name")
151
    $build_name = canonicalName ($build_name, 'RPM');
137
        if ( $cvt );
-
 
138
 
152
 
139
    unless ( $build_name =~ m/^[a-zA-Z][_+a-zA-Z0-9]+$/ )
-
 
140
    {
153
    #
141
        Error ("Package Name does not conform to RedHat Requirements",
-
 
142
               "Must be at least two characters long",
154
    #   Sanity test the version information
143
               "Must start with an alphabetic character",
-
 
144
               "Must only contain: (a-zA-Z) (0-9) and _",
-
 
145
               "Provided Name: $::ScmBuildPackage",
-
 
146
               "Massaged: $build_name");
-
 
147
    }
155
    #   
148
 
156
 
149
    unless ( $::ScmBuildVersionFull =~ m/^[0-9][-+:.A-Za-z0-9]+$/ )
157
    unless ( $::ScmBuildVersionFull =~ m/^[0-9][-+:.A-Za-z0-9]+$/ )
150
    {
158
    {
151
        Error ("Package Version does not conform to RedHat Requirements",
159
        Error ("Package Version does not conform to RedHat Requirements",
152
               "Must only contain: (a-zA-Z) (0-9), _ and .",
160
               "Must only contain: (a-zA-Z) (0-9), _ and .",
Line 158... Line 166...
158
    #   Build up the build name
166
    #   Build up the build name
159
    #       Add variant to base name.
167
    #       Add variant to base name.
160
    #
168
    #
161
    if ( $build_variant )
169
    if ( $build_variant )
162
    {
170
    {
163
        unless ( $build_variant =~ m/^[a-z[A-Z]][_+a-zA-Z0-9]+$/ )
171
        unless ( $build_variant =~ m/^[a-z[A-Z][_+a-zA-Z0-9]+$/ )
164
        {
172
        {
165
            Error ("Build Variant does not conform to RedHat Requirements",
173
            Error ("Build Variant does not conform to RedHat Requirements",
166
                   "Must be at least two characters long",
174
                   "Must be at least two characters long",
167
                   "Must start with an alphabetic character",
175
                   "Must start with an alphabetic character",
168
                   "Must only contain: (a-zA-Z) (0-9) and _",
176
                   "Must only contain: (a-zA-Z) (0-9) and _",
Line 222... Line 230...
222
        $tarFileName .= '.tgz' unless $tarFileName =~ m~\.tgz$~;
230
        $tarFileName .= '.tgz' unless $tarFileName =~ m~\.tgz$~;
223
        push @outputFiles,  $tarFileName;
231
        push @outputFiles,  $tarFileName;
224
 
232
 
225
        #push @optArgs, "-TarFile=--GeneratedProg{$tarFileName}";
233
        #push @optArgs, "-TarFile=--GeneratedProg{$tarFileName}";
226
        push @optArgs, "-TarFile=$tarFileName";
234
        push @optArgs, "-TarFile=$tarFileName";
-
 
235
        push (@optArgs, '-TarOnly' ) if $tarOnly;
227
    }
236
    }
228
 
237
 
229
    #
238
    #
230
    #   Simply use Generate Files
239
    #   Simply use Generate Files
231
    #       With lots of options
240
    #       With lots of options