pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/pkgtools/url2pkg Took over maintainership from Hubert.



details:   https://anonhg.NetBSD.org/pkgsrc/rev/3a56ad3abaf8
branches:  trunk
changeset: 519383:3a56ad3abaf8
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Mon Oct 02 16:49:30 2006 +0000

description:
Took over maintainership from Hubert.

Rewrote url2pkg in Perl, enhancing it in several ways:

- Packages for Perl modules using MakeMaker can be generated almost
  completely. The only thing that usually needs to be filled out after
  running url2pkg is the DESCR file.

- USE_LANGUAGES is filled automatically.

- After generating the initial Makefile, the editor is run to let the
  user edit the Makefile. These changes are preserved as much as
  possible. (This had not been the case before.)

- Extending url2pkg has been made much easier by splitting the tasks that
  do the "magic" into small subroutines and by adding a detailed
  description of what these routines are supposed to do.

Set the version number to 2.0.

diffstat:

 pkgtools/url2pkg/DESCR              |   12 +-
 pkgtools/url2pkg/Makefile           |   37 +-
 pkgtools/url2pkg/PLIST              |    5 +-
 pkgtools/url2pkg/files/MakeMaker.pm |   70 +++++
 pkgtools/url2pkg/files/url2pkg      |  244 --------------------
 pkgtools/url2pkg/files/url2pkg.8    |    6 +-
 pkgtools/url2pkg/files/url2pkg.pl   |  431 ++++++++++++++++++++++++++++++++++++
 7 files changed, 534 insertions(+), 271 deletions(-)

diffs (truncated from 868 to 300 lines):

diff -r 0fb48fa5ffb4 -r 3a56ad3abaf8 pkgtools/url2pkg/DESCR
--- a/pkgtools/url2pkg/DESCR    Mon Oct 02 16:37:47 2006 +0000
+++ b/pkgtools/url2pkg/DESCR    Mon Oct 02 16:49:30 2006 +0000
@@ -1,9 +1,3 @@
-Shellscript that will take an URL of a source .tar.gz (or other)
-file, and perform some steps to generate a package:
-
- - setup a basic Makefile
- - run "make fetch" and "make makesum"
- - generate a dummy pkg/PLIST
- - run "make extract"
- - try to find out the WRKSRC (if needed)
- - try to find out of this package uses GNU auto-configure
+The url2pkg program creates a new pkgsrc package from only the URL of a
+distribution file. It is intended to help pkgsrc developers create new
+packages quickly and easily.
diff -r 0fb48fa5ffb4 -r 3a56ad3abaf8 pkgtools/url2pkg/Makefile
--- a/pkgtools/url2pkg/Makefile Mon Oct 02 16:37:47 2006 +0000
+++ b/pkgtools/url2pkg/Makefile Mon Oct 02 16:49:30 2006 +0000
@@ -1,31 +1,38 @@
-# $NetBSD: Makefile,v 1.43 2006/06/12 17:02:23 reed Exp $
+# $NetBSD: Makefile,v 1.44 2006/10/02 16:49:30 rillig Exp $
 #
 
-DISTNAME=      url2pkg-1.34
-CATEGORIES=    pkgtools sysutils
-MASTER_SITES=  # Nothing
-DISTFILES=     # Nothing
+DISTNAME=      url2pkg-2.0
+CATEGORIES=    pkgtools
+MASTER_SITES=  # none
+DISTFILES=     # none
 
-MAINTAINER=    hubertf%NetBSD.org@localhost
-HOMEPAGE=      # Nothing
+MAINTAINER=    rillig%NetBSD.org@localhost
+HOMEPAGE=      http://www.NetBSD.org/Documentation/pkgsrc/creating.html
 COMMENT=       Tool to automate initial steps in building a package
 
 PKG_INSTALLATION_TYPES=        overwrite pkgviews
 
 WRKSRC=                ${WRKDIR}
-EXTRACT_ONLY=  # empty
 NO_CHECKSUM=   yes
-NO_CONFIGURE=  yes
-USE_LANGUAGES= # empty
+NO_BUILD=      yes
+USE_LANGUAGES= # none
+USE_TOOLS+=    perl:run
+
+INSTALLATION_DIRS=     bin ${PKGMANDIR}/man8 lib/url2pkg/ExtUtils
 
-INSTALLATION_DIRS=     bin ${PKGMANDIR}/man8
+do-extract:
+       cp ${FILESDIR}/url2pkg.pl ${WRKSRC}/
 
-do-build:
-       ${SED} -e 's|@MAKE@|${MAKE}|g'          \
-       < ${FILESDIR}/url2pkg > ${WRKSRC}/url2pkg
+SUBST_CLASSES+=                up
+SUBST_STAGE.up=                do-configure
+SUBST_FILES.up=                url2pkg.pl
+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'
 
 do-install:
