pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/pkgtools/url2pkg pkgtools/url2pkg: update to 19.3.4



details:   https://anonhg.NetBSD.org/pkgsrc/rev/459376848a1f
branches:  trunk
changeset: 342944:459376848a1f
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sun Oct 27 19:19:54 2019 +0000

description:
pkgtools/url2pkg: update to 19.3.4

Changes since 19.3.3:

The code that handles license names is the same for Python and Perl
modules.

Python packages that use distutils.extension can be handled. An example
package is devel/py-pysha3.

The DESCR file is filled from the package's README file.

The PLIST is generated with some comments providing further assistance.

diffstat:

 pkgtools/url2pkg/Makefile              |   5 ++-
 pkgtools/url2pkg/PLIST                 |   3 +-
 pkgtools/url2pkg/files/Build.pm        |  12 +++++--
 pkgtools/url2pkg/files/MakeMaker.pm    |  14 ++++++---
 pkgtools/url2pkg/files/setuptools.py   |  13 ++++++++-
 pkgtools/url2pkg/files/url2pkg.py      |  50 +++++++++++++++++++++++++++++----
 pkgtools/url2pkg/files/url2pkg_test.py |  15 ++++++---
 7 files changed, 87 insertions(+), 25 deletions(-)

diffs (297 lines):

diff -r 8f6dbdf8e278 -r 459376848a1f pkgtools/url2pkg/Makefile
--- a/pkgtools/url2pkg/Makefile Sun Oct 27 18:58:06 2019 +0000
+++ b/pkgtools/url2pkg/Makefile Sun Oct 27 19:19:54 2019 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.106 2019/10/06 12:55:30 rillig Exp $
+# $NetBSD: Makefile,v 1.107 2019/10/27 19:19:54 rillig Exp $
 
-PKGNAME=       url2pkg-19.3.3
+PKGNAME=       url2pkg-19.3.4
 CATEGORIES=    pkgtools
 
 MAINTAINER=    rillig%NetBSD.org@localhost
@@ -41,6 +41,7 @@
        ${INSTALL_DATA} ${WRKSRC}/setuptools.py ${DESTDIR}${PREFIX}/lib/url2pkg/
        ${INSTALL_DATA} /dev/null ${DESTDIR}${PREFIX}/lib/url2pkg/distutils/__init__.py
        ${INSTALL_DATA} ${WRKSRC}/setuptools.py ${DESTDIR}${PREFIX}/lib/url2pkg/distutils/core.py
+       ${INSTALL_DATA} ${WRKSRC}/setuptools.py ${DESTDIR}${PREFIX}/lib/url2pkg/distutils/extension.py
 
 .include "../../lang/python/application.mk"
 .include "../../mk/bsd.pkg.mk"
diff -r 8f6dbdf8e278 -r 459376848a1f pkgtools/url2pkg/PLIST
--- a/pkgtools/url2pkg/PLIST    Sun Oct 27 18:58:06 2019 +0000
+++ b/pkgtools/url2pkg/PLIST    Sun Oct 27 19:19:54 2019 +0000
@@ -1,8 +1,9 @@
-@comment $NetBSD: PLIST,v 1.8 2019/10/06 12:55:30 rillig Exp $
+@comment $NetBSD: PLIST,v 1.9 2019/10/27 19:19:54 rillig Exp $
 bin/url2pkg
 lib/url2pkg/ExtUtils/MakeMaker.pm
 lib/url2pkg/Module/Build.pm
 lib/url2pkg/distutils/__init__.py
 lib/url2pkg/distutils/core.py
+lib/url2pkg/distutils/extension.py
 lib/url2pkg/setuptools.py
 man/man8/url2pkg.8
diff -r 8f6dbdf8e278 -r 459376848a1f pkgtools/url2pkg/files/Build.pm
--- a/pkgtools/url2pkg/files/Build.pm   Sun Oct 27 18:58:06 2019 +0000
+++ b/pkgtools/url2pkg/files/Build.pm   Sun Oct 27 19:19:54 2019 +0000
@@ -56,6 +56,11 @@
        printf("var\t%s\t%s\n", $varname, $value);
 }
 
+sub url2pkg_write_cmd($$) {
+       my ($self, $cmd, $arg) = @_;
+       printf("cmd\t%s\t%s\n", $cmd, $arg);
+}
+
 sub VERSION($$) {
        my ($class, $min_version) = @_;
        return $min_version <= $VERSION;
@@ -79,10 +84,9 @@
 
        $self->url2pkg_write_var("COMMENT", $self->{"dist_abstract"});
        my $license = $self->{"license"} || "";
-       if ($license eq "perl") {
-               $self->url2pkg_write_var("LICENSE", "\${PERL5_LICENSE}");
-       } elsif ($license ne "") {
-               $self->url2pkg_write_var("#LICENSE", "# TODO: $license (from Build.PL)")
+       if ($license ne "") {
+               $self->url2pkg_write_cmd("license", $license);
+               $self->url2pkg_write_var("license_default", "# TODO: $license (from Build.PL)")
        }
 }
 
diff -r 8f6dbdf8e278 -r 459376848a1f pkgtools/url2pkg/files/MakeMaker.pm
--- a/pkgtools/url2pkg/files/MakeMaker.pm       Sun Oct 27 18:58:06 2019 +0000
+++ b/pkgtools/url2pkg/files/MakeMaker.pm       Sun Oct 27 19:19:54 2019 +0000
@@ -99,10 +99,15 @@
        printf("var\t%s\t%s\n", $varname, $value);
 }
 
