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:           Tue Oct  1 19:41:23 UTC 2019

Modified Files:
        pkgsrc/pkgtools/url2pkg: Makefile
        pkgsrc/pkgtools/url2pkg/files: MakeMaker.pm setuptools.py url2pkg.pl
            url2pkg.t

Log Message:
pkgtools/url2pkg: update to 19.3.0

Changes since 2.37:

* Test dependencies in Perl MakeMaker modules are copied to the
  package Makefile.

* Unknown dependencies in Perl MakeMaker modules no longer abort url2pkg
  but instead are added as "# TODO" dependencies to the package Makefile.

* The license from Perl MakeMaker and Python modules is copied to the
  package Makefile.

* The build dependencies, COMMENT and HOMEPAGE from Python setuptools
  modules are copied to the package Makefile.

* No more "undefined $url" when running url2pkg in a directory that
  already has a package Makefile and is extracted.


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 pkgsrc/pkgtools/url2pkg/Makefile
cvs rdiff -u -r1.11 -r1.12 pkgsrc/pkgtools/url2pkg/files/MakeMaker.pm
cvs rdiff -u -r1.2 -r1.3 pkgsrc/pkgtools/url2pkg/files/setuptools.py
cvs rdiff -u -r1.74 -r1.75 pkgsrc/pkgtools/url2pkg/files/url2pkg.pl
cvs rdiff -u -r1.12 -r1.13 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.101 pkgsrc/pkgtools/url2pkg/Makefile:1.102
--- pkgsrc/pkgtools/url2pkg/Makefile:1.101      Tue Oct  1 18:43:46 2019
+++ pkgsrc/pkgtools/url2pkg/Makefile    Tue Oct  1 19:41:23 2019
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.101 2019/10/01 18:43:46 rillig Exp $
+# $NetBSD: Makefile,v 1.102 2019/10/01 19:41:23 rillig Exp $
 
-PKGNAME=       url2pkg-2.37
+PKGNAME=       url2pkg-19.3.0
 CATEGORIES=    pkgtools
 
 MAINTAINER=    rillig%NetBSD.org@localhost

Index: pkgsrc/pkgtools/url2pkg/files/MakeMaker.pm
diff -u pkgsrc/pkgtools/url2pkg/files/MakeMaker.pm:1.11 pkgsrc/pkgtools/url2pkg/files/MakeMaker.pm:1.12
--- pkgsrc/pkgtools/url2pkg/files/MakeMaker.pm:1.11     Thu Sep 12 18:23:00 2019
+++ pkgsrc/pkgtools/url2pkg/files/MakeMaker.pm  Tue Oct  1 19:41:23 2019
@@ -75,14 +75,14 @@ sub url2pkg_find_category($) {
        return "";
 }
 
