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