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

CVS User gwolf cvs at dh-make-perl.alioth.debian.org
Mon Aug 29 18:11:20 UTC 2005


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

Modified Files:
	rules.Module-Build.xs rules.Module-Build.noxs 
	rules.MakeMaker.xs rules.MakeMaker.noxs dh-make-perl 
Log Message:
- Don't ignore 'make clean' results if Makefile/Build exist
- Better handling of Module::Install / Module::Build


--- /cvsroot/dh-make-perl/dh-make-perl/rules.Module-Build.xs	2005/03/24 01:44:23	1.2
+++ /cvsroot/dh-make-perl/dh-make-perl/rules.Module-Build.xs	2005/08/29 18:11:20	1.3
@@ -43,7 +43,7 @@
 	dh_testroot
 
 	# Add commands to clean up after the build process here
-	-$(PERL) Build distclean
+	[ ! -f Build ] || $(PERL) Build distclean
 
 	dh_clean build-stamp install-stamp
 
--- /cvsroot/dh-make-perl/dh-make-perl/rules.Module-Build.noxs	2005/03/24 01:44:23	1.2
+++ /cvsroot/dh-make-perl/dh-make-perl/rules.Module-Build.noxs	2005/08/29 18:11:20	1.3
@@ -37,7 +37,7 @@
 	dh_testroot
 
 	# Add commands to clean up after the build process here
-	-$(PERL) Build distclean
+	[ ! -f Build ] || $(PERL) Build distclean
 
 	dh_clean build-stamp install-stamp
 
--- /cvsroot/dh-make-perl/dh-make-perl/rules.MakeMaker.xs	2005/03/24 01:44:23	1.2
+++ /cvsroot/dh-make-perl/dh-make-perl/rules.MakeMaker.xs	2005/08/29 18:11:20	1.3
@@ -43,7 +43,7 @@
 	dh_testroot
 
 	# Add commands to clean up after the build process here
-	-$(MAKE) realclean
+	[ ! -f Makefile ] || $(MAKE) realclean
 
 	dh_clean build-stamp install-stamp
 
--- /cvsroot/dh-make-perl/dh-make-perl/rules.MakeMaker.noxs	2005/03/24 01:44:23	1.2
+++ /cvsroot/dh-make-perl/dh-make-perl/rules.MakeMaker.noxs	2005/08/29 18:11:20	1.3
@@ -34,7 +34,7 @@
 	dh_testroot
 
 	# Add commands to clean up after the build process here
-	-$(MAKE) distclean
+	[ ! -f Makefile ] || $(MAKE) realclean
 
 	dh_clean build-stamp install-stamp
 
--- /cvsroot/dh-make-perl/dh-make-perl/dh-make-perl	2005/05/18 14:42:30	1.36
+++ /cvsroot/dh-make-perl/dh-make-perl/dh-make-perl	2005/08/29 18:11:20	1.37
@@ -155,12 +155,12 @@
 our %overrides;
 my $datadir = '/usr/share/dh-make-perl';
 my $homedir = "$ENV{HOME}/.dh-make-perl";
-my ($perlname, $maindir, $modulepm);
+my ($perlname, $maindir, $modulepm, $meta);
 my ($pkgname, $srcname, $version, $desc, $longdesc, $copyright, $author);
 my ($extrasfields, $extrapfields);
 my (@docs, $changelog, @args);
 my ($cpanmodule, $cpanplusmodule, $cpanmirror, $build, $install, $dbflags, 
-    $excludeRE, $notest);
+    $excludeRE, $notest, $nometa);
 
 my $mod_cpan_version;
 
@@ -181,18 +181,21 @@
 	"build!" => \$build,
 	"install!" => \$install,
 	"notest" => \$notest,
+	"nometa" => \$nometa,
 	) || 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]
 USAGE
 
 $excludeRE = '(?:\/|^)(?:CVS|.svn)\/' if ($excludeRE && $excludeRE == 1);
 
 load_overrides();
 my $tarball = setup_dir();
-   ($pkgname, $version) = extract_basic();
+$meta = process_meta("$maindir/META.yml") if (-f "$maindir/META.yml");
+($pkgname, $version) = extract_basic();
 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");
@@ -203,7 +206,11 @@
 $depends .= ", " . extract_depends($maindir);
 apply_overrides();
 
-die "Cannot find a description for the package: use the --desc switch\n" unless $desc;
+die "Cannot find a description for the package: use the --desc switch\n" 
+    unless $desc;
+print "Package does not provide a long description - " , 
+    " Please fill it in manually.\n"
+    if (!defined $longdesc or $longdesc =~ /^\s*\.?\s*/);
 print "Using maintainer: $maintainer\n";
 print "Found changelog: $changelog\n" if defined $changelog;
 print "Found docs: @docs\n";
@@ -310,6 +317,16 @@
 		|| die "Cannot install package $startdir/$debname\n";
 }
 
+sub process_meta {
+    my ($file);
+    $file = shift;
+    # Command line option nometa causes this function not to be run
+    return {} if $nometa;
+
+    # Returns a simple hashref with all the keys/values defined in META.yml
+    return YAML::LoadFile($file);
+}
+
 sub extract_basic_copyright {
 	for my $f (qw(LICENSE LICENCE COPYING)) {
 		if (-f $f) {
@@ -320,50 +337,48 @@
 }
 
 sub extract_basic {
-	($perlname, $version) = extract_name_ver();
-	find(\&check_for_xs, $maindir);
-	$pkgname = lc $perlname;
-	$pkgname =~ s/::/-/;
-	$pkgname = 'lib'.$pkgname unless $pkgname =~ /^lib/;
-	$pkgname .= '-perl' unless ($pkgname =~ /-perl$/ and $cpanmodule !~ /::perl$/i);
+    ($perlname, $version) = extract_name_ver();
+    find(\&check_for_xs, $maindir);
+    $pkgname = lc $perlname;
+    $pkgname =~ s/::/-/;
+    $pkgname = 'lib'.$pkgname unless $pkgname =~ /^lib/;
+    $pkgname .= '-perl' unless ($pkgname =~ /-perl$/ and $cpanmodule !~ /::perl$/i);
 
-	# ensure policy compliant names and versions (from Joeyh)...
-	$pkgname =~ s/[^-.+a-zA-Z0-9]+/-/g;
+    # ensure policy compliant names and versions (from Joeyh)...
+    $pkgname =~ s/[^-.+a-zA-Z0-9]+/-/g;
         
-	$srcname = $pkgname;
-	$version =~ s/[^-.+a-zA-Z0-9]+/-/g;
-	$version = "0$version" unless $version =~ /^\d/;
-	
-	print "Found: $perlname $version ($pkgname arch=$arch)\n";
-	$debiandir = "$maindir/debian";
-
-	$copyright = extract_basic_copyright();
-	if ($modulepm) {
-		extract_desc($modulepm);
-	}
-
-	find(sub {
-		(! $excludeRE || ! $File::Find::name =~ /$excludeRE/) && /\.(pm|pod)$/ && do { extract_desc($_) };
-	}, $maindir);
+    $srcname = $pkgname;
+    $version =~ s/[^-.+a-zA-Z0-9]+/-/g;
+    $version = "0$version" unless $version =~ /^\d/;
+
+    print "Found: $perlname $version ($pkgname arch=$arch)\n";
+    $debiandir = "$maindir/debian";
+
+    $copyright = extract_basic_copyright();
+    if ($modulepm) {
+	extract_desc($modulepm);
+    }
+
+    find(sub {
+	(! $excludeRE || ! $File::Find::name =~ /$excludeRE/) && /\.(pm|pod)$/ && do { extract_desc($_) };
+    }, $maindir);
 
-        return ($pkgname, $version);
+    return ($pkgname, $version);
 }
 
 sub extract_name_ver {
-	my $meta = "$maindir/META.yml";
 	my $makefile = "$maindir/Makefile.PL";
 	my ($name, $ver);
-	if(-f $meta) {
-                ($name, $ver) = extract_name_ver_from_meta($meta);
-	} 
-	return ($name && $ver) ?  ($name, $ver) :
-	    extract_name_ver_from_makefile($makefile);
-}
 
-sub extract_name_ver_from_meta {
-	my $meta = shift;
-	my $data = YAML::LoadFile($meta);
-	return ($data->{name}, $data->{version});
+	if (defined $meta->{name} and defined $meta->{version}) {
+	    $name = $meta->{name};
+	    $ver = $meta->{version};
+
+	} else {
+	    ($name, $ver) = extract_name_ver_from_makefile($makefile);
+	}
+
+	return ($name, $ver);
 }
 
 sub extract_name_ver_from_makefile {
@@ -373,51 +388,81 @@
 	open (MF, "<$makefile") || die "Cannot open $makefile: $!\n";
 	$file = <MF>;
 	close(MF);
-    $name = $4 if $file =~ /(['"]?)DISTNAME\1\s*(=>|,)\s*(['"]?)(\S+)\3/s;
-    $name = $4 if ! $name && $file =~ /(['"]?)NAME\1\s*(=>|,)\s*(['"]?)(\S+)\3/s;	
-	$ver = $4 if $file =~ /(['"]?)VERSION\1\s*(=>|,)\s*(['"]?)(\S+)\3/s;
-	$vfrom = $4 if $file =~ /(['"]?)VERSION_FROM\1\s*(=>|,)\s*(['"]?)(\S+)\3/s;
-	$dir = dirname($makefile) || './';
+
+	# Get the name
+	if ($file =~ /([\'\"]?)DISTNAME\1\s*(=>|,)\s*([\'\"]?)(\S+)\3/s) {
+	    # Regular MakeMaker
+	    $name = $4;
+	} elsif ($file =~ /([\'\"]?)NAME\1\s*(=>|,)\s*([\'\"]?)(\S+)\3/s) {
+	    # Regular MakeMaker
+	    $name = $4;
+	} elsif ($file =~ /name\(([\'\"]?)(\S+)\1\);/s) {
+	    # Module::Install syntax
+	    $name = $2;
+	}
 	$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);
+
+	# Get the version
+	if (defined $version) {
+	    # Explicitly specified
+	    $ver = $version;
+
+	} elsif ($file =~ /([\'\"]?)VERSION\1\s*(=>|,)\s*([\'\"]?)(\S+)\3/s) {
+	    # Regular MakeMaker
+	    $ver = $4;
+	    # Where is the version taken from?
+	    $vfrom = $4 if 
+		$file =~ /([\'\"]?)VERSION_FROM\1\s*(=>|,)\s*([\'\"]?)(\S+)\3/s;
+
+	} elsif ($file =~ /version\((\S+)\)/s) {
+	    # Module::Install
+	    $ver = $1;
+	}
+
+	$modulepm = "$dir/$vfrom" if defined $vfrom;
+
+	$dir = dirname($makefile) || './';
+
 	for (($name, $ver)) {
 		next unless defined;
 		next unless /^\$/;
 		# decode simple vars
 		s/(\$\w+).*/$1/;
-		if ($file =~ /\Q$_\E\s*=\s*(['"]?)(\S+)\1\s*;/) {
+		if ($file =~ /\Q$_\E\s*=\s*([\'\"]?)(\S+)\1\s*;/) {
 			$_ = $2;
 		}
 	}
-	$ver = $version if defined $version;
-	$modulepm = "$dir/$vfrom" if defined $vfrom;
+
 	unless (defined $ver) {
-		local $/ = "\n";
-		# apply the method used by makemaker
-		if ( open(MF, "<$dir/$vfrom") ) {
-			while (<MF>) {
-				if (/([\$*])(([\w\:\']*)\bVERSION)\b.*\=/) {
-					no strict;
-					#warn "ver: $_";
-					$ver = (eval $_)[0];
-					last;
-				}
-			}
-			close(MF);
+	    local $/ = "\n";
+	    # apply the method used by makemaker
+	    if (defined $dir and defined $vfrom and -f "$dir/$vfrom"
+		and open(MF, "<$dir/$vfrom") ) {
+		while (<MF>) {
+		    if (/([\$*])(([\w\:\']*)\bVERSION)\b.*\=/) {
+			no strict;
+			#warn "ver: $_";
+			$ver = (eval $_)[0];
+			last;
+		    }
+		}
+		close(MF);
+	    } else {
+		if ( $mod_cpan_version ) {
+		    $ver = $mod_cpan_version;
+		    warn "Cannot use internal module data to gather the ".
+			"version; using cpan_version\n";
 		} else {
-			if ( $mod_cpan_version ) {
-				warn "Cannot open $dir/$vfrom to gather the ".
-				     "version: using cpan_version\n";
-				$ver = $mod_cpan_version;
-			} else {
-				die "Cannot open $dir/$vfrom to gather the ".
-				    "version: use --cpan or --version\n";
-			}
+		    die "Cannot use internal module data to gather the ".
+			"version; use --cpan or --version\n";
 		}
+	    }
 	}
+
 	return ($name, $ver);
 }
 
@@ -428,17 +473,28 @@
 	return unless -f $file;
 	$parser->set_names(qw(NAME DESCRIPTION DETAILS COPYRIGHT AUTHOR AUTHORS));
 	$parser->parse_from_file($file);
-	if ((!$desc) && ($desc = $parser->get('NAME'))) {
-		$desc =~ s/^\s*\S+\s+-\s+//s;
-		$desc =~ s/^\s+//s;
-		$desc =~ s/\s+$//s;
-		$desc =~ s/^([^\s])/ $1/mg;
-		$desc =~ s/\n.*$//s;
+	if ($desc) {
+	    # No-op - We already have it, probably from the command line
+
+	} elsif ($meta->{abstract}) {
+	    # Get it from META.yml
+	    $desc = $meta->{abstract};
+
+	} elsif (my $my_desc = $parser->get('NAME')) {
+	    # Parse it, fix it, send it!
+	    $my_desc =~ s/^\s*\S+\s+-\s+//s;
+	    $my_desc =~ s/^\s+//s;
+	    $my_desc =~ s/\s+$//s;
+	    $my_desc =~ s/^([^\s])/ $1/mg;
+	    $my_desc =~ s/\n.*$//s;
+	    $desc = $my_desc;
 	}
+
 	unless ($longdesc) {
 		$longdesc = $parser->get('DESCRIPTION')
 			|| $parser->get('DETAILS')
-			|| $desc;
+			|| $desc
+			|| ''; # Just to avoid warnings...
 		$longdesc =~ s/^\s+//s;
 		$longdesc =~ s/\s+$//s;
 		$longdesc =~ s/^\t/ /mg;
@@ -447,9 +503,18 @@
 		$longdesc =~ s/^([^\s])/ $1/mg;
 		$longdesc =~ s/\r//g;
 	}
-	$copyright = $parser->get('COPYRIGHT') unless $copyright;
-	$author = $parser->get('AUTHOR') unless $author;
-	$author = $parser->get('AUTHORS') unless $author;
+
+	$copyright = $copyright || $parser->get('COPYRIGHT');
+	if (!$author) {
+	    if (ref $meta->{author}) {
+		# Does the author information appear in META.yml?
+		$author = join(', ', @{$meta->{author}});
+	    } else {
+		# Get it from the POD
+		$author = $parser->get('AUTHOR') || $parser->get('AUTHORS');
+	    }
+	}
+
 	$parser->cleanup;
 }
 
@@ -634,7 +699,7 @@
 	if (defined($copyright)) {
 		print C $copyright;
 		# Fun with regexes
-		if ( $copyright =~ /same terms as Perl itself/i ) {
+		if ( $copyright =~ /terms as Perl itself/i ) {
 		    print C "\n\n", <<END;
 Perl is distributed under your choice of the GNU General Public License or
 the Artistic License.  On Debian GNU/Linux systems, the complete text of the




More information about the Dh-make-perl-cvs-dev mailing list