-sub url2pkg_write_dependency($$) {
-       my ($dep, $ver) = @_;
+sub url2pkg_write_dependency($$$) {
+       my ($type, $dep, $ver) = @_;
 
        my $pkgbase = "p5-$dep" =~ s/::/-/gr;
        my $category = url2pkg_find_category($pkgbase);
 
        if ($category ne "") {
-               printf("DEPENDS\t%s>=%s:../../%s/%s\n", $pkgbase, $ver, $category, $pkgbase);
+               printf("%s\t%s>=%s:../../%s/%s\n", $type, $pkgbase, $ver, $category, $pkgbase);
                return;
        }
 
@@ -90,15 +90,35 @@ sub url2pkg_write_dependency($$) {
        # that it is a built-in module and no dependency declaration is needed.
        return if eval("use $dep $ver; 1;");
 
-       die("$0: ERROR: No pkgsrc package found for dependency $dep>=$ver.\n$@\n");
+       printf("%s\t%s>=%s\n", $type, $pkgbase, $ver);
+}
+
+sub url2pkg_write_var($$) {
+       my ($varname, $value) = @_;
+       return unless defined($value) && $value ne "";
+       printf("var\t%s\t%s\n", $varname, $value);
+}
+
+sub url2pkg_write_depends($$) {
+       my ($type, $deps) = @_;
+
+       return unless $deps;
+       foreach my $dep (sort(keys(%$deps))) {
+               url2pkg_write_dependency($type, $dep, $deps->{$dep});
+       }
 }
 
 sub WriteMakefile(%) {
        my (%options) = @_;
 
-       my $deps = $options{"PREREQ_PM"} || {};
-       foreach my $dep (sort(keys(%$deps))) {
-               url2pkg_write_dependency($dep, $deps->{$dep});
+       url2pkg_write_depends("DEPENDS", $options{"PREREQ_PM"});
+       url2pkg_write_depends("TEST_DEPENDS", $options{"TEST_DEPENDS"});
+
+       my $license = $options{"LICENSE"} || "";
+       if ($license eq "perl") {
+               url2pkg_write_var("LICENSE", "\${PERL5_LICENSE}");
+       } elsif ($license ne "") {
+               url2pkg_write_var("#LICENSE", "# TODO: $license (from Build.PL)")
        }
 }
 

Index: pkgsrc/pkgtools/url2pkg/files/setuptools.py
diff -u pkgsrc/pkgtools/url2pkg/files/setuptools.py:1.2 pkgsrc/pkgtools/url2pkg/files/setuptools.py:1.3
--- pkgsrc/pkgtools/url2pkg/files/setuptools.py:1.2     Wed Sep 11 05:25:55 2019
+++ pkgsrc/pkgtools/url2pkg/files/setuptools.py Tue Oct  1 19:41:23 2019
@@ -1,15 +1,52 @@
-# $NetBSD: setuptools.py,v 1.2 2019/09/11 05:25:55 rillig Exp $
+# $NetBSD: setuptools.py,v 1.3 2019/10/01 19:41:23 rillig Exp $
+
+# This is a drop-in replacement for the setuptools Python module. Instead
+# of actually searching for the dependencies, it extracts the dependency
+# information and includes it in the generated pkgsrc package Makefile.
+
+url2pkg_license_mapping = {
+    'Apache 2': 'apache-2.0',
+    'Apache 2.0': 'apache-2.0',
+    'Apache Software License': '', # too unspecific; needs a version number
+    'BSD': '', # too unspecific
+    'GNU Lesser General Public License (LGPL), Version 3': 'gnu-lgpl-v3',
+    'LGPL': 'gnu-lgpl-v2',
+    'MIT': 'mit',
+    'MIT License': 'mit',
+    'PSF': 'python-software-foundation',
+    'PSF license': 'python-software-foundation',
+    'Python Software Foundation License': 'python-software-foundation',
+    'ZPL 2.1': 'zpl-2.1',
+}
 
 def url2pkg_print_depends(keyword, depends):
     for dep in depends:
         print('%s\t%s%s' % (keyword, dep.replace(' ', ''), '' if '>' in dep else '>=0'))
 
+def url2pkg_print_var(varname, value):
+    if value != '':
+        print('var\t%s\t%s' % (varname, value))
+
+def url2pkg_print_license(license):
+    if license == '':
+        return
+    pkgsrc_license = url2pkg_license_mapping.get(license, '')
+    if pkgsrc_license == '':
+        url2pkg_print_var('#LICENSE', '%s # TODO: from setup.py; needs to be adjusted' % license)
+    else:
+        url2pkg_print_var('LICENSE', pkgsrc_license)
+
 def setup(**kwargs):
-    if 'install_requires' in kwargs:
-        url2pkg_print_depends('DEPENDS', kwargs['install_requires'])
+    url2pkg_print_depends('DEPENDS', kwargs.get('install_requires', []))
+    url2pkg_print_depends('TEST_DEPENDS', kwargs.get('tests_require', []))
+    url2pkg_print_depends('BUILD_DEPENDS', kwargs.get('extras_require', {}).get('dev', []))
+    url2pkg_print_depends('BUILD_DEPENDS', kwargs.get('setup_requires', []))
+    url2pkg_print_var('COMMENT', kwargs.get('description', '').rstrip('.'))
+    url2pkg_print_var('HOMEPAGE', kwargs.get('url', ''))
+    url2pkg_print_license(kwargs.get('license', ''))
 
-    if 'tests_require' in kwargs:
-        url2pkg_print_depends('TEST_DEPENDS', kwargs['tests_require'])
+    # TODO: python_requires (see devel/py-futures)
+    #       example: '>=2.6, <3, >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*')
 
 def find_packages(where='.', exclude=(), include=('*',)):
     return []

Index: pkgsrc/pkgtools/url2pkg/files/url2pkg.pl
diff -u pkgsrc/pkgtools/url2pkg/files/url2pkg.pl:1.74 pkgsrc/pkgtools/url2pkg/files/url2pkg.pl:1.75
--- pkgsrc/pkgtools/url2pkg/files/url2pkg.pl:1.74       Tue Oct  1 18:43:46 2019
+++ pkgsrc/pkgtools/url2pkg/files/url2pkg.pl    Tue Oct  1 19:41:23 2019
@@ -1,5 +1,5 @@
 #! @PERL5@
-# $NetBSD: url2pkg.pl,v 1.74 2019/10/01 18:43:46 rillig Exp $
+# $NetBSD: url2pkg.pl,v 1.75 2019/10/01 19:41:23 rillig Exp $
 #
 
 # Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -457,7 +457,7 @@ 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") == 0 or do {};
+       system("cd '$abs_wrksrc' && perl -I. Makefile.PL < /dev/null 1>&0 2>&0") == 0 or do {};
 
        read_dependencies("cd '$abs_wrksrc' && perl -I$libdir -I. Makefile.PL", {}, "");
 }
@@ -498,6 +498,8 @@ sub adjust_perl_module($) {
 # Example packages:
 #
 # devel/py-ZopeComponent (dependencies, test dependencies)
+# devel/py-gflags (uses distutils.core instead of setuptools; BSD license)
+# devel/py-gcovr (uses setuptools; BSD license)
 sub adjust_python_module() {
 
        return unless -f "$abs_wrksrc/setup.py";
@@ -804,6 +806,16 @@ sub adjust_package_from_extracted_distfi
        adjust_po();
        adjust_use_languages();
 
+       generate_adjusted_Makefile_lines($url)->write_to("Makefile");
+
+       if ($regenerate_distinfo) {
+               make("distinfo");
+       }
+}
+
+sub generate_adjusted_Makefile_lines($) {
+       my ($url) = @_;
+
        my $marker_index = $makefile_lines->index(qr"^# url2pkg-marker");
        if ($marker_index == -1) {
                die("$0: ERROR: didn't find the url2pkg marker in the Makefile.\n");
@@ -848,32 +860,28 @@ sub adjust_package_from_extracted_distfi
                $lines->set($varname, $update_vars{$varname});
        }
 
-       $lines->write_to("Makefile");
-
-       if ($regenerate_distinfo) {
-               make("distinfo");
-       }
+       return $lines;
 }
 
 sub main() {
-       my $url;
-
        if (!-f "../../mk/bsd.pkg.mk") {
                die("ERROR: $0 must be run from a package directory (.../pkgsrc/category/package).\n");
        }
 
-       my @extract_cookie = <w*/.extract_done>;
-       if (scalar(@extract_cookie) == 0) {
-               if (scalar(@ARGV) == 0) {
-                       print("URL: ");
-                       if (!defined($url = <STDIN>)) {
-                               print("\n");
-                               exit(0);
-                       }
-                       chomp($url);
-               } else {
-                       $url = shift(@ARGV);
+       my $url;
+       if (scalar(@ARGV) == 0) {
+               print("URL: ");
+               if (!defined($url = <STDIN>)) {
+                       print("\n");
+                       exit(0);
                }
+               chomp($url);
+       } else {
+               $url = shift(@ARGV);
+       }
+
+       my @extract_cookie = <w*/.extract_done>;
+       if (scalar(@extract_cookie) == 0 || !-f "Makefile") {
 
                generate_initial_package($url);
        } else {

Index: pkgsrc/pkgtools/url2pkg/files/url2pkg.t
diff -u pkgsrc/pkgtools/url2pkg/files/url2pkg.t:1.12 pkgsrc/pkgtools/url2pkg/files/url2pkg.t:1.13
--- pkgsrc/pkgtools/url2pkg/files/url2pkg.t:1.12        Fri Sep 13 13:31:39 2019
+++ pkgsrc/pkgtools/url2pkg/files/url2pkg.t     Tue Oct  1 19:41:23 2019
@@ -1,5 +1,5 @@
 # -*- perl -*-
-# $NetBSD: url2pkg.t,v 1.12 2019/09/13 13:31:39 rillig Exp $
+# $NetBSD: url2pkg.t,v 1.13 2019/10/01 19:41:23 rillig Exp $
 
 require "url2pkg.pl";
 
@@ -102,6 +102,14 @@ sub test_Lines_set__previously_with_comm
        is_deeply($lines, ["LICENSE=\t\${PERL5_LICENSE}"]);
 }
 
+sub test_Lines_set__overwrite_comment_with_comment() {
+       my $lines = Lines->new("#LICENSE=\t# TODO: see mk/license.mk");
+
+       $lines->set("#LICENSE", "\${PERL5_LICENSE}");
+
+       is_deeply($lines, ["#LICENSE=\t\${PERL5_LICENSE}"]);
+}
+
 sub test_Lines_set__not_found() {
        my $lines = Lines->new("OLD_VAR=\told value # old comment");
 
@@ -264,6 +272,60 @@ sub test_read_dependencies() {
        ]);
 }
 
+sub test_generate_adjusted_Makefile_lines() {
+       $main::makefile_lines = Lines->new(
+               "# before 1",
+               "# before 2",
+               "# url2pkg-marker",
+               "# after 1",
+               "# after 2"
+       );
+
+       my $lines = generate_adjusted_Makefile_lines("https://example.org/pkgname-1.0.tar.gz";);
+
+       is_deeply($lines, [
+               "# before 1",
+               "# before 2",
+               "# after 1",
+               "# after 2"
+       ]);
+}
+
+sub test_generate_adjusted_Makefile_lines__dependencies() {
+       $main::makefile_lines = Lines->new(
+               "# \$NetBSD\$",
+               "",
+               "# url2pkg-marker",
+               ".include \"../../mk/bsd.pkg.mk\""
+       );
+       # some dependencies whose directory will not be found
+       add_dependency("DEPENDS", "depends", ">=5.0", "../../devel/depends");
+       add_dependency("TOOL_DEPENDS", "tool-depends", ">=6.0", "../../devel/tool-depends");
+       add_dependency("BUILD_DEPENDS", "build-depends", ">=7.0", "../../devel/build-depends");
+       add_dependency("TEST_DEPENDS", "test-depends", ">=8.0", "../../devel/test-depends");
+       # some dependencies whose directory is explicitly given
+       push(@main::depends, "depends>=11.0:../../devel/depends");
+       push(@main::build_depends, "build-depends>=12.0:../../devel/build-depends");
+       push(@main::test_depends, "test-depends>=13.0:../../devel/test-depends");
+
+       my $lines = generate_adjusted_Makefile_lines("https://example.org/pkgname-1.0.tar.gz";);
+
+       is_deeply($lines, [
+               "# \$NetBSD\$",
+               "",
+               "# TODO: dependency TOOL_DEPENDS # TODO: tool-depends>=6.0",
+               "",
+               "BUILD_DEPENDS+=\t# TODO: build-depends>=7.0",
+               "BUILD_DEPENDS+=\tbuild-depends>=12.0:../../devel/build-depends",
+               "DEPENDS+=\t# TODO: depends>=5.0",
+               "DEPENDS+=\tdepends>=11.0:../../devel/depends",
+               "TEST_DEPENDS+=\t# TODO: test-depends>=8.0",
+               "TEST_DEPENDS+=\ttest-depends>=13.0:../../devel/test-depends",
+               "",
+               ".include \"../../mk/bsd.pkg.mk\""
+       ]);
+}
+
 sub set_up_test() {
        no warnings 'once';
 



Home | Main Index | Thread Index | Old Index