Thu Sep 12 18:23:00 2019 UTC ()
pkgtools/url2pkg: update to 2.36

Changes since 2.35:

* Added support for Module::Build Perl modules.


(rillig)
diff -r1.99 -r1.100 pkgsrc/pkgtools/url2pkg/Makefile
diff -r1.4 -r1.5 pkgsrc/pkgtools/url2pkg/PLIST
diff -r0 -r1.1 pkgsrc/pkgtools/url2pkg/files/Build.pm
diff -r1.10 -r1.11 pkgsrc/pkgtools/url2pkg/files/MakeMaker.pm
diff -r1.69 -r1.70 pkgsrc/pkgtools/url2pkg/files/url2pkg.pl
diff -r1.9 -r1.10 pkgsrc/pkgtools/url2pkg/files/url2pkg.t

cvs diff -r1.99 -r1.100 pkgsrc/pkgtools/url2pkg/Makefile (expand / switch to unified diff)

--- pkgsrc/pkgtools/url2pkg/Makefile 2019/09/12 05:49:03 1.99
+++ pkgsrc/pkgtools/url2pkg/Makefile 2019/09/12 18:23:00 1.100
@@ -1,16 +1,16 @@ @@ -1,16 +1,16 @@
1# $NetBSD: Makefile,v 1.99 2019/09/12 05:49:03 rillig Exp $ 1# $NetBSD: Makefile,v 1.100 2019/09/12 18:23:00 rillig Exp $
2 2
3PKGNAME= url2pkg-2.35 3PKGNAME= url2pkg-2.36
4CATEGORIES= pkgtools 4CATEGORIES= pkgtools
5 5
6MAINTAINER= rillig@NetBSD.org 6MAINTAINER= rillig@NetBSD.org
7HOMEPAGE= http://www.NetBSD.org/docs/pkgsrc/creating.html 7HOMEPAGE= http://www.NetBSD.org/docs/pkgsrc/creating.html
8COMMENT= Tool to automate initial steps in building a package 8COMMENT= Tool to automate initial steps in building a package
9LICENSE= 2-clause-bsd 9LICENSE= 2-clause-bsd
10 10
11WRKSRC= ${WRKDIR} 11WRKSRC= ${WRKDIR}
12NO_CHECKSUM= yes 12NO_CHECKSUM= yes
13NO_BUILD= yes 13NO_BUILD= yes
14USE_LANGUAGES= # none 14USE_LANGUAGES= # none
15USE_TOOLS+= perl:run 15USE_TOOLS+= perl:run
16AUTO_MKDIRS= yes 16AUTO_MKDIRS= yes
@@ -24,18 +24,19 @@ do-test: @@ -24,18 +24,19 @@ do-test:
24.include "../../mk/bsd.prefs.mk" 24.include "../../mk/bsd.prefs.mk"
25 25
26SUBST_CLASSES+= up 26SUBST_CLASSES+= up
27SUBST_STAGE.up= do-configure 27SUBST_STAGE.up= do-configure
28SUBST_MESSAGE.up= Replacing variable placeholders 28SUBST_MESSAGE.up= Replacing variable placeholders
29SUBST_FILES.up= url2pkg.pl MakeMaker.pm 29SUBST_FILES.up= url2pkg.pl MakeMaker.pm
30SUBST_VARS.up= MAKE PERL5 PYTHONBIN 30SUBST_VARS.up= MAKE PERL5 PYTHONBIN
31SUBST_SED.up+= -e 's,@LIBDIR@,${PREFIX}/lib/url2pkg,g' 31SUBST_SED.up+= -e 's,@LIBDIR@,${PREFIX}/lib/url2pkg,g'
32SUBST_SED.up+= -e 's,@PKGSRCDIR@,${BATCH:D/usr/pkgsrc:U${PKGSRCDIR}},g' 32SUBST_SED.up+= -e 's,@PKGSRCDIR@,${BATCH:D/usr/pkgsrc:U${PKGSRCDIR}},g'
33 33
34do-install: 34do-install:
35 ${INSTALL_SCRIPT} ${WRKSRC}/url2pkg.pl ${DESTDIR}${PREFIX}/bin/url2pkg 35 ${INSTALL_SCRIPT} ${WRKSRC}/url2pkg.pl ${DESTDIR}${PREFIX}/bin/url2pkg
36 ${INSTALL_MAN} ${FILESDIR}/url2pkg.8 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man8 36 ${INSTALL_MAN} ${FILESDIR}/url2pkg.8 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man8
 37 ${INSTALL_DATA} ${WRKSRC}/Build.pm ${DESTDIR}${PREFIX}/lib/url2pkg/Module/
