Subversion Repositories DevTools

Rev

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

Rev 6088 Rev 6242
Line 1... Line 1...
1
########################################################################
1
########################################################################
2
# Copyright (C) 2007 ERG Limited, All rights reserved
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 17... Line 17...
17
#                 When used the directive will use GenerateFiles to invoke
17
#                 When used the directive will use GenerateFiles to invoke
18
#                 a script (DebianPackager.pl) to actually do the hard work.
18
#                 a script (DebianPackager.pl) to actually do the hard work.
19
#
19
#
20
# Syntax        : MakeDebianPackage (<platforms>, Options+);
20
# Syntax        : MakeDebianPackage (<platforms>, Options+);
21
#                 Where Options may be one of:
21
#                 Where Options may be one of:
22
#                   --Script=DebianPackagerScript       - Mandatory. Name of a the debian script
22
#                   --Script=PackagerScript             - Mandatory. Name of a the packaging script
23
#                   --Name=Name                         - Debian Package name(optional)
23
#                   --Name=Name                         - Debian Package name(optional)
24
#                   --Variant=Text                      - Package Variant(optional)
24
#                   --Variant=Text                      - Package Variant(optional)
25
#                   --DeployMode                        - Create Deployable packages(optional)
25
#                   --DeployMode                        - Create Deployable packages(optional)
26
#                                                         Default for native targets
26
#                                                         Default for native targets
27
#                                                         These are:
27
#                                                         These are:
28
#                                                           * Packaged into the root of target pkg
28
#                                                           * Packaged into the root of target pkg
29
#                                                           * Have P or D in the name
29
#                                                           * Have P or D in the name
30
#                   --NoDeployMode                      - Create packages that cannot be directly deployed
30
#                   --NoDeployMode                      - Create packages that cannot be directly deployed
31
#                                                         Default for embedded devices
31
#                                                         Default for embedded devices
32
#                   --TarFile=name                      - Create named .tgz file, of the data area, not scripts
32
#                   --TarFile[=TemplateName]            - Create named .tgz file, of the data area [not Debian scripts]
33
#                                                         Name can contain PACKAGE, VERSION and TYPE
-
 
34
#                   --TarFile                           - Same as --TarFile=PACKAGE_VERSION_PLATFORM_TYPE or PACKAGE_VERSION_PLATFORM
33
#                   --TarFile                           - Same as --TarFile=PACKAGE_VERSION_PLATFORM_TYPE or PACKAGE_VERSION_PLATFORM
-
 
34
#                   --TarOnly                           - Suppress the Debian Build
35
#                   --NoArch                            - Marks the package as having no specific architecture
35
#                   --NoArch                            - Marks the package as having no specific architecture
36
#                       
36
#                   
37
#
37
#
-
 
38
#               Templates may contain:
-
 
39
#                   PACKAGE
-
 
40
#                   VARIANT
-
 
41
#                   VERSION
-
 
42
#                   PLATFORM
-
 
43
#                   TYPE
-
 
44
#                   ARCH
-
 
45
#                       
38
#......................................................................#
46
#......................................................................#
39
 
47
 
40
require 5.006_001;
48
require 5.006_001;
41
#use strict;
49
#use strict;
42
use warnings;
50
use warnings;
-
 
51
#use PackagerUtils;
43
 
52
 
44
#-------------------------------------------------------------------------------
53
#-------------------------------------------------------------------------------
45
# Function        : MakeDebianPackage
54
# Function        : MakeDebianPackage
46
#
55
#
47
# Description     : Create a Debian Package
56
# Description     : Create a Debian Package
Line 58... Line 67...
58
 
67
 
59
    my $build_name =  $::ScmBuildPackage;
68
    my $build_name =  $::ScmBuildPackage;
60
    my $build_version = $::ScmBuildVersionFull;
69
    my $build_version = $::ScmBuildVersionFull;
61
    my $build_variant = '';
70
    my $build_variant = '';
62
 
71
 
63
    my $script_set=0;
-
 
64
    my $name_set=0;
72
    my $name_set=0;
65
    my $variant_set=0;
73
    my $variant_set=0;
-
 
74
 
66
    my $deploy_mode = GetGlobalOption('DEBIAN_PACKAGE_DEPLOYABLE', 0);
