pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/pkgtools/url2pkg pkgtools/url2pkg: update to 2.36



details:   https://anonhg.NetBSD.org/pkgsrc/rev/f444d67c7a2f
branches:  trunk
changeset: 339573:f444d67c7a2f
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Thu Sep 12 18:23:00 2019 +0000

description:
pkgtools/url2pkg: update to 2.36

Changes since 2.35:

* Added support for Module::Build Perl modules.

diffstat:

 pkgtools/url2pkg/Makefile           |   5 +-
 pkgtools/url2pkg/PLIST              |   3 +-
 pkgtools/url2pkg/files/Build.pm     |  89 +++++++++++++++++++++++++++++++++++++
 pkgtools/url2pkg/files/MakeMaker.pm |   4 +-
 pkgtools/url2pkg/files/url2pkg.pl   |  38 +++++++++------
 pkgtools/url2pkg/files/url2pkg.t    |  19 +++++++-
 6 files changed, 137 insertions(+), 21 deletions(-)

diffs (truncated from 301 to 300 lines):

diff -r e787b1d9438d -r f444d67c7a2f pkgtools/url2pkg/Makefile
--- a/pkgtools/url2pkg/Makefile Thu Sep 12 18:08:05 2019 +0000
+++ b/pkgtools/url2pkg/Makefile Thu Sep 12 18:23:00 2019 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.99 2019/09/12 05:49:03 rillig Exp $
+# $NetBSD: Makefile,v 1.100 2019/09/12 18:23:00 rillig Exp $
 
-PKGNAME=       url2pkg-2.35
+PKGNAME=       url2pkg-2.36
 CATEGORIES=    pkgtools
 
 MAINTAINER=    rillig%NetBSD.org@localhost
@@ -34,6 +34,7 @@
 do-install:
        ${INSTALL_SCRIPT} ${WRKSRC}/url2pkg.pl ${DESTDIR}${PREFIX}/bin/url2pkg
        ${INSTALL_MAN} ${FILESDIR}/url2pkg.8 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man8
+       ${INSTALL_DATA} ${WRKSRC}/Build.pm ${DESTDIR}${PREFIX}/lib/url2pkg/Module/
        ${INSTALL_DATA} ${WRKSRC}/MakeMaker.pm ${DESTDIR}${PREFIX}/lib/url2pkg/ExtUtils/
        ${INSTALL_DATA} ${WRKSRC}/setuptools.py ${DESTDIR}${PREFIX}/lib/url2pkg/
 
diff -r e787b1d9438d -r f444d67c7a2f pkgtools/url2pkg/PLIST
--- a/pkgtools/url2pkg/PLIST    Thu Sep 12 18:08:05 2019 +0000
+++ b/pkgtools/url2pkg/PLIST    Thu Sep 12 18:23:00 2019 +0000
@@ -1,5 +1,6 @@
-@comment $NetBSD: PLIST,v 1.4 2019/08/18 11:26:33 rillig Exp $
+@comment $NetBSD: PLIST,v 1.5 2019/09/12 18:23:00 rillig Exp $
 bin/url2pkg
 lib/url2pkg/ExtUtils/MakeMaker.pm
+lib/url2pkg/Module/Build.pm
 lib/url2pkg/setuptools.py
 man/man8/url2pkg.8