37 ${INSTALL_DATA} ${WRKSRC}/MakeMaker.pm ${DESTDIR}${PREFIX}/lib/url2pkg/ExtUtils/ 38 ${INSTALL_DATA} ${WRKSRC}/MakeMaker.pm ${DESTDIR}${PREFIX}/lib/url2pkg/ExtUtils/
38 ${INSTALL_DATA} ${WRKSRC}/setuptools.py ${DESTDIR}${PREFIX}/lib/url2pkg/ 39 ${INSTALL_DATA} ${WRKSRC}/setuptools.py ${DESTDIR}${PREFIX}/lib/url2pkg/
39 40
40.include "../../lang/python/application.mk" 41.include "../../lang/python/application.mk"
41.include "../../mk/bsd.pkg.mk" 42.include "../../mk/bsd.pkg.mk"

cvs diff -r1.4 -r1.5 pkgsrc/pkgtools/url2pkg/PLIST (expand / switch to unified diff)

--- pkgsrc/pkgtools/url2pkg/PLIST 2019/08/18 11:26:33 1.4
+++ pkgsrc/pkgtools/url2pkg/PLIST 2019/09/12 18:23:00 1.5
@@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
1@comment $NetBSD: PLIST,v 1.4 2019/08/18 11:26:33 rillig Exp $ 1@comment $NetBSD: PLIST,v 1.5 2019/09/12 18:23:00 rillig Exp $
2bin/url2pkg 2bin/url2pkg
3lib/url2pkg/ExtUtils/MakeMaker.pm 3lib/url2pkg/ExtUtils/MakeMaker.pm
 4lib/url2pkg/Module/Build.pm
4lib/url2pkg/setuptools.py 5lib/url2pkg/setuptools.py
5man/man8/url2pkg.8 6man/man8/url2pkg.8

File Added: pkgsrc/pkgtools/url2pkg/files/Build.pm
# -*-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;

cvs diff -r1.10 -r1.11 pkgsrc/pkgtools/url2pkg/files/MakeMaker.pm (expand / switch to unified diff)

--- pkgsrc/pkgtools/url2pkg/files/MakeMaker.pm 2019/09/11 05:25:55 1.10
+++ pkgsrc/pkgtools/url2pkg/files/MakeMaker.pm 2019/09/12 18:23:00 1.11
@@ -1,16 +1,16 @@ @@ -1,16 +1,16 @@
1# -*-perl-*- 1# -*-perl-*-
2 2
3# Copyright (c) 2010 The NetBSD Foundation, Inc. 3# Copyright (c) 2010, 2019 The NetBSD Foundation, Inc.
4# All rights reserved. 4# All rights reserved.
5# 5#
6# This code is derived from software contributed to The NetBSD Foundation 6# This code is derived from software contributed to The NetBSD Foundation
7# by Roland Illig. 7# by Roland Illig.
8# 8#
9# Redistribution and use in source and binary forms, with or without 9# Redistribution and use in source and binary forms, with or without
10# modification, are permitted provided that the following conditions 10# modification, are permitted provided that the following conditions
11# are met: 11# are met:
12# 1. Redistributions of source code must retain the above copyright 12# 1. Redistributions of source code must retain the above copyright
13# notice, this list of conditions and the following disclaimer. 13# notice, this list of conditions and the following disclaimer.
14# 2. Redistributions in binary form must reproduce the above copyright 14# 2. Redistributions in binary form must reproduce the above copyright
15# notice, this list of conditions and the following disclaimer in the 15# notice, this list of conditions and the following disclaimer in the
16# documentation and/or other materials provided with the distribution. 16# documentation and/or other materials provided with the distribution.
@@ -27,27 +27,27 @@ @@ -27,27 +27,27 @@
27# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28# POSSIBILITY OF SUCH DAMAGE. 28# POSSIBILITY OF SUCH DAMAGE.
29 29
30# This is a drop-in replacement for the MakeMaker Perl module. Instead 30# This is a drop-in replacement for the MakeMaker Perl module. Instead
31# of generating a Makefile, it extracts the dependency information for 31# of generating a Makefile, it extracts the dependency information for
32# other Perl modules. It is used to simplify the generation of pkgsrc 32# other Perl modules. It is used to simplify the generation of pkgsrc
33# packages for Perl modules. 33# packages for Perl modules.
34 34
35package ExtUtils::MakeMaker; 35package ExtUtils::MakeMaker;
36 36
37require 5.013002; 37require 5.013002;
38 38
39use strict; 39use strict;
40use warnings; 40use warnings FATAL => 'all';
41 41
42my $url2pkg_pkgsrcdir = '@PKGSRCDIR@'; 42my $url2pkg_pkgsrcdir = '@PKGSRCDIR@';
43 43
44BEGIN { 44BEGIN {
45 use Exporter; 45 use Exporter;
46 use vars qw(@ISA @EXPORT); 46 use vars qw(@ISA @EXPORT);
47 @ISA = qw(Exporter); 47 @ISA = qw(Exporter);
48} 48}
49 49
50# From lib/perl5/5.18.0/ExtUtils/MakeMaker.pm 50# From lib/perl5/5.18.0/ExtUtils/MakeMaker.pm
51our $VERSION = '6.66'; 51our $VERSION = '6.66';
52 52
53our $Verbose = 0; # exported 53our $Verbose = 0; # exported