75
    my $deploy_mode = GetGlobalOption('DEBIAN_PACKAGE_DEPLOYABLE', 0);
67
 
76
 
-
 
77
    my $tarOnly;
68
    my $tarFileName = '';
78
    my $tarFileName = '';
69
    my @outputFiles;
79
    my @outputFiles;
70
    my @optArgs;
80
    my @optArgs;
71
    my $noArch;
81
    my $noArch;
72
 
82
 
73
    #
83
    my @arglist;
74
    #   Take the project name and convert it into a full path
84
    my $rpmScript;
75
    #
85
    my $debianScript;
76
    my $script;
86
    my $script;
77
 
87
 
78
    #
88
    #
79
    #   Collect user arguments
89
    #   Collect user arguments
80
    #   They are all processed within the toolset
90
    #   They are all processed within the toolset
81
    #
91
    #
82
    foreach ( @elements )
92
    foreach ( @elements )
83
    {
93
    {
84
        if ( m/^--Script=(.+)/ ) {
-
 
85
            $script = $1;
94
        push @arglist, $_;
86
            $script_set++;
-
 
87
 
95
 
-
 
96
        if ( m/^--Script=(.+)/i ) {
-
 
97
            ReportError ("MakeDebianPackage: --Script. Debian script name already set") if $debianScript;
-
 
98
            ReportError ("MakeDebianPackage: --Script. RPM script name already set") if $rpmScript;
-
 
99
            $debianScript = $1;
-
 
100
            $rpmScript = $1;
-
 
101
            pop @arglist;
-
 
102
 
-
 
103
        } elsif ( m/^--RpmScript=(.+)/i ) {
-
 
104
            ReportError ("MakeDebianPackage: --RpmScript. RPM script name already set") if $rpmScript;
-
 
105
            $rpmScript = $1;
-
 
106
            pop @arglist;
-
 
107
 
-
 
108
        } elsif ( m/^--DebianScript=(.+)/i ) {
-
 
109
            ReportError ("MakeDebianPackage: --DebianScript. Debian script name already set") if $debianScript;
-
 
110
            $debianScript = $1;
-
 
111
            pop @arglist;
-
 
112
 
88
        } elsif ( m/^--Name=(.+)/ ) {
113
        } elsif ( m/^--Name=(.+)/i ) {
89
            $build_name = $1;
114
            $build_name = $1;
90
            $name_set++;
115
            $name_set++;
91
 
116
 
92
        } elsif ( m/^--Variant=(.+)/ ) {
117
        } elsif ( m/^--Variant=(.+)/i ) {
93
            $build_variant = $1;
118
            $build_variant = $1;
94
            $variant_set++;
119
            $variant_set++;
95
 
120
 
96
        } elsif ( m/^--DeployMode/ ) {
-
 
97
            $deploy_mode = 1;
-
 
98
 
-
 
99
        } elsif ( m/^--NoDeployMode/ ) {
121
        } elsif ( m/^--(No)?DeployMode/i ) {
100
            $deploy_mode = 0;
122
            $deploy_mode = ! defined($1);
101
 
123
 
102
        } elsif ( m/^--NoArch$/ ) {
124
        } elsif ( m/^--NoArch$/i ) {
103
            $noArch = 1;
125
            $noArch = 1;
104
 
126
 
105
        } elsif ( m/^--TarFile$/ ) {
127
        } elsif ( m/^--TarOnly$/i ) {
106
            $tarFileName = 'DEFAULT';
128
            $tarOnly = 1;
107
            
129
 
108
        } elsif ( m/^--TarFile=(.*)/ ) {
130
        } elsif ( m/^--TarFile(=(.*))?/i ) {
109
            $tarFileName = $1;
131
            $tarFileName = defined($1) ? $2 : 'DEFAULT';
110
            
132
            
111
        } elsif ( m/^--/ ) {
133
        } elsif ( m/^--/ ) {
112
            Error("MakeDebianPackage. Unknown option: $_");
134
            ReportError("MakeDebianPackage. Unknown option: $_");
113
 
135
 
114
        } else {
136
        } else {
115
            Error("MakeDebianPackage. Unknown argument: $_");
137
            ReportError("MakeDebianPackage. Unknown argument: $_");
116
        }
138
        }
117
    }
139
    }
118
 
140
 
119
    #
141
    #
120
    #   Sanity test
142
    #   Sanity test
