pkgsrc-Changes archive

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

CVS commit: pkgsrc/pkgtools/url2pkg/files



Module Name:    pkgsrc
Committed By:   rillig
Date:           Sat Aug 17 12:50:00 UTC 2019

Modified Files:
        pkgsrc/pkgtools/url2pkg/files: MakeMaker.pm

Log Message:
pkgtools/url2pkg: reduce code indentation


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 pkgsrc/pkgtools/url2pkg/files/MakeMaker.pm

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/files/MakeMaker.pm
diff -u pkgsrc/pkgtools/url2pkg/files/MakeMaker.pm:1.6 pkgsrc/pkgtools/url2pkg/files/MakeMaker.pm:1.7
--- pkgsrc/pkgtools/url2pkg/files/MakeMaker.pm:1.6      Wed Aug 22 20:48:38 2018
+++ pkgsrc/pkgtools/url2pkg/files/MakeMaker.pm  Sat Aug 17 12:50:00 2019
@@ -34,6 +34,8 @@
 
 package ExtUtils::MakeMaker;
 
+require 5.013002;
+
 use strict;
 use warnings;
 
@@ -64,38 +66,39 @@ sub find_category($) {
        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