cvs diff -r1.69 -r1.70 pkgsrc/pkgtools/url2pkg/files/Attic/url2pkg.pl (expand / switch to unified diff)

--- pkgsrc/pkgtools/url2pkg/files/Attic/url2pkg.pl 2019/09/12 05:56:59 1.69
+++ pkgsrc/pkgtools/url2pkg/files/Attic/url2pkg.pl 2019/09/12 18:23:00 1.70
@@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
1#! @PERL5@ 1#! @PERL5@
2# $NetBSD: url2pkg.pl,v 1.69 2019/09/12 05:56:59 rillig Exp $ 2# $NetBSD: url2pkg.pl,v 1.70 2019/09/12 18:23:00 rillig Exp $
3# 3#
4 4
5# Copyright (c) 2010 The NetBSD Foundation, Inc. 5# Copyright (c) 2010 The NetBSD Foundation, Inc.
6# All rights reserved. 6# All rights reserved.
7# 7#
8# This code is derived from software contributed to The NetBSD Foundation 8# This code is derived from software contributed to The NetBSD Foundation
9# by Roland Illig. 9# by Roland Illig.
10# 10#
11# Redistribution and use in source and binary forms, with or without 11# Redistribution and use in source and binary forms, with or without
12# modification, are permitted provided that the following conditions 12# modification, are permitted provided that the following conditions
13# are met: 13# are met:
14# 1. Redistributions of source code must retain the above copyright 14# 1. Redistributions of source code must retain the above copyright
15# notice, this list of conditions and the following disclaimer. 15# notice, this list of conditions and the following disclaimer.
@@ -124,30 +124,30 @@ sub lines_add_vars($$) { @@ -124,30 +124,30 @@ sub lines_add_vars($$) {
124 next if $value eq ""; 124 next if $value eq "";
125 my $tabs = "\t" x (($width - length("$name$op") + 7) / 8); 125 my $tabs = "\t" x (($width - length("$name$op") + 7) / 8);
126 push(@$lines, "$name$op$tabs$value"); 126 push(@$lines, "$name$op$tabs$value");
127 } 127 }
128 push(@$lines, ""); 128 push(@$lines, "");
129} 129}
130 130
131# changes the value of an existing variable in the lines. 131# changes the value of an existing variable in the lines.
132sub lines_set($$$) { 132sub lines_set($$$) {
133 my ($lines, $varname, $new_value) = @_; 133 my ($lines, $varname, $new_value) = @_;
134 134
135 my $i = 0; 135 my $i = 0;
136 foreach my $line (@$lines) { 136 foreach my $line (@$lines) {
137 if ($line =~ qr"^\Q$varname\E(\+?=)([ \t]+)([^#\\]*?)(\s*)(#.*|)$") { 137 if ($line =~ qr"^#?\Q$varname\E(\+?=)([ \t]+)([^#\\]*?)(\s*)(#.*|)$") {
138 my ($op, $indent, $old_value, $space_after_value, $comment) = ($1, $2, $3, $4, $5); 138 my ($op, $indent, $old_value, $space_after_value, $comment) = ($1, $2, $3, $4, $5);
139 139
140 $lines->[$i] = "$varname$op$indent$new_value$space_after_value$comment"; 140 $lines->[$i] = "$varname$op$indent$new_value";
141 return true; 141 return true;
142 } 142 }
143 $i++; 143 $i++;
144 } 144 }
145 145
146 return false; 146 return false;
147} 147}
148 148
149# appends to the value of an existing variable in the lines. 149# appends to the value of an existing variable in the lines.
150sub lines_append($$$) { 150sub lines_append($$$) {
151 my ($lines, $varname, $value) = @_; 151 my ($lines, $varname, $value) = @_;
152 152
153 return if $value eq ""; 153 return if $value eq "";
@@ -198,27 +198,27 @@ sub lines_remove_if($$$) { @@ -198,27 +198,27 @@ sub lines_remove_if($$$) {
198 splice(@$lines, $i, 1); 198 splice(@$lines, $i, 1);
199 return true; 199 return true;
200 } 200 }
201 } 201 }
202 $i++; 202 $i++;
203 } 203 }
204 204
205 return false; 205 return false;
206} 206}
207 207
208sub lines_index($$) { 208sub lines_index($$) {
209 my ($lines, $re) = @_; 209 my ($lines, $re) = @_;
210 210
211 foreach my $i (0..$#$lines) { 211 foreach my $i (0 .. $#$lines) {
212 return $i if $lines->[$i] =~ $re; 212 return $i if $lines->[$i] =~ $re;
213 } 213 }
214 return -1; 214 return -1;
215} 215}
216 216
217sub make(@) { 217sub make(@) {
218 my @args = @_; 218 my @args = @_;
219 219
220 (system { $make } ($make, @args)) == 0 or die; 220 (system { $make } ($make, @args)) == 0 or die;
221} 221}
222 222
223# The following adjust_* subroutines are called after the distfiles have 223# The following adjust_* subroutines are called after the distfiles have
224# been downloaded and extracted. They inspect the extracted files 224# been downloaded and extracted. They inspect the extracted files
@@ -265,31 +265,34 @@ our @bl3_lines; @@ -265,31 +265,34 @@ our @bl3_lines;
265# a list of pathnames relative to the package path. 265# a list of pathnames relative to the package path.
266# All these files will be included at the bottom of the Makefile. 266# All these files will be included at the bottom of the Makefile.
267our @includes; 267our @includes;
268 268
269# a list of variable assignments that will make up the fourth 269# a list of variable assignments that will make up the fourth
270# paragraph of the package Makefile, where the build configuration 270# paragraph of the package Makefile, where the build configuration
271# takes place. 271# takes place.
272our @build_vars; 272our @build_vars;
273 273
274# similar to the @build_vars, but separated by an empty line in 274# similar to the @build_vars, but separated by an empty line in
275# the Makefile, thereby forming the fifth paragraph. 275# the Makefile, thereby forming the fifth paragraph.
276our @extra_vars; 276our @extra_vars;
277 277
 278# variables from the initial Makefile whose values are replaced
 279our %update_vars;
 280
