r4425 - in /tools/dh-make-perl/trunk: debian/changelog dh-make-perl

gwolf at users.alioth.debian.org gwolf at users.alioth.debian.org
Tue Nov 28 18:51:24 CET 2006


Author: gwolf
Date: Tue Nov 28 18:51:24 2006
New Revision: 4425

URL: http://svn.debian.org/wsvn/?sc=1&rev=4425
Log:
About to prepare/uploade version 0.25

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=4425&op=diff
==============================================================================
--- tools/dh-make-perl/trunk/debian/changelog (original)
+++ tools/dh-make-perl/trunk/debian/changelog Tue Nov 28 18:51:24 2006
@@ -2,8 +2,19 @@
 
   * Fixed the Perl package data parsing function, fixing an unneeded
     warning. Thanks to Johnny Morano for the patch! (Closes: #396846)
-
- -- Gunnar Wolf <gwolf at debian.org>  Fri,  3 Nov 2006 09:46:37 -0600
+  * Generated dependency on Perl was incomplete (it _only_ missed the
+    package name :-/ ) - Thanks to Hilko Bengen for pointing it out.
+    (Closes: #400400)
+  * No longer dies when building Module::Install modules - It now asks
+    the user to manually specify the dependencies. (Closes: #396536)
+  * Can now specify via command line depends, build-depends and build-
+    depends-indep
+  * A bit of basic cleaning, trying to deuglify this very much love-
+    needing source code
+  * Added patch by Jesper Krogh which allows dh-make-perl to generate
+    versioned dependency strings
+
+ -- Gunnar Wolf <gwolf at debian.org>  Tue, 28 Nov 2006 11:47:32 -0600
 
 dh-make-perl (0.24) unstable; urgency=low
 

Modified: tools/dh-make-perl/trunk/dh-make-perl
URL: http://svn.debian.org/wsvn/tools/dh-make-perl/trunk/dh-make-perl?rev=4425&op=diff
==============================================================================
--- tools/dh-make-perl/trunk/dh-make-perl (original)
+++ tools/dh-make-perl/trunk/dh-make-perl Tue Nov 28 18:51:24 2006
@@ -142,10 +142,9 @@
 
 my $debstdversion = '3.7.2';
 my $priority = 'optional';
-#my $section = 'interpreters';
 my $section = 'perl';
 my $depends = '${perl:Depends}';
-my $bdependsi = $perl_pkg->{Version};
+my $bdependsi = "perl (>= $perl_pkg->{Version})";
 my $bdepends = 'debhelper (>= 5.0.0)';
 my $maintainer = get_maintainer();
 my $arch = 'all';
@@ -168,7 +167,8 @@
 my ($extrasfields, $extrapfields);
 my (@docs, $changelog, @args);
 my ($cpanmodule, $cpanplusmodule, $cpanmirror, $build, $install, $dbflags, 
-    $excludeRE, $notest, $nometa, $requiredeps);
+    $excludeRE, $notest, $nometa, $requiredeps, $user_depends, $user_bdepends,
+    $user_bdependsi);
 
 my $mod_cpan_version;
 
@@ -191,12 +191,17 @@
 	"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 ]
-               [ --cpan-mirror MIRROR ] [ --exclude|-i [REGEX] ] [ --notest ]
-               [ --nometa ] [ --requiredeps ]
+               [ --depends DEPENDS ] [ --bdepends BUILD-DEPENDS ]
+               [ --bdependsi BUILD-DEPENDS-INDEP ] [ --cpan-mirror MIRROR ]
+               [ --exclude|-i [REGEX] ] [ --notest ] [ --nometa ] 
+               [ --requiredeps ]
 USAGE
 
 $excludeRE = '(?:\/|^)(?:CVS|.svn)\/' if (defined $excludeRE && 
@@ -212,12 +217,24 @@
 }
 move ($tarball, dirname($tarball) . "/${pkgname}_${version}.orig.tar.gz") if ($tarball && $tarball =~ /(?:\.tar\.gz|\.tgz)$/);
 my $module_build = (-f "$maindir/Build.PL") ? "Module-Build" : "MakeMaker";
-$bdepends .= ', libmodule-build-perl' if ($module_build eq "Module-Build");
-$depends .= ', ${shlibs:Depends}' if $arch eq 'any';
-$depends .= ', ${misc:Depends}';
 extract_changelog($maindir);
 extract_docs($maindir);
-$depends .= ", " . extract_depends($maindir);
+
+if (defined $user_bdepends) {
+    $bdepends = $user_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;
+} else {
+    $depends .= ', ${shlibs:Depends}' if $arch eq 'any';
+    $depends .= ', ${misc:Depends}';
+    $depends .= ", " . extract_depends($maindir, $meta);
+}
+
 apply_overrides();
 
 die "Cannot find a description for the package: use the --desc switch\n" 
@@ -252,7 +269,7 @@
 }
 
 sub setup_dir {
-	my $tarball;
+	my ($dist, $mod, $cpanversion, $tarball);
 	$mod_cpan_version = '';
 	if ($cpanmodule) {
         # Is the module a core module
@@ -271,7 +288,6 @@
 		$CPAN::Config->{'histfile'}  = $ENV{'HOME'} . "/.cpan/history";
 		$CPAN::Config->{'keep_source_where'} = $ENV{'HOME'} . "/.cpan/source";
                 
-		my ($dist, $mod, $cpanversion);
 		$mod = CPAN::Shell->expand('Module', '/^'.$cpanmodule.'$/') 
 			|| die "Can't find '$cpanmodule' module on CPAN\n";
 		$mod_cpan_version = $mod->cpan_version;
@@ -300,13 +316,14 @@
 		$maindir = $new_maindir;
 
 	} elsif ($cpanplusmodule) {
-        die "CPANPLUS support is b0rken at the moment.";
-        
+	        die "CPANPLUS support is b0rken at the moment.";
+ 	        my ($cb, $href, $file);
+
 		eval "use CPANPLUS 0.045;";
-		my $cb = CPANPLUS::Backend->new(conf => {debug => 1, verbose => 1});
-		my $href = $cb->fetch( modules => [ $cpanplusmodule ], fetchdir => $ENV{'PWD'});
+		$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;
-		my $file = (values %$href)[0];
+		$file = (values %$href)[0];
 		print $file, "\n\n";
 		$maindir = $cb->extract( files => [ $file ], extractdir => $ENV{'PWD'} )->{$file};
 	} else {
@@ -416,8 +433,8 @@
 }
 
 sub extract_name_ver {
-	my ($name, $ver);
-        my $makefile = makefile_pl();
+	my ($name, $ver, $makefile);
+	$makefile = makefile_pl();
 
 	if (defined $meta->{name} and defined $meta->{version}) {
 	    $name = $meta->{name};
@@ -431,8 +448,8 @@
 }
 
 sub extract_name_ver_from_makefile {
-	my $makefile = shift;
-	my ($file, $name, $ver, $vfrom, $dir);
+	my ($file, $name, $ver, $vfrom, $dir, $makefile);
+	$makefile = shift;
 	local $/ = undef;
 	open (MF, "<$makefile") || die "Cannot open $makefile: $!\n";
 	$file = <MF>;
@@ -520,9 +537,9 @@
 }
 
 sub extract_desc {
-	my ($file) = shift;
-	my $line;
-	my $parser = new MyPod;
+        my ($file, $parser);
+	$file = shift;
+	$parser = new MyPod;
 	return unless -f $file;
 	$parser->set_names(qw(NAME DESCRIPTION DETAILS COPYRIGHT AUTHOR AUTHORS));
 	$parser->parse_from_file($file);
@@ -592,42 +609,64 @@
 }
 
 sub extract_depends {
-	my ($dir) = shift;
+	my ($dir, $meta, %dep_hash, $error, @uses, @deps, @not_debs);
+	$dir = shift;
+	$meta = shift;
+	local @INC = ($dir, @INC);
+
 	$dir .= '/' unless $dir =~ m/\/$/;
-	local @INC = ($dir, @INC);
-
-	my $mod_dep = Module::Depends::Intrusive->new();
+
+	### Mental note to self: It'd be worth it to fall back to 
+	### Module:::Depends and _only_ then fail
+	eval {
+	    no warnings;
+	    local *STDERR;
+	    open(STDERR, ">/dev/null");
+	    my $mod_dep = Module::Depends::Intrusive->new();
 	
-	$mod_dep->dist_dir( $dir );
-	$mod_dep->find_modules();
-
-	my %dep_hash = %{$mod_dep->requires};
+	    $mod_dep->dist_dir( $dir );
+	    $mod_dep->find_modules();
+
+	    %dep_hash = %{$mod_dep->requires};
+
+	    $error = $mod_dep->error();
+	    die "Error: $error\n" if $error;
+	};
+	if ($@ or $error) {
+	    warn '='x70,"\n";
+	    warn "Could not find the dependencies for the requested module\n";
+
+	    warn "Module::Depends::Intrusive reports: $error\n" if $error;
+	    warn "Generated error: $@" if $@;
+
+	    warn "Please check if your module depends on Module::Install\n" .
+		"for its build process - Automatically finding its\n" .
+		"dependencies is unsupported, please specify them manually\n" .
+		"using the 'depends' option. \n";
+	    warn '='x70,"\n";
+
+	    exit 1;
+	}
 	
-	my $error = $mod_dep->error();
-	die "Error: $error\n" if $error;
-	
-	my @uses;
-
 	foreach my $module (keys( %dep_hash )) {
 		next if (grep ( /^$module$/, @pragmas, @stdmodules));
 		
 		push @uses, $module;
 	}
 
-	my @deps;
-	my @not_debs;
-
 	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;
 
-			my @search = `apt-file search $module.pm`;
+			@search = `apt-file search $module.pm`;
 
 			# Regex's to search the return of apt-file to find the right pkg
-			my $ls  = '(?:lib|share)';
-			my $ver = '\d+(\.\d+)+';
-			my $re  = "usr/(?:$ls/perl/$ver|$ls/perl5)/$module\\.pm";
+			$ls  = '(?:lib|share)';
+			$ver = '\d+(\.\d+)+';
+			$re  = "usr/(?:$ls/perl/$ver|$ls/perl5)/$module\\.pm";
 				
 			for (@search) {
 				# apt-file output
@@ -636,8 +675,13 @@
 				my ($p, $f) = split / /, $_;
 				chop($p); #Get rid of the ":"
 				if ($f =~ /$re/ && ! grep { $_ eq $p } @deps, "perl", "perl-base", "perl-modules") {
-					push @deps, $p;
-					last;
+				    if (exists $dep_hash{$mod}) {
+					push @deps, {name=>$p, 
+						     version=>$dep_hash{$mod}};
+				    } else {
+					push @deps, {name => $p};
+				    }
+				    last;
 				}
 			}
 			
@@ -651,7 +695,8 @@
 	}
 	
 	print "\n";
-	print "Needs the following debian packages: " . join (", ", @deps) . "\n" if (@deps);
+	print "Needs the following debian packages: " .
+	    join (", ", map {$_->{name}} @deps) . "\n" if (@deps);
 	if (@not_debs) {
 		my $missing_debs_str = "Needs the following modules for which there are no debian packages available: "
 			. join (", ", @not_debs) . "\n";
@@ -661,8 +706,10 @@
 			print $missing_debs_str;
 		}
 	}
-	
-	return join (", ", @deps);
+
+	return join (", ", map { $_->{version} ?
+				     $_->{name} ." (>= ". $_->{version} .")" :
+				     $_->{name} } @deps);
 }
 
 sub check_for_xs {
@@ -672,14 +719,15 @@
 }
 
 sub fix_rules  {
-	my ($rules_file, $changelog_file, @docs) = @_;
-
-	my $test_line = ($module_build eq 'Module-Build') ? 
+        my ($rules_file, $changelog_file, @docs, $test_line, @content);
+        ($rules_file, $changelog_file, @docs) = @_;
+
+	$test_line = ($module_build eq 'Module-Build') ? 
 	    '$(PERL) Build test' : '$(MAKE) test';
 	$test_line = "#$test_line" if $notest;
 
 	open (FH, "+<$rules_file") || die "Can't open $rules_file: $!";
-	my @content = <FH>;
+	@content = <FH>;
 	seek(FH, 0, 0) || die "Can't rewind $rules_file: $!";
 	truncate(FH, 0)|| die "Can't truncate $rules_file: $!";
 	for (@content) {
@@ -694,7 +742,8 @@
 sub create_control {
 	my ($file) = shift;
 
-	if ($arch ne 'all') {
+	if ($arch ne 'all' and 
+	    !defined($user_bdepends) and !defined($user_bdependsi)) {
 	    $bdepends .= ", $bdependsi";
 	    $bdependsi = '';
 	}
@@ -703,7 +752,7 @@
 	print C "Source: $srcname\n";
 	print C "Section: $section\n";
 	print C "Priority: $priority\n";
-	print C "Build-Depends: $bdepends\n";
+	print C "Build-Depends: $bdepends\n" if $bdepends;
 	print C "Build-Depends-Indep: $bdependsi\n" if $bdependsi;
 	print C $extrasfields if defined $extrasfields;
 	print C "Maintainer: $maintainer\n";
@@ -711,7 +760,7 @@
 	print C "\n";
 	print C "Package: $pkgname\n";
 	print C "Architecture: $arch\n";
-	print C "Depends: $depends\n";
+	print C "Depends: $depends\n" if $depends;
 	print C $extrapfields if defined $extrapfields;
 	print C "Description: $desc\n$longdesc\n .\n This description was automagically extracted from the module by dh-make-perl.\n";
 	close(C);
@@ -728,9 +777,9 @@
 }
 
 sub create_rules {
-	use File::Copy;
-	my ($file) = shift;
-	my $rulesname = $arch eq 'all'?"rules.$module_build.noxs":"rules.$module_build.xs";
+        my ($file, $rulesname);
+	($file) = shift;
+	$rulesname = $arch eq 'all'?"rules.$module_build.noxs":"rules.$module_build.xs";
 	my $error;
 	
 	for my $source (("$homedir/$rulesname", "$datadir/$rulesname")) {
@@ -809,9 +858,9 @@
 }
 
 sub get_maintainer {
-	my $user = $ENV{LOGNAME} || $ENV{USER};
-	my $pwnam = getpwuid($<);
-	my ($email, $name, $mailh);
+        my ($user, $pwnam, $email, $name, $mailh);
+	$user = $ENV{LOGNAME} || $ENV{USER};
+	$pwnam = getpwuid($<);
 	die "Cannot determine current user\n" unless $pwnam;
 	if (defined $ENV{DEBFULLNAME}) {
 		$name = $ENV{DEBFULLNAME};
@@ -833,9 +882,13 @@
 }
 
 sub load_overrides {
-	# FIXME: check for errors
-	do "$datadir/overrides";
-	do "$homedir/overrides";
+    eval {
+	do "$datadir/overrides" if -f "$datadir/overrides";
+	do "$homedir/overrides" if -f "$homedir/overrides";
+    };
+    if ($@) {
+	die "Error when processing the overrides files: $@";
+    }
 }
 
 sub apply_overrides {
@@ -888,8 +941,8 @@
 }
 
 sub get_override_val {
-	my ($data, $subkey, $key) = @_;
-	my $val;
+        my ($data, $subkey, $key, $val);
+	($data, $subkey, $key) = @_;
 	$val = defined($data->{$subkey.$key})?$data->{$subkey.$key}:$data->{$key};
 	return &$val() if (defined($val) && ref($val) eq 'CODE');
 	return $val;
@@ -920,6 +973,32 @@
 =item B<--version> I<VERSION>
 
 Specifies the version of the resulting package.
+
+=item B<--depends> I<DEPENDS>
+
+Manually specify the string to be used for the module's dependencies. This 
+should be used when building modules where dh-make-perl cannot guess the Perl
+dependencies (such as modules built using L<Module::Install>), or when the
+Perl code depends on non-Perl binaries or libraries. Usually, dh-make-perl
+will figure out the dependencies by itself.
+
+=item B<--bdepends> I<BUILD-DEPENDS>
+
+Manually specify the string to be used for the module's build-dependencies
+(that is, the packages and their versions that have to be installed in order
+to successfully build the package). Keep in mind that packages generated by
+dh-make-perl require debhelper (>= 5.0.0) to be specified as a build 
+dependency. Same note as for --depends applies here - Use only when needed.
+
+=item B<--bdependsi> I<BUILD-DEPENDS-INDEP>
+
+Manually specify the string to be used for the module's build-dependencies
+for architecture-independent builds. Same notes as those for the --depends 
+and --bdepends options apply here.
+
+Note that for --depends, --bdepends and --bdependsi you can also specify that
+the field should not appear in debian/rules (if you really mean it, of course
+;-) ) by giving it an empty string as an argument.
 
 =item B<--cpan-mirror> I<MIRROR>
 
@@ -1052,6 +1131,8 @@
   Fermin Galan E<lt>galan at dit.upm.esE<gt>
   Geoff Richards E<lt>qef at ungwe.orgE<gt>
   Gergely Nagy E<lt>algernon at bonehunter.rulez.orgE<gt>
+  Hilko Bengen E<lt>bengen at debian.orgE<gt>
+  Jesper Krogh E<lt>jesper at krogh.ccE<gt>
   Johnny Morano E<lt>jmorano at moretrix.comE<gt>
   Juerd E<lt>juerd at ouranos.juerd.netE<gt>
   Matt Hope E<lt>dopey at debian.orgE<gt>




More information about the Pkg-perl-cvs-commits mailing list