blib/lib/CPANPLUS/Dist/Deb/Constants.pm untested

filter: Statementstmt 0.0% 0 / 310 Branchbran 0.0% 0 / 48 Conditioncond 0.0% 0 / 70 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 60 Podpod n/a totaltotal 0.0% 0 / 488 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package CPANPLUS::Dist::Deb::Constants;
2  
3 use strict;
4 use CPANPLUS::Error;
5 use CPANPLUS::Internals::Constants;
6  
7 use IPC::Cmd qw[can_run];
8 use File::Spec;
9 use Locale::Maketext::Simple Class => 'CPANPLUS', Style => 'gettext';
10  
11 use vars qw[$VERSION @EXPORT];
12  
13 use base 'Exporter';
14 use Package::Constants;
15 $VERSION = '0.01';
16 @EXPORT = Package::Constants->list( __PACKAGE__ );
17  
18 use constant DEB_BASE_DIR => sub { my $conf = shift or return;
19 my $perl = shift || $^X;
20 require CPANPLUS::Internals::Utils;
21 return File::Spec->catdir(
22 $conf->get_conf('base'),
23 CPANPLUS::Internals::Utils
24 ->_perl_version(perl => $perl),
25 $conf->_get_build('distdir'),
26 'debian',
27 );
28 };
29  
30 use constant DEB_DEBIAN_DIR => sub { File::Spec->catfile( @_,
31 'debian' )
32 };
33 use constant DEB_CHANGELOG => sub { File::Spec->catfile( @_,
34 DEB_DEBIAN_DIR->(), 'changelog' )
35 };
36 use constant DEB_COMPAT => sub { File::Spec->catfile( @_,
37 DEB_DEBIAN_DIR->(), 'compat' )
38 };
39 use constant DEB_CONTROL => sub { File::Spec->catfile( @_,
40 DEB_DEBIAN_DIR->(), 'control' )
41 };
42 use constant DEB_RULES => sub { File::Spec->catfile( @_,
43 DEB_DEBIAN_DIR->(), 'rules' )
44 };
45 use constant DEB_COPYRIGHT => sub { File::Spec->catfile( @_,
46 DEB_DEBIAN_DIR->(), 'copyright' )
47 };
48 use constant DEB_README => sub { File::Spec->catfile( @_,
49 DEB_DEBIAN_DIR->(),
50 'README.Debian' )
51 };
52  
53  
54 use constant DEB_README_CONTENTS
55 => qq[
56  
57 Note that this debian package is automatically generated from it's CPAN
58 counterpart. By releasing a package to CPAN we assume the license
59 permits automatic repackaging, but we do not guarantee this is the case!
60 This package still adheres to the license as mentioned in the original
61 package, even if the provided copyright file for this package states a
62 different license.
63  
64 All packages presented here, or created by CPANPLUS::Dist::Deb in
65 general come without warranty or even fitness of use; use at your own
66 risk at your own discretion.
67  
68 If licenses are of major concern to you DO NOT USE THIS PACKAGE but
69 stick to the official debian mirrors instead!
70  
71 ];
72  
73
74 use constant DEB_ARCHITECTURE => sub { my $arch =
75 `dpkg-architecture -qDEB_BUILD_ARCH`;
76 chomp $arch; return $arch;
77 };
78  
79 use constant DEB_DH_PERL_OPTS => sub { use Config;
80 return join " ", $Config{sitelib},
81 $Config{sitearch};
82 };
83  
84 use constant DEB_SITEBIN_DIR => sub { use Config;
85 return $Config{installsitebin};
86 };
87  
88 use constant DEB_INSTALL_SITEBIN
89 => sub { my $loc = shift or return;
90 return $loc eq 'site'
91 ? 'INSTALLSCRIPT=' .
92 DEB_SITEBIN_DIR->()
93 : '';
94 };
95  
96 use constant DEB_MAKEMAKERFLAGS => sub { my $pre = shift;
97 my $loc = $pre ? 'site' : 'vendor';
98 return "INSTALLDIRS=$loc ".
99 DEB_INSTALL_SITEBIN->($loc);
100 };
101  
102 use constant DEB_BUILDFLAGS => sub { my $pre = shift;
103 my $loc = $pre ? 'site' : 'vendor';
104 return "installdirs=$loc ";
105 };
106  
107  
108 use constant DEB_DISTDIR_PREFIX => sub { my $pre = shift || '';
109 my $dir = $pre . 'lib';
110 return $dir;
111 };
112  
113 use constant DEB_DISTDIR => sub { my $dist = shift or return;
114 my $pre = shift || '';
115 my ($l) =
116 $dist->parent->module =~ /^(.)/;
117
118 return File::Spec->catdir(
119 qw[main pool],
120 DEB_DISTDIR_PREFIX->($pre),
121 lc($l),
122 $dist->status->package_name
123 );
124 };
125  
126  
127 use constant DEB_BIN_BUILDPACKAGE
128 => sub {my $p = can_run('dpkg-buildpackage');
129 unless( $p ) {
130 error(loc(
131 "Could not find '%1' in your ".
132 "path --unable to genearte ".
133 "debian archives",
134 'dpkg-buildpackage' ));
135 return;
136 }
137 return $p;
138 };
139  
140 ### leave out all .a and .so files
141 ### all properly shell escaped ;(
142 use constant DEB_DPKG_SOURCE_IGNORE
143 #=> '-i\(\?i:.\*.\(\?:so\|a\$\)\)';
144 => '-i.s?[oa]';
145  
146 use constant DEB_PACKAGE_NAME => sub {my $mod = shift or return;
147 my $pre = shift || '';
148 my $pkg = lc $mod->package_name;
149
150 ### remove any weird '.|_pm' notations
151 ### in the pkg name
152 $pkg =~ s/(\.|_)pm//gi;
153
154 my $deb = $pre . 'lib' .
155 $pkg . '-perl';
156
157 $deb =~ s/_/-/g; # no _ allowed!
158
159 ### strip double leading 'lib'
160 $deb =~ s/^(${pre}lib)lib/$1/;
161
162 ### strip trailing '-perl-perl' unless
163 ### module name actually ends
164 ### in 'perl'
165 $deb =~ s/-perl-perl$/-perl/
166 unless $mod->module =~ /perl$/i;
167
168 return $deb;
169 };
170
171 use constant DEB_ORIG_PACKAGE_NAME
172 => sub { my $mod = $_[0] or return;
173 DEB_PACKAGE_NAME->( @_ ) . '_' .
174 $mod->package_version . '.orig.' .
175 $mod->package_extension;
176 };
177  
178
179 use constant DEB_VERSION => sub {my $mod = shift or return;
180 my $ver = shift || 1;
181 return $mod->package_version .
182 '-' . $ver;
183 };
184 use constant DEB_RULES_ARCH => sub { return shift() ? 'any' : 'all'; };
185 use constant DEB_DEB_FILE_NAME => sub {my $mod = shift() or return;
186 my $dir = shift() or return;
187 my $pre = shift() || '';
188 my $xs = shift() ? 1 : 0;
189 my $arch = $xs
190 ? DEB_ARCHITECTURE->()
191 : DEB_RULES_ARCH->();
192  
193 my $name = join '_',
194 DEB_PACKAGE_NAME->($mod, $pre),
195 DEB_VERSION->($mod),
196 $arch .'.deb';
197 return File::Spec->catfile(
198 $dir, $name
199 );
200 };
201  
202 use constant DEB_METAFILE_PROGRAM => sub { can_run('apt-ftparchive') };
203 use constant DEB_METAFILE_SOURCES => 'sources';
204 use constant DEB_METAFILE_SOURCES_FILE => 'Sources.gz';
205 use constant DEB_METAFILE_PACKAGES => 'packages';
206 use constant DEB_METAFILE_PACKAGES_FILE => 'Packages.gz';
207 use constant DEB_DEFAULT_RELEASE => 'unstable';
208  
209 use constant DEB_OUTPUT_METAFILE
210 => sub { my $type = shift or return;
211 my $path = shift or return;
212 my $rel = shift ||
213 DEB_DEFAULT_RELEASE;
214  
215 ### sources.gz file
216 if( $type eq DEB_METAFILE_SOURCES ) {
217 return File::Spec->catfile(
218 $path, 'dists', $rel,
219 'main', 'source',
220 DEB_METAFILE_SOURCES_FILE
221 );
222
223 ### packages.gz file
224 } elsif( $type eq
225 DEB_METAFILE_PACKAGES
226 ) {
227 return File::Spec->catfile(
228 $path, 'dists', $rel, 'main',
229 'binary-'.DEB_ARCHITECTURE->(),
230 DEB_METAFILE_PACKAGES_FILE
231 );
232
233 ### dont know what you wanted
234 } else {
235 return;
236 }
237 };
238
239
240
241 use constant DEB_LICENSE_GPL => '/usr/share/common-licenses/GPL';
242 use constant DEB_LICENSE_ARTISTIC
243 => '/usr/share/common-licenses/Artistic';
244  
245 use constant DEB_URGENCY => 'urgency=low';
246 use constant DEB_DEBHELPER => 'debhelper (>= 4.0.2)';
247  
248 ### since this will be installed in a versioned dir, we depend on at least
249 ### this version of perl (all older perls paths will be included automatically
250 ### by perl, unless you explicilty undefined 'inc_version_list' as a config
251 ### argument
252 use constant DEB_THIS_PERL_DEPENDS
253 => sub { use Config;
254 "perl (>= $Config{version})" };
255 use constant DEB_PERL_DEPENDS => '${perl:Depends}, ${misc:Depends}, ' .
256 DEB_THIS_PERL_DEPENDS->();
257  
258
259 use constant DEB_STANDARDS_VERSION
260 => '3.6.1';
261  
262 use constant DEB_STANDARD_COPYRIGHT_PERL =>
263 "This library is free software; you can redistribute it and/or modify\n" .
264 "it under the same terms as Perl itself (GPL or Artistic license).\n\n" .
265 "On Debian systems the complete text of the GPL and Artistic\n" .
266 "licenses can be found at:\n\t" .
267 DEB_LICENSE_GPL . "\n\t" . DEB_LICENSE_ARTISTIC;
268  
269 use constant DEB_REPLACE_PERL_CORE
270 =>"perl-modules, perl-base, perl";
271  
272  
273 use constant DEB_FIND_DOCS => sub { my $dir = shift or return;
274
275 my $dh;
276 unless( opendir $dh, $dir ) {
277 error(loc("Could not open dir %1",
278 $dir));
279 return;
280 }
281
282 my @docs = grep /README|TODO|BUGS|
283 NEWS|ANNOUNCE/ix,
284 readdir $dh;
285
286 ### return relative path!
287 return @docs;
288 };
289  
290 use constant DEB_FIND_CHANGELOG => sub { my $dir = shift or return;
291
292 my $dh;
293 unless( opendir $dh, $dir ) {
294 error(loc("Could not open dir %1",
295 $dir));
296 return;
297 }
298
299 my ($log) = grep /^change(s|log)$/i,
300 readdir $dh;
301
302 ### return relative path!
303 return $log;
304 };
305  
306 use constant DEB_GET_RULES_CONTENT =>
307 sub {my $self = shift;
308 my $pre = shift || '';
309 my $has_xs = shift || 0;
310 my $verbose = shift || 0;
311 my $dist = $self->status->dist;
312 my $distdir = $dist->status->distdir;
313 my $inst =
314 $self->status->installer_type;
315  
316 my $sub = $inst eq INSTALLER_BUILD
317 ? $has_xs
318 ? 'DEB_RULES_BUILD_XS_CONTENT'
319 : 'DEB_RULES_BUILD_NOXS_CONTENT'
320 : $has_xs
321 ? 'DEB_RULES_MM_XS_CONTENT'
322 : 'DEB_RULES_MM_NOXS_CONTENT';
323  
324 msg(loc("Using rule set '%1'", $sub),
325 $verbose);
326
327 my $docs = join ' ', DEB_FIND_DOCS->(
328 $distdir );
329 my $log = DEB_FIND_CHANGELOG->(
330 $distdir );
331  
332 my $loc = $pre ? 'site' : 'vendor';
333 ### returns a coderef to a coderef
334 my $code = __PACKAGE__->can($sub);
335 return $code->()->($self, $loc,
336 $docs, $log );
337 };
338  
339  
340 use constant DEB_RULES_MM_NOXS_CONTENT =>
341 sub {
342 my $self = shift;
343 my $loc = shift or return;
344 my $docs = shift || '';
345 my $changes = shift || '';
346 my $dh_opts = DEB_DH_PERL_OPTS->();
347
348 my $inst_docs = "\t-dh_installdocs" .
349 ($docs ? " $docs" : '');
350 my $inst_changes = "\t-dh_installchangelogs" .
351 ($changes ? " $changes" : '');
352
353 ### EU::MM doesn't have an 'installsitescript'
354 ### directive.. it just tosses everything in
355 ### 'installscript' which is /usr/bin/ which
356 ### is WRONG. M::B actually does the right
357 ### thing here....
358 my $bindir = DEB_INSTALL_SITEBIN->($loc);
359
360 return q[#!/usr/bin/make -f
361 # Uncomment this to turn on verbose mode.
362 #export DH_VERBOSE=1
363  
364 # If set to a true value then MakeMaker's prompt function will
365 # always return the default without waiting for user input.
366 export PERL_MM_USE_DEFAULT=1
367  
368 PACKAGE=$(shell dh_listpackages)
369  
370 ifndef PERL
371 PERL = /usr/bin/perl
372 endif
373  
374 TMP =$(CURDIR)/debian/tmp
375  
376  
377 build: build-stamp
378 build-stamp:
379 dh_testdir
380  
381 touch build-stamp
382  
383 clean:
384 dh_testdir
385 dh_testroot
386  
387 dh_clean -d
388 rm -f build-stamp install-stamp
389  
390 install: install-stamp
391 install-stamp: build-stamp
392 dh_testdir
393 dh_testroot
394 dh_clean -d -k
395  
396 $(MAKE) install DESTDIR=$(TMP) PREFIX=/usr
397 @find . -type f | grep '/perllocal.pod$$' | xargs rm -f
398  
399 dh_movefiles /usr
400  
401 touch install-stamp
402  
403 binary-arch:
404 # We have nothing to do by default.
405  
406 binary-indep: build install
407 dh_testdir
408 dh_testroot
409  
410 ] . qq[
411  
412 ### doc/changelog install lines
413 $inst_docs
414 $inst_changes
415  
416 ]. q[
417  
418 dh_perl ] . $dh_opts . q[
419 dh_link
420 dh_compress
421 dh_fixperms
422 dh_installdeb
423 dh_gencontrol
424 dh_md5sums
425 dh_builddeb
426  
427 source diff:
428 @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
429  
430 binary: binary-indep binary-arch
431 .PHONY: build clean binary-indep binary-arch binary
432  
433 ];
434 };
435  
436 use constant DEB_RULES_MM_XS_CONTENT
437 => sub {
438 my $self = shift;
439 my $loc = shift or return;
440 my $docs = shift || '';
441 my $changes = shift || '';
442 my $dh_opts = DEB_DH_PERL_OPTS->();
443
444 my $inst_docs = "\t-dh_installdocs" .
445 ($docs ? " $docs" : '');
446 my $inst_changes = "\t-dh_installchangelogs" .
447 ($changes ? " $changes" : '');
448  
449
450 ### EU::MM doesn't have an 'installsitescript'
451 ### directive.. it just tosses everything in
452 ### 'installscript' which is /usr/bin/ which
453 ### is WRONG. M::B actually does the right
454 ### thing here....
455 my $bindir = DEB_INSTALL_SITEBIN->($loc);
456
457 return q[#!/usr/bin/make -f
458 # Uncomment this to turn on verbose mode.
459 #export DH_VERBOSE=1
460  
461 # If set to a true value then MakeMaker's prompt function will
462 # always return the default without waiting for user input.
463 export PERL_MM_USE_DEFAULT=1
464  
465 PACKAGE=$(shell dh_listpackages)
466  
467 ifndef PERL
468 PERL = /usr/bin/perl
469 endif
470  
471 TMP =$(CURDIR)/debian/tmp
472  
473 build: build-stamp
474 build-stamp:
475 dh_testdir
476  
477 touch build-stamp
478  
479 clean:
480 dh_testdir
481 dh_testroot
482  
483 dh_clean -d
484 rm -f build-stamp install-stamp
485  
486 install: install-stamp
487 install-stamp:
488 dh_testdir
489 dh_testroot
490 dh_clean -d -k
491  
492 $(MAKE) install DESTDIR=$(TMP) PREFIX=/usr
493 -find . -type f | grep '/perllocal.pod$$' | xargs rm -f
494
495 dh_movefiles /usr
496  
497 touch install-stamp
498  
499 # Build architecture-independent files here.
500 binary-indep: build install
501 # We have nothing to do by default.
502  
503 # Build architecture-dependent files here.
504 binary-arch: build install
505 dh_testdir
506 dh_testroot
507  
508 ] . qq[
509  
510 ### doc/changelog install lines
511 $inst_docs
512 $inst_changes
513  
514 ]. q[
515  
516 dh_installexamples
517 dh_link
518 dh_compress
519 dh_fixperms
520 dh_makeshlibs
521 dh_installdeb
522 dh_perl ] . $dh_opts . q[
523 dh_shlibdeps
524 dh_gencontrol
525 dh_md5sums
526 dh_builddeb
527  
528 source diff:
529 @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
530  
531 binary: binary-indep binary-arch
532 .PHONY: build clean binary-indep binary-arch binary
533  
534 ];
535 };
536  
537 use constant DEB_RULES_BUILD_NOXS_CONTENT => sub {
538 my $self = shift;
539 my $loc = shift or return;
540 my $docs = shift || '';
541 my $changes = shift || '';
542 my $dh_opts = DEB_DH_PERL_OPTS->();
543
544 my $inst_docs = "\t-dh_installdocs" .
545 ($docs ? " $docs" : '');
546 my $inst_changes = "\t-dh_installchangelogs" .
547 ($changes ? " $changes" : '');
548  
549 return q[#!/usr/bin/make -f
550 # Uncomment this to turn on verbose mode.
551 #export DH_VERBOSE=1
552  
553 # If set to a true value then MakeMaker's prompt function will
554 # always return the default without waiting for user input.
555 export PERL_MM_USE_DEFAULT=1
556  
557 PACKAGE=$(shell dh_listpackages)
558  
559 ifndef PERL
560 PERL = /usr/bin/perl
561 endif
562  
563 BUILD = ./Build
564 TMP =$(CURDIR)/debian/tmp
565  
566  
567 build: build-stamp
568 build-stamp:
569 dh_testdir
570  
571 touch build-stamp
572  
573 clean:
574 dh_testdir
575 dh_testroot
576  
577 dh_clean -d
578 rm -f build-stamp install-stamp
579  
580 install: install-stamp
581 install-stamp: build-stamp
582 dh_testdir
583 dh_testroot
584 dh_clean -d -k
585  
586 $(PERL) $(BUILD) install destdir=$(TMP)
587 -find . -type f | grep '/perllocal.pod$$' | xargs rm -f
588
589 dh_movefiles /usr
590  
591 touch install-stamp
592  
593 binary-arch:
594 # We have nothing to do by default.
595  
596 binary-indep: build install
597 dh_testdir
598 dh_testroot
599  
600 ] . qq[
601  
602 ### doc/changelog install lines
603 $inst_docs
604 $inst_changes
605  
606 ]. q[
607  
608 dh_perl ] . $dh_opts . q[
609 dh_link
610 dh_compress
611 dh_fixperms
612 dh_installdeb
613 dh_gencontrol
614 dh_md5sums
615 dh_builddeb
616  
617 source diff:
618 @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
619  
620 binary: binary-indep binary-arch
621 .PHONY: build clean binary-indep binary-arch binary
622  
623 ];
624 };
625  
626 use constant DEB_RULES_BUILD_XS_CONTENT => sub {
627 my $self = shift;
628 my $loc = shift or return;
629 my $docs = shift || '';
630 my $changes = shift || '';
631 my $dh_opts = DEB_DH_PERL_OPTS->();
632
633 my $inst_docs = "\t-dh_installdocs" .
634 ($docs ? " $docs" : '');
635 my $inst_changes = "\t-dh_installchangelogs" .
636 ($changes ? " $changes" : '');
637  
638 return q[#!/usr/bin/make -f
639 # Uncomment this to turn on verbose mode.
640 #export DH_VERBOSE=1
641  
642 # If set to a true value then MakeMaker's prompt function will
643 # always return the default without waiting for user input.
644 export PERL_MM_USE_DEFAULT=1
645  
646 PACKAGE=$(shell dh_listpackages)
647  
648 ifndef PERL
649 PERL = /usr/bin/perl
650 endif
651  
652 TMP =$(CURDIR)/debian/tmp
653  
654 BUILD = ./Build
655  
656  
657 build: build-stamp
658 build-stamp:
659 dh_testdir
660  
661 touch build-stamp
662  
663 clean:
664 dh_testdir
665 dh_testroot
666
667 # Delete any .o files explicitly *just* to be safe
668 -find . -name \*.o -print0 | xargs -r0 rm -f
669  
670  
671 dh_clean -d
672 rm -f build-stamp install-stamp
673  
674 install: install-stamp
675 install-stamp:
676 dh_testdir
677 dh_testroot
678 dh_clean -d -k
679  
680 # Add here commands to install the package into debian/tmp.
681 $(PERL) $(BUILD) install destdir=$(TMP)
682 -find . -type f | grep '/perllocal.pod$$' | xargs rm -f
683  
684 dh_movefiles /usr
685  
686 touch install-stamp
687  
688 # Build architecture-independent files here.
689 binary-indep: build install
690 # We have nothing to do by default.
691  
692 # Build architecture-dependent files here.
693 binary-arch: build install
694 dh_testdir
695 dh_testroot
696  
697 ] . qq[
698  
699 ### doc/changelog install lines
700 $inst_docs
701 $inst_changes
702  
703 ]. q[
704 dh_installexamples
705 dh_link
706 dh_compress
707 dh_fixperms
708 dh_makeshlibs
709 dh_installdeb
710 dh_perl ] . $dh_opts . q[
711 dh_shlibdeps
712 dh_gencontrol
713 dh_md5sums
714 dh_builddeb
715  
716 source diff:
717 @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
718  
719 binary: binary-indep binary-arch
720 .PHONY: build clean binary-indep binary-arch binary
721  
722 ];
723 };
724  
725 1;