[dh-make-perl-cvs-dev] CVS dh-make-perl

CVS User gwolf cvs@dh-make-perl.alioth.debian.org
Thu, 24 Mar 2005 17:12:04 +0000


Update of /cvsroot/dh-make-perl/dh-make-perl
In directory haydn:/tmp/cvs-serv14647

Modified Files:
	dh-make-perl 
Log Message:
Revert csacca's changes, as they trampled over other code


--- /cvsroot/dh-make-perl/dh-make-perl/dh-make-perl	2005/03/24 04:33:29	1.26
+++ /cvsroot/dh-make-perl/dh-make-perl/dh-make-perl	2005/03/24 17:12:03	1.27
@@ -3,24 +3,27 @@
 # TODO: 
 # * get more info from the package (maybe using CPAN methods)
 
-###########################################################
-##  Standard Perl modules and pragmas
-###########################################################
+package MyPod;
+use Pod::Parser;
+use YAML;
+
+@MyPod::ISA = qw(Pod::Parser);
 
 my @pragmas = qw(attributes attrs autouse base bigint bignum
-         bigrat blib bytes charnames constant
-         diagnostics encoding fields filetest if 
-         integer less lib locale open ops overload
-         re sigtrap sort strict subs threads utf8
-         vars vmsish warnings warnings::register);
+				 bigrat blib bytes charnames constant
+				 diagnostics encoding fields filetest if 
+				 integer less lib locale open ops overload
+				 re sigtrap sort strict subs threads utf8
+				 vars vmsish warnings warnings::register);
 
 my @stdmodules = qw(AnyDBM_File Attribute::Handlers::demo::Demo
 Attribute::Handlers::demo::Descriptions
-Attribute::Handlers::demo::MyClass Attribute::Handlers
-AutoLoader AutoSplit Benchmark Carp::Heavy Carp CGI::Apache CGI::Carp CGI::Cookie CGI::Fast
-CGI::Pretty CGI::Push CGI::Switch CGI::Util CGI Class::ISA
-Class::Struct CPAN::FirstTime CPAN::Nox CPAN Cwd DB
-Devel::SelfStubber Digest DirHandle Dumpvalue English Env
+Attribute::Handlers::demo::MyClass Attribute::Handlers attributes
+AutoLoader AutoSplit autouse base Benchmark bigint bignum bigrat blib
+bytes Carp::Heavy Carp CGI::Apache CGI::Carp CGI::Cookie CGI::Fast
+CGI::Pretty CGI::Push CGI::Switch CGI::Util CGI charnames Class::ISA
+Class::Struct constant CPAN::FirstTime CPAN::Nox CPAN Cwd DB
+Devel::SelfStubber diagnostics Digest DirHandle Dumpvalue English Env
 Exporter::Heavy Exporter ExtUtils::Command::MM ExtUtils::Command
 ExtUtils::Constant ExtUtils::Embed ExtUtils::Installed ExtUtils::Install
 ExtUtils::Liblist::Kid ExtUtils::Liblist ExtUtils::MakeMaker::bytes
@@ -30,15 +33,15 @@
 ExtUtils::MM_MacOS ExtUtils::MM_NW5 ExtUtils::MM_OS2 ExtUtils::MM
 ExtUtils::MM_Unix ExtUtils::MM_UWIN ExtUtils::MM_VMS ExtUtils::MM_Win32
 ExtUtils::MM_Win95 ExtUtils::MY ExtUtils::Packlist ExtUtils::testlib
-Fatal File::Basename File::CheckTree File::Compare File::Copy
+Fatal fields File::Basename File::CheckTree File::Compare File::Copy
 File::DosGlob File::Find File::Path File::Spec::Cygwin File::Spec::Epoc
 File::Spec::Functions File::Spec::Mac File::Spec::OS2 File::Spec::Unix
 File::Spec::VMS File::Spec::Win32 File::Spec File::stat File::Temp
-FileCache FileHandle Filter::Simple FindBin Getopt::Long
+FileCache FileHandle filetest Filter::Simple FindBin Getopt::Long
 Getopt::Std Hash::Util I18N::Collate I18N::LangTags::List I18N::LangTags
-IPC::Open2 IPC::Open3 Locale::Constants Locale::Country
+if integer IPC::Open2 IPC::Open3 less Locale::Constants Locale::Country
 Locale::Currency Locale::Language Locale::Maketext::GutsLoader
-Locale::Maketext::Guts Locale::Maketext Locale::Script
+Locale::Maketext::Guts Locale::Maketext Locale::Script locale
 Math::BigFloat Math::BigFloat::Trace Math::BigInt::Calc
 Math::BigInt::Scalar Math::BigInt::Trace Math::BigInt Math::BigRat
 Math::Complex Math::Trig Memoize::AnyDBM_File Memoize::ExpireFile
@@ -47,7 +50,7 @@
 Net::Domain Net::FTP::A Net::FTP::dataconn Net::FTP::E Net::FTP::I
 Net::FTP::L Net::FTP Net::hostent Net::netent Net::Netrc Net::NNTP
 Net::Ping Net::POP3 Net::protoent Net::servent Net::SMTP Net::Time NEXT
-PerlIO PerlIO::via::QuotedPrint Pod::Checker Pod::Find
+open overload PerlIO PerlIO::via::QuotedPrint Pod::Checker Pod::Find
 Pod::Functions Pod::Html Pod::InputObjects Pod::LaTeX Pod::Man
 Pod::ParseLink Pod::Parser Pod::ParseUtils Pod::Perldoc::BaseTo
 Pod::Perldoc::GetOptsOO Pod::Perldoc::ToChecker Pod::Perldoc::ToMan
@@ -55,7 +58,7 @@
 Pod::Perldoc::ToText Pod::Perldoc::ToTk Pod::Perldoc::ToXml Pod::Perldoc
 Pod::Plainer Pod::PlainText Pod::Select Pod::Text::Color
 Pod::Text::Overstrike Pod::Text::Termcap Pod::Text Pod::Usage
-Search::Dict SelectSaver SelfLoader Shell
+Search::Dict SelectSaver SelfLoader Shell sigtrap sort strict subs
 Switch Symbol Term::ANSIColor Term::Cap Term::Complete Term::ReadLine
 Test::Builder Test::Harness::Assert Test::Harness::Iterator
 Test::Harness::Straps Test::Harness Test::More Test::Simple Test
@@ -63,70 +66,50 @@
 Text::Wrap Thread Thread::Queue Thread::Semaphore Tie::Array Tie::File
 Tie::Handle Tie::Hash Tie::Memoize Tie::RefHash Tie::Scalar
 Tie::SubstrHash Time::gmtime Time::Local Time::localtime Time::tm
-Unicode::Collate Unicode::UCD UNIVERSAL User::grent User::pwent);
-
-#####
-# This is global because we use have data definitions outside that we want
-# to use in the program.  This might want to be converted to YAML in the future
-our %overrides;
-#####
-
-
-###########################################################
-##  MyPod Class (inherits from Pod::Parser)
-###########################################################
-
-package MyPod;
-use Pod::Parser;
-use YAML;
-
-@MyPod::ISA = qw(Pod::Parser);
-
-# The subs below overload the standard Pod parsing so that we can
-# automagically pull information out of the module documentation.
+Unicode::Collate Unicode::UCD UNIVERSAL User::grent User::pwent utf8
+vars vmsish warnings warnings::register);
 
 sub set_names {
-    my ($parser, @names) = @_;
-    foreach my $n (@names) {
-        $parser->{_deb_}->{$n} = undef;
-    }
+	my ($parser, @names) = @_;
+	foreach my $n (@names) {
+		$parser->{_deb_}->{$n} = undef;
+	}
 }
 
 sub get {
-    my ($parser, $name) = @_;
-    $parser->{_deb_}->{$name};
+	my ($parser, $name) = @_;
+	$parser->{_deb_}->{$name};
 }
 
 sub cleanup {
-    my $parser = shift;
-    delete $parser->{_current_};
-    foreach my $k ( keys %{$parser->{_deb_}}) {
-        $parser->{_deb_}->{$k} = undef;
-    }
+	my $parser = shift;
+	delete $parser->{_current_};
+	foreach my $k ( keys %{$parser->{_deb_}}) {
+		$parser->{_deb_}->{$k} = undef;
+	}
 }
 
 sub command {
-    my ($parser, $command, $paragraph, $line_num) = @_;
-
-    $paragraph =~ s/\s+$//s; # s/\s// is a white-space remover
-    if ($command =~ /head/ && exists($parser->{_deb_}->{$paragraph})) {
-        $parser->{_current_} = $paragraph;
-        $parser->{_lineno_} = $line_num;
-    } else {
-        delete $parser->{_current_};
-    }
-    #print "GOT: $command -> $paragraph\n";
+	my ($parser, $command, $paragraph, $line_num) = @_;
+	$paragraph =~ s/\s+$//s;
+	if ($command =~ /head/ && exists($parser->{_deb_}->{$paragraph})) {
+		$parser->{_current_} = $paragraph;
+		$parser->{_lineno_} = $line_num;
+	} else {
+		delete $parser->{_current_};
+	}
+	#print "GOT: $command -> $paragraph\n";
 }
 
 sub add_text {
-    my ($parser, $paragraph, $line_num) = @_;
-    return unless exists $parser->{_current_};
-    return if ($line_num - $parser->{_lineno_} > 15);
-    $paragraph =~ s/^\s+//s;
-    $paragraph =~ s/\s+$//s;
-    $paragraph = $parser->interpolate($paragraph, $line_num);
-    $parser->{_deb_}->{$parser->{_current_}} .= "\n\n".$paragraph;
-    #print "GOT: $paragraph'\n";
+	my ($parser, $paragraph, $line_num) = @_;
+	return unless exists $parser->{_current_};
+	return if ($line_num - $parser->{_lineno_} > 15);
+	$paragraph =~ s/^\s+//s;
+	$paragraph =~ s/\s+$//s;
+	$paragraph = $parser->interpolate($paragraph, $line_num);
+	$parser->{_deb_}->{$parser->{_current_}} .= "\n\n".$paragraph;
+	#print "GOTT: $paragraph'\n";
 }
 
 sub verbatim { shift->add_text(@_)}