278# these are inserted below the second paragraph in the Makefile. 281# these are inserted below the second paragraph in the Makefile.
279our @todos; 282our @todos;
280 283
281# the package name is $pkgname_prefix${DISTNAME$pkgname_transform}. 284# the package name is $pkgname_prefix${DISTNAME$pkgname_transform}.
282our $pkgname_prefix = ""; # example: ${PYPKGPREFIX}- 285our $pkgname_prefix = ""; # example: ${PYPKGPREFIX}-
283our $pkgname_transform = ""; # example: :S,-v,-, 286our $pkgname_transform = ""; # example: :S,-v,-,
284 287
285our $regenerate_distinfo = false; 288our $regenerate_distinfo = false;
286 289
287# Example: 290# Example:
288# add_dependency("DEPENDS", "package", ">=1", "../../category/package"); 291# add_dependency("DEPENDS", "package", ">=1", "../../category/package");
289# 292#
290sub add_dependency($$$$) { 293sub add_dependency($$$$) {
291 my ($type, $pkgbase, $constraint, $dep_dir) = @_; 294 my ($type, $pkgbase, $constraint, $dep_dir) = @_;
292 295
293 if ($dep_dir ne "" && -f "$dep_dir/buildlink3.mk") { 296 if ($dep_dir ne "" && -f "$dep_dir/buildlink3.mk") {
294 # TODO: add type to bl3_lines (BUILDLINK_DEPENDS) 297 # TODO: add type to bl3_lines (BUILDLINK_DEPENDS)
295 # TODO: add constraint to bl3_lines (BUILDLINK_API_DEPENDS) 298 # TODO: add constraint to bl3_lines (BUILDLINK_API_DEPENDS)
@@ -316,29 +319,35 @@ sub read_dependencies($$$) { @@ -316,29 +319,35 @@ sub read_dependencies($$$) {
316 my ($cmd, $env, $pkgnameprefix) = @_; 319 my ($cmd, $env, $pkgnameprefix) = @_;
317 my @dep_lines; 320 my @dep_lines;
318 321
319 my %prev_ENV = %ENV; 322 my %prev_ENV = %ENV;
320 foreach my $name (keys %$env) { 323 foreach my $name (keys %$env) {
321 $ENV{$name} = $env->{$name}; 324 $ENV{$name} = $env->{$name};
322 } 325 }
323 open(DEPS, "$cmd |") or die; 326 open(DEPS, "$cmd |") or die;
324 %ENV = %prev_ENV; 327 %ENV = %prev_ENV;
325 328
326 while (defined (my $line = <DEPS>)) { 329 while (defined (my $line = <DEPS>)) {
327 chomp($line); 330 chomp($line);
328 331
329 next unless $line =~ qr"^(\w+)\t([^\s:>]+)(>[^\s:]+|)(?::(\.\./\.\./\S+))?$"; 332 if ($line =~ qr"^(\w+)\t([^\s:>]+)(>[^\s:]+|)(?::(\.\./\.\./\S+))?$") {
330 push(@dep_lines, [$1, $2, $3 || ">=0", $4 || ""]); 333 push(@dep_lines, [ $1, $2, $3 || ">=0", $4 || "" ]);
 334 } elsif ($line =~ qr"^var\t(\S+)\t(.+)$") {
 335 $main::update_vars{$1} = $2;
 336 } else {
 337 printf STDERR "url2pkg: unknown dependency line: %s\n", $line;
 338 }
331 } 339 }
 340
332 close(DEPS) or die; 341 close(DEPS) or die;
333 342
334 foreach my $dep_line (@dep_lines) { 343 foreach my $dep_line (@dep_lines) {
335 my ($type, $pkgbase, $constraint, $dir) = @$dep_line; 344 my ($type, $pkgbase, $constraint, $dir) = @$dep_line;
336 345
337 if ($dir eq "" && $pkgnameprefix ne "") { 346 if ($dir eq "" && $pkgnameprefix ne "") {
338 $dir = find_package("$pkgnameprefix$pkgbase"); 347 $dir = find_package("$pkgnameprefix$pkgbase");
339 if ($dir ne "") { 348 if ($dir ne "") {
340 $pkgbase = "$pkgnameprefix$pkgbase"; 349 $pkgbase = "$pkgnameprefix$pkgbase";
341 } 350 }
342 } 351 }
343 if ($dir eq "") { 352 if ($dir eq "") {
344 $dir = find_package($pkgbase); 353 $dir = find_package($pkgbase);
@@ -391,29 +400,27 @@ sub adjust_gconf2_schemas() { @@ -391,29 +400,27 @@ sub adjust_gconf2_schemas() {
391sub adjust_libtool() { 400sub adjust_libtool() {
392 if (-f "$abs_wrksrc/ltconfig" || -f "$abs_wrksrc/ltmain.sh") { 401 if (-f "$abs_wrksrc/ltconfig" || -f "$abs_wrksrc/ltmain.sh") {
393 push(@build_vars, var("USE_LIBTOOL", "=", "yes")); 402 push(@build_vars, var("USE_LIBTOOL", "=", "yes"));
394 } 403 }
395 if (-d "$abs_wrksrc/libltdl") { 404 if (-d "$abs_wrksrc/libltdl") {
396 push(@includes, "../../devel/libltdl/convenience.mk"); 405 push(@includes, "../../devel/libltdl/convenience.mk");
397 } 406 }
398} 407}
399 408
400# Example packages: 409# Example packages:
401# devel/p5-Algorithm-CheckDigits 410# devel/p5-Algorithm-CheckDigits
402sub adjust_perl_module_Build_PL() { 411sub adjust_perl_module_Build_PL() {
403 412
404 # TODO: Implement this similarly to the Makefile.PL mock below. 413 read_dependencies("cd '$abs_wrksrc' && perl -I$libdir -I. Build.PL", {}, "");
405 
406 push(@todos, "Look for the dependencies in Build.PL."); 
407 414
408 push(@build_vars, var("PERL5_MODULE_TYPE", "=", "Module::Build")); 415 push(@build_vars, var("PERL5_MODULE_TYPE", "=", "Module::Build"));
409} 416}
410 417
411# Example packages: 418# Example packages:
412# devel/p5-Algorithm-Diff (no dependencies) 419# devel/p5-Algorithm-Diff (no dependencies)
413# devel/p5-Carp-Assert-More (dependencies without version numbers) 420# devel/p5-Carp-Assert-More (dependencies without version numbers)
414# www/p5-HTML-Quoted (dependency with version number) 421# www/p5-HTML-Quoted (dependency with version number)
415sub adjust_perl_module_Makefile_PL() { 422sub adjust_perl_module_Makefile_PL() {
416 423
417 # To avoid fix_up_makefile error for p5-HTML-Quoted, generate Makefile first. 424 # To avoid fix_up_makefile error for p5-HTML-Quoted, generate Makefile first.
418 system("cd '$abs_wrksrc' && perl -I. Makefile.PL < /dev/null") == 0 or do {}; 425 system("cd '$abs_wrksrc' && perl -I. Makefile.PL < /dev/null") == 0 or do {};
419 426
@@ -438,27 +445,27 @@ sub adjust_perl_module() { @@ -438,27 +445,27 @@ sub adjust_perl_module() {
438 unlink("PLIST") or do {}; 445 unlink("PLIST") or do {};
439} 446}
440 447
441# Example packages: 448# Example packages:
442# 449#
443# devel/py-ZopeComponent (dependencies, test dependencies) 450# devel/py-ZopeComponent (dependencies, test dependencies)
444sub adjust_python_module() { 451sub adjust_python_module() {
445 452
446 return unless -f "$abs_wrksrc/setup.py"; 453 return unless -f "$abs_wrksrc/setup.py";
447 454
448 my $cmd = "cd '$abs_wrksrc' && $pythonbin setup.py build"; 455 my $cmd = "cd '$abs_wrksrc' && $pythonbin setup.py build";
449 my $env = { 456 my $env = {
450 "PYTHONDONTWRITEBYTECODE" => "x", 457 "PYTHONDONTWRITEBYTECODE" => "x",
451 "PYTHONPATH" => $libdir 458 "PYTHONPATH" => $libdir
452 }; 459 };
453 read_dependencies($cmd, $env, "py-"); 460 read_dependencies($cmd, $env, "py-");
454 461
455 $pkgname_prefix = "\${PYPKGPREFIX}-"; 462 $pkgname_prefix = "\${PYPKGPREFIX}-";
456 push(@categories, "python"); 463 push(@categories, "python");
457 push(@includes, "../../lang/python/egg.mk"); 464 push(@includes, "../../lang/python/egg.mk");
458} 465}
459 466
460sub adjust_cargo() { 467sub adjust_cargo() {
461 open(CONF, "<", "$abs_wrksrc/Cargo.lock") or return; 468 open(CONF, "<", "$abs_wrksrc/Cargo.lock") or return;
462 469
463 while (defined(my $line = <CONF>)) { 470 while (defined(my $line = <CONF>)) {
464 # "checksum cargo-package-name cargo-package-version 471 # "checksum cargo-package-name cargo-package-version
@@ -699,28 +706,27 @@ sub adjust_lines_python_module($$) { @@ -699,28 +706,27 @@ sub adjust_lines_python_module($$) {
699 my @lines = @$lines; 706 my @lines = @$lines;
700 if (lines_remove(\@lines, "GITHUB_PROJECT") 707 if (lines_remove(\@lines, "GITHUB_PROJECT")
701 && lines_set(\@lines, "DISTNAME", "$pkgbase-$pkgversion_norev") 708 && lines_set(\@lines, "DISTNAME", "$pkgbase-$pkgversion_norev")
702 && lines_set(\@lines, "PKGNAME", "\${PYPKGPREFIX}-\${DISTNAME}") 709 && lines_set(\@lines, "PKGNAME", "\${PYPKGPREFIX}-\${DISTNAME}")
703 && lines_set(\@lines, "MASTER_SITES", "\${MASTER_SITE_PYPI:=$pkgbase1/$pkgbase/}") 710 && lines_set(\@lines, "MASTER_SITES", "\${MASTER_SITE_PYPI:=$pkgbase1/$pkgbase/}")
704 && lines_remove(\@lines, "DIST_SUBDIR") 711 && lines_remove(\@lines, "DIST_SUBDIR")
705 && (lines_remove_if(\@lines, "EXTRACT_SUFX", ".zip") || true)) { 712 && (lines_remove_if(\@lines, "EXTRACT_SUFX", ".zip") || true)) {
706 713
707 @$lines = @lines; 714 @$lines = @lines;
708 $regenerate_distinfo = true 715 $regenerate_distinfo = true
709 } 716 }
710} 717}
711 718
712sub adjust_package_from_extracted_distfiles($) 719sub adjust_package_from_extracted_distfiles($) {
713{ 
714 my ($url) = @_; 720 my ($url) = @_;
715 721
716 chomp($abs_wrkdir = `$make show-var VARNAME=WRKDIR`); 722 chomp($abs_wrkdir = `$make show-var VARNAME=WRKDIR`);
717 723
718 # 724 #
719 # Determine the value of WRKSRC. 725 # Determine the value of WRKSRC.
720 # 726 #
721 727
722 my @files = (); 728 my @files = ();
723 opendir(WRKDIR, $abs_wrkdir) or die; 729 opendir(WRKDIR, $abs_wrkdir) or die;
724 while (defined(my $f = readdir(WRKDIR))) { 730 while (defined(my $f = readdir(WRKDIR))) {
725 next if $f =~ qr"^\." 731 next if $f =~ qr"^\."
726 || $f eq "pax_global_header" 732 || $f eq "pax_global_header"
@@ -748,28 +754,26 @@ sub adjust_package_from_extracted_distfi @@ -748,28 +754,26 @@ sub adjust_package_from_extracted_distfi
748 adjust_cmake(); 754 adjust_cmake();
749 adjust_meson(); 755 adjust_meson();
750 adjust_gconf2_schemas(); 756 adjust_gconf2_schemas();
751 adjust_libtool(); 757 adjust_libtool();
752 adjust_perl_module(); 758 adjust_perl_module();
753 adjust_python_module(); 759 adjust_python_module();
754 adjust_cargo(); 760 adjust_cargo();
755 adjust_pkg_config(); 761 adjust_pkg_config();
756 adjust_po(); 762 adjust_po();
757 adjust_use_languages(); 763 adjust_use_languages();
758 764
759 print("url2pkg> Adjusting the Makefile\n"); 765 print("url2pkg> Adjusting the Makefile\n");
760 766
761 my $seen_marker = false; 
762 
763 my @prev_lines = read_lines("Makefile"); 767 my @prev_lines = read_lines("Makefile");
764 my $marker_index = lines_index(\@prev_lines, qr"^# url2pkg-marker"); 768 my $marker_index = lines_index(\@prev_lines, qr"^# url2pkg-marker");
765 if ($marker_index == -1) { 769 if ($marker_index == -1) {
766 die("$0: ERROR: didn't find the url2pkg marker in the Makefile.\n"); 770 die("$0: ERROR: didn't find the url2pkg marker in the Makefile.\n");
767 } 771 }
768 772
769 my @lines = @prev_lines[0 .. $marker_index - 1]; 773 my @lines = @prev_lines[0 .. $marker_index - 1];
770 774
771 if (lines_index(\@lines, qr"^PKGNAME=") == -1) { 775 if (lines_index(\@lines, qr"^PKGNAME=") == -1) {
772 my $distname_index = lines_index(\@lines, qr"^DISTNAME=(\t+)"); 776 my $distname_index = lines_index(\@lines, qr"^DISTNAME=(\t+)");
773 if ($distname_index != -1) { 777 if ($distname_index != -1) {
774 my $pkgname_line = "PKGNAME=\t$pkgname_prefix\${DISTNAME$pkgname_transform}"; 778 my $pkgname_line = "PKGNAME=\t$pkgname_prefix\${DISTNAME$pkgname_transform}";
775 splice(@lines, $distname_index + 1, 0, $pkgname_line); 779 splice(@lines, $distname_index + 1, 0, $pkgname_line);
@@ -791,26 +795,30 @@ sub adjust_package_from_extracted_distfi @@ -791,26 +795,30 @@ sub adjust_package_from_extracted_distfi
791 795
792 lines_add_vars(\@lines, \@build_vars); 796 lines_add_vars(\@lines, \@build_vars);
793 lines_add_vars(\@lines, \@extra_vars); 797 lines_add_vars(\@lines, \@extra_vars);
794 798
795 push(@lines, @bl3_lines); 799 push(@lines, @bl3_lines);
796 push(@lines, map { $_ = ".include \"$_\"" } @includes); 800 push(@lines, map { $_ = ".include \"$_\"" } @includes);
797 801
798 push(@lines, @prev_lines[$marker_index + 1 .. $#prev_lines]); 802 push(@lines, @prev_lines[$marker_index + 1 .. $#prev_lines]);
799 803
800 lines_append(\@lines, "CATEGORIES", join(" ", @categories)); 804 lines_append(\@lines, "CATEGORIES", join(" ", @categories));
801 805
802 adjust_lines_python_module(\@lines, $url); 806 adjust_lines_python_module(\@lines, $url);
803 807
 808 foreach my $varname (keys %update_vars) {
 809 lines_set(\@lines, $varname, $update_vars{$varname});
 810 }
 811
804 write_lines("Makefile", @lines); 812 write_lines("Makefile", @lines);
805 813
806 if ($regenerate_distinfo) { 814 if ($regenerate_distinfo) {
807 make("distinfo"); 815 make("distinfo");
808 } 816 }
809} 817}
810 818
811sub main() { 819sub main() {
812 my $url; 820 my $url;
813 821
814 if (!-f "../../mk/bsd.pkg.mk") { 822 if (!-f "../../mk/bsd.pkg.mk") {
815 die("ERROR: $0 must be run from a package directory (.../pkgsrc/category/package).\n"); 823 die("ERROR: $0 must be run from a package directory (.../pkgsrc/category/package).\n");
816 } 824 }

cvs diff -r1.9 -r1.10 pkgsrc/pkgtools/url2pkg/files/Attic/url2pkg.t (expand / switch to unified diff)

--- pkgsrc/pkgtools/url2pkg/files/Attic/url2pkg.t 2019/09/12 05:45:34 1.9
+++ pkgsrc/pkgtools/url2pkg/files/Attic/url2pkg.t 2019/09/12 18:23:00 1.10
@@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
1# -*- perl -*- 1# -*- perl -*-
2# $NetBSD: url2pkg.t,v 1.9 2019/09/12 05:45:34 rillig Exp $ 2# $NetBSD: url2pkg.t,v 1.10 2019/09/12 18:23:00 rillig Exp $
3 3
4require "url2pkg.pl"; 4require "url2pkg.pl";
5 5
6use Test::More; 6use Test::More;
7 7
8use strict; 8use strict;
9use warnings; 9use warnings;
10 10
11sub test_lines_add_vars__simple() { 11sub test_lines_add_vars__simple() {
12 my $lines = []; 12 my $lines = [];
13 13
14 lines_add_vars($lines, [ 14 lines_add_vars($lines, [
15 var("1", "=", "one"), 15 var("1", "=", "one"),
@@ -73,26 +73,42 @@ sub test_lines_append__value_with_commen @@ -73,26 +73,42 @@ sub test_lines_append__value_with_commen
73 lines_append($lines, "VARNAME", "appended"); 73 lines_append($lines, "VARNAME", "appended");
74 74
75 is_deeply($lines, ["VARNAME=\tvalue appended # comment"]); 75 is_deeply($lines, ["VARNAME=\tvalue appended # comment"]);
76} 76}
77 77
78sub test_lines_append__value_without_comment() { 78sub test_lines_append__value_without_comment() {
79 my $lines = ["VARNAME+=\tvalue"]; 79 my $lines = ["VARNAME+=\tvalue"];
80 80
81 lines_append($lines, "VARNAME", "appended"); 81 lines_append($lines, "VARNAME", "appended");
82 82
83 is_deeply($lines, ["VARNAME+=\tvalue appended"]); 83 is_deeply($lines, ["VARNAME+=\tvalue appended"]);
84} 84}
85 85
 86sub test_lines_set__previously_with_comment() {
 87 my $lines = ["LICENSE=\t# TODO: see mk/license.mk"];
 88
 89 lines_set($lines, "LICENSE", "\${PERL5_LICENSE}");
 90
 91 is_deeply($lines, ["LICENSE=\t\${PERL5_LICENSE}"]);
 92}
 93
 94sub test_lines_set__not_found() {
 95 my $lines = ["OLD_VAR=\told value # old comment"];
 96
 97 lines_set($lines, "NEW_VAR", "new value");
 98
 99 is_deeply($lines, ["OLD_VAR=\told value # old comment"]);
 100}
 101
86sub test_lines_index() { 102sub test_lines_index() {
87 my $lines = ["1", "2", "345"]; 103 my $lines = ["1", "2", "345"];
88 104
89 is(lines_index($lines, "1"), 0); 105 is(lines_index($lines, "1"), 0);
90 is(lines_index($lines, "2"), 1); 106 is(lines_index($lines, "2"), 1);
91 is(lines_index($lines, "345"), 2); 107 is(lines_index($lines, "345"), 2);
92 is(lines_index($lines, "4"), 2); 108 is(lines_index($lines, "4"), 2);
93 109
94 is(lines_index($lines, qr"^(\d\d)\d$"), 2); 110 is(lines_index($lines, qr"^(\d\d)\d$"), 2);
95 is(lines_index($lines, qr"^\d\s\d$"), -1); 111 is(lines_index($lines, qr"^\d\s\d$"), -1);
96 is(lines_index($lines, qr"(\d)"), 0); 112 is(lines_index($lines, qr"(\d)"), 0);
97 is($1, undef); # capturing groups do not work here 113 is($1, undef); # capturing groups do not work here
98} 114}
@@ -233,26 +249,27 @@ sub set_up_test() { @@ -233,26 +249,27 @@ sub set_up_test() {
233 $main::abs_wrksrc = ""; 249 $main::abs_wrksrc = "";
234 250
235 @main::wrksrc_files = (); 251 @main::wrksrc_files = ();
236 @main::wrksrc_dirs = (); 252 @main::wrksrc_dirs = ();
237 @main::categories = (); 253 @main::categories = ();
238 254
239 @main::depends = (); 255 @main::depends = ();
240 @main::build_depends = (); 256 @main::build_depends = ();
241 @main::test_depends = (); 257 @main::test_depends = ();
242 @main::bl3_lines = (); 258 @main::bl3_lines = ();
243 @main::includes = (); 259 @main::includes = ();
244 @main::build_vars = (); 260 @main::build_vars = ();
245 @main::extra_vars = (); 261 @main::extra_vars = ();
 262 %main::update_vars = ();
246 @main::todos = (); 263 @main::todos = ();
247 264
248 $main::pkgname_prefix = ""; 265 $main::pkgname_prefix = "";
249 $main::pkgname_transform = ""; 266 $main::pkgname_transform = "";
250 $main::regenerate_distinfo = 0; 267 $main::regenerate_distinfo = 0;
251} 268}
252 269
253sub t_main() { 270sub t_main() {
254 my $pkgsrcdir = $ENV{"PKGSRCDIR"} or die; 271 my $pkgsrcdir = $ENV{"PKGSRCDIR"} or die;
255 chdir("$pkgsrcdir/pkgtools/url2pkg") or die; 272 chdir("$pkgsrcdir/pkgtools/url2pkg") or die;
256 273
257 no strict 'refs'; 274 no strict 'refs';
258 foreach my $testname (sort grep { $_ =~ qr"^test_" } keys %{"main::"}) { 275 foreach my $testname (sort grep { $_ =~ qr"^test_" } keys %{"main::"}) {