121
    #
143
    #
122
    Error ("MakeDebianPackage: Not supported on a GENERIC target") if ( $ScmPlatform eq 'GENERIC' );
144
    ReportError ("MakeDebianPackage: Not supported on a GENERIC target") if ( $ScmPlatform eq 'GENERIC' );
123
    Error ("MakeDebianPackage: Script name not defined") unless ( $script );
145
    ReportError ("MakeDebianPackage: Script name not defined") unless ( $debianScript || $rpmScript );
124
    Error ("MakeDebianPackage: --Script option can only be used once") if ( $script_set > 1 );
146
    ReportError ("MakeDebianPackage: --Name option can only be used once") if ( $name_set > 1 );
125
    Error ("MakeDebianPackage: --Name option can only be used once") if ( $name_set > 1 );
147
    ReportError ("MakeDebianPackage: --Variant option can only be used once") if ( $variant_set > 1 );
-
 
148
    ErrorDoExit();
-
 
149
 
-
 
150
    #
-
 
151
    #   Determine what we are really doing
-
 
152
    #       Under Redhat we will generate an RPM
-
 
153
    #
-
 
154
    if ( ActivePlatform('PKG_RPM') ) {
-
 
155
        return unless (defined $rpmScript);
-
 
156
        return MakeRpmPackage ($platforms, "--Script=$rpmScript", @arglist );
-
 
157
    }
-
 
158
 
-
 
159
    return unless (defined $debianScript);
-
 
160
    $script = $debianScript;
-
 
161
    ErrorDoExit();
-
 
162
 
-
 
163
 
-
 
164
    #
-
 
165
    #   If the platform cannot generate a native installer then (silently) ignore the request
-
 
166
    #   unless the user has specified a --TarOnly
-
 
167
    #
-
 
168
    my $canGenerateInstaller = ActivePlatform('PKG_DEB');
-
 
169
    if ( !$canGenerateInstaller && !$tarOnly) {
126
    Error ("MakeDebianPackage: --Variant option can only be used once") if ( $variant_set > 1 );
170
        Verbose ("MakeDebianPackage: Installer not builadble for this platform");
-
 
171
        return;
-
 
172
    }
127
 
173
 
128
    #
174
    #
129
    #   Build up the build name
175
    #   Build up the build name
130
    #       Add variant to base name.
176
    #       Add variant to base name.
131
    #
177
    #
Line 134... Line 180...
134
        $build_name .= '-' . $build_variant;
180
        $build_name .= '-' . $build_variant;
135
    }
181
    }
136
 
182
 
137
    #
183
    #
138
    #   Sanity check the package name and version
184
    #   Sanity check the package name and version
139
    #   Debian has strict requirements than JATS
185
    #   Debian has stricter requirements than JATS
140
    #       Name:    Lower case letters (a-z), digits (0-9), plus (+) and minus (-) signs, and periods (.).
186
    #       Name:    Lower case letters (a-z), digits (0-9), plus (+) and minus (-) signs, and periods (.).
141
    #                Release Manager does not allow '.'
187
    #                Release Manager does not allow '.'
142
    #       Version: alphanumerics and the characters . + - : (full stop, plus, hyphen, colon) and should start with a digit
188
    #       Version: alphanumerics and the characters . + - : (full stop, plus, hyphen, colon) and should start with a digit
143
    #
189
    #
144
    #   Allow ( and cleanup )
190
    #   Allow ( and cleanup )
Line 147... Line 193...
147
    #       Whitespace   -> -
193
    #       Whitespace   -> -
148
    #       _           -> -
194
    #       _           -> -
149
    #       Remove multiple '-' characters
195
    #       Remove multiple '-' characters
150
    #       Lowercase all text
196
    #       Lowercase all text
151
    #
197
    #
152
    my $cvt = 0;
-
 
153
    $cvt = 1 if ( $build_name =~ s/^ERG/erg-/ );
-
 
154
    $cvt = 2 if ( $build_name =~ s/^VIX/vix-/ );
-
 
155
    $cvt = 3 if ( $build_name =~ s~\s~-~g );
-
 
156
    $cvt = 4 if ( $build_name =~ s~_~-~g );
-
 
157
    $cvt = 5 if ( $build_name =~ s~--+~-~g );
-
 
158
    if ( $build_name =~ m/[A-Z]/ )
