/usr/share/perl5/DhMakePerl/Config.pm is in dh-make-perl 0.75-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | package DhMakePerl::Config;
use strict;
use warnings;
=head1 NAME
DhMakePerl::Config - dh-make-perl configuration class
=cut
use base 'Class::Accessor';
use Dpkg::Source::Package;
use constant options => (
'apt-contents-dir=s',
'arch=s', 'backups!',
'basepkgs=s',
'bdepends=s', 'bdependsi=s',
'build!', 'closes=i',
'config-file=s', 'core-ok',
'cpan-mirror=s', 'cpan=s',
'cpanplus=s', 'data-dir=s',
'dbflags=s', 'depends=s',
'desc=s', 'dh=i',
'dist=s', 'email|e=s',
'exclude|i:s{,}',
'home-dir=s', 'install!',
'intrusive!',
'network!',
'nometa', 'notest',
'only|o=s@',
'packagename|p=s', 'pkg-perl!',
'recursive!',
'requiredeps', 'sources-list=s',
'source-format=s', 'vcs=s',
'verbose!', 'version=s',
);
use constant commands =>
( 'make', 'refresh|R', 'refresh-cache', 'dump-config', 'locate', 'help' );
__PACKAGE__->mk_accessors(
do {
my @opts = ( __PACKAGE__->options, __PACKAGE__->commands );
for (@opts) {
s/[=:!|].*//;
s/-/_/g;
}
@opts;
},
'command',
'cpan2deb',
'_explicitly_set',
);
use File::Basename qw(basename);
use File::Spec::Functions qw(catfile);
use Getopt::Long;
use Tie::IxHash ();
use YAML ();
use constant DEFAULTS => {
backups => 1,
data_dir => '/usr/share/dh-make-perl',
dbflags => ( $> == 0 ? "" : "-rfakeroot" ),
dh => 8,
dist => '',
email => '',
exclude => qr/$Dpkg::Source::Package::diff_ignore_default_regexp/,
home_dir => "$ENV{HOME}/.dh-make-perl",
network => 1,
only => [ 'control', 'copyright', 'docs', 'examples', 'rules' ],
source_format => '3.0 (quilt)',
vcs => 'git',
verbose => 1,
};
use constant cpan2deb_DEFAULTS => {
build => 1,
#recursive => 1,
};
sub new {
my $class = shift;
my $values = shift || {};
my $cpan2deb = basename($0) eq 'cpan2deb';
my $self = $class->SUPER::new(
{ %{ $class->DEFAULTS },
( $cpan2deb
? %{ $class->cpan2deb_DEFAULTS }
: ()
),
cpan2deb => $cpan2deb,
%$values,
},
);
$self->_explicitly_set( {} ) unless $self->_explicitly_set;
return $self;
}
=head1 METHODS
=over
=item parse_command_line_options()
Parses command line options and populates object members.
=cut
sub parse_command_line_options {
my $self = shift;
# first get 'regular' options. commands are parsed in another
# run below.
Getopt::Long::Configure( qw( pass_through no_auto_abbrev no_ignore_case ) );
my %opts;
GetOptions( \%opts, $self->options, )
or die "Error parsing command-line options\n";
# Make CPAN happy, make the user happy: Be more tolerant!
# Accept names to be specified with double-colon, dash or slash
$opts{cpan} =~ s![/-]!::!g if $opts{cpan};
# "If no argument is given (but the switch is specified - not specifying
# the switch will include everything), it defaults to dpkg-source's
# default values."
$opts{exclude} = '^$' if ! defined $opts{exclude}; # switch not specified
# take everything
$opts{exclude} = $self->DEFAULTS->{'exclude'} if ! $opts{exclude}; # arguments not specified
# back to defaults
# handle comma-separated multiple values in --only
$opts{only} = [ split( /,/, join( ',', @{ $opts{only} } ) ) ]
if exists $opts{only};
while ( my ( $k, $v ) = each %opts ) {
my $field = $k;
$field =~ s/-/_/g;
$self->$field( $opts{$k} );
$self->_explicitly_set->{$k} = 1;
}
# see what are we told to do
%opts = ();
Getopt::Long::Configure('no_pass_through');
GetOptions( \%opts, $self->commands )
or die "Error parsing command-line options\n";
if (%opts) {
my $cmd = ( keys %opts )[0];
warn "WARNING: double dashes in front of sub-commands are deprecated\n";
warn "WARNING: for instance, use '$cmd' instead of '--$cmd'\n";
}
else {
my %cmds;
for( $self->commands ) {
my $c = $_;
$c =~ s/\|.+//; # strip short alternatives
$cmds{$c} = 1;
}
# treat the first non-option as command
# if it looks like one
$opts{ shift(@ARGV) } = 1
if $ARGV[0]
and $cmds{ $ARGV[0] };
# by default, create source package
$opts{make} = 1 unless %opts;
}
if ( scalar( keys %opts ) > 1 ) {
die "Only one of " .
map( $_, $self->commands ) . " can be specified\n";
}
$self->command( ( keys %opts )[0] );
$self->verbose(1)
if $self->command eq 'make'
and not $self->_explicitly_set->{verbose};
if ($self->cpan2deb) {
@ARGV == 1 or die "cpan2deb requires exactly one non-option argument";
$self->cpan( shift @ARGV );
$self->build(1);
$self->command('make');
}
$self->check_obsolete_entries;
}
=item parse_config_file()
Parse configuration file. I<config_file> member is used for location the file,
if not set, F<dh-make-perl.conf> file in I<home_dir> is used.
=cut
sub parse_config_file {
my $self = shift;
my $fn = $self->config_file
|| catfile( $self->home_dir, 'dh-make-perl.conf' );
if ( -e $fn ) {
local $@;
my $yaml = eval { YAML::LoadFile($fn) };
die "Error parsing $fn: $@" if $@;
die
"Error parsing $fn: config-file is not allowed in the configuration file"
if $yaml->{'config-file'};
for ( $self->options ) {
( my $key = $_ ) =~ s/[!=|].*//;
next unless exists $yaml->{$key};
my $value = delete $yaml->{$key};
next
if $self->_explicitly_set
->{$key}; # cmd-line opts take precedence
( my $opt = $key ) =~ s/-/_/g;
$self->$opt($value);
}
die "Error parsing $fn: the following keys are not known:\n"
. join( "\n", map( " - $_", keys %$yaml ) )
if %$yaml;
$self->check_obsolete_entries;
}
}
=item dump_config()
Returns a string representation of all configuration options. Suitable for
populating configuration file.
=cut
sub dump_config {
my $self = shift;
my %hash;
tie %hash, 'Tie::IxHash';
for my $opt ( $self->options ) {
$opt =~ s/[=!|].*//;
( my $field = $opt ) =~ s/-/_/g;
$hash{$opt} = $self->$field;
}
local $YAML::UseVersion = 1;
local $YAML::Stringify = 1;
return YAML::Dump( \%hash );
}
=item check_obsolete_entries
Checks for presense of deprecated/obsolete entries and warns/dies if any is
found.
=cut
sub check_obsolete_entries {
my ($self) = @_;
warn "--notest ignored. if you don't want to run the tests when building the package, add 'nocheck' to DEB_BUILD_OPTIONS\n"
if $self->notest;
if ( $self->dh < 7 ) {
warn "debhelper compatibility levels before 7 are not supported.\n";
exit(1);
}
}
=back
=head1 COPYRIGHT & LICENSE
=over
=item Copyright (C) 2008-2010 Damyan Ivanov <dmn@debian.org>
=item Copyright (C) 2009-2010 Gregor Herrmann <gregoa@debian.org>
=item Copyright (C) 2009 Ryan Niebur <RyanRyan52@gmail.com>
=back
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License version 2 as published by the Free
Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
Street, Fifth Floor, Boston, MA 02110-1301 USA.
=cut
1;
|