pkgsrc-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: pkgsrc/pkgtools/url2pkg
Module Name: pkgsrc
Committed By: rillig
Date: Thu Sep 12 04:18:28 UTC 2019
Modified Files:
pkgsrc/pkgtools/url2pkg: Makefile
pkgsrc/pkgtools/url2pkg/files: url2pkg.pl url2pkg.t
Log Message:
pkgtools/url2pkg: update to 2.35
Changes since 2.34:
* Python packages get a PKGNAME variable containing PYPKGPREFIX
* Refactoring: merged duplicate code for reading dependencies
To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 pkgsrc/pkgtools/url2pkg/Makefile
cvs rdiff -u -r1.66 -r1.67 pkgsrc/pkgtools/url2pkg/files/url2pkg.pl
cvs rdiff -u -r1.7 -r1.8 pkgsrc/pkgtools/url2pkg/files/url2pkg.t
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: pkgsrc/pkgtools/url2pkg/Makefile
diff -u pkgsrc/pkgtools/url2pkg/Makefile:1.97 pkgsrc/pkgtools/url2pkg/Makefile:1.98
--- pkgsrc/pkgtools/url2pkg/Makefile:1.97 Wed Sep 11 05:25:55 2019
+++ pkgsrc/pkgtools/url2pkg/Makefile Thu Sep 12 04:18:28 2019
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.97 2019/09/11 05:25:55 rillig Exp $
+# $NetBSD: Makefile,v 1.98 2019/09/12 04:18:28 rillig Exp $
-PKGNAME= url2pkg-2.34
+PKGNAME= url2pkg-2.35
CATEGORIES= pkgtools
MAINTAINER= pkgsrc-users%NetBSD.org@localhost
Index: pkgsrc/pkgtools/url2pkg/files/url2pkg.pl
diff -u pkgsrc/pkgtools/url2pkg/files/url2pkg.pl:1.66 pkgsrc/pkgtools/url2pkg/files/url2pkg.pl:1.67
--- pkgsrc/pkgtools/url2pkg/files/url2pkg.pl:1.66 Thu Sep 12 02:49:33 2019
+++ pkgsrc/pkgtools/url2pkg/files/url2pkg.pl Thu Sep 12 04:18:28 2019
@@ -1,5 +1,5 @@
#! @PERL5@
-# $NetBSD: url2pkg.pl,v 1.66 2019/09/12 02:49:33 rillig Exp $
+# $NetBSD: url2pkg.pl,v 1.67 2019/09/12 04:18:28 rillig Exp $
#
# Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -37,9 +37,10 @@ use warnings;
# Build-time Configuration.
#
-my $make = "@MAKE@";
-my $libdir = "@LIBDIR@";
-my $pythonbin = "@PYTHONBIN@";
+my $make = '@MAKE@';
+my $libdir = '@LIBDIR@';
+my $pythonbin = '@PYTHONBIN@';
+my $pkgsrcdir = '@PKGSRCDIR@';
use constant true => 1;
use constant false => 0;
@@ -99,8 +100,9 @@ sub write_lines($@) {
sub find_package($) {
my ($pkgbase) = @_;
- my @candidates = <../../*/$pkgbase>;
- return scalar(@candidates) == 1 ? $candidates[0] : "";
+ my @candidates = <$pkgsrcdir/*/$pkgbase>;
+ return "" unless @candidates == 1;
+ return $candidates[0] =~ s/\Q$pkgsrcdir\E/..\/../r;
}
# appends the given variable assignments to the lines, aligning the
@@ -244,13 +246,13 @@ my @categories;
# the dependencies of the package, in the form
# "package>=version:../../category/package".
-my @depends;
-my @build_depends;
-my @test_depends;
+our @depends;
+our @build_depends;
+our @test_depends;
# .include, interleaved with BUILDLINK3_API_DEPENDS.
# These lines are added at the bottom of the Makefile.
-my @bl3_lines;
+our @bl3_lines;
# a list of pathnames relative to the package path.
# All these files will be included at the bottom of the Makefile.
@@ -301,6 +303,42 @@ sub add_dependency($$$$) {
}
}
+sub read_dependencies($$$) {
+ my ($cmd, $env, $pkgnameprefix) = @_;
+ my @dep_lines;
+
+ my %prev_ENV = %ENV;
+ foreach my $name (keys %$env) {
+ $ENV{$name} = $env->{$name};
+ }
+ open(DEPS, "$cmd |") or die;
+ %ENV = %prev_ENV;
+
+ while (defined (my $line = <DEPS>)) {
+ chomp($line);
+
+ next unless $line =~ qr"^(\w+)\t([^\s:>]+)(>[^\s:]+|)(?::(\.\./\.\./\S+))?$";
+ push(@dep_lines, [$1, $2, $3 || ">=0", $4 || ""]);
+ }
+ close(DEPS) or die;
+
+ foreach my $dep_line (@dep_lines) {
+ my ($type, $pkgbase, $constraint, $dir) = @$dep_line;
+
+ if ($dir eq "" && $pkgnameprefix ne "") {
+ $dir = find_package("$pkgnameprefix$pkgbase");
+ if ($dir ne "") {
+ $pkgbase = "$pkgnameprefix$pkgbase";
+ }
+ }
+ if ($dir eq "") {
+ $dir = find_package($pkgbase);
+ }
+
+ add_dependency($type, $pkgbase, $constraint, $dir);
+ }
+}
+
sub adjust_configure() {
my $gnu_configure = false;
@@ -368,17 +406,9 @@ sub adjust_perl_module_Build_PL() {
sub adjust_perl_module_Makefile_PL() {
# To avoid fix_up_makefile error for p5-HTML-Quoted, generate Makefile first.
- system("cd '$abs_wrksrc' && perl -I. Makefile.PL < /dev/null") or do {};
-
- open(DEPS, "cd '$abs_wrksrc' && perl -I$libdir -I. Makefile.PL |") or die;
- while (defined(my $dep = <DEPS>)) {
- chomp($dep);
+ system("cd '$abs_wrksrc' && perl -I. Makefile.PL < /dev/null") == 0 or do {};
- if ($dep =~ qr"^(\w+)\t(\S+)(>\S+|):(\.\./\.\./\S+)$") {
- add_dependency($1, $2, $3, $4);
- }
- }
- close(DEPS) or die;
+ read_dependencies("cd '$abs_wrksrc' && perl -I$libdir -I. Makefile.PL", {}, "");
}
sub adjust_perl_module() {
@@ -406,33 +436,14 @@ sub adjust_python_module() {
return unless -f "$abs_wrksrc/setup.py";
- my %old_env = %ENV;
- $ENV{"PYTHONDONTWRITEBYTECODE"} = "x";
- $ENV{"PYTHONPATH"} = $libdir;
-
- my @dep_lines;
- open(DEPS, "cd '$abs_wrksrc' && $pythonbin setup.py build |") or die;
- %ENV = %old_env;
- while (defined(my $line = <DEPS>)) {
- chomp($line);
- if ($line =~ qr"^(\w+)\t(\S+?)(>=.*|)$") {
- push(@dep_lines, [$1, $2, $3]);
- }
- }
- close(DEPS) or die;
-
- foreach my $dep_line (@dep_lines) {
- my ($type, $pkgbase, $constraint) = @$dep_line;
- my $dep_dir = find_package("py-$pkgbase");
- if ($dep_dir ne "") {
- $pkgbase = "py-$pkgbase";
- } else {
- $dep_dir = find_package($pkgbase);
- }
-
- add_dependency($type, $pkgbase, $constraint, $dep_dir);
- }
+ my $cmd = "cd '$abs_wrksrc' && $pythonbin setup.py build";
+ my $env = {
+ "PYTHONDONTWRITEBYTECODE" => "x",
+ "PYTHONPATH" => $libdir
+ };
+ read_dependencies($cmd, $env, "py-");
+ $pkgname = "\${PYPKGPREFIX}-\${DISTNAME}";
push(@categories, "python");
push(@includes, "../../lang/python/egg.mk");
}
Index: pkgsrc/pkgtools/url2pkg/files/url2pkg.t
diff -u pkgsrc/pkgtools/url2pkg/files/url2pkg.t:1.7 pkgsrc/pkgtools/url2pkg/files/url2pkg.t:1.8
--- pkgsrc/pkgtools/url2pkg/files/url2pkg.t:1.7 Thu Sep 12 02:35:07 2019
+++ pkgsrc/pkgtools/url2pkg/files/url2pkg.t Thu Sep 12 04:18:28 2019
@@ -1,5 +1,5 @@
# -*- perl -*-
-# $NetBSD: url2pkg.t,v 1.7 2019/09/12 02:35:07 rillig Exp $
+# $NetBSD: url2pkg.t,v 1.8 2019/09/12 04:18:28 rillig Exp $
require "url2pkg.pl";
@@ -157,14 +157,51 @@ sub test_generate_initial_package_Makefi
]);
}
+sub test_read_dependencies() {
+ my $cmd = "printf '%s\n' \"\$URL2PKG_DEPENDENCIES\"";
+ my @dep_lines = (
+ "DEPENDS\tpackage>=version:../../pkgtools/pkglint",
+ "DEPENDS\tpackage>=version:../../pkgtools/x11-links",
+ "BUILD_DEPENDS\turl2pkg>=1.0",
+ "TEST_DEPENDS\tpkglint",
+ "A line that is not a dependency at all",
+ ""
+ );
+ my $env = { "URL2PKG_DEPENDENCIES" => join("\n", @dep_lines) };
+
+ read_dependencies($cmd, $env, "");
+
+ is($ENV{"URL2PKG_DEPENDENCIES"}, undef);
+ is_deeply(\@main::depends, [
+ "package>=version:../../pkgtools/pkglint"
+ ]);
+ is_deeply(\@main::bl3_lines, [
+ ".include \"../../pkgtools/x11-links/buildlink3.mk\""
+ ]);
+ is_deeply(\@main::build_depends, [
+ "url2pkg>=1.0:../../pkgtools/url2pkg"
+ ]);
+ is_deeply(\@main::test_depends, [
+ "pkglint>=0:../../pkgtools/pkglint"
+ ]);
+}
+
+sub set_up_test() {
+ @main::depends = ();
+ @main::build_depends = ();
+ @main::test_depends = ();
+ @main::bl3_lines = ();
+}
+
sub t_main() {
my $pkgsrcdir = $ENV{"PKGSRCDIR"} or die;
chdir("$pkgsrcdir/pkgtools/url2pkg") or die;
no strict 'refs';
foreach my $testname (sort grep { $_ =~ qr"^test_" } keys %{"main::"}) {
- my $testfunc = \&{"main::$testname"};
- $testfunc->() if defined($testfunc);
+ next if $testname eq "test_depends"; # it's an array
+ set_up_test();
+ &{"main::$testname"}();
}
done_testing();
Home |
Main Index |
Thread Index |
Old Index