+sub url2pkg_write_cmd($$) {
+       my ($cmd, $arg) = @_;
+       printf("cmd\t%s\t%s\n", $cmd, $arg);
+}
+
 sub url2pkg_write_depends($$) {
        my ($type, $deps) = @_;
 
-       return unless $deps;
+       return unless defined $deps;
        foreach my $dep (sort(keys(%$deps))) {
                url2pkg_write_dependency($type, $dep, $deps->{$dep});
        }
@@ -115,10 +120,9 @@
        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 Makefile.PL)")
+       if ($license ne "") {
+               url2pkg_write_cmd("license", $license);
+               url2pkg_write_cmd("license_default", "# TODO: $license (from Makefile.PL)");
        }
 }
 
diff -r 8f6dbdf8e278 -r 459376848a1f pkgtools/url2pkg/files/setuptools.py
--- a/pkgtools/url2pkg/files/setuptools.py      Sun Oct 27 18:58:06 2019 +0000
+++ b/pkgtools/url2pkg/files/setuptools.py      Sun Oct 27 19:19:54 2019 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: setuptools.py,v 1.6 2019/10/27 13:15:04 rillig Exp $
+# $NetBSD: setuptools.py,v 1.7 2019/10/27 19:19:55 rillig Exp $
 
 # This is a drop-in replacement for the setuptools Python module. Instead
 # of actually searching for the dependencies, it extracts the dependency
@@ -44,3 +44,14 @@
 
 def find_packages(where='.', exclude=(), include=('*',)):
     return []
+
+
+# for distutils.core; see devel/py-pysha3-1.0.2 for an example
+class Command:
+    pass
+
+
+# for distutils.extension; see devel/py-pysha3-1.0.2 for an example
+class Extension:
+    def __init__(self, *args, **kwargs):
+        pass
diff -r 8f6dbdf8e278 -r 459376848a1f pkgtools/url2pkg/files/url2pkg.py
--- a/pkgtools/url2pkg/files/url2pkg.py Sun Oct 27 18:58:06 2019 +0000
+++ b/pkgtools/url2pkg/files/url2pkg.py Sun Oct 27 19:19:54 2019 +0000
@@ -1,5 +1,5 @@
 #! @PYTHONBIN@
-# $NetBSD: url2pkg.py,v 1.23 2019/10/27 13:15:04 rillig Exp $
+# $NetBSD: url2pkg.py,v 1.24 2019/10/27 19:19:55 rillig Exp $
 
 # Copyright (c) 2019 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -122,6 +122,7 @@
              'BSD'),  # too unspecific, may be 2-clause, 3-clause, 4-clause
             ('${PERL5_LICENSE}', 'perl'),
             ('apache-2.0', 'Apache 2', 'Apache 2.0'),
+            ('artistic-2.0', 'artistic_2'),
             ('gnu-gpl-v3', 'GNU Lesser General Public License (LGPL), Version 3'),
             ('gnu-lgpl-v2', 'LGPL'),
             ('mit', 'MIT', 'MIT License'),
@@ -137,10 +138,11 @@
             return license_name
         return ''
 
+
 class Lines:
     """
-    A list of Makefile lines with high-level methods for manipulating
-    variable assignments.
+    A list of lines (typically from a Makefile, but other file types work as
+    well) with high-level methods for manipulating variable assignments.
     """
     lines: List[str]
 
@@ -483,7 +485,6 @@
     def generate_package(self, g: Globals) -> Lines:
         pkgdir = g.pkgdir
         makefile = pkgdir / 'Makefile'
-        descr = pkgdir / 'DESCR'
         plist = pkgdir / 'PLIST'
 
         initial_lines = self.generate_Makefile()
@@ -493,8 +494,14 @@
         except OSError:
             pass
         initial_lines.write_to(makefile)
-        plist.is_file() or Lines('@comment $''NetBSD$').write_to(plist)
-        descr.is_file() or Lines().write_to(descr)
+
+        plist_lines = [
+            f'@comment $''NetBSD$',
+            f'@comment TODO: to fill this file with the file listing:',
+            f'@comment TODO: 1. run "{g.make} package"',
+            f'@comment TODO: 2. run "{g.make} print-PLIST"'
+        ]
+        plist.is_file() or Lines(*plist_lines).write_to(plist)
 
         subprocess.check_call([g.editor, makefile])
 
@@ -570,6 +577,8 @@
 
     regenerate_distinfo: bool
 
+    descr_lines: List[str]
+
     def __init__(self, g: Globals, url: str, initial_lines: Lines):
         self.g = g
         self.url = url
