| 1 | package Module::Starter::Plugin::DebPackage; | ||
| 2 | |||
| 3 | 3 | ▶ | use base 'Module::Starter::Simple'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 3 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 3 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | 3 | ▶ | use version; our $VERSION = qv('0.0.5'); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 3 | ▶ | use File::Path qw(); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | 3 | ▶ | use File::Spec qw(); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | 3 | ▶ | use POSIX qw(strftime); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | |||
| 14 | # Overloaded to create a step after create_modules | ||
| 15 | 0 | ▶ | sub create_modules { |
|
Subroutine
create_modules: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 16 | 0 | my ($self, @modules) = @_; | |
| 17 | |||
| 18 | 0 | $self->progress( "Calling SUPER::create_modules" ); | |
| 19 | 0 | my @files = $self->SUPER::create_modules(@modules); | |
| 20 | |||
| 21 | 0 | $self->progress( "Calling extra step: create_debian_conf" ); | |
| 22 | 0 | push @files, $self->create_debian_conf(); | |
| 23 | |||
| 24 | 0 | return @files; | |
| 25 | } | ||
| 26 | |||
| 27 | 0 | ▶ | sub create_debian_conf { |
|
Subroutine
create_debian_conf: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 28 | 0 | my ($self) = @_; | |
| 29 | |||
| 30 | 0 | my @files = (); | |
| 31 | |||
| 32 | # Define attributes used for deb conf files | ||
| 33 | $self->{deb_pkg_name} = 'lib' | ||
| 34 | . lc( $self->{main_module} ) | ||
| 35 | 0 | . '-perl'; | |
| 36 | 0 | $self->{deb_pkg_name} =~ s/::/-/g; | |
| 37 | |||
| 38 | 0 | my @datestamp = localtime(); | |
| 39 | 0 | $self->{deb_datestamp} = strftime( '%a, %d %b %Y %H:%M:%S %z', @datestamp ); | |
| 40 | 0 | $self->{deb_year} = strftime( '%Y', @datestamp ); | |
| 41 | |||
| 42 | # Create the debian directory | ||
| 43 | 0 | my $deb_dir = File::Spec->catdir( $self->{basedir}, 'debian' ); | |
| 44 | 0 | File::Path::mkpath( $deb_dir ); | |
| 45 | |||
| 46 | # Create the compat file | ||
| 47 | 0 | my $compat_file = File::Spec->catfile( $deb_dir, 'compat' ); | |
| 48 | 0 | $self->create_file( $compat_file, $self->deb_compat_guts() ); | |
| 49 | 0 | $self->progress("Created ${compat_file}"); | |
| 50 | 0 | push @files, $compat_file; | |
| 51 | |||
| 52 | # Create the control file | ||
| 53 | 0 | my $control_file = File::Spec->catfile( $deb_dir, 'control' ); | |
| 54 | 0 | $self->create_file( $control_file, $self->deb_control_guts() ); | |
| 55 | 0 | $self->progress("Created ${control_file}"); | |
| 56 | 0 | push @files, $control_file; | |
| 57 | |||
| 58 | # Create the changelog file | ||
| 59 | 0 | my $changelog_file = File::Spec->catfile( $deb_dir, 'changelog' ); | |
| 60 | 0 | $self->create_file( $changelog_file, $self->deb_changelog_guts() ); | |
| 61 | 0 | $self->progress("Created ${changelog_file}"); | |
| 62 | 0 | push @files, $changelog_file; | |
| 63 | |||
| 64 | # Create the copyright file | ||
| 65 | 0 | my $copyright_file = File::Spec->catfile( $deb_dir, 'copyright' ); | |
| 66 | 0 | $self->create_file( $copyright_file, $self->deb_copyright_guts() ); | |
| 67 | 0 | $self->progress("Created ${copyright_file}"); | |
| 68 | 0 | push @files, $copyright_file; | |
| 69 | |||
| 70 | # Create the conffiles file | ||
| 71 | 0 | my $conffiles_file = File::Spec->catfile( $deb_dir, 'conffiles' ); | |
| 72 | 0 | $self->create_file( $conffiles_file, $self->deb_conffiles_guts() ); | |
| 73 | 0 | $self->progress("Created ${conffiles_file}"); | |
| 74 | 0 | push @files, $conffiles_file; | |
| 75 | |||
| 76 | # Create the rules file | ||
| 77 | 0 | my $rules_file = File::Spec->catfile( $deb_dir, 'rules' ); | |
| 78 | 0 | $self->create_file( $rules_file, $self->deb_rules_guts() ); | |
| 79 | 0 | chmod 0755, $rules_file; | |
| 80 | 0 | $self->progress("Created ${rules_file}"); | |
| 81 | 0 | push @files, $rules_file; | |
| 82 | |||
| 83 | 0 | return @files; | |
| 84 | } | ||
| 85 | |||
| 86 | 0 | ▶ | sub deb_compat_guts { |
|
Subroutine
deb_compat_guts: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 87 | 0 | my ($self) = @_; | |
| 88 | |||
| 89 | 0 | return <<"END_COMPAT_GUTS"; | |
| 90 | 6 | ||
| 91 | END_COMPAT_GUTS | ||
| 92 | } | ||
| 93 | |||
| 94 | 0 | ▶ | sub deb_control_guts { |
|
Subroutine
deb_control_guts: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 95 | 0 | my ($self) = @_; | |
| 96 | |||
| 97 | 0 | 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 | 0 | ▶ | sub deb_changelog_guts { |
|
Subroutine
deb_changelog_guts: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 119 | 0 | my ($self) = @_; | |
| 120 | |||
| 121 | 0 | 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 | 0 | ▶ | sub deb_copyright_guts { |
|
Subroutine
deb_copyright_guts: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 131 | 0 | my ($self) = @_; | |
| 132 | |||
| 133 | 0 | 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 | 0 | ▶ | sub deb_conffiles_guts { |
|
Subroutine
deb_conffiles_guts: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 156 | 0 | my ($self) = @_; | |
| 157 | |||
| 158 | # An empty file | ||
| 159 | 0 | return ''; | |
| 160 | } | ||
| 161 | |||
| 162 | 0 | ▶ | sub deb_rules_guts { |
|
Subroutine
deb_rules_guts: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 163 | 0 | my ($self) = @_; | |
| 164 | |||
| 165 | 0 | 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 <marc@dch-faq.de> 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<Module::Starter> 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<make deb>. | ||
| 273 | |||
| 274 | =head1 METHODS | ||
| 275 | |||
| 276 | =head2 create_modules | ||
| 277 | |||
| 278 | This method first executes C<SUPER::create_modules> and then creates | ||
| 279 | the debian config files by running C<create_debian_conf>. | ||
| 280 | |||
| 281 | =head2 create_debian_conf | ||
| 282 | |||
| 283 | Creates the debian config files. | ||
| 284 | |||
| 285 | This method is creates, populates (using the C<deb_*_guts> 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<Module::Starter::Simple>. | ||
| 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<< <bjdean at bjdean.id.au> >> | ||
| 323 | |||
| 324 | =head1 BUGS | ||
| 325 | |||
| 326 | Please report any bugs or feature requests to C<bug-module-starter-plugin-debpackage at rt.cpan.org>, or through | ||
| 327 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Module-Starter-Plugin-DebPackage>. 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<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Module-Starter-Plugin-DebPackage> | ||
| 343 | |||
| 344 | =item * AnnoCPAN: Annotated CPAN documentation | ||
| 345 | |||
| 346 | L<http://annocpan.org/dist/Module-Starter-Plugin-DebPackage> | ||
| 347 | |||
| 348 | =item * CPAN Ratings | ||
| 349 | |||
| 350 | L<http://cpanratings.perl.org/d/Module-Starter-Plugin-DebPackage> | ||
| 351 | |||
| 352 | =item * Search CPAN | ||
| 353 | |||
| 354 | L<http://search.cpan.org/dist/Module-Starter-Plugin-DebPackage/> | ||
| 355 | |||
| 356 | =back | ||
| 357 | |||
| 358 | =head1 ACKNOWLEDGEMENTS | ||
| 359 | |||
| 360 | Thanks to Andy Lester, Ricardo Signes and C.J. Adams-Collier for | ||
| 361 | writing L<Module::Starter>. | ||
| 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 | 3 | 1; # End of Module::Starter::Plugin::DebPackage | |