File Coverage

blib/lib/Module/Starter/Plugin/DebPackage.pm
Criterion Covered Total %
statement 74 74 100.0
branch n/a
condition n/a
subroutine 15 15 100.0
pod 8 8 100.0
total 97 97 100.0


line stmt bran cond sub pod time code
1             package Module::Starter::Plugin::DebPackage;
2              
3 2     2   32834 use base 'Module::Starter::Simple';
  2         5  
  2         2534  
4              
5 2     2   47292 use warnings;
  2         7  
  2         69  
6 2     2   17 use strict;
  2         10  
  2         71  
7              
8 2     2   1840 use version; our $VERSION = qv('0.0.5');
  2         5087  
  2         13  
9              
10 2     2   196 use File::Path qw();
  2         5  
  2         38  
11 2     2   13 use File::Spec qw();
  2         5  
  2         43  
12 2     2   2115 use POSIX qw(strftime);
  2         13888  
  2         13  
13              
14             # Overloaded to create a step after create_modules
15             sub create_modules {
16 1     1 1 3697 my ($self, @modules) = @_;
17              
18 1         5 $self->progress( "Calling SUPER::create_modules" );
19 1         146 my @files = $self->SUPER::create_modules(@modules);
20              
21 1         1725 $self->progress( "Calling extra step: create_debian_conf" );
22 1         134 push @files, $self->create_debian_conf();
23              
24 1         9 return @files;
25             }
26              
27             sub create_debian_conf {
28 1     1 1 3 my ($self) = @_;
29            
30 1         3 my @files = ();
31              
32             # Define attributes used for deb conf files
33 1         6 $self->{deb_pkg_name} = 'lib'
34             . lc( $self->{main_module} )
35             . '-perl';
36 1         6 $self->{deb_pkg_name} =~ s/::/-/g;
37              
38 1         26 my @datestamp = localtime();
39 1         77 $self->{deb_datestamp} = strftime( '%a, %d %b %Y %H:%M:%S %z', @datestamp );
40 1         42 $self->{deb_year} = strftime( '%Y', @datestamp );
41              
42             # Create the debian directory
43 1         11 my $deb_dir = File::Spec->catdir( $self->{basedir}, 'debian' );
44 1         170 File::Path::mkpath( $deb_dir );
45              
46             # Create the compat file
47 1         12 my $compat_file = File::Spec->catfile( $deb_dir, 'compat' );
48 1         10 $self->create_file( $compat_file, $self->deb_compat_guts() );
49 1         202 $self->progress("Created ${compat_file}");
50 1         169 push @files, $compat_file;
51              
52             # Create the control file
53 1         18 my $control_file = File::Spec->catfile( $deb_dir, 'control' );
54 1         11 $self->create_file( $control_file, $self->deb_control_guts() );
55 1         178 $self->progress("Created ${control_file}");
56 1         128 push @files, $control_file;
57              
58             # Create the changelog file
59 1         16 my $changelog_file = File::Spec->catfile( $deb_dir, 'changelog' );
60 1         10 $self->create_file( $changelog_file, $self->deb_changelog_guts() );
61 1         126 $self->progress("Created ${changelog_file}");
62 1         131 push @files, $changelog_file;
63              
64             # Create the copyright file
65 1         25 my $copyright_file = File::Spec->catfile( $deb_dir, 'copyright' );
66 1         15 $self->create_file( $copyright_file, $self->deb_copyright_guts() );
67 1         214 $self->progress("Created ${copyright_file}");
68 1         197 push @files, $copyright_file;
69              
70             # Create the conffiles file
71 1         16 my $conffiles_file = File::Spec->catfile( $deb_dir, 'conffiles' );
72 1         10 $self->create_file( $conffiles_file, $self->deb_conffiles_guts() );
73 1         115 $self->progress("Created ${conffiles_file}");
74 1         143 push @files, $conffiles_file;
75              
76             # Create the rules file
77 1         17 my $rules_file = File::Spec->catfile( $deb_dir, 'rules' );
78 1         10 $self->create_file( $rules_file, $self->deb_rules_guts() );
79 1         303 chmod 0755, $rules_file;
80 1         8 $self->progress("Created ${rules_file}");
81 1         177 push @files, $rules_file;
82              
83 1         7 return @files;
84             }
85              
86             sub deb_compat_guts {
87 1     1 1 4 my ($self) = @_;
88              
89 1         4 return <<"END_COMPAT_GUTS";
90             6
91             END_COMPAT_GUTS
92             }
93              
94             sub deb_control_guts {
95 1     1 1 3 my ($self) = @_;
96              
97 1         10 return <<"END_CONTROL_GUTS";
98             Source: $self->{deb_pkg_name}
99             Section: perl
100             Priority: optional
101             Build-Depends: debhelper (>= 6.0.0)
102             Build-Depends-Indep: perl
103             Maintainer: $self->{author} <$self->{email}>
104             Standards-Version: 3.7.2
105             Homepage: http://search.cpan.org/dist/$self->{distro}
106              
107             Package: $self->{deb_pkg_name}
108             Architecture: all
109             Depends: \${perl:Depends}, \${misc:Depends}
110             Description: One-liner description of module
111             One-liner description of module
112             .
113             Describe the module in detail here
114             .
115             END_CONTROL_GUTS
116             }
117              
118             sub deb_changelog_guts {
119 1     1 1 3 my ($self) = @_;
120              
121 1         10 return <<"END_CHANGELOG_GUTS";
122             $self->{deb_pkg_name} (0.01) unstable; urgency=low
123              
124             * Initial Release.
125              
126             -- $self->{author} <$self->{email}> $self->{deb_datestamp}
127             END_CHANGELOG_GUTS
128             }
129              
130             sub deb_copyright_guts {
131 1     1 1 2 my ($self) = @_;
132              
133 1         105 return <<"END_COPYRIGHT_GUTS";
134             This is the debian package for the $self->{main_module} module.
135             It was created by $self->{author} <$self->{email}> using module-starter
136             with the Module::Starter::Plugin::DebPackage plugin.
137              
138             It was downloaded from http://search.cpan.org/dist/$self->{distro}
139              
140             Copyright (C) $self->{deb_year} $self->{author} <$self->{email}>
141              
142             This program is free software; you can redistribute it and/or modify it
143             under the terms of either: the GNU General Public License as published
144             by the Free Software Foundation; or the Artistic License.
145              
146             See http://dev.perl.org/licenses/ for more information.
147              
148             The author is: $self->{author} <$self->{email}>
149              
150             The Debian packaging is (C) $self->{deb_year}, $self->{author} <$self->{email}> and
151             is licensed under the same terms as the software itself (see above).
152             END_COPYRIGHT_GUTS
153             }
154              
155             sub deb_conffiles_guts {
156 1     1 1 3 my ($self) = @_;
157              
158             # An empty file
159 1         5 return '';
160             }
161              
162             sub deb_rules_guts {
163 1     1 1 3 my ($self) = @_;
164              
165 1         5 return <<'END_RULES_GUTS';
166             #!/usr/bin/make -f
167             # This debian/rules file is provided as a template for normal perl
168             # packages. It was created by Marc Brockschmidt for
169             # the Debian Perl Group (http://pkg-perl.alioth.debian.org/) but may
170             # be used freely wherever it is useful.
171              
172             # Uncomment this to turn on verbose mode.
173             #export DH_VERBOSE=1
174              
175             # If set to a true value then MakeMaker's prompt function will
176             # always return the default without waiting for user input.
177             export PERL_MM_USE_DEFAULT=1
178              
179             PACKAGE=$(shell dh_listpackages)
180              
181             ifndef PERL
182             PERL = /usr/bin/perl
183             endif
184              
185             TMP =$(CURDIR)/debian/$(PACKAGE)
186              
187             build: build-stamp
188             build-stamp:
189             dh_testdir
190              
191             # As this is a architecture independent package, we are not
192             # supposed to install stuff to /usr/lib. MakeMaker creates
193             # the dirs, we prevent this by setting the INSTALLVENDORARCH
194             # and VENDORARCHEXP environment variables.
195              
196             # Add commands to compile the package here
197             $(PERL) Makefile.PL INSTALLDIRS=vendor \
198             INSTALLVENDORARCH=/usr/share/perl5/ \
199             VENDORARCHEXP=/usr/share/perl5/
200             $(MAKE)
201             $(MAKE) test
202              
203             touch $@
204              
205             clean:
206             dh_testdir
207             dh_testroot
208              
209             dh_clean build-stamp install-stamp
210              
211             # Add commands to clean up after the build process here
212             [ ! -f Makefile ] || $(MAKE) realclean
213              
214             install: install-stamp
215             install-stamp: build-stamp
216             dh_testdir
217             dh_testroot
218             dh_clean -k
219              
220             # Add commands to install the package into debian/$PACKAGE_NAME here
221             $(MAKE) install DESTDIR=$(TMP) PREFIX=/usr
222              
223             touch $@
224              
225             binary-arch:
226             # We have nothing to do here for an architecture-independent package
227              
228             binary-indep: build install
229             dh_testdir
230             dh_testroot
231             dh_installexamples
232             dh_installdocs README
233             dh_installchangelogs Changes
234             dh_perl
235             dh_compress
236             dh_fixperms
237             dh_installdeb
238             dh_gencontrol
239             dh_md5sums
240             dh_builddeb
241              
242             source diff:
243             @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
244              
245             binary: binary-indep binary-arch
246             .PHONY: build clean binary-indep binary-arch binary
247             END_RULES_GUTS
248             }
249              
250             =head1 NAME
251              
252             Module::Starter::Plugin::DebPackage - Module::Starter plugin which creates debian package config files
253              
254             =head1 VERSION
255              
256             Version 0.01
257              
258             =head1 SYNOPSIS
259              
260             use Module::Starter qw(
261             Module::Starter::Simple
262             Module::Starter::Plugin::DebPackage
263             );
264              
265             use Module::Starter::App;
266             Module::Starter::App->run;
267              
268             =head1 ABSTRACT
269              
270             This is a plugin for L that includes a set of skeleton
271             debian package configuration files for the new module. Once the Makefile
272             is generated the package can be built using C.
273              
274             =head1 METHODS
275              
276             =head2 create_modules
277              
278             This method first executes C and then creates
279             the debian config files by running C.
280              
281             =head2 create_debian_conf
282              
283             Creates the debian config files.
284              
285             This method is creates, populates (using the C methods) and
286             reports progress for all files created by this plugin.
287              
288             =head2 deb_compat_guts
289              
290             Generate the contents for the compat file.
291              
292             The compat version is important because the default version used by debhelper
293             is 1 which will generate a incomplete deb.
294              
295             =head2 deb_control_guts
296              
297             Generate the contents for the control file.
298              
299             =head2 deb_changelog_guts
300              
301             Generate the contents for the changelog file.
302              
303             =head2 deb_copyright_guts
304              
305             Generate the contents for the copyright file.
306              
307             This is the normal perl license used by L.
308              
309             =head2 deb_conffiles_guts
310              
311             Generate the contents for the conffiles file.
312              
313             This is an empty file - add any configuration files that should not be
314             overwritten during package updates.
315              
316             =head2 deb_rules_guts
317              
318             Generate the contents for the rules file.
319              
320             =head1 AUTHOR
321              
322             Bradley Dean, C<< >>
323              
324             =head1 BUGS
325              
326             Please report any bugs or feature requests to C, or through
327             the web interface at L. I will be notified, and then you'll
328             automatically be notified of progress on your bug as I make changes.
329              
330             =head1 SUPPORT
331              
332             You can find documentation for this module with the perldoc command.
333              
334             perldoc Module::Starter::Plugin::DebPackage
335              
336             You can also look for information at:
337              
338             =over 4
339              
340             =item * RT: CPAN's request tracker
341              
342             L
343              
344             =item * AnnoCPAN: Annotated CPAN documentation
345              
346             L
347              
348             =item * CPAN Ratings
349              
350             L
351              
352             =item * Search CPAN
353              
354             L
355              
356             =back
357              
358             =head1 ACKNOWLEDGEMENTS
359              
360             Thanks to Andy Lester, Ricardo Signes and C.J. Adams-Collier for
361             writing L.
362              
363             =head1 LICENSE AND COPYRIGHT
364              
365             Copyright 2009 Bradley Dean.
366              
367             This program is free software; you can redistribute it and/or modify it
368             under the terms of either: the GNU General Public License as published
369             by the Free Software Foundation; or the Artistic License.
370              
371             See http://dev.perl.org/licenses/ for more information.
372              
373             =cut
374              
375             1; # End of Module::Starter::Plugin::DebPackage