@@ -591,6 +600,7 @@
         self.pkgname_transform = ''
         self.makefile_lines = Lines()
         self.regenerate_distinfo = False
+        self.descr_lines = []
 
     def add_dependency(self, kind: str, pkgbase: str, constraint: str, dep_dir: str) -> None:
         """ add_dependency('DEPENDS', 'package', '>=1', '../../category/package') """
@@ -698,6 +708,13 @@
     def wrksrc_open(self, relative_pathname: str):
         return (self.abs_wrksrc / relative_pathname).open()
 
+    def wrksrc_head(self, relative_pathname: str, n: int):
+        try:
+            with (self.abs_wrksrc / relative_pathname).open(encoding="UTF-8") as f:
+                return f.read().splitlines()[:n]
+        except IOError:
+            return []
+
     def wrksrc_find(self, what: Union[str, Callable[[str], bool]]) -> List[str]:
         def search(f):
             return re.search(what, f) if type(what) == str else what(f)
@@ -721,6 +738,22 @@
     def wrksrc_isfile(self, relative_pathname: str) -> bool:
         return (self.abs_wrksrc / relative_pathname).is_file()
 
+    def adjust_descr(self):
+        for filename in ('README', 'README.txt', 'README.md'):
+            lines = self.wrksrc_head(filename, 21)
+            if len(lines) == 21:
+                lines[-1] = '...'
+            if lines:
+                self.descr_lines = [
+                    f'TODO: Adjust the following lines from {filename}',
+                    '',
+                    *lines]
+                return
+
+        self.descr_lines = [
+            'TODO: Fill in a short description of the package.',
+            'TODO: It should be between 3 and 20 lines.']
+
     def adjust_configure(self):
         if not self.wrksrc_isfile('configure'):
             return
@@ -765,7 +798,7 @@
 
     def adjust_perl_module_Makefile_PL(self):
         # Example packages:
-        # devel/p5-Algorithm-Diff (no dependencies)
+        # devel/p5-Algorithm-Diff (no dependencies, no license)
         # devel/p5-Carp-Assert-More (dependencies without version numbers)
         # www/p5-HTML-Quoted (dependency with version number)
 
@@ -990,6 +1023,7 @@
         self.wrksrc_dirs = scan(self.abs_wrksrc, Path.is_dir)
         self.wrksrc_files = scan(self.abs_wrksrc, Path.is_file)
 
+        self.adjust_descr()
         self.adjust_configure()
         self.adjust_cmake()
         self.adjust_meson()
@@ -1003,6 +1037,8 @@
         self.adjust_use_languages()
 
         self.generate_lines().write_to(self.g.pkgdir / 'Makefile')
+        descr = (self.g.pkgdir / 'DESCR')
+        descr.is_file() or Lines(*self.descr_lines).write_to(descr)
 
         if self.regenerate_distinfo:
             self.g.bmake('distinfo')
diff -r 8f6dbdf8e278 -r 459376848a1f pkgtools/url2pkg/files/url2pkg_test.py
--- a/pkgtools/url2pkg/files/url2pkg_test.py    Sun Oct 27 18:58:06 2019 +0000
+++ b/pkgtools/url2pkg/files/url2pkg_test.py    Sun Oct 27 19:19:54 2019 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: url2pkg_test.py,v 1.22 2019/10/27 13:15:04 rillig Exp $
+# $NetBSD: url2pkg_test.py,v 1.23 2019/10/27 19:19:55 rillig Exp $
 
 import pytest
 from url2pkg import *
@@ -99,7 +99,7 @@
     assert g.pkgsrc_license('Apache 2') == 'apache-2.0'
 
     # Not explicitly in the list, looked up from PKGSRCDIR.
-    assert g.pkgsrc_license('artistic-2.0') == 'artistic-2.0'
+    assert g.pkgsrc_license('skype21-license') == 'skype21-license'
 
     # Neither in the list nor in PKGSRCDIR/licenses.
     assert g.pkgsrc_license('unknown') == ''
@@ -647,12 +647,17 @@
 
     Generator(url).generate_package(g)
 
-    assert (tmp_path / 'DESCR').read_text() == ''
+    assert not (tmp_path / 'DESCR').is_file()  # is created later
     assert len((tmp_path / 'Makefile').read_text().splitlines()) == 13
-    assert (tmp_path / 'PLIST').read_text() == '@comment $''NetBSD$\n'
+    assert (tmp_path / 'PLIST').read_text().splitlines() == [
+        '@comment $''NetBSD$',
+        '@comment TODO: to fill this file with the file listing:',
+        '@comment TODO: 1. run "true package"',
+        '@comment TODO: 2. run "true print-PLIST"',
+    ]
 
     # Since bmake is only fake in this test, the distinfo file is not created.
-    expected_files = ['DESCR', 'Makefile', 'PLIST']
+    expected_files = ['Makefile', 'PLIST']
     assert sorted([f.name for f in tmp_path.glob("*")]) == expected_files
 
 



Home | Main Index | Thread Index | Old Index