-       ${INSTALL_SCRIPT} ${WRKSRC}/url2pkg ${PREFIX}/bin/url2pkg
+       ${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/
 
 .include "../../mk/bsd.pkg.mk"
diff -r 0fb48fa5ffb4 -r 3a56ad3abaf8 pkgtools/url2pkg/PLIST
--- a/pkgtools/url2pkg/PLIST    Mon Oct 02 16:37:47 2006 +0000
+++ b/pkgtools/url2pkg/PLIST    Mon Oct 02 16:49:30 2006 +0000
@@ -1,3 +1,6 @@
-@comment $NetBSD: PLIST,v 1.1 2001/10/31 21:19:12 zuntum Exp $
+@comment $NetBSD: PLIST,v 1.2 2006/10/02 16:49:30 rillig Exp $
 bin/url2pkg
+lib/url2pkg/ExtUtils/MakeMaker.pm
 man/man8/url2pkg.8
+@dirrm lib/url2pkg/ExtUtils
+@dirrm lib/url2pkg
diff -r 0fb48fa5ffb4 -r 3a56ad3abaf8 pkgtools/url2pkg/files/MakeMaker.pm
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/url2pkg/files/MakeMaker.pm       Mon Oct 02 16:49:30 2006 +0000
@@ -0,0 +1,70 @@
+# -*-perl-*-
+
+# This is a drop-in replacement for the MakeMaker Perl module. Instead
+# of generating a Makefile, it extracts the dependency information for
+# other Perl modules. It is used to simplify the generation of pkgsrc
+# packages for Perl modules.
+
+package ExtUtils::MakeMaker;
+
+use strict;
+use warnings;
+
+BEGIN {
+       use Exporter;
+       use vars qw(@ISA @EXPORT);
+       @ISA = qw(Exporter);
+       @EXPORT = qw(WriteMakefile);
+}
+
+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;
+
+       opendir(D, pkgsrcdir) or die;
+       foreach my $cat (readdir(D)) {
+               next if ($cat =~ qr"^\.");
+
+               if (-d (sprintf("%s/%s/%s", pkgsrcdir, $cat, $pkg))) {
+                       $retval = $cat;
+               }
+       }
+       closedir(D);
+       return $retval;
+}
+
+sub WriteMakefile(%) {
+       my (%options) = @_;
+
+       if (exists($options{"PREREQ_PM"})) {
+               my $deps = $options{"PREREQ_PM"};
+
+               foreach my $dep (sort(keys(%{$deps}))) {
+                       my ($ver, $pkgbase, $category);
+
+                       $ver = $deps->{$dep};
+                       ($pkgbase = "p5-${dep}") =~ s/::/-/g;
+                       $category = find_category($pkgbase);
+
+                       if (defined($category)) {
+                               printf("%s>=%s:../../%s/%s\n", $pkgbase, $ver, $category, $pkgbase);
+
+                       } else {
+                               # If the package does not exist but the
+                               # Perl module can be loaded, assume that
+                               # no extra dependency is needed. Otherwise fail.
+                               if (!eval(sprintf("use %s %s; 1;", $dep, $ver))) {
+                                       die("$0: ERROR: No pkgsrc package found for dependency ${dep}>=${ver}.\n$@\n");
+                               }
+                       }
+               }
+       }
+}
+
+1;
diff -r 0fb48fa5ffb4 -r 3a56ad3abaf8 pkgtools/url2pkg/files/url2pkg
--- a/pkgtools/url2pkg/files/url2pkg    Mon Oct 02 16:37:47 2006 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,244 +0,0 @@
-#!/bin/sh
-#
-# $NetBSD: url2pkg,v 1.38 2006/06/12 17:02:23 reed Exp $
-#
-# url2pkg
-# (c) 1999-2002 Hubert Feyrer <hubert%feyrer.de@localhost>
-#
-
-if [ "$MAKE" = "" ]; then
-       MAKE=@MAKE@
-fi
-
-if [ "$PKGEDITOR" != "" ]; then
-       editor="$PKGEDITOR"
-elif [ "$EDITOR" != "" ]; then
-       editor="$EDITOR"
-else
-       editor="vi"
-fi
-
-if [ "$PKGMAINTAINER" != "" ]; then
-       email_maintainer="$PKGMAINTAINER"
-elif [ "$REPLYTO" != "" ]; then
-       email_maintainer="$REPLYTO"
-else
-       email_maintainer="INSERT_YOUR_MAIL_ADDRESS_HERE"
-fi
-
-if [ ! -f ../../mk/bsd.pkg.mk ]; then
-       echo "Run this in .../pkgsrc/foo/bar !"
-       exit 1
-fi
-
-if [ ! -f w*/.extract_done ]; then
-       if [ "$1" = "" ]; then
-               echo -n 'URL: '
-               read url
-       else
-               url="$1"
-       fi
-
-       found=0
-       for A in `cat ../../mk/fetch/sites.mk`; do
-               if [ "`expr "$A" : ".*+="`" -gt 0 ]; then
-                       master_site="`echo $A|cut -f1 -d +`"
-               fi
-               if [ ! "${A}" = "\\" ]; then
-               if [ `expr "$url" : "$A"` -gt 0 ]; then
-                       found=1
-                       DISTNAME=`expr "$url" : '.*/\([^/?]*\)'`
-                       name=`expr "$url" : "${A}\(.*\)/[^/]*\$"`
-                       MASTER_SITES="\${${master_site}:=${name}/}"
-                       case "${master_site}" in
-                       "MASTER_SITE_SOURCEFORGE")
-                               HOMEPAGE="http://$name.sourceforge.net/"; ; ;;
-                       "MASTER_SITE_GNU")
-                               HOMEPAGE="http://www.gnu.org/software/$name/"; ; ;;
-                       esac
-                       HOMEPAGE=`expr "$url" : '\(.*/\)[^/]*$'`
-                       break
-               fi
-               fi
-       done
-
-       if [ $found = 0 ]; then
-               prdownloads="http://prdownloads.sourceforge.net/";
-               if [ `expr "$url" : "$prdownloads.*"` -gt 0 ]; then
-                       DISTNAME=`expr "$url" : '.*/\([^/?]*\)'`
-                       sfname=`expr "$url" : "${prdownloads}\(.*\)/[^/]*\$"`
-                       MASTER_SITES='${MASTER_SITE_SOURCEFORGE:='"$sfname"'/}'
-                       HOMEPAGE="http://$sfname.sourceforge.net/";
-                       found=1
-               fi
-       fi
-
-       if [ $found = 0 ]; then
-               DISTNAME=`expr "$url" : '.*/\([^/]*\)$'`
-               MASTER_SITES=`expr "$url" : '\(.*/\)[^/]*$'`
-               HOMEPAGE=$MASTER_SITES
-       fi
-
-       case "$DISTNAME" in
-       *.tgz)          EXTRACT_SUFX=".tgz" 
-                       DISTNAME=`expr ${DISTNAME} : '\(.*\)\.[^.]*'`
-                       ;;
-       *.tar.Z)        EXTRACT_SUFX=.tar.Z 
-                       DISTNAME=`expr ${DISTNAME} : '\(.*\)\.[^.]*\.[^.]*'`
-                       ;;
-       *.tar.gz)       EXTRACT_SUFX=.tar.gz 
-                       DISTNAME=`expr ${DISTNAME} : '\(.*\)\.[^.]*\.[^.]*'`
-                       ;;
-        *.tar.bz2)     EXTRACT_SUFX=.tar.bz2
-                       DISTNAME=`expr ${DISTNAME} : '\(.*\)\.[^.]*\.[^.]*'`
-                       ;;
-       *)              EXTRACT_SUFX=`expr ${DISTNAME} : '.*\(\.[^.]*\)'`
-                       DISTNAME=`expr ${DISTNAME} : '\(.*\)\.[^.]*'`
-                       ;;
-       esac
-       
-       if [ -f Makefile ]; then
-               mv Makefile Makefile.BAK
-       fi
-
-       category=`pwd | sed 's|^.*/\([^/]*\)/[^/]*$|\1|'`
-       (
-       echo '# $'NetBSD'$'
-       echo '#'
-       echo ""
-       echo "DISTNAME=         $DISTNAME"
-       echo "CATEGORIES=               $category"
-       echo "MASTER_SITES=             $MASTER_SITES"
-       if [ "$EXTRACT_SUFX" != ".tar.gz" ]; then
-               echo "EXTRACT_SUFX=             ${EXTRACT_SUFX}"
-       fi
-       echo ""
-       echo "MAINTAINER=               $email_maintainer"
-       echo "HOMEPAGE=         $HOMEPAGE"
-       echo "COMMENT=          SHORT_DESCRIPTION_OF_THE_PACKAGE"
-       echo ""
-       echo '.include "../../mk/bsd.pkg.mk"'
-       ) >Makefile
-       
-       echo '@comment $'NetBSD'$' > PLIST
-       touch distinfo
-       
-       ${editor} +5 Makefile
-       
-       echo "Running 'make makesum' ..."
-       $MAKE makesum
-       
-       echo "Running 'make extract' ..."
-       $MAKE extract
-fi
-
-#
-# Exec Artificial Intelligence Modules here ...
-#
-wrksrc=`cd w* ; echo *`



Home | Main Index | Thread Index | Old Index