-
 
159
    {
-
 
160
        $cvt = 6;
-
 
161
        $build_name = lc $build_name;
-
 
162
    }
-
 
163
 
-
 
164
    Warning ("Package Name converted to debian friendly form: $build_name")
-
 
165
        if ( $cvt );
-
 
166
 
198
 
167
    unless ( $build_name =~ m/^[a-z][-+a-z0-9]+$/ )
-
 
168
    {
199
    #
169
        Error ("Package Name does not conform to Debian Requirements",
200
    #   Convert the build_name to a form that is Debian complient
170
               "Must be at least two characters long",
-
 
171
               "Must start with an alphabetic character",
-
 
172
               "Must only contain: (a-z) (0-9) and -",
-
 
173
               "Provided Name: $::ScmBuildPackage");
-
 
174
    }
201
    #
-
 
202
    $build_name = canonicalName ($build_name, 'Debian');
175
 
203
 
-
 
204
    #
-
 
205
    #   Sanity test the version information
-
 
206
    #   
176
    unless ( $::ScmBuildVersionFull =~ m/^[0-9][-+:.A-Za-z0-9]+$/ )
207
    unless ( $::ScmBuildVersionFull =~ m/^[0-9][-+:.A-Za-z0-9]+$/ )
177
    {
208
    {
178
        Error ("Package Version does not conform to Debian Requirements",
209
        Error ("Package Version does not conform to Debian Requirements",
179
               "Must only contain: (a-zA-Z) (0-9), - and .",
210
               "Must only contain: (a-zA-Z) (0-9), - and .",
180
               "Must start with a number",
211
               "Must start with a number",
Line 188... Line 219...
188
    #   Note: "_" used since this is the format of dpkg-name
219
    #   Note: "_" used since this is the format of dpkg-name
189
    #   Note: dpkg-name generates: Name _ Version _ Architecture [ _ Type ]
220
    #   Note: dpkg-name generates: Name _ Version _ Architecture [ _ Type ]
190
    #
221
    #
191
    #
222
    #
192
    my $PkgType = $deploy_mode ? ( '_' . '$(GBE_TYPE)' ) : '' ;
223
    my $PkgType = $deploy_mode ? ( '_' . '$(GBE_TYPE)' ) : '' ;
-
 
224
    my $PkgArch = GetGlobalOption('PACKAGE_ARCH', $::ScmPlatform);
193
    my $PkgArch = $::ScmPlatform;
225
    my $Platform = $::ScmPlatform;
194
    if ($noArch)
226
        if ($noArch) {
195
    {
227
            $PkgArch = 'all';
196
        $PkgArch = 'all';
228
            $Platform = 'all';
197
        $PkgType = '';
229
            $PkgType = '';
198
        push @optArgs, "-NoArch";
230
            push @optArgs, "-NoArch";
199
    }
231
        }
-
 
232
 
200
    my $DebianPkgName = "${build_name}_${::ScmBuildVersionFull}_${PkgArch}${PkgType}.deb";
233
    my $PkgName = "${build_name}_${::ScmBuildVersionFull}_${Platform}${PkgType}.deb";
201
    push @outputFiles,  $DebianPkgName;
234
    push @outputFiles,  $PkgName;
-
 
235
    push @optArgs, "-PkgArch=$PkgArch";
202
 
236
 
203
    #
237
    #
204
    #   Create name for the optional TGZ file
238
    #   Create name for the optional TGZ file
205
    #   Allow use to specify parts of the name symbolically
239
    #       Allow user to specify parts of the name symbolically
206
    #
240
    #
207
    if ($tarFileName)
241
    if ($tarFileName)
208
    {
242
    {
209
        if ($tarFileName eq 'DEFAULT')
243
        if ($tarFileName eq 'DEFAULT')
210
        {
244
        {
Line 213... Line 247...
213
            {
247
            {
214
                $tarFileName .= '_TYPE';
248
                $tarFileName .= '_TYPE';
215
            }
249
            }
216
        }
250
        }
217
 
251
 
-
 
252
        if ($noArch) {
-
 
253
            $PkgArch = 'all';
-
 
254
        }
-
 
255
 
218
        $tarFileName =~ s~PACKAGE~${build_name}~g;
256
        $tarFileName =~ s~PACKAGE~${build_name}~g;
219
        $tarFileName =~ s~VERSION~${::ScmBuildVersionFull}~g;
257
        $tarFileName =~ s~VERSION~${::ScmBuildVersionFull}~g;
220
        $tarFileName =~ s~PLATFORM~${PkgArch}~g;
258
        $tarFileName =~ s~PLATFORM~${Platform}~g;
-
 
259
        $tarFileName =~ s~ARCH~${PkgArch}~g;
221
        $tarFileName =~ s~TYPE~\$(GBE_TYPE)~;
260
        $tarFileName =~ s~TYPE~\$(GBE_TYPE)~;
222
        $tarFileName .= '.tgz';
261
        $tarFileName .= '.tgz' unless $tarFileName =~ m~\.tgz$~;
223
        push @outputFiles,  $tarFileName;
262
        push @outputFiles,  $tarFileName;
-
 
263
 
224
        push @optArgs, "-TarFile=--GeneratedProg{$tarFileName}";
264
        #push @optArgs, "-TarFile=--GeneratedProg{$tarFileName}";
-
 
265
        push @optArgs, "-TarFile=$tarFileName";
-
 
266
        push (@optArgs, '-TarOnly' ) if $tarOnly;
225
    }
267
    }
226
 
268
 
227
    #
269
    #
228
    #   Simply use Generate Files
270
    #   Simply use Generate Files
229
    #   With lots of options
271
    #       With lots of options
230
    #
272
    #
231
    Src ( '*', $script );
273
    Src ( '*', $script );
232
    GenerateFiles ('*', "--Tool=DebianPackager.pl",               # Associated tool
274
    GenerateFiles ('*', "--Tool=DebianPackager.pl",               # Associated tool
233
                        "-DebianPackage=--Prerequisite($script)", # Packager script
-
 
234
                        "--AutoGenerate",                         # Build when needed
275
                        "--AutoGenerate",                         # Build when needed
235
                        "--UnknownPreq",                          # Always build
276
                        "--UnknownPreq",                          # Always build
236
                        "--Clean",                                # Script supports jats clean
277
                        "--Clean",                                # Script supports jats clean
237
                        "--Text=Debian Package",                  # Display when building
278
                        "--Text=Debian Package",                  # Display when building
238
                        
279
                        
Line 259... Line 300...
259
                        '--Var(PackagePkgDir)',                   # My Package/pkg.target
300
                        '--Var(PackagePkgDir)',                   # My Package/pkg.target
260
 
301
 
261
                        '--Var(LocalIncDir)',                     # Installed Artifacts
302
                        '--Var(LocalIncDir)',                     # Installed Artifacts
262
                        '--Var(LocalLibDir)',
303
                        '--Var(LocalLibDir)',
263
                        '--Var(LocalBinDir)',
304
                        '--Var(LocalBinDir)',
264
                        '--Var(PkgArch)',
-
 
265
 
305
 
-
 
306
                        "-genDeb",                                # Type to generate
-
 
307
                        "-Script=--Prerequisite($script)",        # Packager script
266
                        "-Name=$build_name",                      # Base Package Name
308
                        "-Name=$build_name",                      # Massaged Package Name
267
                        "-Variant=$build_variant",                # Variant Name
309
                        "-Variant=$build_variant",                # Variant Name
268
                        "-Output=--GeneratedProg{$DebianPkgName}",# Specify output file
310
                        "-Output=--GeneratedProg{$PkgName}",      # Specify output file
269
                        @optArgs,                                 # Optional args - tarfile
311
                        @optArgs,                                 # Optional args
270
                        );
312
                        );
271
 
313
 
272
    #
314
    #
273
    #   The Packager has created a binary in the 'PROG' directory
315
    #   The Packager has created a binary in the 'PROG' directory
274
    #   Lets package it as a program.
316
    #   Lets package it as a program.
275
    #
317
    #
276
    if ($deploy_mode)
318
    if ($deploy_mode) {
277
    {
-
 
278
        PackageFile ('*', @outputFiles );
319
        PackageFile ('*', @outputFiles );
279
    }
320
    }
280
    else
321
    else {
281
    {
-
 
282
        PackageProg ('*', @outputFiles );
322
        PackageProg ('*', @outputFiles );
283
    }
323
    }
284
}
324
}
285
 
325
 
286
1;
326
1;