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: add abstracti...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/57b7a3b81e33
branches:  trunk
changeset: 399873:57b7a3b81e33
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sun Aug 18 06:41:16 2019 +0000

description:
pkgtools/url2pkg: add abstraction for variable assignments

diffstat:

 pkgtools/url2pkg/files/url2pkg.pl |  93 ++++++++++++++++++++------------------
 1 files changed, 50 insertions(+), 43 deletions(-)

diffs (244 lines):

diff -r 13b1c52e3471 -r 57b7a3b81e33 pkgtools/url2pkg/files/url2pkg.pl
--- a/pkgtools/url2pkg/files/url2pkg.pl Sun Aug 18 06:23:41 2019 +0000
+++ b/pkgtools/url2pkg/files/url2pkg.pl Sun Aug 18 06:41:16 2019 +0000
@@ -1,5 +1,5 @@
 #! @PERL@
-# $NetBSD: url2pkg.pl,v 1.50 2019/08/18 06:23:19 maya Exp $
+# $NetBSD: url2pkg.pl,v 1.51 2019/08/18 06:41:16 rillig Exp $
 #
 
 # Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -65,6 +65,12 @@
        return $ENV{"PKGMAINTAINER"} || $ENV{"REPLYTO"} || "INSERT_YOUR_MAIL_ADDRESS_HERE";
 }
 
+sub var($$$) {
+       my ($name, $op, $value) = @_;
+
+       return [$name, $op, $value];
+}
+
 sub add_section($$) {
        my ($lines, $vars) = @_;
 
@@ -72,17 +78,17 @@
 
        my $width = 0;
        foreach my $var (@{$vars}) {
-               my ($name, $value) = @$var;
+               my ($name, $op, $value) = @$var;
                next if $value eq "";
-               my $len = (length("$name= ") + 7) & -8;
+               my $len = (length("$name$op\t") + 7) & -8;
                $width = ($len > $width) ? $len : $width;
        }
 
        foreach my $var (@{$vars}) {
-               my ($name, $value) = @$var;
+               my ($name, $op, $value) = @$var;
                next if $value eq "";
-               my $tabs = "\t" x (($width - length("$name=") + 7) / 8);
-               push(@$lines, "$name=$tabs$value");
+               my $tabs = "\t" x (($width - length("$name$op") + 7) / 8);
+               push(@$lines, "$name$op$tabs$value");
        }
        push(@$lines, "");
 }
@@ -108,23 +114,24 @@
 #
 # @depends
 # @build_depends
-#      the dependencies of the package, in the form "package>=version".
+#      the dependencies of the package, in the form
+#      "package>=version:../../category/package".
 # @includes
 #      a list of pathnames relative to the package path.
 #      All these files will be included at the bottom of the Makefile.
 # @build_vars
-#      a list of [varname, value] items that contain variables that
-#      will be defined in the fourth paragraph of the package Makefile,
-#      where the build configuration takes place.
+#      a list of variable assignments that will make up the fourth
+#      paragraph of the package Makefile, where the build configuration
+#      takes place.
 # @extra_vars
 #      similar to the @build_vars, but separated by an empty line in
-#      the Makefile, therefore forming the fifth paragraph.
-# @todo
+#      the Makefile, thereby forming the fifth paragraph.
+# @todos
 #      these are inserted below the second paragraph in the Makefile.
 
 my ($distname, $abs_wrkdir, $abs_wrksrc);
 my (@wrksrc_files, @wrksrc_dirs);
-my (@depends, @build_depends, @includes, @build_vars, @extra_vars, @todo);
+my (@depends, @build_depends, @includes, @build_vars, @extra_vars, @todos);
 my ($pkgname);
 
 #
@@ -144,14 +151,14 @@
        close(CONF);
 
        my $varname = ($gnu_configure ? "GNU_CONFIGURE" : "HAS_CONFIGURE");
