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 29... Line 29...
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[=TemplateName]            - Create named .tgz file, of the data area [not Debian scripts]
32
#                   --TarFile[=TemplateName]            - Create named .tgz file, of the data area [not Debian scripts]
33
#                   --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
34
#                   --NoArch                            - Marks the package as having no specific architecture
35
#                   --NoArch                            - Marks the package as having no specific architecture
35
#                   
36
#                   
36
#
37
#
37
#               Templates may contain:
38
#               Templates may contain:
38
#                   PACKAGE
39
#                   PACKAGE
Line 44... Line 45...
44
#......................................................................#
45
#......................................................................#
45
 
46
 
46
require 5.006_001;
47
require 5.006_001;
47
#use strict;
48
#use strict;
48
use warnings;
49
use warnings;
-
 
50
#use PackagerUtils;
49
 
51
 
50
#-------------------------------------------------------------------------------
52
#-------------------------------------------------------------------------------
51
# Function        : MakeDebianPackage
53
# Function        : MakeDebianPackage
52
#
54
#
53
# Description     : Create a Debian Package
55
# Description     : Create a Debian Package
Line 64... Line 66...
64
 
66
 
65
    my $build_name =  $::ScmBuildPackage;
67
    my $build_name =  $::ScmBuildPackage;
66
    my $build_version = $::ScmBuildVersionFull;
68
    my $build_version = $::ScmBuildVersionFull;
67
    my $build_variant = '';
69
    my $build_variant = '';
68
 
70
 
69
    my $script_set=0;
-
 
70
    my $name_set=0;
71
    my $name_set=0;
71
    my $variant_set=0;
72
    my $variant_set=0;
-
 
73
 
72
    my $deploy_mode = GetGlobalOption('DEBIAN_PACKAGE_DEPLOYABLE', 0);
74
    my $deploy_mode = GetGlobalOption('DEBIAN_PACKAGE_DEPLOYABLE', 0);
73
 
75
 
-
 
76
    my $tarOnly;
74
    my $tarFileName = '';
77
    my $tarFileName = '';
75
    my @outputFiles;
78
    my @outputFiles;
76
    my @optArgs;
79
    my @optArgs;
77
    my $noArch;
80
    my $noArch;
78
 
81
 
79
    #
82
    my @arglist;
80
    #   Take the project name and convert it into a full path
83
    my $rpmScript;
81
    #
84
    my $debianScript;
82
    my $script;
85
    my $script;
83
 
86
 
84
    #
87
    #
85
    #   Collect user arguments
88
    #   Collect user arguments
86
    #   They are all processed within the toolset
89
    #   They are all processed within the toolset
87
    #
90
    #
88
    foreach ( @elements )
91
    foreach ( @elements )
89
    {
92
    {
-
 
93
        push @arglist, $_;
-
 
94
 
90
        if ( m/^--Script=(.+)/i ) {
95
        if ( m/^--Script=(.+)/i ) {
-
 
96
            ReportError ("MakeDebianPackage: --Script. Debian script name already set") if $debianScript;
-
 
97
            ReportError ("MakeDebianPackage: --Script. RPM script name already set") if $rpmScript;
-
 
98
            $debianScript = $1;
91
            $script = $1;
99
            $rpmScript = $1;
-
 
100
            pop @arglist;
-
 
101
 
-
 
102
        } elsif ( m/^--RpmScript=(.+)/i ) {
-
 
103
            ReportError ("MakeDebianPackage: --RpmScript. RPM script name already set") if $rpmScript;
92
            $script_set++;
104
            $rpmScript = $1;
-
 
105
            pop @arglist;
-
 
106
 
-
 
107
        } elsif ( m/^--DebianScript=(.+)/i ) {
-
 
108
            ReportError ("MakeDebianPackage: --DebianScript. Debian script name already set") if $debianScript;
-
 
109
            $debianScript = $1;
-
 
110
            pop @arglist;
93
 
111
 
94
        } elsif ( m/^--Name=(.+)/i ) {
112
        } elsif ( m/^--Name=(.+)/i ) {
95
            $build_name = $1;
113
            $build_name = $1;
96
            $name_set++;
114
            $name_set++;
97
 
115
 
Line 103... Line 121...
103
            $deploy_mode = ! defined($1);
121
            $deploy_mode = ! defined($1);
104
 
122
 
105
        } elsif ( m/^--NoArch$/i ) {
123
        } elsif ( m/^--NoArch$/i ) {
106
            $noArch = 1;
124
            $noArch = 1;
107
 
125
 
-
 
126
        } elsif ( m/^--TarOnly$/i ) {
-
 
127
            $tarOnly = 1;
-
 
128
 
108
        } elsif ( m/^--TarFile(=(.*))?/i ) {
129
        } elsif ( m/^--TarFile(=(.*))?/i ) {
109
            $tarFileName = defined($1) ? $2 : 'DEFAULT';
130
            $tarFileName = defined($1) ? $2 : 'DEFAULT';
110
            
131
            
111
        } elsif ( m/^--/ ) {
132
        } elsif ( m/^--/ ) {
112
            Error("MakeDebianPackage. Unknown option: $_");
133
            ReportError("MakeDebianPackage. Unknown option: $_");
113
 
134
 
114
        } else {
135
        } else {
115
            Error("MakeDebianPackage. Unknown argument: $_");
136
            ReportError("MakeDebianPackage. Unknown argument: $_");
116
        }
137
        }
117
    }
138
    }
