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