-       push(@build_vars, [$varname, "yes"]);
+       push(@build_vars, var($varname, "=", "yes"));
 }
 
 sub magic_cmake() {
        open(CONF, "<", "${abs_wrksrc}/CMakeLists.txt") or return;
        close(CONF);
 
-       push(@build_vars, ["USE_CMAKE", "yes"]);
+       push(@build_vars, var("USE_CMAKE", "=", "yes"));
 }
 
 sub magic_meson() {
@@ -166,7 +173,7 @@
        if (@gconf2_files) {
                foreach my $f (@gconf2_files) {
                        if ($f =~ qr"(.*schemas)") {
-                               push(@extra_vars, ["GCONF_SCHEMAS+", $1]);
+                               push(@extra_vars, var("GCONF_SCHEMAS", "+=", $1));
                        }
                }
                push(@includes, "../../devel/GConf/schemas.mk");
@@ -175,7 +182,7 @@
 
 sub magic_libtool() {
        if (-f "${abs_wrksrc}/ltconfig" || -f "${abs_wrksrc}/ltmain.sh") {
-               push(@build_vars, ["USE_LIBTOOL", "yes"]);
+               push(@build_vars, var("USE_LIBTOOL", "=", "yes"));
        }
        if (-d "${abs_wrksrc}/libltdl") {
                push(@includes, "../../devel/libltdl/convenience.mk");
@@ -187,9 +194,9 @@
 
                # It's a Module::Build module. Dependencies cannot yet be
                # extracted automatically.
-               push(@todo, "Look for the dependencies in Build.PL.");
+               push(@todos, "Look for the dependencies in Build.PL.");
 
-               push(@build_vars, ["PERL5_MODULE_TYPE", "Module::Build"]);
+               push(@build_vars, var("PERL5_MODULE_TYPE", "=", "Module::Build"));
 
        } elsif (-f "${abs_wrksrc}/Makefile.PL") {
 
@@ -214,7 +221,7 @@
        my $packlist = $distname;
        $packlist =~ s/-[0-9].*//;
        $packlist =~ s/-/\//g;
-       push(@build_vars, ["PERL5_PACKLIST", "auto/${packlist}/.packlist"]);
+       push(@build_vars, var("PERL5_PACKLIST", "=", "auto/${packlist}/.packlist"));
        push(@includes, "../../lang/perl5/module.mk");
        $pkgname = "p5-\${DISTNAME}";
 }
@@ -225,7 +232,7 @@
        while (defined(my $line = <CONF>)) {
                # "checksum cargo-package-name cargo-package-version
                if ($line =~ m/("checksum)\s(\S+)\s(\S+)/) {
-                       push(@build_vars, ["CARGO_CRATE_DEPENDS", "$2-$3"]);
+                       push(@build_vars, var("CARGO_CRATE_DEPENDS", "=", "$2-$3"));
                }
        }
        close(CONF);
@@ -237,16 +244,16 @@
 sub magic_pkg_config() {
        my @pkg_config_files = grep { /\.pc\.in$/ && ! /-uninstalled\.pc\.in$/ } @wrksrc_files;
        if (@pkg_config_files) {
-               push(@build_vars, ["USE_TOOLS+", "pkg-config"]);
+               push(@build_vars, var("USE_TOOLS", "+=", "pkg-config"));
        }
        foreach my $f (@pkg_config_files) {
-               push(@extra_vars, ["PKGCONFIG_OVERRIDE+", $f]);
+               push(@extra_vars, var("PKGCONFIG_OVERRIDE", "+=", $f));
        }
 }
 
 sub magic_po() {
        if (grep(/\.g?mo$/, @wrksrc_files)) {
-               push(@build_vars, ["USE_PKGLOCALEDIR", "yes"]);
+               push(@build_vars, var("USE_PKGLOCALEDIR", "=", "yes"));
        }
 }
 
@@ -262,7 +269,7 @@
                $use_languages = "# none";
        }
        if ($use_languages ne "c") {
-               push(@build_vars, ["USE_LANGUAGES", $use_languages]);
+               push(@build_vars, var("USE_LANGUAGES", "=", $use_languages));
        }
 }
 
@@ -387,20 +394,20 @@
        push(@lines, "");
 
        add_section(\@lines, [
-               ["GITHUB_PROJECT", $github_project],
-               ["DISTNAME", $distname],
-               ["CATEGORIES", $categories],
-               ["MASTER_SITES", $master_sites],
-               ["GITHUB_RELEASE", $github_release],
-               ["EXTRACT_SUFX", $extract_sufx],
-               ["DIST_SUBDIR", $dist_subdir],
+               var("GITHUB_PROJECT", "=", $github_project),
+               var("DISTNAME", "=", $distname),
+               var("CATEGORIES", "=", $categories),
+               var("MASTER_SITES", "=", $master_sites),
+               var("GITHUB_RELEASE", "=", $github_release),
+               var("EXTRACT_SUFX", "=", $extract_sufx),
+               var("DIST_SUBDIR", "=", $dist_subdir),
        ]);
 
        add_section(\@lines, [
-               ["MAINTAINER", get_maintainer()],
-               ["HOMEPAGE", $homepage],
-               ["COMMENT", "TODO: Short description of the package"],
-               ["#LICENSE", "# TODO: (see mk/license.mk)"],
+               var("MAINTAINER", "=", get_maintainer()),
+               var("HOMEPAGE", "=", $homepage),
+               var("COMMENT", "=", "TODO: Short description of the package"),
+               var("#LICENSE", "=", "# TODO: (see mk/license.mk)"),
        ]);
 
        push(@lines, "# url2pkg-marker (please do not remove this line.)");
@@ -458,12 +465,12 @@
        closedir(WRKDIR);
        if (@files == 1) {
                if ($files[0] ne $distname) {
-                       push(@build_vars, ["WRKSRC", "\${WRKDIR}/$files[0]"]);
+                       push(@build_vars, var("WRKSRC", "=", "\${WRKDIR}/$files[0]"));
                }
                $abs_wrksrc = "${abs_wrkdir}/$files[0]";
        } else {
-               push(@build_vars, ["WRKSRC", "\${WRKDIR}" .
-                   ((@files > 1) ? " # More than one possibility -- please check manually." : "")]);
+               push(@build_vars, var("WRKSRC", "=", "\${WRKDIR}" .
+                   ((@files > 1) ? " # More than one possibility -- please check manually." : "")));
                $abs_wrksrc = $abs_wrkdir;
        }
 
@@ -502,8 +509,8 @@
                }
        }
 
-       if (@todo) {
-               foreach my $todo (@todo) {
+       if (@todos) {
+               foreach my $todo (@todos) {
                        push(@lines, "# TODO: $todo");
                }
                push(@lines, "");
@@ -511,10 +518,10 @@
 
        my @depend_vars;
        foreach my $dep (@build_depends) {
-               push(@depend_vars, ["BUILD_DEPENDS+", $dep]);
+               push(@depend_vars, var("BUILD_DEPENDS", "+=", $dep));
        }
        foreach my $dep (@depends) {
-               push(@depend_vars, ["DEPENDS+", $dep]);
+               push(@depend_vars, var("DEPENDS", "+=", $dep));
        }
        add_section(\@lines, \@depend_vars);
 



Home | Main Index | Thread Index | Old Index