File Coverage

blib/lib/LCFG/Build/Tool/OSXPkg.pm
Criterion Covered Total %
statement 10 12 83.3
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 14 16 87.5


line stmt bran cond sub pod time code
1             package LCFG::Build::Tool::OSXPkg; # -*-cperl-*-
2 1     1   1674 use strict;
  1         2  
  1         102  
3 1     1   5 use warnings;
  1         2  
  1         124  
4              
5             # $Id: OSXPkg.pm.in 20973 2012-05-18 16:54:45Z squinney@INF.ED.AC.UK $
6             # $Source: /var/cvs/dice/LCFG-Build-Tools/lib/LCFG/Build/Tool/OSXPkg.pm.in,v $
7             # $Revision: 20973 $
8             # $HeadURL: https://svn.lcfg.org/svn/source/tags/LCFG-Build-Tools/LCFG_Build_Tools_0_4_0/lib/LCFG/Build/Tool/OSXPkg.pm.in $
9             # $Date: 2012-05-18 17:54:45 +0100 (Fri, 18 May 2012) $
10              
11             our $VERSION = '0.4.0';
12              
13 1     1   5 use LCFG::Build::Utils::OSXPkg;
  1         2  
  1         11  
14              
15 1     1   502 use Moose;
  0            
  0            
