r5693 - in /tools/dh-make-perl/trunk: debian/changelog dh-make-perl
gwolf at users.alioth.debian.org
gwolf at users.alioth.debian.org
Wed Jul 4 01:39:55 UTC 2007
Author: gwolf
Date: Wed Jul 4 01:39:55 2007
New Revision: 5693
URL: http://svn.debian.org/wsvn/?sc=1&rev=5693
Log:
A bit of reorganizing dh-make-perl to make it suck less :)
And a potential, never-so-far-reported bug squished.
Modified:
tools/dh-make-perl/trunk/debian/changelog
tools/dh-make-perl/trunk/dh-make-perl
Modified: tools/dh-make-perl/trunk/debian/changelog
URL: http://svn.debian.org/wsvn/tools/dh-make-perl/trunk/debian/changelog?rev=5693&op=diff
==============================================================================
--- tools/dh-make-perl/trunk/debian/changelog (original)
+++ tools/dh-make-perl/trunk/debian/changelog Wed Jul 4 01:39:55 2007
@@ -1,3 +1,13 @@
+dh-make-perl (0.27) unstable; urgency=low
+
+ * Moved all the options received from the user to %opts, for better
+ code readability
+ * When the module to be packaged declares a dependency on a specific
+ Perl version, reflect it in the output dependency/build dependency
+ information, rather than complaining that no such module exists
+
+ -- Gunnar Wolf <gwolf at debian.org> Tue, 03 Jul 2007 20:38:45 -0500
+
dh-make-perl (0.26) unstable; urgency=low
[ Frank Lichtenheld ]
Modified: tools/dh-make-perl/trunk/dh-make-perl
URL: http://svn.debian.org/wsvn/tools/dh-make-perl/trunk/dh-make-perl?rev=5693&op=diff
==============================================================================
--- tools/dh-make-perl/trunk/dh-make-perl (original)
+++ tools/dh-make-perl/trunk/dh-make-perl Wed Jul 4 01:39:55 2007
@@ -8,6 +8,7 @@
use User::pwent;
use Getopt::Long;
use Cwd;
+use CPAN;
use Module::Depends::Intrusive;
use strict;
@@ -173,47 +174,26 @@
$desc, $longdesc, $copyright, $author);
my ($extrasfields, $extrapfields);
my (@docs, $changelog, @args);
-my ($core_ok, $cpanmodule, $cpanplusmodule, $cpanmirror, $build, $install,
- $dbflags, $excludeRE, $notest, $nometa, $requiredeps, $user_depends,
- $user_bdepends, $user_bdependsi);
+
+my %opts;
my $mod_cpan_version;
-$dbflags = $>==0?"":"-rfakeroot";
+$opts{dbflags} = $>==0?"":"-rfakeroot";
chomp($date);
-GetOptions(
- "core-ok" => \$core_ok,
- "cpan=s" => \$cpanmodule,
-# "cpanplus=s" => \$cpanplusmodule,
- "cpan-mirror=s" => \$cpanmirror,
- "desc=s" => \$desc,
- "arch=s" => \$arch,
- "version=s" => \$pkgversion,
- "help" => sub {die "\n"},
- # disabled: see build_package()
- "dbflags=s" => \$dbflags,
- "exclude|i:s{,}" => \$excludeRE,
- "build!" => \$build,
- "install!" => \$install,
- "notest" => \$notest,
- "nometa" => \$nometa,
- "requiredeps" => \$requiredeps,
- "depends=s" => \$user_depends,
- "bdepends=s" => \$user_bdepends,
- "bdependsi=s" => \$user_bdependsi
- ) || die <<"USAGE";
-Usage:
-$0 [ --build ] [ --install ] [ SOURCE_DIR | --cpan MODULE ]
-Other options: [ --desc DESCRIPTION ] [ --arch all|any ] [ --version VERSION ]
- [ --depends DEPENDS ] [ --bdepends BUILD-DEPENDS ]
- [ --bdependsi BUILD-DEPENDS-INDEP ] [ --cpan-mirror MIRROR ]
- [ --exclude|-i [REGEX] ] [ --notest ] [ --nometa ]
- [ --requiredeps ] [ --core-ok ]
-USAGE
-
-$excludeRE = '(?:\/|^)(?:CVS|.svn)\/' if (defined $excludeRE &&
- $excludeRE eq '');
+GetOptions(\%opts,
+ 'arch=s', 'bdepends=s', 'bdependsi=s', 'build!', 'core-ok',
+ 'cpan=s', 'cpanplus=s', 'cpan-mirror=s', 'dbflags=s', 'depends=s',
+ 'desc=s', 'exclude|i:s{,}', 'help', 'install!', 'nometa', 'notest',
+ 'requiredeps', 'version=s') or die usage_instructions();
+
+# Help requested? Nice, we can just die! Isn't it helpful?
+die usage_instructions() if $opts{help};
+die "CPANPLUS support disabled, sorry" if $opts{cpanplus};
+
+$opts{exclude} = '(?:\/|^)(?:CVS|.svn)\/' if (defined $opts{exclude} &&
+ $opts{exclude} eq '');
load_overrides();
my $tarball = setup_dir();
@@ -228,15 +208,15 @@
extract_changelog($maindir);
extract_docs($maindir);
-if (defined $user_bdepends) {
- $bdepends = $user_bdepends;
+if (defined $opts{bdepends}) {
+ $bdepends = $opts{bdepends};
} else {
$bdepends .= ', libmodule-build-perl' if ($module_build eq "Module-Build");
}
-$bdependsi = $user_bdependsi if defined $user_bdependsi;
-
-if (defined $user_depends) {
- $depends = $user_depends;
+$bdependsi = $opts{bdependsi} if defined $opts{bdependsi};
+
+if (defined $opts{depends}) {
+ $depends = $opts{depends};
} else {
$depends .= ', ${shlibs:Depends}' if $arch eq 'any';
$depends .= ', ${misc:Depends}';
@@ -260,15 +240,27 @@
create_changelog("$debiandir/changelog");
create_rules("$debiandir/rules");
create_compat("$debiandir/compat");
-create_watch("$debiandir/watch", $cpanmodule) if ($cpanmodule);
+create_watch("$debiandir/watch", $opts{cpan}) if ($opts{cpan});
#create_readme("$debiandir/README.Debian");
create_copyright("$debiandir/copyright");
fix_rules("$debiandir/rules", (defined $changelog ? $changelog : ''), @docs);
apply_final_overrides();
-build_package($maindir) if $build or $install;
-install_package($debiandir) if $install;
+build_package($maindir) if $opts{build} or $opts{install};
+install_package($debiandir) if $opts{install};
print "Done\n";
exit(0);
+
+sub usage_instructions {
+return <<"USAGE"
+Usage:
+$0 [ --build ] [ --install ] [ SOURCE_DIR | --cpan MODULE ]
+Other options: [ --desc DESCRIPTION ] [ --arch all|any ] [ --version VERSION ]
+ [ --depends DEPENDS ] [ --bdepends BUILD-DEPENDS ]
+ [ --bdependsi BUILD-DEPENDS-INDEP ] [ --cpan-mirror MIRROR ]
+ [ --exclude|-i [REGEX] ] [ --notest ] [ --nometa ]
+ [ --requiredeps ] [ --core-ok ]
+USAGE
+}
sub get_perl_pkg_details {
my (@dpkg_info);
@@ -279,26 +271,32 @@
sub setup_dir {
my ($dist, $mod, $cpanversion, $tarball);
$mod_cpan_version = '';
- if ($cpanmodule) {
+ if ($opts{cpan}) {
my ($new_maindir);
- # Is the module a core module
- if ((grep(/$cpanmodule/, @pragmas)) ||
- (grep(/$cpanmodule/, @stdmodules))) {
- die "$cpanmodule is a standard module.\n" unless $core_ok;
+ # Is the module a core module?
+ if ((grep(/$opts{cpan}/, @pragmas)) ||
+ (grep(/$opts{cpan}/, @stdmodules))) {
+ die "$opts{cpan} is a standard module.\n"
+ unless $opts{'core-ok'};
}
-
- require CPAN;
+
+ # 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;
+
+### require CPAN;
CPAN::Config->load;
- unshift @{$CPAN::Config->{'urllist'}}, $cpanmirror if $cpanmirror;
+ unshift(@{$CPAN::Config->{'urllist'}}, $opts{'cpan-mirror'})
+ if $opts{'cpan-mirror'};
$CPAN::Config->{'build_dir'} = $ENV{'HOME'} . "/.cpan/build";
$CPAN::Config->{'cpan_home'} = $ENV{'HOME'} . "/.cpan/";
$CPAN::Config->{'histfile'} = $ENV{'HOME'} . "/.cpan/history";
$CPAN::Config->{'keep_source_where'} = $ENV{'HOME'} . "/.cpan/source";
- $mod = CPAN::Shell->expand('Module', '/^'.$cpanmodule.'$/')
- || die "Can't find '$cpanmodule' module on CPAN\n";
+ $mod = CPAN::Shell->expand('Module', '/^'.$opts{cpan}.'$/')
+ || die "Can't find '$opts{cpan}' module on CPAN\n";
$mod_cpan_version = $mod->cpan_version;
$cpanversion = $CPAN::VERSION;
$cpanversion =~ s/_.*//;
@@ -324,17 +322,17 @@
`mv "$maindir" "$new_maindir"`;
$maindir = $new_maindir;
- } elsif ($cpanplusmodule) {
+ } elsif ($opts{cpanplus}) {
die "CPANPLUS support is b0rken at the moment.";
- my ($cb, $href, $file);
-
- eval "use CPANPLUS 0.045;";
- $cb = CPANPLUS::Backend->new(conf => {debug => 1, verbose => 1});
- $href = $cb->fetch( modules => [ $cpanplusmodule ], fetchdir => $ENV{'PWD'});
- die "Cannot get $cpanplusmodule\n" if keys(%$href) != 1;
- $file = (values %$href)[0];
- print $file, "\n\n";
- $maindir = $cb->extract( files => [ $file ], extractdir => $ENV{'PWD'} )->{$file};
+# my ($cb, $href, $file);
+
+# eval "use CPANPLUS 0.045;";
+# $cb = CPANPLUS::Backend->new(conf => {debug => 1, verbose => 1});
+# $href = $cb->fetch( modules => [ $opts{cpanplus} ], fetchdir => $ENV{'PWD'});
+# die "Cannot get $opts{cpanplus}\n" if keys(%$href) != 1;
+# $file = (values %$href)[0];
+# print $file, "\n\n";
+# $maindir = $cb->extract( files => [ $file ], extractdir => $ENV{'PWD'} )->{$file};
} else {
$maindir = shift(@ARGV) || '.';
$maindir =~ s/\/$//;
@@ -345,7 +343,7 @@
sub build_package {
my $maindir = shift;
# uhmf! dpkg-genchanges doesn't cope with the deb being in another dir..
- #system("dpkg-buildpackage -b -us -uc $dbflags") == 0
+ #system("dpkg-buildpackage -b -us -uc $opts{dbflags}") == 0
system("fakeroot make -C $maindir -f debian/rules clean");
system("fakeroot make -C $maindir -f debian/rules binary") == 0
|| die "Cannot create deb package\n";
@@ -371,7 +369,7 @@
my ($file, $yaml);
$file = shift;
# Command line option nometa causes this function not to be run
- return {} if $nometa;
+ return {} if $opts{nometa};
# YAML::LoadFile has the bad habit of dying when it cannot properly parse
# a file - Catch it in an eval, and if it dies, return -again- just an
@@ -405,7 +403,7 @@
$pkgname = lc $perlname;
$pkgname =~ s/::/-/;
$pkgname = 'lib'.$pkgname unless $pkgname =~ /^lib/;
- $pkgname .= '-perl' unless ($pkgname =~ /-perl$/ and $cpanmodule !~ /::perl$/i);
+ $pkgname .= '-perl' unless ($pkgname =~ /-perl$/ and $opts{cpan} !~ /::perl$/i);
# ensure policy compliant names and versions (from Joeyh)...
$pkgname =~ s/[^-.+a-zA-Z0-9]+/-/g;
@@ -422,9 +420,9 @@
extract_desc($modulepm);
}
- $excludeRE = '^$' unless $excludeRE;
+ $opts{exclude} = '^$' unless $opts{exclude};
find(sub {
- $File::Find::name !~ /$excludeRE/ &&
+ $File::Find::name !~ /$opts{exclude}/ &&
/\.(pm|pod)$/ &&
extract_desc($_);
}, $maindir);
@@ -499,9 +497,9 @@
}
$name =~ s/,.*$//;
# band aid: need to find a solution also for build in directories
- # warn "name is $name (cpan name: $cpanmodule)\n";
- $name = $cpanmodule if ($name eq '__PACKAGE__' && $cpanmodule);
- $name = $cpanplusmodule if ($name eq '__PACKAGE__' && $cpanplusmodule);
+ # warn "name is $name (cpan name: $opts{cpan})\n";
+ $name = $opts{cpan} if ($name eq '__PACKAGE__' && $opts{cpan});
+ $name = $opts{cpanplus} if ($name eq '__PACKAGE__' && $opts{cpanplus});
# Get the version
if (defined $pkgversion) {
@@ -627,7 +625,7 @@
$dir .= '/' unless $dir =~ m(/$);
find(sub {
$changelog = substr($File::Find::name, length($dir))
- if (!defined($changelog) && /^change(s|log)$/i && (! $excludeRE || ! $File::Find::name =~ /$excludeRE/));
+ if (!defined($changelog) && /^change(s|log)$/i && (! $opts{exclude} || ! $File::Find::name =~ /$opts{exclude}/));
}, $dir);
}
@@ -636,7 +634,7 @@
$dir .= '/' unless $dir =~ m(/$);
find(sub {
push (@docs, substr($File::Find::name, length($dir)))
- if (/^(README|TODO|BUGS|NEWS|ANNOUNCE)/i && (! $excludeRE || ! $File::Find::name =~ /$excludeRE/)) ;
+ if (/^(README|TODO|BUGS|NEWS|ANNOUNCE)/i && (! $opts{exclude} || ! $File::Find::name =~ /$opts{exclude}/)) ;
}, $dir);
}
@@ -680,7 +678,7 @@
exit 1;
}
-
+
foreach my $module (keys( %dep_hash )) {
next if (grep ( /^$module$/, @pragmas, @stdmodules));
@@ -688,43 +686,49 @@
}
if (`which apt-file`) {
- foreach my $module (@uses) {
- my (@search, $ls, $ver, $re, $mod);
- $mod = $module;
- print "Searching for $module package using apt-file.\n";
- $module =~ s|::|/|g;
-
- @search = `apt-file search $module.pm`;
-
- # Regex's to search the return of apt-file to find the right pkg
- $ls = '(?:lib|share)';
- $ver = '\d+(\.\d+)+';
- $re = "usr/(?:$ls/perl/$ver|$ls/perl5)/$module\\.pm";
-
- for (@search) {
- # apt-file output
- # package-name: path/to/perl/module.pm
- chomp;
- my ($p, $f) = split / /, $_;
- chop($p); #Get rid of the ":"
- if ($f =~ /$re/ && ! grep { $_ eq $p } @deps, "perl", "perl-base", "perl-modules") {
- if (exists $dep_hash{$mod}) {
- push @deps, {name=>$p,
- version=>$dep_hash{$mod}};
- } else {
- push @deps, {name => $p};
- }
- last;
- }
+ foreach my $module (@uses) {
+ my (@search, $ls, $ver, $re, $mod);
+
+ if ($module eq 'perl') {
+ substitute_perl_dependency($dep_hash{perl});
+ next;
+ }
+
+ $mod = $module;
+ print "Searching for $module package using apt-file.\n";
+ $module =~ s|::|/|g;
+
+ @search = `apt-file search $module.pm`;
+
+ # Regex's to search the return of apt-file to find the right pkg
+ $ls = '(?:lib|share)';
+ $ver = '\d+(\.\d+)+';
+ $re = "usr/(?:$ls/perl/$ver|$ls/perl5)/$module\\.pm";
+
+ for (@search) {
+ # apt-file output
+ # package-name: path/to/perl/module.pm
+ chomp;
+ my ($p, $f) = split / /, $_;
+ chop($p); #Get rid of the ":"
+ if ($f =~ /$re/ && ! grep { $_ eq $p } @deps, "perl", "perl-base", "perl-modules") {
+ if (exists $dep_hash{$mod}) {
+ push @deps, {name=>$p,
+ version=>$dep_hash{$mod}};
+ } else {
+ push @deps, {name => $p};
}
-
- unless (@search) {
- $module =~ s|/|::|g;
- push @not_debs, $module;
+ last;
}
}
- } elsif ( $requiredeps ) {
- die "--requiredeps was specified, but apt-file was not found\n";
+
+ unless (@search) {
+ $module =~ s|/|::|g;
+ push @not_debs, $module;
+ }
+ }
+ } elsif ( $opts{requiredeps} ) {
+ die "--requiredeps was specified, but apt-file was not found\n";
}
print "\n";
@@ -733,7 +737,7 @@
if (@not_debs) {
my $missing_debs_str = "Needs the following modules for which there are no debian packages available: "
. join (", ", @not_debs) . "\n";
- if ( $requiredeps ) {
+ if ( $opts{requiredeps} ) {
die $missing_debs_str;
} else {
print $missing_debs_str;
@@ -745,8 +749,32 @@
$_->{name} } @deps);
}
+sub substitute_perl_dependency {
+ # If we get 'perl' specified in here, the module requires a
+ # specific version of Perl in order to be run. This is only
+ # reliable if we have ${perl:Depends} in $depends and either
+ # of $bdepends and $bdependsi - Warn otherwise.
+ my ($version, $dep_str, $old_dep_str, $old_bdep_str);
+ $version = shift;
+
+ # Over-escaping? I'm putting this in variables to get a bit more clarity.
+ # Remember they will be fed into the regex engine.
+ $dep_str = "perl (>= $version)";
+ $old_dep_str = '\\$\\{perl:Depends\\}';
+ $old_bdep_str = "perl \\(>= $perl_pkg->{Version}\\)";
+
+ unless ($depends =~ s/$old_dep_str/$dep_str/ and
+ ($bdepends =~ s/$old_bdep_str/$dep_str/ or
+ $bdependsi =~ s/$old_bdep_str/$dep_str/)) {
+ warn "The module requires Perl version $version, but you have ",
+ "apparently overriden the default dependency handling.\n",
+ "Please note that you might need to manually edit your debian/control ",
+ "- It might not make sense at all!\n";
+ }
+}
+
sub check_for_xs {
- (! $excludeRE || ! $File::Find::name =~ /$excludeRE/) && /\.(xs|c|cpp|cxx)$/i && do {
+ (! $opts{exclude} || ! $File::Find::name =~ /$opts{exclude}/) && /\.(xs|c|cpp|cxx)$/i && do {
$arch = 'any';
};
}
@@ -757,7 +785,7 @@
$test_line = ($module_build eq 'Module-Build') ?
'$(PERL) Build test' : '$(MAKE) test';
- $test_line = "#$test_line" if $notest;
+ $test_line = "#$test_line" if $opts{notest};
$fh = _file_rw($rules_file);
@content = $fh->getlines;
@@ -777,7 +805,7 @@
my $fh = _file_w(shift);
if ($arch ne 'all' and
- !defined($user_bdepends) and !defined($user_bdependsi)) {
+ !defined($opts{bdepends}) and !defined($opts{bdependsi})) {
$bdepends .= ", $bdependsi";
$bdependsi = '';
}
More information about the Pkg-perl-cvs-commits
mailing list