| 407 |
dpurdie |
1 |
########################################################################
|
| 6242 |
dpurdie |
2 |
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
|
| 407 |
dpurdie |
3 |
#
|
|
|
4 |
# Module name : jats.sh
|
|
|
5 |
# Module type : Makefile system
|
|
|
6 |
# Compiler(s) : n/a
|
|
|
7 |
# Environment(s): jats
|
|
|
8 |
#
|
|
|
9 |
# Description : This package extends the JATS toolset at build time
|
|
|
10 |
# It provides additional directives to the JATS makefiles
|
|
|
11 |
# to simplify the directives.
|
|
|
12 |
#
|
|
|
13 |
# The directive matches up with a run-time tool to
|
|
|
14 |
# do the bulk of the work.
|
|
|
15 |
#
|
|
|
16 |
# Operation : This package adds the JATS directive MakeDebianPackage
|
|
|
17 |
# When used the directive will use GenerateFiles to invoke
|
|
|
18 |
# a script (DebianPackager.pl) to actually do the hard work.
|
|
|
19 |
#
|
|
|
20 |
# Syntax : MakeDebianPackage (<platforms>, Options+);
|
|
|
21 |
# Where Options may be one of:
|
| 6242 |
dpurdie |
22 |
# --Script=PackagerScript - Mandatory. Name of a the packaging script
|
| 4188 |
dpurdie |
23 |
# --Name=Name - Debian Package name(optional)
|
|
|
24 |
# --Variant=Text - Package Variant(optional)
|
| 6738 |
dpurdie |
25 |
# --VersionPrefix=Text - Prefixes the version with the passed text(optional)
|
|
|
26 |
# --ExtDesc=Text - Stored in the variable $opt_extdesc availabe in the
|
|
|
27 |
# packaging script(optional)
|
| 4188 |
dpurdie |
28 |
# --DeployMode - Create Deployable packages(optional)
|
| 4907 |
dpurdie |
29 |
# Default for native targets
|
| 4188 |
dpurdie |
30 |
# These are:
|
|
|
31 |
# * Packaged into the root of target pkg
|
|
|
32 |
# * Have P or D in the name
|
| 5857 |
dpurdie |
33 |
# --NoDeployMode - Create packages that cannot be directly deployed
|
| 5215 |
dpurdie |
34 |
# Default for embedded devices
|
| 6242 |
dpurdie |
35 |
# --TarFile[=TemplateName] - Create named .tgz file, of the data area [not Debian scripts]
|
| 4740 |
dpurdie |
36 |
# --TarFile - Same as --TarFile=PACKAGE_VERSION_PLATFORM_TYPE or PACKAGE_VERSION_PLATFORM
|
| 6242 |
dpurdie |
37 |
# --TarOnly - Suppress the Debian Build
|
| 5215 |
dpurdie |
38 |
# --NoArch - Marks the package as having no specific architecture
|
| 6242 |
dpurdie |
39 |
#
|
|
|
40 |
#
|
|
|
41 |
# Templates may contain:
|
|
|
42 |
# PACKAGE
|
|
|
43 |
# VARIANT
|
|
|
44 |
# VERSION
|
|
|
45 |
# PLATFORM
|
|
|
46 |
# TYPE
|
|
|
47 |
# ARCH
|
| 4740 |
dpurdie |
48 |
#
|
| 407 |
dpurdie |
49 |
#......................................................................#
|
|
|
50 |
|
| 409 |
alewis |
51 |
require 5.006_001;
|
| 407 |
dpurdie |
52 |
#use strict;
|
|
|
53 |
use warnings;
|
| 6242 |
dpurdie |
54 |
#use PackagerUtils;
|
| 407 |
dpurdie |
55 |
|
|
|
56 |
#-------------------------------------------------------------------------------
|
|
|
57 |
# Function : MakeDebianPackage
|
|
|
58 |
#
|
|
|
59 |
# Description : Create a Debian Package
|
|
|
60 |
#
|
| 4188 |
dpurdie |
61 |
# Inputs : See above
|
| 407 |
dpurdie |
62 |
#
|
| 4188 |
dpurdie |
63 |
# Returns : Nothing
|
| 407 |
dpurdie |
64 |
#
|
|
|
65 |
sub MakeDebianPackage
|
|
|
66 |
{
|
|
|
67 |
my( $platforms, @elements ) = @_;
|
|
|
68 |
Debug2( "MakeDebianPackage($platforms, @elements)" );
|
|
|
69 |
return if ( ! ActivePlatform($platforms) );
|
|
|
70 |
|
|
|
71 |
my $build_name = $::ScmBuildPackage;
|
|
|
72 |
my $build_version = $::ScmBuildVersionFull;
|
| 417 |
dpurdie |
73 |
my $build_variant = '';
|
| 6738 |
dpurdie |
74 |
my $build_version_prefix = '';
|
|
|
75 |
my $build_extdesc = '';
|
| 407 |
dpurdie |
76 |
|
| 417 |
dpurdie |
77 |
my $name_set=0;
|
|
|
78 |
my $variant_set=0;
|
| 6738 |
dpurdie |
79 |
my $version_prefix_set=0;
|
|
|
80 |
my $extdesc_set=0;
|
| 6242 |
dpurdie |
81 |
|
| 4907 |
dpurdie |
82 |
my $deploy_mode = GetGlobalOption('DEBIAN_PACKAGE_DEPLOYABLE', 0);
|
| 417 |
dpurdie |
83 |
|
| 6242 |
dpurdie |
84 |
my $tarOnly;
|
| 4740 |
dpurdie |
85 |
my $tarFileName = '';
|
|
|
86 |
my @outputFiles;
|
|
|
87 |
my @optArgs;
|
| 5215 |
dpurdie |
88 |
my $noArch;
|
| 4740 |
dpurdie |
89 |
|
| 6242 |
dpurdie |
90 |
my @arglist;
|
|
|
91 |
my $rpmScript;
|
|
|
92 |
my $debianScript;
|
| 407 |
dpurdie |
93 |
my $script;
|
|
|
94 |
|
|
|
95 |
#
|
|
|
96 |
# Collect user arguments
|
|
|
97 |
# They are all processed within the toolset
|
|
|
98 |
#
|
|
|
99 |
foreach ( @elements )
|
|
|
100 |
{
|
| 6242 |
dpurdie |
101 |
push @arglist, $_;
|
| 407 |
dpurdie |
102 |
|
| 6242 |
dpurdie |
103 |
if ( m/^--Script=(.+)/i ) {
|
|
|
104 |
ReportError ("MakeDebianPackage: --Script. Debian script name already set") if $debianScript;
|
|
|
105 |
ReportError ("MakeDebianPackage: --Script. RPM script name already set") if $rpmScript;
|
|
|
106 |
$debianScript = $1;
|
|
|
107 |
$rpmScript = $1;
|
|
|
108 |
pop @arglist;
|
|
|
109 |
|
|
|
110 |
} elsif ( m/^--RpmScript=(.+)/i ) {
|
|
|
111 |
ReportError ("MakeDebianPackage: --RpmScript. RPM script name already set") if $rpmScript;
|
|
|
112 |
$rpmScript = $1;
|
|
|
113 |
pop @arglist;
|
|
|
114 |
|
|
|
115 |
} elsif ( m/^--DebianScript=(.+)/i ) {
|
|
|
116 |
ReportError ("MakeDebianPackage: --DebianScript. Debian script name already set") if $debianScript;
|
|
|
117 |
$debianScript = $1;
|
|
|
118 |
pop @arglist;
|
|
|
119 |
|
|
|
120 |
} elsif ( m/^--Name=(.+)/i ) {
|
| 417 |
dpurdie |
121 |
$build_name = $1;
|
|
|
122 |
$name_set++;
|
|
|
123 |
|
| 6242 |
dpurdie |
124 |
} elsif ( m/^--Variant=(.+)/i ) {
|
| 417 |
dpurdie |
125 |
$build_variant = $1;
|
|
|
126 |
$variant_set++;
|
| 4188 |
dpurdie |
127 |
|
| 6738 |
dpurdie |
128 |
} elsif ( m/^--VersionPrefix=(.+)/i ) {
|
|
|
129 |
$build_version_prefix = $1;
|
|
|
130 |
$version_prefix_set++;
|
|
|
131 |
|
|
|
132 |
} elsif ( m/^--ExtDesc=(.+)/i ) {
|
|
|
133 |
$build_extdesc = $1;
|
|
|
134 |
$extdesc_set++;
|
|
|
135 |
|
| 6242 |
dpurdie |
136 |
} elsif ( m/^--(No)?DeployMode/i ) {
|
|
|
137 |
$deploy_mode = ! defined($1);
|
| 4907 |
dpurdie |
138 |
|
| 6242 |
dpurdie |
139 |
} elsif ( m/^--NoArch$/i ) {
|
| 5215 |
dpurdie |
140 |
$noArch = 1;
|
|
|
141 |
|
| 6242 |
dpurdie |
142 |
} elsif ( m/^--TarOnly$/i ) {
|
|
|
143 |
$tarOnly = 1;
|
|
|
144 |
|
|
|
145 |
} elsif ( m/^--TarFile(=(.*))?/i ) {
|
|
|
146 |
$tarFileName = defined($1) ? $2 : 'DEFAULT';
|
| 4740 |
dpurdie |
147 |
|
| 407 |
dpurdie |
148 |
} elsif ( m/^--/ ) {
|
| 6242 |
dpurdie |
149 |
ReportError("MakeDebianPackage. Unknown option: $_");
|
| 407 |
dpurdie |
150 |
|
|
|
151 |
} else {
|
| 6242 |
dpurdie |
152 |
ReportError("MakeDebianPackage. Unknown argument: $_");
|
| 407 |
dpurdie |
153 |
}
|
|
|
154 |
}
|
|
|
155 |
|
|
|
156 |
#
|
|
|
157 |
# Sanity test
|
|
|
158 |
#
|
| 6242 |
dpurdie |
159 |
ReportError ("MakeDebianPackage: Not supported on a GENERIC target") if ( $ScmPlatform eq 'GENERIC' );
|
|
|
160 |
ReportError ("MakeDebianPackage: Script name not defined") unless ( $debianScript || $rpmScript );
|
|
|
161 |
ReportError ("MakeDebianPackage: --Name option can only be used once") if ( $name_set > 1 );
|
|
|
162 |
ReportError ("MakeDebianPackage: --Variant option can only be used once") if ( $variant_set > 1 );
|
| 6738 |
dpurdie |
163 |
ReportError ("MakeDebianPackage: --VersionPrefix option can only be used once") if ( $version_prefix_set > 1 );
|
|
|
164 |
ReportError ("MakeDebianPackage: --ExtDesc option can only be used once") if ( $extdesc_set > 1 );
|
| 6242 |
dpurdie |
165 |
ErrorDoExit();
|
| 407 |
dpurdie |
166 |
|
| 417 |
dpurdie |
167 |
#
|
| 6242 |
dpurdie |
168 |
# Determine what we are really doing
|
|
|
169 |
# Under Redhat we will generate an RPM
|
|
|
170 |
#
|
|
|
171 |
if ( ActivePlatform('PKG_RPM') ) {
|
|
|
172 |
return unless (defined $rpmScript);
|
|
|
173 |
return MakeRpmPackage ($platforms, "--Script=$rpmScript", @arglist );
|
|
|
174 |
}
|
|
|
175 |
|
|
|
176 |
return unless (defined $debianScript);
|
|
|
177 |
$script = $debianScript;
|
|
|
178 |
ErrorDoExit();
|
|
|
179 |
|
|
|
180 |
|
|
|
181 |
#
|
|
|
182 |
# If the platform cannot generate a native installer then (silently) ignore the request
|
|
|
183 |
# unless the user has specified a --TarOnly
|
|
|
184 |
#
|
|
|
185 |
my $canGenerateInstaller = ActivePlatform('PKG_DEB');
|
|
|
186 |
if ( !$canGenerateInstaller && !$tarOnly) {
|
|
|
187 |
Verbose ("MakeDebianPackage: Installer not builadble for this platform");
|
|
|
188 |
return;
|
|
|
189 |
}
|
|
|
190 |
|
|
|
191 |
#
|
| 417 |
dpurdie |
192 |
# Build up the build name
|
|
|
193 |
# Add variant to base name.
|
|
|
194 |
#
|
|
|
195 |
if ( $build_variant )
|
|
|
196 |
{
|
|
|
197 |
$build_name .= '-' . $build_variant;
|
|
|
198 |
}
|
| 6738 |
dpurdie |
199 |
|
|
|
200 |
#
|
|
|
201 |
# Build up the version
|
|
|
202 |
# Add the version prefix to the base version
|
|
|
203 |
if ( $build_version_prefix )
|
|
|
204 |
{
|
|
|
205 |
$build_version = $build_version_prefix . '-' . $build_version;
|
|
|
206 |
}
|
| 407 |
dpurdie |
207 |
|
|
|
208 |
#
|
|
|
209 |
# Sanity check the package name and version
|
| 6242 |
dpurdie |
210 |
# Debian has stricter requirements than JATS
|
| 407 |
dpurdie |
211 |
# Name: Lower case letters (a-z), digits (0-9), plus (+) and minus (-) signs, and periods (.).
|
|
|
212 |
# Release Manager does not allow '.'
|
|
|
213 |
# Version: alphanumerics and the characters . + - : (full stop, plus, hyphen, colon) and should start with a digit
|
|
|
214 |
#
|
| 409 |
alewis |
215 |
# Allow ( and cleanup )
|
|
|
216 |
# ERGxxxxx -> erg-xxx
|
| 427 |
dpurdie |
217 |
# VIXxxxxx -> vix-xxx
|
|
|
218 |
# Whitespace -> -
|
| 409 |
alewis |
219 |
# _ -> -
|
| 427 |
dpurdie |
220 |
# Remove multiple '-' characters
|
|
|
221 |
# Lowercase all text
|
| 409 |
alewis |
222 |
#
|
| 407 |
dpurdie |
223 |
|
| 6242 |
dpurdie |
224 |
#
|
|
|
225 |
# Convert the build_name to a form that is Debian complient
|
|
|
226 |
#
|
|
|
227 |
$build_name = canonicalName ($build_name, 'Debian');
|
| 409 |
alewis |
228 |
|
| 6242 |
dpurdie |
229 |
#
|
|
|
230 |
# Sanity test the version information
|
|
|
231 |
#
|
| 6738 |
dpurdie |
232 |
unless ( $build_version =~ m/^[0-9][-+:.A-Za-z0-9]+$/ )
|
| 407 |
dpurdie |
233 |
{
|
|
|
234 |
Error ("Package Version does not conform to Debian Requirements",
|
|
|
235 |
"Must only contain: (a-zA-Z) (0-9), - and .",
|
| 5215 |
dpurdie |
236 |
"Must start with a number",
|
| 407 |
dpurdie |
237 |
);
|
|
|
238 |
}
|
|
|
239 |
|
|
|
240 |
#
|
|
|
241 |
# Create the name of the target package
|
|
|
242 |
# The form of the name is of a fixed form.
|
|
|
243 |
#
|
|
|
244 |
# Note: "_" used since this is the format of dpkg-name
|
| 4188 |
dpurdie |
245 |
# Note: dpkg-name generates: Name _ Version _ Architecture [ _ Type ]
|
| 407 |
dpurdie |
246 |
#
|
|
|
247 |
#
|
| 4188 |
dpurdie |
248 |
my $PkgType = $deploy_mode ? ( '_' . '$(GBE_TYPE)' ) : '' ;
|
| 6242 |
dpurdie |
249 |
my $PkgArch = GetGlobalOption('PACKAGE_ARCH', $::ScmPlatform);
|
|
|
250 |
my $Platform = $::ScmPlatform;
|
|
|
251 |
if ($noArch) {
|
|
|
252 |
$PkgArch = 'all';
|
|
|
253 |
$Platform = 'all';
|
|
|
254 |
$PkgType = '';
|
|
|
255 |
push @optArgs, "-NoArch";
|
|
|
256 |
}
|
| 4740 |
dpurdie |
257 |
|
| 6738 |
dpurdie |
258 |
my $PkgName = "${build_name}_${build_version}_${Platform}${PkgType}.deb";
|
| 6242 |
dpurdie |
259 |
push @optArgs, "-PkgArch=$PkgArch";
|
| 6535 |
dpurdie |
260 |
unless ($tarOnly) {
|
|
|
261 |
push (@outputFiles, $PkgName);
|
|
|
262 |
push @optArgs, "-Output=--GeneratedProg{$PkgName}";
|
|
|
263 |
}
|
| 6242 |
dpurdie |
264 |
|
| 407 |
dpurdie |
265 |
#
|
| 4740 |
dpurdie |
266 |
# Create name for the optional TGZ file
|
| 6242 |
dpurdie |
267 |
# Allow user to specify parts of the name symbolically
|
| 4740 |
dpurdie |
268 |
#
|
|
|
269 |
if ($tarFileName)
|
|
|
270 |
{
|
|
|
271 |
if ($tarFileName eq 'DEFAULT')
|
|
|
272 |
{
|
|
|
273 |
$tarFileName = 'PACKAGE_VERSION_PLATFORM';
|
| 5215 |
dpurdie |
274 |
if ($deploy_mode && ! $noArch)
|
| 4740 |
dpurdie |
275 |
{
|
|
|
276 |
$tarFileName .= '_TYPE';
|
|
|
277 |
}
|
|
|
278 |
}
|
|
|
279 |
|
| 6242 |
dpurdie |
280 |
if ($noArch) {
|
|
|
281 |
$PkgArch = 'all';
|
|
|
282 |
}
|
|
|
283 |
|
| 4740 |
dpurdie |
284 |
$tarFileName =~ s~PACKAGE~${build_name}~g;
|
| 6738 |
dpurdie |
285 |
$tarFileName =~ s~VERSION~${build_version}~g;
|
| 6242 |
dpurdie |
286 |
$tarFileName =~ s~PLATFORM~${Platform}~g;
|
|
|
287 |
$tarFileName =~ s~ARCH~${PkgArch}~g;
|
| 4740 |
dpurdie |
288 |
$tarFileName =~ s~TYPE~\$(GBE_TYPE)~;
|
| 6242 |
dpurdie |
289 |
$tarFileName .= '.tgz' unless $tarFileName =~ m~\.tgz$~;
|
| 4740 |
dpurdie |
290 |
push @outputFiles, $tarFileName;
|
| 6242 |
dpurdie |
291 |
|
| 6535 |
dpurdie |
292 |
push @optArgs, "-TarFile=--GeneratedProg{$tarFileName}";
|
|
|
293 |
# push @optArgs, "-TarFile=$tarFileName";
|
| 6242 |
dpurdie |
294 |
push (@optArgs, '-TarOnly' ) if $tarOnly;
|
| 4740 |
dpurdie |
295 |
}
|
|
|
296 |
|
|
|
297 |
#
|
| 407 |
dpurdie |
298 |
# Simply use Generate Files
|
| 6242 |
dpurdie |
299 |
# With lots of options
|
| 407 |
dpurdie |
300 |
#
|
|
|
301 |
Src ( '*', $script );
|
|
|
302 |
GenerateFiles ('*', "--Tool=DebianPackager.pl", # Associated tool
|
|
|
303 |
"--AutoGenerate", # Build when needed
|
|
|
304 |
"--UnknownPreq", # Always build
|
|
|
305 |
"--Clean", # Script supports jats clean
|
|
|
306 |
"--Text=Debian Package", # Display when building
|
|
|
307 |
|
|
|
308 |
'--Var(BuildName)', # Target Package
|
|
|
309 |
'--Var(BuildVersion)', # Target Version
|
|
|
310 |
'--Var(Platform)', # Target platform
|
|
|
311 |
'--Var(Product)', # Target product
|
|
|
312 |
'--Var(Target)', # Underlying Target
|
|
|
313 |
'--Var(Type)', # Build Type
|
|
|
314 |
|
|
|
315 |
'--Var(Verbose)', # Verbose operation
|
|
|
316 |
|
|
|
317 |
'--Var(InterfaceDir)', # Interface Directory
|
|
|
318 |
'--Var(InterfaceIncDir)',
|
|
|
319 |
'--Var(InterfaceLibDir)',
|
|
|
320 |
'--Var(InterfaceBinDir)',
|
|
|
321 |
|
|
|
322 |
'--Var(LibDir)', # My Artifacts
|
|
|
323 |
'--Var(BinDir)',
|
|
|
324 |
|
|
|
325 |
'--Var(PackageDir)', # My Package
|
|
|
326 |
'--Var(PackageLibDir)', # My Package Library
|
|
|
327 |
'--Var(PackageBinDir)', # My Package Bin
|
|
|
328 |
'--Var(PackagePkgDir)', # My Package/pkg.target
|
|
|
329 |
|
|
|
330 |
'--Var(LocalIncDir)', # Installed Artifacts
|
|
|
331 |
'--Var(LocalLibDir)',
|
|
|
332 |
'--Var(LocalBinDir)',
|
|
|
333 |
|
| 6242 |
dpurdie |
334 |
"-genDeb", # Type to generate
|
|
|
335 |
"-Script=--Prerequisite($script)", # Packager script
|
|
|
336 |
"-Name=$build_name", # Massaged Package Name
|
| 6738 |
dpurdie |
337 |
"-Version=$build_version", # Massaged Version
|
| 427 |
dpurdie |
338 |
"-Variant=$build_variant", # Variant Name
|
| 6738 |
dpurdie |
339 |
"-VersionPrefix=$build_version_prefix", # Version Prefix
|
|
|
340 |
"-ExtDesc=$build_extdesc", # External Description of Package
|
| 6242 |
dpurdie |
341 |
@optArgs, # Optional args
|
| 407 |
dpurdie |
342 |
);
|
|
|
343 |
|
|
|
344 |
#
|
|
|
345 |
# The Packager has created a binary in the 'PROG' directory
|
|
|
346 |
# Lets package it as a program.
|
|
|
347 |
#
|
| 6242 |
dpurdie |
348 |
if ($deploy_mode) {
|
| 4740 |
dpurdie |
349 |
PackageFile ('*', @outputFiles );
|
| 4188 |
dpurdie |
350 |
}
|
| 6242 |
dpurdie |
351 |
else {
|
| 4740 |
dpurdie |
352 |
PackageProg ('*', @outputFiles );
|
| 4188 |
dpurdie |
353 |
}
|
| 407 |
dpurdie |
354 |
}
|
|
|
355 |
|
|
|
356 |
1;
|