16              
17             extends 'LCFG::Build::Tool::Pack';
18              
19             has 'nopayload' => (
20             is => 'rw',
21             isa => 'Bool',
22             lazy => 1,
23             default => sub { $_[0]->spec->get_buildinfo('nopayload') },
24             documentation => 'Specify no payload in the package',
25             );
26              
27             override 'abstract' => sub {
28             return q{Build MacOSX packages from the tagged source tree};
29             };
30              
31             override 'execute' => sub {
32             my ($self) = @_;
33              
34             super; # packs the source
35              
36             my $spec = $self->spec;
37             my $module = $spec->fullname;
38              
39             my $dirname = join q{-}, $module, $spec->version;
40             my $outdir = File::Spec->catdir( $self->resultsdir, $dirname );
41              
42             my $tarname = $spec->tarname;
43             my $tarfile = File::Spec->catfile( $outdir, $tarname );
44              
45             my $pkgident = $spec->pkgident;
46             my $pkgversion = $spec->version . '.' . $spec->release;
47             my $pkgname = join q{-}, $spec->fullname, $spec->version, $spec->release;
48              
49             my $nopayload = $self->nopayload;
50              
51             # Leave @filters as hardwired to ( "usr/lib/lcfg/defaults/server" ) until
52             # we can specify filters in the spec structure (lcfg.yml)
53             # The scripts directory is set to undef for now too.
54             my @filters = ( 'usr/lib/lcfg/defaults/server' );
55             my $result
56             = LCFG::Build::Utils::OSXPkg->build( $outdir, $tarfile, $dirname,
57             $pkgname, $pkgversion, $pkgident,
58             \@filters, undef, $nopayload );
59              
60             $self->log("Successfully built packages for $module");
61             for my $package ( @{ $result->{packages} } ) {
62             $self->log("Package: $package");
63             }
64              
65             return;
66             };
67              
68             __PACKAGE__->meta->make_immutable;
69              
70             no Moose;
71             1;
72             __END__
73              
74             =head1 NAME
75              
76             LCFG::Build::Tool::OSXPkg - LCFG software packaging tool
77              
78             =head1 VERSION
79              
80             This documentation refers to LCFG::Build::Tool::OSXPkg version 0.4.0
81              
82             =head1 SYNOPSIS
83              
84             my $tool = LCFG::Build::Tool::OSXPkg->new( dir => '.' );
85              
86             $tool->execute;
87              
88             my $tool2 = LCFG::Build::Tool::OSXPkg->new_with_options();
89              
90             $tool2->execute;
91              
92             =head1 DESCRIPTION
93              
94             This module provides software release tools for the LCFG build
95             suite.
96              
97             This is a tool to take a tagged copy of the source for a project
98             managed with the LCFG build tools and package it into a gzipped source
99             tar file. Build metadata files for supported platforms (e.g. a
100             specfile for building binary RPMs) are also generated at the same
101             time. It is also possible to do limited autoconf-style macro
102             substitution prior to the source being packaged. This allows the
103             generation of 'pristine' tar files where downstream users will be
104             unaware of the additional source-file processing that has been carried
105             out prior to distribution. A Mac OS X package will then be generated
106             from the gzipped source tar file, assuming CMake is used to build and
107             install the project.
108              
109             More information on the LCFG build tools is available from the website
110             http://www.lcfg.org/doc/buildtools/
111              
112             =head1 ATTRIBUTES
113              
114             The following attributes are modifiable via the command-line (i.e. via
115             @ARGV) as well as the normal way when the Tool object is
116             created. Unless stated the options take strings as arguments and can
117             be used like C<--foo=bar>. Boolean options can be expressed as either
118             C<--foo> or C<--no-foo> to signify true and false values.
119              
120             =over 4
121              
122             =item dryrun
123              
124             A boolean value which indicates whether actions which permanently
125             alter the contents of files should be carried out. The default value
126             is false (0). When running in dry-run mode various you will typically
127             get extra output to the screen showing what would have been done.
128              
129             =item quiet
130              
131             A boolean value which indicates whether the actions should attempt to
132             be quieter. The default value is false (0).
133              
134             =item dir
135              
136             The path of the project directory which contains the software for
137             which you want to create a release. If this is not specified then a
138             default value of the current directory (.) will be used. This
139             directory must already contain the LCFG build metadata file (lcfg.yml)
140             for the software.
141              
142             =item resultsdir
143              
144             When a project is packaged for release the generated products (the
145             gzipped source tar file, various build metadata files and possibly
146             binary RPMS, etc) are stored into a directory named after the
147             combination of the full name of the project and the version
148             number. For example, a project named 'foo' with version '1.2.3' would
149             have an output directory of 'foo-1.2.3'. You should note that if the
150             C<base> attribute is specified in the metadata file (this is the case
151             for LCFG components) then that is also used. If the previous example
152             was an LCFG component it would have a directory named
153             'lcfg-foo-1.2.3'.
154              
155             This attribute controls the parent directory into which that generated
156             directory will be placed. The default on a Unix system is
157             C<$HOME/lcfgbuild/> which will be created if it does not already
158             exist.
159              
160             =item gencmake
161              
162             This is a boolean value which controls whether CMake build files will
163             be created when the source code for the project is packaged. The
164             default is to take the setting from C<gencmake> option in the
165             C<buildinfo> section of the LCFG build metadata file.
166              
167             =item translate
168              
169             This is a boolean value which controls whether source files will be
170             translated BEFORE they are packaged. The default is to take the
171             setting from C<translate_before_pack> option in the C<buildinfo>
172             section of the LCFG build metadata file.
173              
174             =item remove_after_translate
175              
176             This is a boolean value which controls whether input files will be
177             removed after they have been translated. They are only removed if the
178             input and output filenames do not match (e.g. foo.cin becomes
179             foo). The default is to take the setting from
180             C<remove_input_after_translate> option in the C<buildinfo> section of
181             the LCFG build metadata file.
182              
183             =item nopayload
184              
185             This is a boolean value which controls whether the Mac OS X package
186             contains a payload, or only scripts to be executed as part of the
187             install action. The default is to take the setting from the
188             C<nopayload> option in the C<buildinfo> section of the LCFG build
189             metadata file.
190              
191             =back
192              
193             The following methods are not modifiable by the command-line, they are
194             however directly modifiable via the Tool object if
195             necessary. Typically you will only need to query these attributes,
196             they are automatically created when you need them using values for
197             some of the other command-line attributes.
198              
199             =over 4
200              
201             =item spec
202              
203             This is a reference to the current project metadata object, see
204             L<LCFG::Build::PkgSpec> for full details.
205              
206             =item vcs
207              
208             This is a reference to the current version-control object, see
209             L<LCFG::Build::VCS> for full details.
210              
211             =back
212              
213             =head1 SUBROUTINES/METHODS
214              
215             =over 4
216              
217             =item execute
218              
219             This method first calls the execute() method in L<LCFG::Build::Tool::Pack>
220             to generate a gzipped source tar file and the build metadata files for
221             the various supported platforms (e.g. a specfile for creating binary
222             RPMs). Once that is done the binary packages for MacOSX are created
223             from the source tar file using PackageMaker.
224              
225             =item fail($message)
226              
227             Immediately fails (i.e. dies) and displays the message.
228              
229             =item log($message)
230              
231             Logs the message to the screen if the C<quiet> attribute has not been
232             specified. A message string is prefixed with 'LCFG: ' to help visually
233             separate it from other output.
234              
235             =back
236              
237             =head1 DEPENDENCIES
238              
239             This module is L<Moose> powered and uses L<MooseX::App::Cmd> to handle
240             command-line options.
241              
242             The following modules from the LCFG build tools suite are also
243             required: L<LCFG::Build::Tool::Pack>, L<LCFG::Build::PkgSpec>,
244             L<LCFG::Build::VCS> and VCS helper module for your preferred
245             version-control system.
246              
247             For building packages you will also need
248             L<LCFG::Build::Utils::OSXPkg>.
249              
250             =head1 SEE ALSO
251              
252             L<LCFG::Build::Tools>, L<LCFG::Build::Skeleton>, lcfg-reltool(1), pkgbuild(1)
253              
254             =head1 PLATFORMS
255              
256             This is the list of platforms on which we have tested this
257             software. We expect this software to work on any Unix-like platform
258             which is supported by Perl.
259              
260             Mac OS X 10.7
261              
262             =head1 BUGS AND LIMITATIONS
263              
264             There are no known bugs in this application. Please report any
265             problems to bugs@lcfg.org, feedback and patches are also always very
266             welcome.
267              
268             =head1 AUTHOR
269              
270             Kenneth MacDonald <Kenneth.MacDonald@ed.ac.uk>
271             Stephen Quinney <squinney@inf.ed.ac.uk>
272              
273             =head1 LICENSE AND COPYRIGHT
274              
275             Copyright (C) 2008-2012 University of Edinburgh. All rights reserved.
276              
277             This library is free software; you can redistribute it and/or modify
278             it under the terms of the GPL, version 2 or later.
279              
280             =cut