pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/pkgtools/url2pkg/files pkgtools/url2pkg: reduce code i...
details: https://anonhg.NetBSD.org/pkgsrc/rev/6369ff90ddbf
branches: trunk
changeset: 399811:6369ff90ddbf
user: rillig <rillig%pkgsrc.org@localhost>
date: Sat Aug 17 12:50:00 2019 +0000
description:
pkgtools/url2pkg: reduce code indentation
diffstat:
pkgtools/url2pkg/files/MakeMaker.pm | 43 +++++++++++++++++++-----------------
1 files changed, 23 insertions(+), 20 deletions(-)
diffs (72 lines):
diff -r 614375ba7780 -r 6369ff90ddbf pkgtools/url2pkg/files/MakeMaker.pm
--- a/pkgtools/url2pkg/files/MakeMaker.pm Sat Aug 17 11:57:36 2019 +0000
+++ b/pkgtools/url2pkg/files/MakeMaker.pm Sat Aug 17 12:50:00 2019 +0000
@@ -34,6 +34,8 @@
package ExtUtils::MakeMaker;
+require 5.013002;
+
use strict;
use warnings;
@@ -64,38 +66,39 @@
foreach my $cat (readdir(D)) {
next if ($cat =~ qr"^\.");
- if (-d (conf_pkgsrcdir."/${cat}/${pkg}")) {
+ if (-f (conf_pkgsrcdir."/${cat}/${pkg}/Makefile")) {
$retval = $cat;
}
}
- closedir(D);
+ closedir(D) or die;
return $retval;
}
+sub writeDependency($$) {
+ my ($dep, $ver) = @_;
+
+ my $pkgbase = "p5-" . ($dep =~ s/::/-/gr);
+ my $category = find_category($pkgbase);
+
+ if (defined($category)) {
+ printf("%s>=%s:../../%s/%s\n", $pkgbase, $ver, $category, $pkgbase);
+ return;
+ }
+
+ # If the package does not exist but the Perl module can be
+ # loaded, assume that no extra dependency is needed.
+ return if eval("use $dep $ver; 1;");
+
+ die("$0: ERROR: No pkgsrc package found for dependency ${dep}>=${ver}.\n$@\n");
+}
+
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");
- }
- }
+ writeDependency($dep, $deps->{$dep});
}
}
}
Home |
Main Index |
Thread Index |
Old Index