118
 
139
 
119
    #
140
    #
120
    #   Sanity test
141
    #   Sanity test
121
    #
142
    #
122
    Error ("MakeDebianPackage: Not supported on a GENERIC target") if ( $ScmPlatform eq 'GENERIC' );
143
    ReportError ("MakeDebianPackage: Not supported on a GENERIC target") if ( $ScmPlatform eq 'GENERIC' );
123
    Error ("MakeDebianPackage: Script name not defined") unless ( $script );
144
    ReportError ("MakeDebianPackage: Script name not defined") unless ( $debianScript || $rpmScript );
124
    Error ("MakeDebianPackage: --Script option can only be used once") if ( $script_set > 1 );
145
    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 );
146
    ReportError ("MakeDebianPackage: --Variant option can only be used once") if ( $variant_set > 1 );
-
 
147
    ErrorDoExit();
-
 
148
 
-
 
149
    #
-
 
150
    #   Determine what we are really doing
-
 
151
    #       Under Redhat we will generate an RPM
-
 
152
    #
-
 
153
    if ( ActivePlatform('PKG_RPM') ) {
-
 
154
        return unless (defined $rpmScript);
-
 
155
        return MakeRpmPackage ($platforms, "--Script=$rpmScript", @arglist );
-
 
156
    }
-
 
157
 
-
 
158
    return unless (defined $debianScript);
-
 
159
    $script = $debianScript;
-
 
160
    ErrorDoExit();
-
 
161
 
-
 
162
 
-
 
163
    #
-
 
164
    #   If the platform cannot generate a native installer then (silently) ignore the request
-
 
165
    #   unless the user has specified a --TarOnly
-
 
166
    #
-
 
167
    my $canGenerateInstaller = ActivePlatform('PKG_DEB');
-
 
168
    if ( !$canGenerateInstaller && !$tarOnly) {
126
    Error ("MakeDebianPackage: --Variant option can only be used once") if ( $variant_set > 1 );
169
        Verbose ("MakeDebianPackage: Installer not builadble for this platform");
-
 
170
        return;
-
 
171
    }
127
 
172
 
128
    #
173
    #
129
    #   Build up the build name
174
    #   Build up the build name
130
    #       Add variant to base name.
175
    #       Add variant to base name.
131
    #
176
    #
Line 147... Line 192...
147
    #       Whitespace   -> -
192
    #       Whitespace   -> -
148
    #       _           -> -
193
    #       _           -> -
149
    #       Remove multiple '-' characters
194
    #       Remove multiple '-' characters
150
    #       Lowercase all text
195
    #       Lowercase all text
151
    #
196
    #
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
 
197
 
167
    unless ( $build_name =~ m/^[a-z][-+a-z0-9]+$/ )
-
 
168
    {
198
    #
169
        Error ("Package Name does not conform to Debian Requirements",
199
    #   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
               "Massaged: $build_name");
-
 
175
    }
200
    #
-
 
201
    $build_name = canonicalName ($build_name, 'Debian');
176
 
202
 
-
 
203
    #
-
 
204
    #   Sanity test the version information
-
 
205
    #   
177
    unless ( $::ScmBuildVersionFull =~ m/^[0-9][-+:.A-Za-z0-9]+$/ )
206
    unless ( $::ScmBuildVersionFull =~ m/^[0-9][-+:.A-Za-z0-9]+$/ )
178
    {
207
    {
179
        Error ("Package Version does not conform to Debian Requirements",
208
        Error ("Package Version does not conform to Debian Requirements",
180
               "Must only contain: (a-zA-Z) (0-9), - and .",
209
               "Must only contain: (a-zA-Z) (0-9), - and .",
181
               "Must start with a number",
210
               "Must start with a number",
Line 228... Line 257...
228
        $tarFileName .= '.tgz' unless $tarFileName =~ m~\.tgz$~;
257
        $tarFileName .= '.tgz' unless $tarFileName =~ m~\.tgz$~;
229
        push @outputFiles,  $tarFileName;
258
        push @outputFiles,  $tarFileName;
230
 
259
 
231
        #push @optArgs, "-TarFile=--GeneratedProg{$tarFileName}";
260
        #push @optArgs, "-TarFile=--GeneratedProg{$tarFileName}";
232
        push @optArgs, "-TarFile=$tarFileName";
261
        push @optArgs, "-TarFile=$tarFileName";
-
 
262
        push (@optArgs, '-TarOnly' ) if $tarOnly;
233
    }
263
    }
234
 
264
 
235
    #
265
    #
236
    #   Simply use Generate Files
266
    #   Simply use Generate Files
237
    #       With lots of options
267
    #       With lots of options