| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package LCFG::Build::Utils::OSXPkg; # -*-cperl-*- |
|
2
|
1
|
|
|
1
|
|
851
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
31
|
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
45
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# $Id: OSXPkg.pm.in 26631 2014-10-31 10:52:42Z squinney@INF.ED.AC.UK $ |
|
6
|
|
|
|
|
|
|
# $Source: /var/cvs/dice/LCFG-Build-Tools/lib/LCFG/Build/Utils/MacOSX.pm.in,v $ |
|
7
|
|
|
|
|
|
|
# $Revision: 26631 $ |
|
8
|
|
|
|
|
|
|
# $HeadURL: https://svn.lcfg.org/svn/source/tags/LCFG-Build-Tools/LCFG_Build_Tools_0_4_5/lib/LCFG/Build/Utils/OSXPkg.pm.in $ |
|
9
|
|
|
|
|
|
|
# $Date: 2014-10-31 10:52:42 +0000 (Fri, 31 Oct 2014) $ |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.4.5'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
4
|
use File::Copy (); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
18
|
|
|
14
|
1
|
|
|
1
|
|
6
|
use File::Spec (); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
10
|
|
|
15
|
1
|
|
|
1
|
|
2
|
use File::Temp (); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
13
|
|
|
16
|
1
|
|
|
1
|
|
3
|
use LCFG::Build::Utils; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
11
|
|
|
17
|
1
|
|
|
1
|
|
449
|
use Sys::Hostname (); |
|
|
1
|
|
|
|
|
1271
|
|
|
|
1
|
|
|
|
|
19
|
|
|
18
|
1
|
|
|
1
|
|
501
|
use Readonly; |
|
|
1
|
|
|
|
|
2250
|
|
|
|
1
|
|
|
|
|
500
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Readonly my $CMAKE => '/usr/bin/cmake'; |
|
21
|
|
|
|
|
|
|
Readonly my $MAKE => '/usr/bin/make'; |
|
22
|
|
|
|
|
|
|
Readonly my $PKGBUILD => '/usr/bin/pkgbuild'; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub build { |
|
25
|
0
|
|
|
0
|
1
|
|
my ( $self, $outdir, $tarfile, $dirname, |
|
26
|
|
|
|
|
|
|
$pkgname, $pkgversion, $pkgident, |
|
27
|
|
|
|
|
|
|
$filters, $scriptdir, $nopayload ) = @_; |
|
28
|
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
my $tempdir = File::Temp::tempdir( 'buildtools-XXXXX', |
|
30
|
|
|
|
|
|
|
TMPDIR => 1, |
|
31
|
|
|
|
|
|
|
CLEANUP => 1 ); |
|
32
|
0
|
|
|
|
|
|
chdir $tempdir; |
|
33
|
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
require Archive::Tar; |
|
35
|
0
|
|
|
|
|
|
require IO::Zlib; |
|
36
|
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my $tar = Archive::Tar->new(); |
|
38
|
0
|
|
|
|
|
|
my $tar_ok = $tar->extract_archive( $tarfile, 1); |
|
39
|
0
|
0
|
|
|
|
|
if ( !$tar_ok ) { |
|
40
|
0
|
|
|
|
|
|
die "Failed to extract '$tarfile': " . $tar->error . "\n"; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my $prev_dir = Cwd::getcwd(); # will need to go back to this later |
|
44
|
|
|
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
|
chdir $dirname or |
|
46
|
|
|
|
|
|
|
die "Failed to change directory into $dirname - check tar file."; |
|
47
|
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my @cmake_cmd = ( $CMAKE, '.'); |
|
49
|
0
|
|
|
|
|
|
my $cmake_ok = system @cmake_cmd; |
|
50
|
0
|
0
|
|
|
|
|
if ( $cmake_ok != 0 ) { |
|
51
|
0
|
|
|
|
|
|
die "Failed to run cmake.\n"; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
my $builddir = File::Temp::tempdir( 'buildtools-XXXXX', |
|
55
|
|
|
|
|
|
|
TMPDIR => 1, |
|
56
|
|
|
|
|
|
|
CLEANUP => 1 ); |
|
57
|
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
my $filename = File::Spec->catfile( $outdir, $pkgname . '.pkg') ; |
|
59
|
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
my @make_cmd = ( $MAKE, 'install', |
|
61
|
|
|
|
|
|
|
'DESTDIR=' . $builddir); |
|
62
|
0
|
|
|
|
|
|
my $make_ok = system @make_cmd; |
|
63
|
0
|
0
|
|
|
|
|
if ( $make_ok != 0 ) { |
|
64
|
0
|
|
|
|
|
|
die "Failed to build project .\n"; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
my @pkgbuild_cmd = ( $PKGBUILD, |
|
68
|
|
|
|
|
|
|
'--identifier' => $pkgident, |
|
69
|
|
|
|
|
|
|
'--version' => $pkgversion ); |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# If there's no payload, don't specify the files to package |
|
72
|
0
|
0
|
|
|
|
|
if ( $nopayload ) { |
|
73
|
0
|
|
|
|
|
|
push @pkgbuild_cmd, '--nopayload'; |
|
74
|
|
|
|
|
|
|
} else { |
|
75
|
0
|
|
|
|
|
|
push @pkgbuild_cmd, '--root' => $builddir; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# pkgbuild by default filters .DS_Store, CVS and .svn, but doesn't |
|
79
|
|
|
|
|
|
|
# if we use the --filter option, so add these explicitly |
|
80
|
0
|
|
|
|
|
|
my @default_filters = ( qw/ .DS_Store CVS .svn / ); |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# Add a command line option for each filter |
|
83
|
0
|
|
|
|
|
|
foreach my $filter ( @default_filters, @$filters ) { |
|
84
|
0
|
|
|
|
|
|
push @pkgbuild_cmd, '--filter' => $filter; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
0
|
0
|
0
|
|
|
|
if ( ( defined $scriptdir ) && ( -d $scriptdir ) ) { |
|
88
|
0
|
|
|
|
|
|
push @pkgbuild_cmd, '--scripts' => $scriptdir; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
0
|
|
|
|
|
|
push @pkgbuild_cmd, $filename; |
|
91
|
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
my $pkgbuild_ok = system @pkgbuild_cmd; |
|
93
|
0
|
0
|
|
|
|
|
if ( $pkgbuild_ok != 0 ) { |
|
94
|
0
|
|
|
|
|
|
die "Failed to make package.\n"; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# Check there really is a package |
|
98
|
0
|
0
|
|
|
|
|
if ( ! -f $filename ) { |
|
99
|
0
|
|
|
|
|
|
die "Cannot find expected package: '$filename'.\n"; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
chdir $prev_dir; |
|
103
|
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
my @packages = ( $filename ); |
|
105
|
|
|
|
|
|
|
return { |
|
106
|
0
|
|
|
|
|
|
packages => \@packages |
|
107
|
|
|
|
|
|
|
}; |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
1; |
|
111
|
|
|
|
|
|
|
__END__ |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 NAME |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
LCFG::Build::Utils::OSXPkg - LCFG software building utilities |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 VERSION |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
This documentation refers to LCFG::Build::Utils::OSXPkg version 0.4.5 |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
This module provides a suite of utilities to help in building MacOSX |
|
124
|
|
|
|
|
|
|
packages from LCFG projects, particularly LCFG components. The methods |
|
125
|
|
|
|
|
|
|
are mostly used by tools which implement the LCFG::Build::Tool base |
|
126
|
|
|
|
|
|
|
class (e.g. LCFG::Build::Tool::OSXPkg) but typically they are designed to |
|
127
|
|
|
|
|
|
|
be generic enough to be used elsewhere. |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
There is one public method you can call on this class. |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=over 4 |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item build( $outdir, $tarfile, $dirname, $pkgname, $pkgversion, $pkgident, $filters, $scriptdir, $nopayload ) |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
This method assumes that C<$tarfile> contains sources that C<cmake> |
|
138
|
|
|
|
|
|
|
can build and install. C<pkgbuild> is then called to create the |
|
139
|
|
|
|
|
|
|
package. |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=over 4 |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item B<$outdir> |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Absolute path to the directory where the package will be created. |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=item B<$tarfile> |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Absolute path to the tarfile to unpack, build and package. |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item B<$pkgname> |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
The full name of the package you want to generate, |
|
154
|
|
|
|
|
|
|
e.g. C<lcfg-foo-1.2.3-4>. C<.pkg> will be appended to this for you. |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item B<$pkgversion> |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
The version of the package, e.g. C<1.2.3.4>. |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=item B<$pkgident> |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
A package identifier to pass to C<pkgbuild>, e.g. C<org.lcfg>. |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=item B<$filters> |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
A reference to an array of filter expressions to pass to C<pkgbuild>. |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=item B<$scriptdir> |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Absolute path to a directory of scripts to pass to C<pkgbuild>. There |
|
171
|
|
|
|
|
|
|
is no filtering of the files in this directory and C<pkgbuild> will |
|
172
|
|
|
|
|
|
|
copy all its contents into the package. |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=item B<$nopayload> |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
A boolean that flags whether the package should be created with or |
|
177
|
|
|
|
|
|
|
without a payload. |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=back |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=back |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
For building packages you will need CMake and pkgbuild. |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head1 PLATFORMS |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
This is the list of platforms on which we have tested this |
|
190
|
|
|
|
|
|
|
software. We expect this software to work on any Unix-like platform |
|
191
|
|
|
|
|
|
|
which is supported by Perl. |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Mac OS X 10.7 |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
There are no known bugs in this application. Please report any |
|
198
|
|
|
|
|
|
|
problems to bugs@lcfg.org, feedback and patches are also always very |
|
199
|
|
|
|
|
|
|
welcome. |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head1 AUTHOR |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
Kenneth MacDonald <Kenneth.MacDonald@ed.ac.uk> |
|
204
|
|
|
|
|
|
|
Stephen Quinney <squinney@inf.ed.ac.uk> |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
Copyright (C) 2008-2012 University of Edinburgh. All rights reserved. |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
211
|
|
|
|
|
|
|
it under the terms of the GPL, version 2 or later. |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=cut |