Subversion Repositories DevTools

Rev

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

Rev 6856 Rev 6857
Line 1... Line 1...
1
########################################################################
1
########################################################################
2
# Copyright (C) 2007 ERG Limited, All rights reserved
2
# Copyright (c) VIX TECHNOLOGY (AUST) LTD
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
35
#                   --NoArch                            - Marks the package as having no specific architecture
34
#                   --NoArch                            - Marks the package as having no specific architecture
36
#                       
35
#                   
37
#
36
#
-
 
37
#               Templates may contain:
-
 
38
#                   PACKAGE
-
 
39
#                   VARIANT
-
 
40
#                   VERSION
-
 
41
#                   PLATFORM
-
 
42
#                   TYPE
-
 
43
#                       
38
#......................................................................#
44
#......................................................................#
39
 
45
 
40
require 5.006_001;
46
require 5.006_001;
41
#use strict;
47
#use strict;
42
use warnings;
48
use warnings;
Line 79... Line 85...
79
    #   Collect user arguments
85
    #   Collect user arguments
80
    #   They are all processed within the toolset
86
    #   They are all processed within the toolset
81
    #
87
    #
82
    foreach ( @elements )
88
    foreach ( @elements )
83
    {
89
    {
84
        if ( m/^--Script=(.+)/ ) {
90
        if ( m/^--Script=(.+)/i ) {
85
            $script = $1;
91
            $script = $1;
86
            $script_set++;
92
            $script_set++;
87
 
93
 
88
        } elsif ( m/^--Name=(.+)/ ) {
94
        } elsif ( m/^--Name=(.+)/i ) {
89
            $build_name = $1;
95
            $build_name = $1;
90
            $name_set++;
96
            $name_set++;
91
 
97
 
92
        } elsif ( m/^--Variant=(.+)/ ) {
98
        } elsif ( m/^--Variant=(.+)/i ) {
93
            $build_variant = $1;
99
            $build_variant = $1;
94
            $variant_set++;
100
            $variant_set++;
95
 
101
 
96
        } elsif ( m/^--DeployMode/ ) {
102
        } elsif ( m/^--(No)?DeployMode/i ) {
97
            $deploy_mode = 1;
103
            $deploy_mode = ! defined($1);
98
 
104
 
99
        } elsif ( m/^--NoDeployMode/ ) {
-
 
100
            $deploy_mode = 0;
-
 
101
 
-
 
102
        } elsif ( m/^--NoArch$/ ) {
105
        } elsif ( m/^--NoArch$/i ) {
103
            $noArch = 1;
106
            $noArch = 1;
104
 
107
 
105
        } elsif ( m/^--TarFile$/ ) {
108
        } elsif ( m/^--TarFile(=(.*))?/i ) {
106
            $tarFileName = 'DEFAULT';
109
            $tarFileName = defined($1) ? $2 : 'DEFAULT';
107
            
-
 
108
        } elsif ( m/^--TarFile=(.*)/ ) {
-
 
109
            $tarFileName = $1;
-
 
110
            
110
            
111
        } elsif ( m/^--/ ) {
111
        } elsif ( m/^--/ ) {
112
            Error("MakeDebianPackage. Unknown option: $_");
112
            Error("MakeDebianPackage. Unknown option: $_");
113
 
113
 
114
        } else {
114
        } else {
Line 134... Line 134...
134
        $build_name .= '-' . $build_variant;
134
        $build_name .= '-' . $build_variant;
135
    }
135
    }
136
 
136
 
137
    #
137
    #
138
    #   Sanity check the package name and version
138
    #   Sanity check the package name and version
139
    #   Debian has strict requirements than JATS
139
    #   Debian has stricter requirements than JATS
140
    #       Name:    Lower case letters (a-z), digits (0-9), plus (+) and minus (-) signs, and periods (.).
140
    #       Name:    Lower case letters (a-z), digits (0-9), plus (+) and minus (-) signs, and periods (.).
141
    #                Release Manager does not allow '.'
141
    #                Release Manager does not allow '.'
142
    #       Version: alphanumerics and the characters . + - : (full stop, plus, hyphen, colon) and should start with a digit
142
    #       Version: alphanumerics and the characters . + - : (full stop, plus, hyphen, colon) and should start with a digit
143
    #
143
    #
144
    #   Allow ( and cleanup )
144
    #   Allow ( and cleanup )
Line 168... Line 168...
168
    {
168
    {
169
        Error ("Package Name does not conform to Debian Requirements",
169
        Error ("Package Name does not conform to Debian Requirements",
170
               "Must be at least two characters long",
170
               "Must be at least two characters long",
171
               "Must start with an alphabetic character",
171
               "Must start with an alphabetic character",
172
               "Must only contain: (a-z) (0-9) and -",
172
               "Must only contain: (a-z) (0-9) and -",
173
               "Provided Name: $::ScmBuildPackage");
173
               "Provided Name: $::ScmBuildPackage",
-
 
174
               "Massaged: $build_name");
174
    }
175
    }
175
 
176
 
176
    unless ( $::ScmBuildVersionFull =~ m/^[0-9][-+:.A-Za-z0-9]+$/ )
177
    unless ( $::ScmBuildVersionFull =~ m/^[0-9][-+:.A-Za-z0-9]+$/ )
177
    {
178
    {
178
        Error ("Package Version does not conform to Debian Requirements",
179
        Error ("Package Version does not conform to Debian Requirements",
Line 188... Line 189...
188
    #   Note: "_" used since this is the format of dpkg-name
189
    #   Note: "_" used since this is the format of dpkg-name
189
    #   Note: dpkg-name generates: Name _ Version _ Architecture [ _ Type ]
190
    #   Note: dpkg-name generates: Name _ Version _ Architecture [ _ Type ]
190
    #
191
    #
191
    #
192
    #
192
    my $PkgType = $deploy_mode ? ( '_' . '$(GBE_TYPE)' ) : '' ;
193
    my $PkgType = $deploy_mode ? ( '_' . '$(GBE_TYPE)' ) : '' ;
193
    my $PkgArch = $::ScmPlatform;
194
    my $PkgArch = GetGlobalOption('PACKAGE_ARCH', $::ScmPlatform);
194
    if ($noArch)
195
        if ($noArch)
195
    {
196
        {
196
        $PkgArch = 'all';
197
            $PkgArch = 'all';
197
        $PkgType = '';
198
            $PkgType = '';
198
        push @optArgs, "-NoArch";
199
            push @optArgs, "-NoArch";
199
    }
200
        }
200
    my $DebianPkgName = "${build_name}_${::ScmBuildVersionFull}_${PkgArch}${PkgType}.deb";
201
    my $PkgName = "${build_name}_${::ScmBuildVersionFull}_${PkgArch}${PkgType}.deb";
201
    push @outputFiles,  $DebianPkgName;
202
    push @outputFiles,  $PkgName;
-
 
203
    push @optArgs, "-PkgArch=$PkgArch";
202
 
204
 
203
    #
205
    #
204
    #   Create name for the optional TGZ file
206
    #   Create name for the optional TGZ file
205
    #   Allow use to specify parts of the name symbolically
207
    #       Allow user to specify parts of the name symbolically
206
    #
208
    #
207
    if ($tarFileName)
209
    if ($tarFileName)
208
    {
210
    {
209
        if ($tarFileName eq 'DEFAULT')
211
        if ($tarFileName eq 'DEFAULT')
210
        {
212
        {
Line 213... Line 215...
213
            {
215
            {
214
                $tarFileName .= '_TYPE';
216
                $tarFileName .= '_TYPE';
215
            }
217
            }
216
        }
218
        }
217
 
219
 
-
 
220
        if ($noArch) {
-
 
221
            $PkgArch = 'all';
-
 
222
        }
-
 
223
 
218
        $tarFileName =~ s~PACKAGE~${build_name}~g;
224
        $tarFileName =~ s~PACKAGE~${build_name}~g;
219
        $tarFileName =~ s~VERSION~${::ScmBuildVersionFull}~g;
225
        $tarFileName =~ s~VERSION~${::ScmBuildVersionFull}~g;
220
        $tarFileName =~ s~PLATFORM~${PkgArch}~g;
226
        $tarFileName =~ s~PLATFORM~${PkgArch}~g;
221
        $tarFileName =~ s~TYPE~\$(GBE_TYPE)~;
227
        $tarFileName =~ s~TYPE~\$(GBE_TYPE)~;
222
        $tarFileName .= '.tgz';
228
        $tarFileName .= '.tgz' unless $tarFileName =~ m~\.tgz$~;
223
        push @outputFiles,  $tarFileName;
229
        push @outputFiles,  $tarFileName;
-
 
230
 
224
        push @optArgs, "-TarFile=--GeneratedProg{$tarFileName}";
231
        #push @optArgs, "-TarFile=--GeneratedProg{$tarFileName}";
-
 
232
        push @optArgs, "-TarFile=$tarFileName";
225
    }
233
    }
226
 
234
 
227
    #
235
    #
228
    #   Simply use Generate Files
236
    #   Simply use Generate Files
229
    #   With lots of options
237
    #       With lots of options
230
    #
238
    #
231
    Src ( '*', $script );
239
    Src ( '*', $script );
232
    GenerateFiles ('*', "--Tool=DebianPackager.pl",               # Associated tool
240
    GenerateFiles ('*', "--Tool=DebianPackager.pl",               # Associated tool
233
                        "-DebianPackage=--Prerequisite($script)", # Packager script
-
 
234
                        "--AutoGenerate",                         # Build when needed
241
                        "--AutoGenerate",                         # Build when needed
235
                        "--UnknownPreq",                          # Always build
242
                        "--UnknownPreq",                          # Always build
236
                        "--Clean",                                # Script supports jats clean
243
                        "--Clean",                                # Script supports jats clean
237
                        "--Text=Debian Package",                  # Display when building
244
                        "--Text=Debian Package",                  # Display when building
238
                        
245
                        
Line 259... Line 266...
259
                        '--Var(PackagePkgDir)',                   # My Package/pkg.target
266
                        '--Var(PackagePkgDir)',                   # My Package/pkg.target
260
 
267
 
261
                        '--Var(LocalIncDir)',                     # Installed Artifacts
268
                        '--Var(LocalIncDir)',                     # Installed Artifacts
262
                        '--Var(LocalLibDir)',
269
                        '--Var(LocalLibDir)',
263
                        '--Var(LocalBinDir)',
270
                        '--Var(LocalBinDir)',
264
                        '--Var(PkgArch)',
-
 
265
 
271
 
-
 
272
                        "-genDeb",                                # Type to generate
-
 
273
                        "-Script=--Prerequisite($script)",        # Packager script
266
                        "-Name=$build_name",                      # Base Package Name
274
                        "-Name=$build_name",                      # Massaged Package Name
267
                        "-Variant=$build_variant",                # Variant Name
275
                        "-Variant=$build_variant",                # Variant Name
268
                        "-Output=--GeneratedProg{$DebianPkgName}",# Specify output file
276
                        "-Output=--GeneratedProg{$PkgName}",      # Specify output file
269
                        @optArgs,                                 # Optional args - tarfile
277
                        @optArgs,                                 # Optional args
270
                        );
278
                        );
271
 
279
 
272
    #
280
    #
273
    #   The Packager has created a binary in the 'PROG' directory
281
    #   The Packager has created a binary in the 'PROG' directory
274
    #   Lets package it as a program.
282
    #   Lets package it as a program.
275
    #
283
    #
276
    if ($deploy_mode)
284
    if ($deploy_mode) {
277
    {
-
 
278
        PackageFile ('*', @outputFiles );
285
        PackageFile ('*', @outputFiles );
279
    }
286
    }
280
    else
287
    else {
281
    {
-
 
282
        PackageProg ('*', @outputFiles );
288
        PackageProg ('*', @outputFiles );
283
    }
289
    }
284
}
290
}
285
 
291
 
286
1;
292
1;