[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: ${misc:Depends} breaking with Module::Build



Julian Mehnle wrote:
Jens Porup wrote:

Well, I finally got my in-house perl apps packaged correctly, but apt
isn't picking up the requires => packages listed in my Build.PL.

	dpkg-gencontrol: warning: unknown substitution variable ${misc:Depends}

How do I make Module::Build make these dependencies forcing and binding?


Module::Build can't do that for you, "Automatic generation of
miscellaneous dependencies" is a debhelper feature.  See the debhelper
man-page.  (${misc:Depends} is a substitution variable for dependencies
caused by using certain debhelper features, not for Perl dependencies.)

You may want to look at the dh_perl man-page for automating the main
"perl" dependency, but as far as I know there is no automatic way to
generate the Debian dependencies for required Perl module packages.  You
need to add them to the control file manually.

The current CVS[1] of dh-make-perl has decent dependency checking.  If
you want to do it on your own, you can use a combination of
Module::Depends::Intrusive (from libmodule-depends-perl) and apt-file to
get the dependencies of your module and find the appropriate Debian
packages.  You could try something like what dh-make-perl does (see code
at bottom).

Chris Sacca

[1] https://alioth.debian.org/scm/?group_id=30181

use Module::Depends::Intrusive;

sub extract_depends {
	my ($dir) = shift;
	$dir .= '/' unless $dir =~ m/\/$/;

	my $mod_dep = Module::Depends::Intrusive->new();

	$mod_dep->dist_dir( $dir );
	$mod_dep->find_modules();

	my %dep_hash = %{$mod_dep->requires};

	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) {
			print "Searching for $module package using apt-file.\n";
			$module =~ s|::|/|g;

			my @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";

			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") {
					push @deps, $p;
					last;
				}
			}

			unless (@search) {
			    $module =~ s|/|::|g;
				push @not_debs, $module;
		    }
		}
	}

	print "\n";
	print "Needs the following debian packages: " . join (", ", @deps) .
"\n" if (@deps);
	print "Needs the following modules for which there are debian packages
availible: "
		. join (", ", @not_debs) . "\n" if (@not_debs);

	return join (", ", @deps);
}


--
Christopher Sacca <csacca@thecsl.org> | http://csacca.thecsl.org
Americorps CTC VISTA | http://www.cpcs.umb.edu/vista/
1024D/AFF87013 - FC21 092C 95C6 0071 6416  E79B CB46 96A4 AFF8 7013

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: