pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/pkgtools/url2pkg Updated url2pkg to 2.1.



details:   https://anonhg.NetBSD.org/pkgsrc/rev/7b26e5737957
branches:  trunk
changeset: 519408:7b26e5737957
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Mon Oct 02 19:39:24 2006 +0000

description:
Updated url2pkg to 2.1.

Changes since 2.0:

- Made the dependency detection for Perl modules work again. The code
  does not assume to be run in a special directory anymore.

- Perl modules that use the prompt() function to query the user
  interactively can be handled. All questions are assumed to be answered
  by just pressing <enter>.

- Made url2pkg more robust when interpreting the output of MakeMaker.pm.
  Many Perl modules write additional things to stdout during the
  generation of the Makefile.

- The language for the *.f files is "fortran", not "f".

- Fixed the regular expression for prdownloads.sourceforge.net links, so
  that the distfile name is properly extracted.

diffstat:

 pkgtools/url2pkg/Makefile           |  17 ++++++++++++-----
 pkgtools/url2pkg/files/MakeMaker.pm |  18 ++++++++++++------
 pkgtools/url2pkg/files/url2pkg.pl   |  20 ++++++++++++--------
 3 files changed, 36 insertions(+), 19 deletions(-)

diffs (142 lines):

diff -r ced3c1be405b -r 7b26e5737957 pkgtools/url2pkg/Makefile
--- a/pkgtools/url2pkg/Makefile Mon Oct 02 19:35:43 2006 +0000
+++ b/pkgtools/url2pkg/Makefile Mon Oct 02 19:39:24 2006 +0000
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.44 2006/10/02 16:49:30 rillig Exp $
+# $NetBSD: Makefile,v 1.45 2006/10/02 19:39:24 rillig Exp $
 #
 
-DISTNAME=      url2pkg-2.0
+DISTNAME=      url2pkg-2.1
 CATEGORIES=    pkgtools
 MASTER_SITES=  # none
 DISTFILES=     # none
@@ -21,18 +21,25 @@
 INSTALLATION_DIRS=     bin ${PKGMANDIR}/man8 lib/url2pkg/ExtUtils
 
 do-extract:
-       cp ${FILESDIR}/url2pkg.pl ${WRKSRC}/
+       cd ${FILESDIR} && cp *.pl *.pm ${WRKSRC}/
+
+.include "../../mk/bsd.prefs.mk"
 
 SUBST_CLASSES+=                up
 SUBST_STAGE.up=                do-configure
-SUBST_FILES.up=                url2pkg.pl
+SUBST_FILES.up=                url2pkg.pl MakeMaker.pm
 SUBST_SED.up=          -e 's,@MAKE@,'${MAKE:Q}',g'
 SUBST_SED.up+=         -e 's,@PERL@,${PERL5},g'
 SUBST_SED.up+=         -e 's,@PERLLIBDIR@,${PREFIX}/lib/url2pkg,g'
+.if defined(BATCH)
+SUBST_SED.up+=         -e 's,@PKGSRCDIR@,/usr/pkgsrc,g'
+.else
+SUBST_SED.up+=         -e 's,@PKGSRCDIR@,${PKGSRCDIR},g'
+.endif
 
 do-install:
        ${INSTALL_SCRIPT} ${WRKSRC}/url2pkg.pl ${PREFIX}/bin/url2pkg
        ${INSTALL_MAN} ${FILESDIR}/url2pkg.8 ${PREFIX}/${PKGMANDIR}/man8
-       ${INSTALL_DATA} ${FILESDIR}/MakeMaker.pm ${PREFIX}/lib/url2pkg/ExtUtils/
+       ${INSTALL_DATA} ${WRKSRC}/MakeMaker.pm ${PREFIX}/lib/url2pkg/ExtUtils/
 
 .include "../../mk/bsd.pkg.mk"
diff -r ced3c1be405b -r 7b26e5737957 pkgtools/url2pkg/files/MakeMaker.pm
--- a/pkgtools/url2pkg/files/MakeMaker.pm       Mon Oct 02 19:35:43 2006 +0000
+++ b/pkgtools/url2pkg/files/MakeMaker.pm       Mon Oct 02 19:39:24 2006 +0000
@@ -10,28 +10,28 @@
 use strict;
 use warnings;
 
+use constant conf_pkgsrcdir    => '@PKGSRCDIR@';
+
 BEGIN {
        use Exporter;
        use vars qw(@ISA @EXPORT);
        @ISA = qw(Exporter);
-       @EXPORT = qw(WriteMakefile);
+       @EXPORT = qw(WriteMakefile prompt);
 }
 
-use constant pkgsrcdir => "../..";
-
 # Finds and returns the category a given package lies in.
 # If the package does not exist, C<undef> is returned.
 # If the package exists more than once, it is unspecified which
 # of the categories is returned.
 sub find_category($) {
        my ($pkg) = @_;
-       my $retval;
+       my ($retval, $pkgsrcdir);
 
-       opendir(D, pkgsrcdir) or die;
+       opendir(D, conf_pkgsrcdir) or die;
        foreach my $cat (readdir(D)) {
                next if ($cat =~ qr"^\.");
 
-               if (-d (sprintf("%s/%s/%s", pkgsrcdir, $cat, $pkg))) {
+               if (-d (conf_pkgsrcdir."/${cat}/${pkg}")) {
                        $retval = $cat;
                }
        }
@@ -67,4 +67,10 @@
        }
 }
 
+sub prompt(@) {
+       my ($message, $default) = @_;
+
+       return $default || "";
+}
+
 1;
diff -r ced3c1be405b -r 7b26e5737957 pkgtools/url2pkg/files/url2pkg.pl
--- a/pkgtools/url2pkg/files/url2pkg.pl Mon Oct 02 19:35:43 2006 +0000
+++ b/pkgtools/url2pkg/files/url2pkg.pl Mon Oct 02 19:39:24 2006 +0000
@@ -1,5 +1,5 @@
 #! @PERL@
-# $NetBSD: url2pkg.pl,v 1.1 2006/10/02 16:49:30 rillig Exp $
+# $NetBSD: url2pkg.pl,v 1.2 2006/10/02 19:39:24 rillig Exp $
 #
 
 use strict;
@@ -139,7 +139,11 @@
                open(DEPS, "cd ${abs_wrksrc} && perl -I${perllibdir} Makefile.PL |") or die;
                while (defined(my $dep = <DEPS>)) {
                        chomp($dep);
-                       push(@depends, $dep);
+                       if ($dep =~ qr"\.\./\.\./") {
+                               # Many Perl modules write other things to
+                               # stdout, so filter them out.
+                               push(@depends, $dep);
+                       }
                }
                close(DEPS) or die;
 
@@ -175,13 +179,13 @@
        my $c_files = `cd $abs_wrksrc && find * -type f -name "*.c" -print 2>/dev/null`;
        my $cxx_files = `cd $abs_wrksrc && find * -type f "(" -name "*.cpp" -o -name "*.cc" -o -name "*.C" ")" -print 2>/dev/null`;
        my $f_files = `cd $abs_wrksrc && find * -type f -name "*.f" -print 2>/dev/null`;
-       my $languages = {};
+       my @languages;
 
-       $c_files =~ qr"\S" and $languages->{"c"} = true;
-       $cxx_files =~ qr"\S" and $languages->{"c++"} = true;
-       $f_files =~ qr"\S" and $languages->{"f"} = true;
+       $c_files =~ qr"\S" and push(@languages, "c");
+       $cxx_files =~ qr"\S" and push(@languages, "c++");
+       $f_files =~ qr"\S" and push(@languages, "fortran");
 
-       my $use_languages = join(" ", sort(keys(%{$languages})));
+       my $use_languages = join(" ", @languages);
        if ($use_languages eq "") {
                $use_languages = "# none";
        }
@@ -234,7 +238,7 @@
        }
 
        if (!$found) {
-               if ($url =~ qr"^http://prdownloads\.sourceforge\.net/([^/]*)/[^/]*\?download$") {
+               if ($url =~ qr"^http://prdownloads\.sourceforge\.net/([^/]*)/([^/]+)\?download$") {
                        my $pkgbase = $1;
                        $distfile = $2;
 



Home | Main Index | Thread Index | Old Index