@@ -144,22 +127,15 @@
 	return $seq_argument;
 }
 
-###########################################################
-##  Main
-###########################################################
-
 package main;
 
-use strict;
-
 use File::Basename;
 use File::Find;
 use File::Copy qw(copy move);
 use User::pwent;
 use Getopt::Long;
 use Cwd;
-use YAML;
-use Module::Depends::Intrusive;
+use strict;
 
 my $debstdversion = '3.6.1';
 my $priority = 'optional';
@@ -246,19 +222,10 @@
 print "Done\n";
 exit(0);
 
-###########
-## END MAIN
-###########
-
 sub setup_dir {
 	my $tarball;
 	$mod_cpan_version = '';
 	if ($cpanmodule) {
-		# Is the module a core module
-                if ((grep(/$cpanmodule/, @pragmas)) || (grep(/$cpanmodule/, @stdmodules))) {
-                    die "$cpanmodule is a standard module.\n";
-                }
-
 		require CPAN;
 		CPAN::Config->load;
 
@@ -496,74 +463,65 @@
 }
 
 sub extract_depends {
-    my ($dir) = shift;
-    $dir .= '/' unless $dir =~ m/\/$/;
-
-    ##  NOTE
-    ##  Now using libmodule-depends-perl
+	my ($dir) = shift;
+	$dir .= '/' unless $dir =~ m/\/$/;
 
-    my $mod_dep = Module::Depends::Intrusive->new();
+	my (@Modules, @use, @depends);
+	
+	find( sub {push @Modules, $File::Find::name if /pm$/ && (! $excludeRE || ! $File::Find::name =~ /$excludeRE/) }, $dir); #Find all modules
     
-    $mod_dep->dist_dir( $dir );
-    $mod_dep->find_modules();
+	foreach my $module (@Modules) {
+		open (FH, $module) or print "Couldn't open $module\n", next;
+		while(<FH>) {
+			if ($_ && /^\s*use ([^; \t\"(]+)(?: \d(?:\.\d+)+)?.*;\s*$/) {
+				my $m = $1;
+				my $f = $m;
+				   $f =~ s!::!/!g;
+				if ($m && $m !~ /^v?5/){ #Is not a perl version
+					if (! grep ($m eq $_, @pragmas)     #Is not a pragma
+						&&
+						! grep ($m eq $_, @stdmodules)) #Is not a standard module
+					{
+						if (! grep {$_ eq $m} @use) { #Prevent dupes
+							if (! grep { $_ && $_ =~ /$f.pm$/ } @Modules) { #Modules in this package
+								push @use, $m;
+							}
+						}
+					}
+				}								
+			}
+		}
+		close FH;
+	}
 
-    my %dep_hash = %{$mod_dep->requires};
-    
-    my $depstr ='';
+	if (`which apt-file`) {
+		for my $u (@use) {
+			print "Searching package for module $u with apt-file.\n";
+			$u =~ s!::!/!g;
+
+			my @search = `apt-file search $u.pm`;
+
+			my $ls  = '(?:lib|share)';
+			my $ver = '\d+(\.\d+)+';
+			my $re  = "usr/(?:(?:local/)?$ls/perl/$ver|$ls/perl5)/$u\\.pm";
+				
+			for (@search) {
+				chomp; 
+				my ($p, $f) = split / /, $_;
+				chop($p); #Get rid of the ":"
+				if ($f =~ /$re/ && ! grep ($_ eq $p, @depends, "perl", "perl-base", "perl-modules")) {
+					push @depends, $p;
+					last;
+				}
+			}
+		}
+	} else {
+		print "Needs the following modules: ", join (", ", @use), "\n"
+	}
 
-    foreach my $module (keys( %dep_hash )) {
-        next if (grep ( /^$module$/, @pragmas));
-        next if (grep ( /^$module$/, @stdmodules));
-        
-        if ($depstr) {
-            $depstr = join ( ", ", ($depstr, $module));
-        } else {
-            $depstr = $module;
-        }
-    }
-      
-    my @uses = split( ", ", $depstr);
-    my @deps;
-
-    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/(?:(?:local/)?$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;
-                }
-            }
-        }
-        foreach my $module (@uses) {
-            $module =~ s|/|::|g;
-        }
-    }
-    
-    print "\n\n";
-    print "Needs the following modules: " . join (", ", @uses) . "\n" if (@uses);
-    print "At least some will be provided by: " . join (", ", @deps) . "\n" if (@deps);
-    
-    @deps = @uses unless (@deps);
-    
-    return join (", ", @deps);    
+	return join ", ", @depends;	
 }
 
-
 sub check_for_xs {
 	(! $excludeRE || ! $File::Find::name =~ /$excludeRE/) && /\.(xs|c|cpp|cxx)$/i && do {
 		$arch = 'any';