diff -r e787b1d9438d -r f444d67c7a2f pkgtools/url2pkg/files/Build.pm
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/url2pkg/files/Build.pm   Thu Sep 12 18:23:00 2019 +0000
@@ -0,0 +1,89 @@
+# -*-perl-*-
+
+# Copyright (c) 2019 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Roland Illig.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+# This is a drop-in replacement for the Module::Build 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 Module::Build;
+
+use strict;
+use warnings FATAL => 'all';
+
+our $VERSION = 0.4224; # from Perl-5.30
+
+sub url2pkg_write_dependencies($$$) {
+       my ($self, $varname, $key) = @_;
+       return unless defined $self->{$key};
+
+       my $deps = $self->{$key};
+       foreach my $item (keys %$deps) {
+               my $pkgbase = "p5-$item" =~ s/::/-/gr;
+               printf("%s\t%s>=%s\n", $varname, $pkgbase, $deps->{$item});
+       }
+}
+
+sub url2pkg_write_var($$$) {
+       my ($self, $varname, $value) = @_;
+       return unless defined($value) && $value ne "";
+       printf("var\t%s\t%s\n", $varname, $value);
+}
+
+sub VERSION($$) {
+       my ($class, $min_version) = @_;
+       return $min_version <= $VERSION;
+}
+
+sub new(%) {
+       my ($class, %args) = @_;
+       my $self = \%args;
+       bless($self, $class);
+       return $self;
+}
+
+sub create_build_script($) {
+       my ($self) = @_;
+
+       $self->url2pkg_write_dependencies("BUILD_DEPENDS", "configure_requires");
+       $self->url2pkg_write_dependencies("BUILD_DEPENDS", "build_requires");
+       $self->url2pkg_write_dependencies("DEPENDS", "requires");
+       $self->url2pkg_write_dependencies("TEST_DEPENDS", "test_requires");
+       $self->url2pkg_write_dependencies("#RECOMMENDS", "recommends");
+
+       $self->url2pkg_write_var("COMMENT", $self->{"dist_abstract"});
+       my $license = $self->{"license"} || "";
+       if ($license eq "perxl") {
+               $self->url2pkg_write_var("LICENSE", "\${PERL5_LICENSE}");
+       } elsif ($license ne "") {
+               $self->url2pkg_write_var("#LICENSE", "# TODO: $license (from Build.PL)")
+       }
+}
+
+1;
diff -r e787b1d9438d -r f444d67c7a2f pkgtools/url2pkg/files/MakeMaker.pm
--- a/pkgtools/url2pkg/files/MakeMaker.pm       Thu Sep 12 18:08:05 2019 +0000
+++ b/pkgtools/url2pkg/files/MakeMaker.pm       Thu Sep 12 18:23:00 2019 +0000
@@ -1,6 +1,6 @@
 # -*-perl-*-
 
-# Copyright (c) 2010 The NetBSD Foundation, Inc.
+# Copyright (c) 2010, 2019 The NetBSD Foundation, Inc.
 # All rights reserved.
 #
 # This code is derived from software contributed to The NetBSD Foundation
@@ -37,7 +37,7 @@
 require 5.013002;
 
 use strict;
-use warnings;
+use warnings FATAL => 'all';
 
 my $url2pkg_pkgsrcdir = '@PKGSRCDIR@';
 
diff -r e787b1d9438d -r f444d67c7a2f pkgtools/url2pkg/files/url2pkg.pl
--- a/pkgtools/url2pkg/files/url2pkg.pl Thu Sep 12 18:08:05 2019 +0000
+++ b/pkgtools/url2pkg/files/url2pkg.pl Thu Sep 12 18:23:00 2019 +0000
@@ -1,5 +1,5 @@
 #! @PERL5@
