line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
Software::Packager - Common software packaging interface |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Software::Packager; |
8
|
|
|
|
|
|
|
my $packager = new Software::Packager(); |
9
|
|
|
|
|
|
|
$packager->version('1.2.3.4.5.6'); |
10
|
|
|
|
|
|
|
$packager->package_name("Somename"); |
11
|
|
|
|
|
|
|
$packager->program_name('Software Packager'); |
12
|
|
|
|
|
|
|
$packager->description("This is the description."); |
13
|
|
|
|
|
|
|
$packager->short_description("This is a short description."); |
14
|
|
|
|
|
|
|
$packager->output_dir("/home/software/packages"); |
15
|
|
|
|
|
|
|
$packager->category("Applications"); |
16
|
|
|
|
|
|
|
$packager->architecture("sparc"); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my %object_data = ( |
19
|
|
|
|
|
|
|
'SOURCE' => '/source/file1', |
20
|
|
|
|
|
|
|
'TYPE' => 'file', |
21
|
|
|
|
|
|
|
'DESTINATION' => '/usr/local/file1', |
22
|
|
|
|
|
|
|
'USER' => 'joe', |
23
|
|
|
|
|
|
|
'GROUP' => 'staff', |
24
|
|
|
|
|
|
|
'MODE' => '0750', |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
$packager->add_item(%object_data); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $version = $packager->version(); |
29
|
|
|
|
|
|
|
my $name = $packager->package_name(); |
30
|
|
|
|
|
|
|
my $program_name = $packager->program_name(); |
31
|
|
|
|
|
|
|
my $description = $packager->description(); |
32
|
|
|
|
|
|
|
my $description = $packager->short_description(); |
33
|
|
|
|
|
|
|
my $output_directory = $packager->output_dir(); |
34
|
|
|
|
|
|
|
my $category = $packager->category(); |
35
|
|
|
|
|
|
|
my $arch = $packager->architecture(); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 DESCRIPTION |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
The Software Packager module is designed to provide a common interface for |
40
|
|
|
|
|
|
|
packaging software on any platform. This module does not do the packaging of |
41
|
|
|
|
|
|
|
the software but is merely a wraper around the various software packaging tools |
42
|
|
|
|
|
|
|
already provided with various operating systems. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
This module provides the base API and sets default values common to the various |
45
|
|
|
|
|
|
|
software packaging methods. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 EXTENDING Software::Packager |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
To extend the Software::Packager suite all that is required is to create a |
50
|
|
|
|
|
|
|
module that the wraps the desired software packaging system. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
package Software::Packager; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
#################### |
57
|
|
|
|
|
|
|
# Standard Modules |
58
|
2
|
|
|
2
|
|
1424
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
95
|
|
59
|
2
|
|
|
2
|
|
13
|
use Config; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
93
|
|
60
|
2
|
|
|
2
|
|
2483
|
use Data::Dumper; |
|
2
|
|
|
|
|
23232
|
|
|
2
|
|
|
|
|
129
|
|
61
|
|
|
|
|
|
|
# Custom modules |
62
|
2
|
|
|
2
|
|
1203
|
use Software::Packager::Object; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
69
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
#################### |
65
|
|
|
|
|
|
|
# Variables |
66
|
2
|
|
|
2
|
|
12
|
use vars qw(@ISA @EXPORT @EXPORT_OK $VERSION); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
5231
|
|
67
|
|
|
|
|
|
|
@ISA = qw(); |
68
|
|
|
|
|
|
|
@EXPORT = qw(); |
69
|
|
|
|
|
|
|
@EXPORT_OK = qw(); |
70
|
|
|
|
|
|
|
$VERSION = 0.09; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
#################### |
73
|
|
|
|
|
|
|
# Functions |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 FUNCTIONS |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
78
|
|
|
|
|
|
|
################################################################################ |
79
|
|
|
|
|
|
|
# Function: new() |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 B |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
my $packager = new Software::Packager(); |
84
|
|
|
|
|
|
|
or |
85
|
|
|
|
|
|
|
my $packager = new Software::Packager('tar'); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This function creates and returns a new Packager object appropriate for the |
88
|
|
|
|
|
|
|
current platform. Optionally the packager type can be passed and the |
89
|
|
|
|
|
|
|
appropriate software packager will be returned. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
92
|
|
|
|
|
|
|
sub new |
93
|
|
|
|
|
|
|
{ |
94
|
1
|
|
|
1
|
1
|
139656
|
my $class = shift; |
95
|
1
|
|
|
|
|
3
|
my $type = shift; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# find which platform we are on and return the correct packager. |
98
|
|
|
|
|
|
|
# there has to be a better way to do this. |
99
|
1
|
|
|
|
|
2
|
my $packager = undef; |
100
|
1
|
50
|
|
|
|
4
|
if (scalar $type) |
101
|
|
|
|
|
|
|
{ |
102
|
1
|
|
|
|
|
5
|
$type = ucfirst lc $type; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
else |
105
|
|
|
|
|
|
|
{ |
106
|
0
|
0
|
|
|
|
0
|
if ($Config{'osname'} eq 'linux') |
107
|
|
|
|
|
|
|
{ |
108
|
|
|
|
|
|
|
# need to find distrubution for linux |
109
|
0
|
0
|
|
|
|
0
|
if ($Config{'myuname'} =~ /redhat|caldera/i) |
|
|
0
|
|
|
|
|
|
110
|
|
|
|
|
|
|
{ |
111
|
0
|
|
|
|
|
0
|
$type = ucfirst lc 'rpm'; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
elsif ($Config{'something'} =~ /debian/) |
114
|
|
|
|
|
|
|
{ |
115
|
0
|
|
|
|
|
0
|
$type = ucfirst lc 'dpkg'; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
else |
119
|
|
|
|
|
|
|
{ |
120
|
0
|
|
|
|
|
0
|
$type = ucfirst lc $Config{'osname'}; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
1
|
|
|
|
|
4
|
my $load_module = "require Software::Packager::$type;\n"; |
125
|
1
|
|
|
|
|
4
|
$load_module .= '$packager' . " = new Software::Packager::$type();\n"; |
126
|
1
|
|
|
|
|
73
|
eval $load_module; |
127
|
1
|
50
|
|
|
|
9
|
if ($@) |
128
|
|
|
|
|
|
|
{ |
129
|
0
|
|
|
|
|
0
|
warn "$@\n"; |
130
|
0
|
|
|
|
|
0
|
warn "Error: Failed to load Software::Packager::$type\n"; |
131
|
0
|
|
|
|
|
0
|
warn " Using Software::Packager::Tar\n"; |
132
|
0
|
|
|
|
|
0
|
require Software::Packager::Tar; |
133
|
0
|
|
|
|
|
0
|
$packager = new Software::Packager::Tar(); |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
# do some initalisation |
137
|
1
|
|
|
|
|
10
|
$packager->version('0.0.0.0'); |
138
|
1
|
|
|
|
|
25
|
$packager->description("This software installation package has been created with Software::Packager version $VERSION\n"); |
139
|
1
|
|
|
|
|
8
|
$packager->output_dir("."); |
140
|
|
|
|
|
|
|
|
141
|
1
|
|
|
|
|
4
|
return $packager; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
################################################################################ |
145
|
|
|
|
|
|
|
# Function: version() |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head2 B |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
$packager->version('1.2.3.4.5.6'); |
150
|
|
|
|
|
|
|
my $version = $packager->version(); |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
This function sets the version for the package to the passed value. If no value |
153
|
|
|
|
|
|
|
is passed then the packager version is returned. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
The version passed must be a number seperated by periods "." and contain at |
156
|
|
|
|
|
|
|
least three parts "1.2.3". since some software packaging products require or |
157
|
|
|
|
|
|
|
can handle longer version numbers the default is for a six part version number |
158
|
|
|
|
|
|
|
"1.2.3.4.5.6". |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
The version will be set to the value you pass, however not all software |
161
|
|
|
|
|
|
|
packaging products need this many fields or can handle them, so the version |
162
|
|
|
|
|
|
|
applied to the actual software package will be set to the appropriate lengthed |
163
|
|
|
|
|
|
|
value. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Having said this, as a software package creator, you need to know what version |
166
|
|
|
|
|
|
|
is being applied to the package you are creating, right... so after you set the |
167
|
|
|
|
|
|
|
version check what the version will be set to by calling the version method |
168
|
|
|
|
|
|
|
without any arguments to see what is returned. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Example: If we are on AIX, which has a four part version we would get... |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
$packager->version('10.2.1'); |
173
|
|
|
|
|
|
|
my $version = $packager->version(); |
174
|
|
|
|
|
|
|
print "VERSION: $version\n"; |
175
|
|
|
|
|
|
|
... |
176
|
|
|
|
|
|
|
VERSION: 10.2.1.0 |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
or |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
$packager->version(1); |
181
|
|
|
|
|
|
|
my $version = $packager->version(); |
182
|
|
|
|
|
|
|
print "VERSION: $version\n"; |
183
|
|
|
|
|
|
|
... |
184
|
|
|
|
|
|
|
VERSION: 1.1.0.0 |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Since AIX requires the first two values to be set the second is set to be 1. |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
For full details on version string requirements refer to the operating system |
189
|
|
|
|
|
|
|
documentation or the documentation for the desired packaging system. |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=cut |
192
|
|
|
|
|
|
|
sub version |
193
|
|
|
|
|
|
|
{ |
194
|
8
|
|
|
8
|
1
|
480
|
my $self = shift; |
195
|
8
|
|
|
|
|
12
|
my $value = shift; |
196
|
|
|
|
|
|
|
|
197
|
8
|
100
|
|
|
|
17
|
if ($value) |
198
|
|
|
|
|
|
|
{ |
199
|
2
|
50
|
|
|
|
11
|
if ($value !~ /\d/) |
200
|
|
|
|
|
|
|
{ |
201
|
0
|
|
|
|
|
0
|
warn "Warning: The version specified \"$value\" does not contain any numbers.\n"; |
202
|
|
|
|
|
|
|
} |
203
|
2
|
|
|
|
|
15
|
$self->{'PACKAGE_VERSION'} = $value; |
204
|
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
else |
206
|
|
|
|
|
|
|
{ |
207
|
6
|
|
|
|
|
22
|
return $self->{'PACKAGE_VERSION'}; |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
################################################################################ |
212
|
|
|
|
|
|
|
# Function: package_name() |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=head2 B |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
$packager->package_name("Somename"); |
217
|
|
|
|
|
|
|
my $name = $packager->package_name(); |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
This method sets the package name to the passed value. If no arguments are |
220
|
|
|
|
|
|
|
passed the package name is returned. |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
Note that some software packaging methods place various limitations on the |
223
|
|
|
|
|
|
|
package name. For example on Solaris the package name is limited to 9 Charaters |
224
|
|
|
|
|
|
|
while the RedHat Package Manager is very strict about the format of the names |
225
|
|
|
|
|
|
|
of the packages it creates. |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=cut |
228
|
|
|
|
|
|
|
sub package_name |
229
|
|
|
|
|
|
|
{ |
230
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
231
|
0
|
|
|
|
|
0
|
my $value = shift; |
232
|
|
|
|
|
|
|
|
233
|
0
|
0
|
|
|
|
0
|
if ($value) |
234
|
|
|
|
|
|
|
{ |
235
|
0
|
|
|
|
|
0
|
$self->{'PACKAGE_NAME'} = $value; |
236
|
|
|
|
|
|
|
} |
237
|
|
|
|
|
|
|
else |
238
|
|
|
|
|
|
|
{ |
239
|
0
|
|
|
|
|
0
|
return $self->{'PACKAGE_NAME'}; |
240
|
|
|
|
|
|
|
} |
241
|
|
|
|
|
|
|
} |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
################################################################################ |
244
|
|
|
|
|
|
|
# Function: program_name() |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=head2 B |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
$packager->program_name('Software Packager'); |
249
|
|
|
|
|
|
|
my $program_name = $packager->program_name(); |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
This method is used to set the name of the program that the package is |
252
|
|
|
|
|
|
|
installing. This may in some cases be the same as the package name but that is |
253
|
|
|
|
|
|
|
not required. |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=cut |
256
|
|
|
|
|
|
|
sub program_name |
257
|
|
|
|
|
|
|
{ |
258
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
259
|
0
|
|
|
|
|
0
|
my $value = shift; |
260
|
|
|
|
|
|
|
|
261
|
0
|
0
|
|
|
|
0
|
if ($value) |
262
|
|
|
|
|
|
|
{ |
263
|
0
|
|
|
|
|
0
|
$self->{'PROGRAM_NAME'} = $value; |
264
|
|
|
|
|
|
|
} |
265
|
|
|
|
|
|
|
else |
266
|
|
|
|
|
|
|
{ |
267
|
0
|
|
|
|
|
0
|
return $self->{'PROGRAM_NAME'}; |
268
|
|
|
|
|
|
|
} |
269
|
|
|
|
|
|
|
} |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
################################################################################ |
272
|
|
|
|
|
|
|
# Function: description() |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
=head2 B |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
$packager->description("This is the description."); |
277
|
|
|
|
|
|
|
my $description = $packager->description(); |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
The description method sets the package description to the passed value. If no |
280
|
|
|
|
|
|
|
arguments are passed the package description is returned. |
281
|
|
|
|
|
|
|
It is important to note that some installation package methods limit the length |
282
|
|
|
|
|
|
|
of the description. Therefore it is advisable to check what the description |
283
|
|
|
|
|
|
|
will be set to by calling the method without any arguments. |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
Example: |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
$packager->description("This is a short message."); |
288
|
|
|
|
|
|
|
my $description = $packager->descriotion(); |
289
|
|
|
|
|
|
|
print "DESCRIPTION: $description\n"; |
290
|
|
|
|
|
|
|
... |
291
|
|
|
|
|
|
|
DESCRIPTION: This is a short message. |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
=cut |
294
|
|
|
|
|
|
|
sub description |
295
|
|
|
|
|
|
|
{ |
296
|
3
|
|
|
3
|
1
|
175
|
my $self = shift; |
297
|
3
|
|
|
|
|
5
|
my $value = shift; |
298
|
|
|
|
|
|
|
|
299
|
3
|
100
|
|
|
|
9
|
if ($value) |
300
|
|
|
|
|
|
|
{ |
301
|
2
|
|
|
|
|
7
|
$self->{'DESCRIPTION'} = $value; |
302
|
|
|
|
|
|
|
} |
303
|
|
|
|
|
|
|
else |
304
|
|
|
|
|
|
|
{ |
305
|
1
|
|
|
|
|
4
|
return $self->{'DESCRIPTION'}; |
306
|
|
|
|
|
|
|
} |
307
|
|
|
|
|
|
|
} |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
################################################################################ |
310
|
|
|
|
|
|
|
# Function: short_description() |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
=head2 B |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
$packager->short_description("This is a short description."); |
315
|
|
|
|
|
|
|
my $description = $packager->short_description(); |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
The short description is typically a single line that describes the package |
318
|
|
|
|
|
|
|
It is important to note that some installation package methods limit the length |
319
|
|
|
|
|
|
|
of the description. Therefore it is advisable to check what the description |
320
|
|
|
|
|
|
|
will be set to by calling the method without any arguments. |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
Example: |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
$packager->short_description("This is a short message."); |
325
|
|
|
|
|
|
|
my $short_description = $packager->short_descriotion(); |
326
|
|
|
|
|
|
|
print "DESCRIPTION: $short_description\n"; |
327
|
|
|
|
|
|
|
... |
328
|
|
|
|
|
|
|
DESCRIPTION: This is a short message. |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
=cut |
331
|
|
|
|
|
|
|
sub short_description |
332
|
|
|
|
|
|
|
{ |
333
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
334
|
0
|
|
|
|
|
0
|
my $value = shift; |
335
|
|
|
|
|
|
|
|
336
|
0
|
0
|
|
|
|
0
|
if ($value) |
337
|
|
|
|
|
|
|
{ |
338
|
0
|
|
|
|
|
0
|
$self->{'SHORT_DESCRIPTION'} = $value; |
339
|
|
|
|
|
|
|
} |
340
|
|
|
|
|
|
|
else |
341
|
|
|
|
|
|
|
{ |
342
|
0
|
|
|
|
|
0
|
return $self->{'SHORT_DESCRIPTION'}; |
343
|
|
|
|
|
|
|
} |
344
|
|
|
|
|
|
|
} |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
################################################################################ |
347
|
|
|
|
|
|
|
# Function: output_dir() |
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
=head2 B |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
$packager->output_dir("/home/software/packages"); |
352
|
|
|
|
|
|
|
my $output_directory = $packager->output_dir(); |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
The output_dir method sets the directory where the final installation package |
355
|
|
|
|
|
|
|
will be placed. |
356
|
|
|
|
|
|
|
The output directory can be set by passing the desired directory to the method. |
357
|
|
|
|
|
|
|
the current outout directory can be checked by calling the method without any |
358
|
|
|
|
|
|
|
arguments. |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
=cut |
361
|
|
|
|
|
|
|
sub output_dir |
362
|
|
|
|
|
|
|
{ |
363
|
5
|
|
|
5
|
1
|
185
|
my $self = shift; |
364
|
5
|
|
|
|
|
8
|
my $value = shift; |
365
|
|
|
|
|
|
|
|
366
|
5
|
100
|
|
|
|
17
|
if ($value) |
367
|
|
|
|
|
|
|
{ |
368
|
2
|
|
|
|
|
7
|
$self->{'OUTPUT_DIR'} = $value; |
369
|
|
|
|
|
|
|
} |
370
|
|
|
|
|
|
|
else |
371
|
|
|
|
|
|
|
{ |
372
|
3
|
|
|
|
|
17
|
return $self->{'OUTPUT_DIR'}; |
373
|
|
|
|
|
|
|
} |
374
|
|
|
|
|
|
|
} |
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
################################################################################ |
377
|
|
|
|
|
|
|
# Function: category() |
378
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
=head2 B |
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
$packager->category("Applications"); |
382
|
|
|
|
|
|
|
my $category = $packager->category(); |
383
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
This method returns or sets the category for the package. |
385
|
|
|
|
|
|
|
Not all packaging systems support categories and so this will only be set where |
386
|
|
|
|
|
|
|
possible. |
387
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
=cut |
389
|
|
|
|
|
|
|
sub category |
390
|
|
|
|
|
|
|
{ |
391
|
2
|
|
|
2
|
1
|
178
|
my $self = shift; |
392
|
2
|
|
|
|
|
2
|
my $value = shift; |
393
|
|
|
|
|
|
|
|
394
|
2
|
100
|
|
|
|
9
|
if ($value) |
395
|
|
|
|
|
|
|
{ |
396
|
1
|
|
|
|
|
4
|
$self->{'CATEGORY'} = $value; |
397
|
|
|
|
|
|
|
} |
398
|
|
|
|
|
|
|
else |
399
|
|
|
|
|
|
|
{ |
400
|
1
|
|
|
|
|
3
|
return $self->{'CATEGORY'}; |
401
|
|
|
|
|
|
|
} |
402
|
|
|
|
|
|
|
} |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
################################################################################ |
405
|
|
|
|
|
|
|
# Function: architecture() |
406
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
=head2 B |
408
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
$packager->architecture("sparc"); |
410
|
|
|
|
|
|
|
my $arch = $packager->architecture(); |
411
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
This method sets the architecture for the package to the passed value. If no |
413
|
|
|
|
|
|
|
argument is passed then the current architecture is returned. |
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
The default value is the name given the current architecture by the current |
416
|
|
|
|
|
|
|
packaging system. |
417
|
|
|
|
|
|
|
|
418
|
|
|
|
|
|
|
Not all packaging systems care about architectures and so this will only be |
419
|
|
|
|
|
|
|
used where it is required. |
420
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
=cut |
422
|
|
|
|
|
|
|
sub architecture |
423
|
|
|
|
|
|
|
{ |
424
|
2
|
|
|
2
|
1
|
171
|
my $self = shift; |
425
|
2
|
|
|
|
|
5
|
my $value = shift; |
426
|
|
|
|
|
|
|
|
427
|
2
|
100
|
|
|
|
6
|
if ($value) |
428
|
|
|
|
|
|
|
{ |
429
|
1
|
|
|
|
|
4
|
$self->{'ARCHITECTURE'} = $value; |
430
|
|
|
|
|
|
|
} |
431
|
|
|
|
|
|
|
else |
432
|
|
|
|
|
|
|
{ |
433
|
1
|
|
|
|
|
4
|
return $self->{'ARCHITECTURE'}; |
434
|
|
|
|
|
|
|
} |
435
|
|
|
|
|
|
|
} |
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
################################################################################ |
438
|
|
|
|
|
|
|
# Function: add_item() |
439
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
=head2 B |
441
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
my %object_data = ( |
443
|
|
|
|
|
|
|
'SOURCE' => '/source/file1', |
444
|
|
|
|
|
|
|
'TYPE' => 'file', |
445
|
|
|
|
|
|
|
'DESTINATION' => '/usr/local/file1', |
446
|
|
|
|
|
|
|
'USER' => 'joe', |
447
|
|
|
|
|
|
|
'GROUP' => 'staff', |
448
|
|
|
|
|
|
|
'MODE' => '0750', |
449
|
|
|
|
|
|
|
); |
450
|
|
|
|
|
|
|
$packager->add_item(%object_data); |
451
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
The add_item method is used to add objects to the software package. By default |
453
|
|
|
|
|
|
|
each object added to the software package must have a unique installation |
454
|
|
|
|
|
|
|
destination, though some packaging systems allow many objects to have the same |
455
|
|
|
|
|
|
|
installation location; with the decision of which object to install happening |
456
|
|
|
|
|
|
|
at install time. This ability is not common to all software packaging systems |
457
|
|
|
|
|
|
|
and thus is only available for systems that support this ability. |
458
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
The add_item method has some mandatory arguments which are described in the |
460
|
|
|
|
|
|
|
module Software::Packager::Object. The documentation for this module should be |
461
|
|
|
|
|
|
|
consulted if a more detailed explanation of these arguments is required. |
462
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
Required arguments: |
464
|
|
|
|
|
|
|
TYPE The type is case insensitive and can be one of: |
465
|
|
|
|
|
|
|
File A standard file. |
466
|
|
|
|
|
|
|
Directory A directory. |
467
|
|
|
|
|
|
|
Softlink A symbolic link. |
468
|
|
|
|
|
|
|
Hardlink A file link. |
469
|
|
|
|
|
|
|
Config A configuration file. |
470
|
|
|
|
|
|
|
Volatile A volatile file. |
471
|
|
|
|
|
|
|
Install An installation file used by the installer. |
472
|
|
|
|
|
|
|
InstallDir A directory to be used by the installer then deleted. |
473
|
|
|
|
|
|
|
Pipe A named pipe. |
474
|
|
|
|
|
|
|
Block A block special device. |
475
|
|
|
|
|
|
|
Charater A Charater special device. |
476
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
If the type is set to File, Install or Config then the SOURCE value must |
478
|
|
|
|
|
|
|
be a real file. |
479
|
|
|
|
|
|
|
If the type is a link then both the SOURCE and DESTINATION must |
480
|
|
|
|
|
|
|
be present. |
481
|
|
|
|
|
|
|
SOURCE This is the source file to add to the package. |
482
|
|
|
|
|
|
|
DESTINATION The installation destination. This must always be present. |
483
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
Optional arguments: |
485
|
|
|
|
|
|
|
MODE The installation permissions. |
486
|
|
|
|
|
|
|
USER The installation user. Defaults to the current user. |
487
|
|
|
|
|
|
|
GROUP The installation group. Default is the current users primary |
488
|
|
|
|
|
|
|
group. |
489
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
=cut |
491
|
|
|
|
|
|
|
sub add_item |
492
|
|
|
|
|
|
|
{ |
493
|
16
|
|
|
16
|
1
|
1077
|
my $self = shift; |
494
|
16
|
|
|
|
|
47
|
my %data = @_; |
495
|
16
|
|
|
|
|
67
|
my $object = new Software::Packager::Object(%data); |
496
|
|
|
|
|
|
|
|
497
|
16
|
50
|
|
|
|
35
|
return undef unless $object; |
498
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
# check that the object has a unique destination |
500
|
16
|
50
|
|
|
|
88
|
if ($self->{'OBJECTS'}->{$object->destination()}) |
501
|
|
|
|
|
|
|
{ |
502
|
0
|
|
|
|
|
0
|
warn "Error: An object with a destination of \"". $object->destination() ."\" has already been added to the package.\n "; |
503
|
0
|
|
|
|
|
0
|
return undef; |
504
|
|
|
|
|
|
|
} |
505
|
|
|
|
|
|
|
|
506
|
16
|
|
|
|
|
51
|
$self->{'OBJECTS'}->{$object->destination()} = $object; |
507
|
|
|
|
|
|
|
} |
508
|
|
|
|
|
|
|
|
509
|
|
|
|
|
|
|
################################################################################ |
510
|
|
|
|
|
|
|
# Function: prerequisites() |
511
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
=head2 B |
513
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
$packager->prerequisites('/usr/bin/perl'); |
515
|
|
|
|
|
|
|
$icon = $packager->prerequisites(); |
516
|
|
|
|
|
|
|
|
517
|
|
|
|
|
|
|
This function returns or sets the prerequisites for this package. since |
518
|
|
|
|
|
|
|
prerequisites can be handled in so many ways it is best to see the |
519
|
|
|
|
|
|
|
documentation in the various packaging system modules. |
520
|
|
|
|
|
|
|
Not all packaging systems can or do use prerequisites and so they will only |
521
|
|
|
|
|
|
|
be used where they are supported. |
522
|
|
|
|
|
|
|
|
523
|
|
|
|
|
|
|
=cut |
524
|
|
|
|
|
|
|
sub prerequisites |
525
|
|
|
|
|
|
|
{ |
526
|
2
|
|
|
2
|
1
|
184
|
my $self = shift; |
527
|
2
|
|
|
|
|
3
|
my $value = shift; |
528
|
|
|
|
|
|
|
|
529
|
2
|
100
|
|
|
|
10
|
if ($value) |
530
|
|
|
|
|
|
|
{ |
531
|
1
|
|
|
|
|
5
|
$self->{'PREREQUISITES'} = $value; |
532
|
|
|
|
|
|
|
} |
533
|
|
|
|
|
|
|
else |
534
|
|
|
|
|
|
|
{ |
535
|
1
|
|
|
|
|
4
|
return $self->{'PREREQUISITES'}; |
536
|
|
|
|
|
|
|
} |
537
|
|
|
|
|
|
|
} |
538
|
|
|
|
|
|
|
|
539
|
|
|
|
|
|
|
################################################################################ |
540
|
|
|
|
|
|
|
# Function: icon() |
541
|
|
|
|
|
|
|
|
542
|
|
|
|
|
|
|
=head2 B |
543
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
$packager->icon('/source/icon.png'); |
545
|
|
|
|
|
|
|
$icon = $packager->icon(); |
546
|
|
|
|
|
|
|
|
547
|
|
|
|
|
|
|
This function returns or sets the icon file name for the package. |
548
|
|
|
|
|
|
|
Not all packaging systems use icons and so this will only be used where the use |
549
|
|
|
|
|
|
|
of icons are supported. |
550
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
=cut |
552
|
|
|
|
|
|
|
sub icon |
553
|
|
|
|
|
|
|
{ |
554
|
2
|
|
|
2
|
1
|
171
|
my $self = shift; |
555
|
2
|
|
|
|
|
4
|
my $value = shift; |
556
|
|
|
|
|
|
|
|
557
|
2
|
100
|
|
|
|
7
|
if ($value) |
558
|
|
|
|
|
|
|
{ |
559
|
1
|
|
|
|
|
4
|
$self->{'ICON'} = $value; |
560
|
|
|
|
|
|
|
} |
561
|
|
|
|
|
|
|
else |
562
|
|
|
|
|
|
|
{ |
563
|
1
|
|
|
|
|
4
|
return $self->{'ICON'}; |
564
|
|
|
|
|
|
|
} |
565
|
|
|
|
|
|
|
} |
566
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
################################################################################ |
568
|
|
|
|
|
|
|
# Function: verdor() |
569
|
|
|
|
|
|
|
|
570
|
|
|
|
|
|
|
=head2 B |
571
|
|
|
|
|
|
|
|
572
|
|
|
|
|
|
|
$packager->vendor('Gondwanatech'); |
573
|
|
|
|
|
|
|
my $vendor = $packager->vendor(); |
574
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
This method is used to specify the vendor of the software package. |
576
|
|
|
|
|
|
|
This is the name of the company or organisation that is creating the software |
577
|
|
|
|
|
|
|
package. |
578
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
=cut |
580
|
|
|
|
|
|
|
sub vendor |
581
|
|
|
|
|
|
|
{ |
582
|
2
|
|
|
2
|
1
|
173
|
my $self = shift; |
583
|
2
|
|
|
|
|
6
|
my $value = shift; |
584
|
|
|
|
|
|
|
|
585
|
2
|
100
|
|
|
|
7
|
if ($value) |
586
|
|
|
|
|
|
|
{ |
587
|
1
|
|
|
|
|
4
|
$self->{'VENDOR'} = $value; |
588
|
|
|
|
|
|
|
} |
589
|
|
|
|
|
|
|
else |
590
|
|
|
|
|
|
|
{ |
591
|
1
|
|
|
|
|
4
|
return $self->{'VENDOR'}; |
592
|
|
|
|
|
|
|
} |
593
|
|
|
|
|
|
|
} |
594
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
################################################################################ |
596
|
|
|
|
|
|
|
# Function: email_contact() |
597
|
|
|
|
|
|
|
|
598
|
|
|
|
|
|
|
=head2 B |
599
|
|
|
|
|
|
|
|
600
|
|
|
|
|
|
|
$packager->email_contact('rbdavison@cpan.org'); |
601
|
|
|
|
|
|
|
my $email = $packager->email_contact(); |
602
|
|
|
|
|
|
|
|
603
|
|
|
|
|
|
|
This function sets or returns the email address for the package contact. |
604
|
|
|
|
|
|
|
Typicaly this will be the person / mail list where help with the software can |
605
|
|
|
|
|
|
|
be sort. |
606
|
|
|
|
|
|
|
|
607
|
|
|
|
|
|
|
=cut |
608
|
|
|
|
|
|
|
sub email_contact |
609
|
|
|
|
|
|
|
{ |
610
|
2
|
|
|
2
|
1
|
171
|
my $self = shift; |
611
|
2
|
|
|
|
|
4
|
my $value = shift; |
612
|
|
|
|
|
|
|
|
613
|
2
|
100
|
|
|
|
6
|
if ($value) |
614
|
|
|
|
|
|
|
{ |
615
|
1
|
|
|
|
|
6
|
$self->{'EMAIL_CONTACT'} = $value; |
616
|
|
|
|
|
|
|
} |
617
|
|
|
|
|
|
|
else |
618
|
|
|
|
|
|
|
{ |
619
|
1
|
|
|
|
|
3
|
return $self->{'EMAIL_CONTACT'}; |
620
|
|
|
|
|
|
|
} |
621
|
|
|
|
|
|
|
} |
622
|
|
|
|
|
|
|
|
623
|
|
|
|
|
|
|
################################################################################ |
624
|
|
|
|
|
|
|
# Function: creator() |
625
|
|
|
|
|
|
|
|
626
|
|
|
|
|
|
|
=head2 B |
627
|
|
|
|
|
|
|
|
628
|
|
|
|
|
|
|
$packager->creator('R Bernard Davison'); |
629
|
|
|
|
|
|
|
my $creator = $packager->creator(); |
630
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
This set the name of the person who created the software package. |
632
|
|
|
|
|
|
|
|
633
|
|
|
|
|
|
|
=cut |
634
|
|
|
|
|
|
|
sub creator |
635
|
|
|
|
|
|
|
{ |
636
|
2
|
|
|
2
|
1
|
168
|
my $self = shift; |
637
|
2
|
|
|
|
|
4
|
my $value = shift; |
638
|
|
|
|
|
|
|
|
639
|
2
|
100
|
|
|
|
6
|
if ($value) |
640
|
|
|
|
|
|
|
{ |
641
|
1
|
|
|
|
|
4
|
$self->{'PACKAGE_CREATOR'} = $value; |
642
|
|
|
|
|
|
|
} |
643
|
|
|
|
|
|
|
else |
644
|
|
|
|
|
|
|
{ |
645
|
1
|
|
|
|
|
4
|
return $self->{'PACKAGE_CREATOR'}; |
646
|
|
|
|
|
|
|
} |
647
|
|
|
|
|
|
|
} |
648
|
|
|
|
|
|
|
|
649
|
|
|
|
|
|
|
################################################################################ |
650
|
|
|
|
|
|
|
# Function: install_dir() |
651
|
|
|
|
|
|
|
|
652
|
|
|
|
|
|
|
=head2 B |
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
$packager->install_dir('/usr/local'); |
655
|
|
|
|
|
|
|
my $base_dir = $packager->install_dir(); |
656
|
|
|
|
|
|
|
|
657
|
|
|
|
|
|
|
This method sets the base directory for the software to be installed. |
658
|
|
|
|
|
|
|
|
659
|
|
|
|
|
|
|
=cut |
660
|
|
|
|
|
|
|
sub install_dir |
661
|
|
|
|
|
|
|
{ |
662
|
2
|
|
|
2
|
1
|
170
|
my $self = shift; |
663
|
2
|
|
|
|
|
4
|
my $value = shift; |
664
|
|
|
|
|
|
|
|
665
|
2
|
100
|
|
|
|
6
|
if ($value) |
666
|
|
|
|
|
|
|
{ |
667
|
1
|
|
|
|
|
4
|
$self->{'BASEDIR'} = $value; |
668
|
|
|
|
|
|
|
} |
669
|
|
|
|
|
|
|
else |
670
|
|
|
|
|
|
|
{ |
671
|
1
|
|
|
|
|
4
|
return $self->{'BASEDIR'}; |
672
|
|
|
|
|
|
|
} |
673
|
|
|
|
|
|
|
} |
674
|
|
|
|
|
|
|
|
675
|
|
|
|
|
|
|
################################################################################ |
676
|
|
|
|
|
|
|
# Function: tmp_dir() |
677
|
|
|
|
|
|
|
|
678
|
|
|
|
|
|
|
=head2 B |
679
|
|
|
|
|
|
|
|
680
|
|
|
|
|
|
|
$packager->tmp_dir('/tmp'); |
681
|
|
|
|
|
|
|
my $tmp_dir = $packager->tmp_dir(); |
682
|
|
|
|
|
|
|
|
683
|
|
|
|
|
|
|
This method returns or sets the temporary build directory to be used for |
684
|
|
|
|
|
|
|
package creation. This directory is used for any preparation that is needed to |
685
|
|
|
|
|
|
|
make the package. This directory should be on a partition with sufficient disk |
686
|
|
|
|
|
|
|
space to hold all temporary objects for the package creation process. |
687
|
|
|
|
|
|
|
|
688
|
|
|
|
|
|
|
=cut |
689
|
|
|
|
|
|
|
sub tmp_dir |
690
|
|
|
|
|
|
|
{ |
691
|
5
|
|
|
5
|
1
|
174
|
my $self = shift; |
692
|
5
|
|
|
|
|
8
|
my $value = shift; |
693
|
|
|
|
|
|
|
|
694
|
5
|
100
|
|
|
|
16
|
if ($value) |
695
|
|
|
|
|
|
|
{ |
696
|
1
|
|
|
|
|
51
|
while (-e $value) |
697
|
|
|
|
|
|
|
{ |
698
|
0
|
|
|
|
|
0
|
warn "Warning: The temporary build directory \"$value\" exists.\n"; |
699
|
0
|
|
|
|
|
0
|
warn " appending /tmp to the name ad trying again.\n"; |
700
|
0
|
|
|
|
|
0
|
$value .= "/tmp"; |
701
|
|
|
|
|
|
|
} |
702
|
1
|
|
|
|
|
6
|
$self->{'TMP_BUILD_DIR'} = $value; |
703
|
|
|
|
|
|
|
} |
704
|
|
|
|
|
|
|
else |
705
|
|
|
|
|
|
|
{ |
706
|
4
|
|
|
|
|
20
|
return $self->{'TMP_BUILD_DIR'}; |
707
|
|
|
|
|
|
|
} |
708
|
|
|
|
|
|
|
} |
709
|
|
|
|
|
|
|
|
710
|
|
|
|
|
|
|
################################################################################ |
711
|
|
|
|
|
|
|
# Function: pre_install_script() |
712
|
|
|
|
|
|
|
# Description: This function returns or sets the pre install script for the |
713
|
|
|
|
|
|
|
# package. |
714
|
|
|
|
|
|
|
# Arguments: file name |
715
|
|
|
|
|
|
|
# Return: file name if nothing passed |
716
|
|
|
|
|
|
|
# |
717
|
|
|
|
|
|
|
sub pre_install_script |
718
|
|
|
|
|
|
|
{ |
719
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
720
|
0
|
|
|
|
|
0
|
my $value = shift; |
721
|
|
|
|
|
|
|
|
722
|
0
|
0
|
|
|
|
0
|
return $self->{'PRE_INSTALL_SCRIPT'} unless $value; |
723
|
0
|
0
|
|
|
|
0
|
if ($self->_test_file($value)) |
724
|
|
|
|
|
|
|
{ |
725
|
0
|
|
|
|
|
0
|
$self->{'PRE_INSTALL_SCRIPT'} = $value; |
726
|
0
|
|
|
|
|
0
|
return 1; |
727
|
|
|
|
|
|
|
} |
728
|
|
|
|
|
|
|
else |
729
|
|
|
|
|
|
|
{ |
730
|
0
|
|
|
|
|
0
|
return undef; |
731
|
|
|
|
|
|
|
} |
732
|
|
|
|
|
|
|
} |
733
|
|
|
|
|
|
|
|
734
|
|
|
|
|
|
|
################################################################################ |
735
|
|
|
|
|
|
|
# Function: post_install_script() |
736
|
|
|
|
|
|
|
# Description: This function returns or sets the post install script for the |
737
|
|
|
|
|
|
|
# package. |
738
|
|
|
|
|
|
|
# Arguments: file name |
739
|
|
|
|
|
|
|
# Return: file name if nothing passed |
740
|
|
|
|
|
|
|
# |
741
|
|
|
|
|
|
|
sub post_install_script |
742
|
|
|
|
|
|
|
{ |
743
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
744
|
0
|
|
|
|
|
0
|
my $value = shift; |
745
|
|
|
|
|
|
|
|
746
|
0
|
0
|
|
|
|
0
|
return $self->{'POST_INSTALL_SCRIPT'} unless $value; |
747
|
0
|
0
|
|
|
|
0
|
if ($self->_test_file($value)) |
748
|
|
|
|
|
|
|
{ |
749
|
0
|
|
|
|
|
0
|
$self->{'POST_INSTALL_SCRIPT'} = $value; |
750
|
0
|
|
|
|
|
0
|
return 1; |
751
|
|
|
|
|
|
|
} |
752
|
|
|
|
|
|
|
else |
753
|
|
|
|
|
|
|
{ |
754
|
0
|
|
|
|
|
0
|
return undef; |
755
|
|
|
|
|
|
|
} |
756
|
|
|
|
|
|
|
} |
757
|
|
|
|
|
|
|
|
758
|
|
|
|
|
|
|
################################################################################ |
759
|
|
|
|
|
|
|
# Function: pre_uninstall_script() |
760
|
|
|
|
|
|
|
# Description: This function returns or sets the pre uninstall script for the |
761
|
|
|
|
|
|
|
# package. |
762
|
|
|
|
|
|
|
# Arguments: file name |
763
|
|
|
|
|
|
|
# Return: file name if nothing passed |
764
|
|
|
|
|
|
|
# |
765
|
|
|
|
|
|
|
sub pre_uninstall_script |
766
|
|
|
|
|
|
|
{ |
767
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
768
|
0
|
|
|
|
|
0
|
my $value = shift; |
769
|
|
|
|
|
|
|
|
770
|
0
|
0
|
|
|
|
0
|
return $self->{'PRE_UNINSTALL_SCRIPT'} unless $value; |
771
|
0
|
0
|
|
|
|
0
|
if ($self->_test_file($value)) |
772
|
|
|
|
|
|
|
{ |
773
|
0
|
|
|
|
|
0
|
$self->{'PRE_UNINSTALL_SCRIPT'} = $value; |
774
|
0
|
|
|
|
|
0
|
return 1; |
775
|
|
|
|
|
|
|
} |
776
|
|
|
|
|
|
|
else |
777
|
|
|
|
|
|
|
{ |
778
|
0
|
|
|
|
|
0
|
return undef; |
779
|
|
|
|
|
|
|
} |
780
|
|
|
|
|
|
|
} |
781
|
|
|
|
|
|
|
|
782
|
|
|
|
|
|
|
################################################################################ |
783
|
|
|
|
|
|
|
# Function: post_uninstall_script() |
784
|
|
|
|
|
|
|
# Description: This function returns or sets the post uninstall script for the |
785
|
|
|
|
|
|
|
# package. |
786
|
|
|
|
|
|
|
# Arguments: file name |
787
|
|
|
|
|
|
|
# Return: file name if nothing passed |
788
|
|
|
|
|
|
|
# |
789
|
|
|
|
|
|
|
sub post_uninstall_script |
790
|
|
|
|
|
|
|
{ |
791
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
792
|
0
|
|
|
|
|
0
|
my $value = shift; |
793
|
|
|
|
|
|
|
|
794
|
0
|
0
|
|
|
|
0
|
return $self->{'POST_UNINSTALL_SCRIPT'} unless $value; |
795
|
0
|
0
|
|
|
|
0
|
if ($self->_test_file($value)) |
796
|
|
|
|
|
|
|
{ |
797
|
0
|
|
|
|
|
0
|
$self->{'POST_UNINSTALL_SCRIPT'} = $value; |
798
|
0
|
|
|
|
|
0
|
return 1; |
799
|
|
|
|
|
|
|
} |
800
|
|
|
|
|
|
|
else |
801
|
|
|
|
|
|
|
{ |
802
|
0
|
|
|
|
|
0
|
return undef; |
803
|
|
|
|
|
|
|
} |
804
|
|
|
|
|
|
|
} |
805
|
|
|
|
|
|
|
|
806
|
|
|
|
|
|
|
################################################################################ |
807
|
|
|
|
|
|
|
# Function: pre_upgrade_script() |
808
|
|
|
|
|
|
|
# Description: This function returns or sets the pre upgrade script for the |
809
|
|
|
|
|
|
|
# package. |
810
|
|
|
|
|
|
|
# Arguments: file name |
811
|
|
|
|
|
|
|
# Return: file name if nothing passed |
812
|
|
|
|
|
|
|
# |
813
|
|
|
|
|
|
|
sub pre_upgrade_script |
814
|
|
|
|
|
|
|
{ |
815
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
816
|
0
|
|
|
|
|
0
|
my $value = shift; |
817
|
|
|
|
|
|
|
|
818
|
0
|
0
|
|
|
|
0
|
return $self->{'PRE_UPGRADE_SCRIPT'} unless $value; |
819
|
0
|
0
|
|
|
|
0
|
if ($self->_test_file($value)) |
820
|
|
|
|
|
|
|
{ |
821
|
0
|
|
|
|
|
0
|
$self->{'PRE_UPGRADE_SCRIPT'} = $value; |
822
|
0
|
|
|
|
|
0
|
return 1; |
823
|
|
|
|
|
|
|
} |
824
|
|
|
|
|
|
|
else |
825
|
|
|
|
|
|
|
{ |
826
|
0
|
|
|
|
|
0
|
return undef; |
827
|
|
|
|
|
|
|
} |
828
|
|
|
|
|
|
|
} |
829
|
|
|
|
|
|
|
|
830
|
|
|
|
|
|
|
################################################################################ |
831
|
|
|
|
|
|
|
# Function: post_upgrade_script() |
832
|
|
|
|
|
|
|
# Description: This function returns or sets the post upgrade script for the |
833
|
|
|
|
|
|
|
# package. |
834
|
|
|
|
|
|
|
# Arguments: file name |
835
|
|
|
|
|
|
|
# Return: file name if nothing passed |
836
|
|
|
|
|
|
|
# |
837
|
|
|
|
|
|
|
sub post_upgrade_script |
838
|
|
|
|
|
|
|
{ |
839
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
840
|
0
|
|
|
|
|
0
|
my $value = shift; |
841
|
|
|
|
|
|
|
|
842
|
0
|
0
|
|
|
|
0
|
return $self->{'POST_UPGRADE_SCRIPT'} unless $value; |
843
|
0
|
0
|
|
|
|
0
|
if ($self->_test_file($value)) |
844
|
|
|
|
|
|
|
{ |
845
|
0
|
|
|
|
|
0
|
$self->{'POST_UPGRADE_SCRIPT'} = $value; |
846
|
0
|
|
|
|
|
0
|
return 1; |
847
|
|
|
|
|
|
|
} |
848
|
|
|
|
|
|
|
else |
849
|
|
|
|
|
|
|
{ |
850
|
0
|
|
|
|
|
0
|
return undef; |
851
|
|
|
|
|
|
|
} |
852
|
|
|
|
|
|
|
} |
853
|
|
|
|
|
|
|
|
854
|
|
|
|
|
|
|
################################################################################ |
855
|
|
|
|
|
|
|
# Function: license_file() |
856
|
|
|
|
|
|
|
# Description: This function returns or sets the license file for the package |
857
|
|
|
|
|
|
|
# Arguments: file name |
858
|
|
|
|
|
|
|
# Return: file name if nothing passed |
859
|
|
|
|
|
|
|
# |
860
|
|
|
|
|
|
|
sub license_file |
861
|
|
|
|
|
|
|
{ |
862
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
863
|
0
|
|
|
|
|
0
|
my $value = shift; |
864
|
|
|
|
|
|
|
|
865
|
0
|
0
|
|
|
|
0
|
if ($value) |
866
|
|
|
|
|
|
|
{ |
867
|
0
|
|
|
|
|
0
|
$self->{'LICENSE_FILE'} = $value; |
868
|
|
|
|
|
|
|
} |
869
|
|
|
|
|
|
|
else |
870
|
|
|
|
|
|
|
{ |
871
|
0
|
|
|
|
|
0
|
return $self->{'LICENSE_FILE'}; |
872
|
|
|
|
|
|
|
} |
873
|
|
|
|
|
|
|
} |
874
|
|
|
|
|
|
|
|
875
|
|
|
|
|
|
|
################################################################################ |
876
|
|
|
|
|
|
|
# Function: copyright() |
877
|
|
|
|
|
|
|
|
878
|
|
|
|
|
|
|
=head2 B |
879
|
|
|
|
|
|
|
|
880
|
|
|
|
|
|
|
This method sets the copyright type for the package. This can either be a file |
881
|
|
|
|
|
|
|
that contains the copyright, The copyright type or the copy information itself |
882
|
|
|
|
|
|
|
|
883
|
|
|
|
|
|
|
As many packaging systems treat copyright information it is wise to check with |
884
|
|
|
|
|
|
|
the various Software::Packager modules to see how they are treated. |
885
|
|
|
|
|
|
|
|
886
|
|
|
|
|
|
|
=cut |
887
|
|
|
|
|
|
|
sub copyright |
888
|
|
|
|
|
|
|
{ |
889
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
890
|
0
|
|
|
|
|
0
|
my $value = shift; |
891
|
|
|
|
|
|
|
|
892
|
0
|
0
|
|
|
|
0
|
if ($value) |
893
|
|
|
|
|
|
|
{ |
894
|
0
|
|
|
|
|
0
|
$self->{'COPYRIGHT'} = $value; |
895
|
|
|
|
|
|
|
} |
896
|
|
|
|
|
|
|
else |
897
|
|
|
|
|
|
|
{ |
898
|
0
|
|
|
|
|
0
|
return $self->{'COPYRIGHT'}; |
899
|
|
|
|
|
|
|
} |
900
|
|
|
|
|
|
|
} |
901
|
|
|
|
|
|
|
|
902
|
|
|
|
|
|
|
################################################################################ |
903
|
|
|
|
|
|
|
# Function: reboot_required() |
904
|
|
|
|
|
|
|
|
905
|
|
|
|
|
|
|
=head2 B |
906
|
|
|
|
|
|
|
|
907
|
|
|
|
|
|
|
$packager->reboot_required(0); |
908
|
|
|
|
|
|
|
$packager->reboot_required(1); |
909
|
|
|
|
|
|
|
|
910
|
|
|
|
|
|
|
This method specifies wether a reboot of the operating system is required after |
911
|
|
|
|
|
|
|
the installation is complete. |
912
|
|
|
|
|
|
|
If set to a true value then any package create will request a reboot after |
913
|
|
|
|
|
|
|
installation. |
914
|
|
|
|
|
|
|
|
915
|
|
|
|
|
|
|
=cut |
916
|
|
|
|
|
|
|
sub reboot_required |
917
|
|
|
|
|
|
|
{ |
918
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
919
|
0
|
|
|
|
|
0
|
my $value = shift; |
920
|
|
|
|
|
|
|
|
921
|
0
|
0
|
|
|
|
0
|
if ($value) |
922
|
|
|
|
|
|
|
{ |
923
|
0
|
|
|
|
|
0
|
$self->{'REBOOT_REQUIRED'} = $value; |
924
|
|
|
|
|
|
|
} |
925
|
|
|
|
|
|
|
else |
926
|
|
|
|
|
|
|
{ |
927
|
0
|
|
|
|
|
0
|
return $self->{'REBOOT_REQUIRED'}; |
928
|
|
|
|
|
|
|
} |
929
|
|
|
|
|
|
|
} |
930
|
|
|
|
|
|
|
|
931
|
|
|
|
|
|
|
################################################################################ |
932
|
|
|
|
|
|
|
# Function: homepage() |
933
|
|
|
|
|
|
|
|
934
|
|
|
|
|
|
|
=head2 B |
935
|
|
|
|
|
|
|
|
936
|
|
|
|
|
|
|
This method sets the home page for the package. This is a URL for a web site |
937
|
|
|
|
|
|
|
that is for the software being released. |
938
|
|
|
|
|
|
|
|
939
|
|
|
|
|
|
|
=cut |
940
|
|
|
|
|
|
|
sub homepage |
941
|
|
|
|
|
|
|
{ |
942
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
943
|
0
|
|
|
|
|
0
|
my $value = shift; |
944
|
|
|
|
|
|
|
|
945
|
0
|
0
|
|
|
|
0
|
if ($value) |
946
|
|
|
|
|
|
|
{ |
947
|
0
|
|
|
|
|
0
|
$self->{'HOMEPAGE'} = $value; |
948
|
|
|
|
|
|
|
} |
949
|
|
|
|
|
|
|
else |
950
|
|
|
|
|
|
|
{ |
951
|
0
|
|
|
|
|
0
|
return $self->{'HOMEPAGE'}; |
952
|
|
|
|
|
|
|
} |
953
|
|
|
|
|
|
|
} |
954
|
|
|
|
|
|
|
|
955
|
|
|
|
|
|
|
################################################################################ |
956
|
|
|
|
|
|
|
# Function: get_object_list() |
957
|
|
|
|
|
|
|
# Description: This function returns the list of objects to be packaged. |
958
|
|
|
|
|
|
|
# Arguments: none. |
959
|
|
|
|
|
|
|
# Return: an array of objects. |
960
|
|
|
|
|
|
|
# |
961
|
|
|
|
|
|
|
sub get_object_list |
962
|
|
|
|
|
|
|
{ |
963
|
3
|
|
|
3
|
0
|
5
|
my $self = shift; |
964
|
|
|
|
|
|
|
|
965
|
3
|
|
|
|
|
5
|
my @destinations; |
966
|
3
|
|
|
|
|
4
|
foreach my $key (keys %{$self->{'OBJECTS'}}) |
|
3
|
|
|
|
|
23
|
|
967
|
|
|
|
|
|
|
{ |
968
|
48
|
|
|
|
|
141
|
push @destinations, $self->{'OBJECTS'}->{$key}->destination(); |
969
|
|
|
|
|
|
|
} |
970
|
3
|
|
|
|
|
31
|
@destinations = sort @destinations; |
971
|
|
|
|
|
|
|
|
972
|
3
|
|
|
|
|
4
|
my @sorted_objects; |
973
|
3
|
|
|
|
|
7
|
foreach my $destination (@destinations) |
974
|
|
|
|
|
|
|
{ |
975
|
48
|
|
|
|
|
44
|
foreach my $key (keys %{$self->{'OBJECTS'}}) |
|
48
|
|
|
|
|
206
|
|
976
|
|
|
|
|
|
|
{ |
977
|
408
|
|
|
|
|
599
|
my $object = $self->{'OBJECTS'}->{$key}; |
978
|
408
|
100
|
|
|
|
858
|
if ($object->destination() eq $destination) |
979
|
|
|
|
|
|
|
{ |
980
|
48
|
|
|
|
|
66
|
push @sorted_objects, $object; |
981
|
48
|
|
|
|
|
126
|
last; |
982
|
|
|
|
|
|
|
} |
983
|
|
|
|
|
|
|
} |
984
|
|
|
|
|
|
|
} |
985
|
|
|
|
|
|
|
|
986
|
3
|
|
|
|
|
15
|
return @sorted_objects; |
987
|
|
|
|
|
|
|
} |
988
|
|
|
|
|
|
|
|
989
|
|
|
|
|
|
|
################################################################################ |
990
|
|
|
|
|
|
|
# Function: get_objects_matching() |
991
|
|
|
|
|
|
|
# Description: This function returns a list of objects that matched the query. |
992
|
|
|
|
|
|
|
# Arguments: $query_field, $query_value |
993
|
|
|
|
|
|
|
# Return: an array of objects. |
994
|
|
|
|
|
|
|
# |
995
|
|
|
|
|
|
|
sub get_objects_matching |
996
|
|
|
|
|
|
|
{ |
997
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
998
|
0
|
|
|
|
|
0
|
my $query = shift; |
999
|
0
|
|
|
|
|
0
|
my $value = shift; |
1000
|
|
|
|
|
|
|
|
1001
|
0
|
|
|
|
|
0
|
my @objects; |
1002
|
0
|
|
|
|
|
0
|
foreach my $object ($self->get_object_list()) |
1003
|
|
|
|
|
|
|
{ |
1004
|
0
|
|
|
|
|
0
|
my $function = lc $query; |
1005
|
0
|
0
|
|
|
|
0
|
push @objects, $object if $object->$function() eq $value; |
1006
|
|
|
|
|
|
|
} |
1007
|
|
|
|
|
|
|
|
1008
|
0
|
|
|
|
|
0
|
return @objects; |
1009
|
|
|
|
|
|
|
} |
1010
|
|
|
|
|
|
|
|
1011
|
|
|
|
|
|
|
################################################################################ |
1012
|
|
|
|
|
|
|
# Function: get_directory_objects() |
1013
|
|
|
|
|
|
|
# Description: This function returns the list of objects that are directories. |
1014
|
|
|
|
|
|
|
# Arguments: none. |
1015
|
|
|
|
|
|
|
# Return: an array of objects. |
1016
|
|
|
|
|
|
|
# |
1017
|
|
|
|
|
|
|
sub get_directory_objects |
1018
|
|
|
|
|
|
|
{ |
1019
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
1020
|
|
|
|
|
|
|
|
1021
|
1
|
|
|
|
|
2
|
my @objects; |
1022
|
1
|
|
|
|
|
9
|
foreach my $object ($self->get_object_list()) |
1023
|
|
|
|
|
|
|
{ |
1024
|
16
|
50
|
|
|
|
31
|
push @objects, $object if $object->type() =~ /^directory$/i; |
1025
|
|
|
|
|
|
|
} |
1026
|
|
|
|
|
|
|
|
1027
|
1
|
|
|
|
|
5
|
return @objects; |
1028
|
|
|
|
|
|
|
} |
1029
|
|
|
|
|
|
|
|
1030
|
|
|
|
|
|
|
################################################################################ |
1031
|
|
|
|
|
|
|
# Function: get_file_objects() |
1032
|
|
|
|
|
|
|
# Description: This function returns the list of objects that are files. |
1033
|
|
|
|
|
|
|
# Arguments: none. |
1034
|
|
|
|
|
|
|
# Return: an array of objects. |
1035
|
|
|
|
|
|
|
# |
1036
|
|
|
|
|
|
|
sub get_file_objects |
1037
|
|
|
|
|
|
|
{ |
1038
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
1039
|
|
|
|
|
|
|
|
1040
|
1
|
|
|
|
|
2
|
my @objects; |
1041
|
1
|
|
|
|
|
2
|
foreach my $object ($self->get_object_list()) |
1042
|
|
|
|
|
|
|
{ |
1043
|
16
|
100
|
|
|
|
39
|
push @objects, $object if $object->type() =~ /^file$/i; |
1044
|
|
|
|
|
|
|
} |
1045
|
|
|
|
|
|
|
|
1046
|
1
|
|
|
|
|
8
|
return @objects; |
1047
|
|
|
|
|
|
|
} |
1048
|
|
|
|
|
|
|
|
1049
|
|
|
|
|
|
|
################################################################################ |
1050
|
|
|
|
|
|
|
# Function: get_link_objects() |
1051
|
|
|
|
|
|
|
# Description: This function returns the list of objects that are links. |
1052
|
|
|
|
|
|
|
# Arguments: none. |
1053
|
|
|
|
|
|
|
# Return: an array of objects. |
1054
|
|
|
|
|
|
|
# |
1055
|
|
|
|
|
|
|
sub get_link_objects |
1056
|
|
|
|
|
|
|
{ |
1057
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
1058
|
|
|
|
|
|
|
|
1059
|
1
|
|
|
|
|
3
|
my @objects; |
1060
|
1
|
|
|
|
|
6
|
foreach my $object ($self->get_object_list()) |
1061
|
|
|
|
|
|
|
{ |
1062
|
16
|
100
|
|
|
|
39
|
push @objects, $object if $object->type() =~ /link/i; |
1063
|
|
|
|
|
|
|
} |
1064
|
|
|
|
|
|
|
|
1065
|
1
|
|
|
|
|
5
|
return @objects; |
1066
|
|
|
|
|
|
|
} |
1067
|
|
|
|
|
|
|
|
1068
|
|
|
|
|
|
|
################################################################################ |
1069
|
|
|
|
|
|
|
# Function: _test_file() |
1070
|
|
|
|
|
|
|
# Description: This function returns true if the passed file exists, if it |
1071
|
|
|
|
|
|
|
# doesn't then it prints an error message and returns undef. |
1072
|
|
|
|
|
|
|
# Arguments: $file. |
1073
|
|
|
|
|
|
|
# Return: true or undef. |
1074
|
|
|
|
|
|
|
# |
1075
|
|
|
|
|
|
|
sub _test_file |
1076
|
|
|
|
|
|
|
{ |
1077
|
0
|
|
|
0
|
|
|
my $self = shift; |
1078
|
0
|
|
|
|
|
|
my $file = shift; |
1079
|
|
|
|
|
|
|
|
1080
|
0
|
0
|
|
|
|
|
return 1 if -f $file; |
1081
|
0
|
|
|
|
|
|
print "Error: File \"$file\" does not exist\n"; |
1082
|
0
|
|
|
|
|
|
return undef; |
1083
|
|
|
|
|
|
|
} |
1084
|
|
|
|
|
|
|
|
1085
|
|
|
|
|
|
|
################################################################################ |
1086
|
|
|
|
|
|
|
# Function: package() |
1087
|
|
|
|
|
|
|
|
1088
|
|
|
|
|
|
|
=head2 B |
1089
|
|
|
|
|
|
|
|
1090
|
|
|
|
|
|
|
This method forms part of the base API it should be overriden by sub classes |
1091
|
|
|
|
|
|
|
of Software::Packager |
1092
|
|
|
|
|
|
|
|
1093
|
|
|
|
|
|
|
=cut |
1094
|
|
|
|
|
|
|
sub package |
1095
|
|
|
|
|
|
|
{ |
1096
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1097
|
0
|
|
|
|
|
|
warn "The base API has been called this module must be sub classed.\n"; |
1098
|
|
|
|
|
|
|
} |
1099
|
|
|
|
|
|
|
|
1100
|
|
|
|
|
|
|
1; |
1101
|
|
|
|
|
|
|
__END__ |