-# $NetBSD: url2pkg.pl,v 1.69 2019/09/12 05:56:59 rillig Exp $
+# $NetBSD: url2pkg.pl,v 1.70 2019/09/12 18:23:00 rillig Exp $
 #
 
 # Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -134,10 +134,10 @@
 
        my $i = 0;
        foreach my $line (@$lines) {
-               if ($line =~ qr"^\Q$varname\E(\+?=)([ \t]+)([^#\\]*?)(\s*)(#.*|)$") {
+               if ($line =~ qr"^#?\Q$varname\E(\+?=)([ \t]+)([^#\\]*?)(\s*)(#.*|)$") {
                        my ($op, $indent, $old_value, $space_after_value, $comment) = ($1, $2, $3, $4, $5);
 
-                       $lines->[$i] = "$varname$op$indent$new_value$space_after_value$comment";
+                       $lines->[$i] = "$varname$op$indent$new_value";
                        return true;
                }
                $i++;
@@ -208,7 +208,7 @@
 sub lines_index($$) {
        my ($lines, $re) = @_;
 
-       foreach my $i (0..$#$lines) {
+       foreach my $i (0 .. $#$lines) {
                return $i if $lines->[$i] =~ $re;
        }
        return -1;
@@ -275,11 +275,14 @@
 # the Makefile, thereby forming the fifth paragraph.
 our @extra_vars;
 
+# variables from the initial Makefile whose values are replaced
+our %update_vars;
+
 # these are inserted below the second paragraph in the Makefile.
 our @todos;
 
 # the package name is $pkgname_prefix${DISTNAME$pkgname_transform}.
-our $pkgname_prefix = "";  # example: ${PYPKGPREFIX}-
+our $pkgname_prefix = "";     # example: ${PYPKGPREFIX}-
 our $pkgname_transform = "";  # example: :S,-v,-,
 
 our $regenerate_distinfo = false;
@@ -326,9 +329,15 @@
        while (defined (my $line = <DEPS>)) {
                chomp($line);
 
-               next unless $line =~ qr"^(\w+)\t([^\s:>]+)(>[^\s:]+|)(?::(\.\./\.\./\S+))?$";
-               push(@dep_lines, [$1, $2, $3 || ">=0", $4 || ""]);
+               if ($line =~ qr"^(\w+)\t([^\s:>]+)(>[^\s:]+|)(?::(\.\./\.\./\S+))?$") {
+                       push(@dep_lines, [ $1, $2, $3 || ">=0", $4 || "" ]);
+               } elsif ($line =~ qr"^var\t(\S+)\t(.+)$") {
+                       $main::update_vars{$1} = $2;
+               } else {
+                       printf STDERR "url2pkg: unknown dependency line: %s\n", $line;
+               }
        }
+
        close(DEPS) or die;
 
        foreach my $dep_line (@dep_lines) {
@@ -401,9 +410,7 @@
 # devel/p5-Algorithm-CheckDigits
 sub adjust_perl_module_Build_PL() {
 
-       # TODO: Implement this similarly to the Makefile.PL mock below.
-
-       push(@todos, "Look for the dependencies in Build.PL.");
+       read_dependencies("cd '$abs_wrksrc' && perl -I$libdir -I. Build.PL", {}, "");
 
        push(@build_vars, var("PERL5_MODULE_TYPE", "=", "Module::Build"));
 }
@@ -448,7 +455,7 @@
        my $cmd = "cd '$abs_wrksrc' && $pythonbin setup.py build";
        my $env = {
                "PYTHONDONTWRITEBYTECODE" => "x",
-               "PYTHONPATH" => $libdir
+               "PYTHONPATH"              => $libdir
        };
        read_dependencies($cmd, $env, "py-");
 
@@ -709,8 +716,7 @@
        }
 }
 
-sub adjust_package_from_extracted_distfiles($)
-{
+sub adjust_package_from_extracted_distfiles($) {
        my ($url) = @_;
 
        chomp($abs_wrkdir = `$make show-var VARNAME=WRKDIR`);
@@ -758,8 +764,6 @@
 
        print("url2pkg> Adjusting the Makefile\n");
 
-       my $seen_marker = false;
-
        my @prev_lines = read_lines("Makefile");
        my $marker_index = lines_index(\@prev_lines, qr"^# url2pkg-marker");
        if ($marker_index == -1) {
@@ -801,6 +805,10 @@
 
        adjust_lines_python_module(\@lines, $url);
 
+       foreach my $varname (keys %update_vars) {
+               lines_set(\@lines, $varname, $update_vars{$varname});
+       }
+
        write_lines("Makefile", @lines);
 
        if ($regenerate_distinfo) {
diff -r e787b1d9438d -r f444d67c7a2f pkgtools/url2pkg/files/url2pkg.t
--- a/pkgtools/url2pkg/files/url2pkg.t  Thu Sep 12 18:08:05 2019 +0000
+++ b/pkgtools/url2pkg/files/url2pkg.t  Thu Sep 12 18:23:00 2019 +0000
@@ -1,5 +1,5 @@
 # -*- perl -*-
-# $NetBSD: url2pkg.t,v 1.9 2019/09/12 05:45:34 rillig Exp $
+# $NetBSD: url2pkg.t,v 1.10 2019/09/12 18:23:00 rillig Exp $
 
 require "url2pkg.pl";
 
@@ -83,6 +83,22 @@
        is_deeply($lines, ["VARNAME+=\tvalue appended"]);
 }
 
+sub test_lines_set__previously_with_comment() {
+       my $lines = ["LICENSE=\t# TODO: see mk/license.mk"];
+
+       lines_set($lines, "LICENSE", "\${PERL5_LICENSE}");
+
+       is_deeply($lines, ["LICENSE=\t\${PERL5_LICENSE}"]);
+}
+
+sub test_lines_set__not_found() {
+       my $lines = ["OLD_VAR=\told value # old comment"];
+
+       lines_set($lines, "NEW_VAR", "new value");
+
+       is_deeply($lines, ["OLD_VAR=\told value # old comment"]);
+}
+
 sub test_lines_index() {
        my $lines = ["1", "2", "345"];
 
@@ -243,6 +259,7 @@
        @main::includes = ();
        @main::build_vars = ();
        @main::extra_vars = ();
+       %main::update_vars = ();
        @main::todos = ();
 



Home | Main Index | Thread Index | Old Index