Mon Oct 28 20:17:24 2019 UTC ()
pkgtools/url2pkg: update to 19.3.5

Changes since 19.3.4:

Added the license names from R2pkg and texlive2pkg.


(rillig)
diff -r1.107 -r1.108 pkgsrc/pkgtools/url2pkg/Makefile
diff -r1.24 -r1.25 pkgsrc/pkgtools/url2pkg/files/url2pkg.py
diff -r1.23 -r1.24 pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py

cvs diff -r1.107 -r1.108 pkgsrc/pkgtools/url2pkg/Makefile (expand / switch to unified diff)

--- pkgsrc/pkgtools/url2pkg/Makefile 2019/10/27 19:19:54 1.107
+++ pkgsrc/pkgtools/url2pkg/Makefile 2019/10/28 20:17:24 1.108
@@ -1,16 +1,16 @@ @@ -1,16 +1,16 @@
1# $NetBSD: Makefile,v 1.107 2019/10/27 19:19:54 rillig Exp $ 1# $NetBSD: Makefile,v 1.108 2019/10/28 20:17:24 rillig Exp $
2 2
3PKGNAME= url2pkg-19.3.4 3PKGNAME= url2pkg-19.3.5
4CATEGORIES= pkgtools 4CATEGORIES= pkgtools
5 5
6MAINTAINER= rillig@NetBSD.org 6MAINTAINER= rillig@NetBSD.org
7HOMEPAGE= http://www.NetBSD.org/docs/pkgsrc/creating.html 7HOMEPAGE= http://www.NetBSD.org/docs/pkgsrc/creating.html
8COMMENT= Tool to automate initial steps in building a package 8COMMENT= Tool to automate initial steps in building a package
9LICENSE= 2-clause-bsd 9LICENSE= 2-clause-bsd
10 10
11WRKSRC= ${WRKDIR} 11WRKSRC= ${WRKDIR}
12NO_CHECKSUM= yes 12NO_CHECKSUM= yes
13NO_BUILD= yes 13NO_BUILD= yes
14USE_LANGUAGES= # none 14USE_LANGUAGES= # none
15USE_TOOLS+= perl:run 15USE_TOOLS+= perl:run
16AUTO_MKDIRS= yes 16AUTO_MKDIRS= yes

cvs diff -r1.24 -r1.25 pkgsrc/pkgtools/url2pkg/files/url2pkg.py (expand / switch to unified diff)

--- pkgsrc/pkgtools/url2pkg/files/url2pkg.py 2019/10/27 19:19:55 1.24
+++ pkgsrc/pkgtools/url2pkg/files/url2pkg.py 2019/10/28 20:17:24 1.25
@@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
1#! @PYTHONBIN@ 1#! @PYTHONBIN@
2# $NetBSD: url2pkg.py,v 1.24 2019/10/27 19:19:55 rillig Exp $ 2# $NetBSD: url2pkg.py,v 1.25 2019/10/28 20:17:24 rillig Exp $
3 3
4# Copyright (c) 2019 The NetBSD Foundation, Inc. 4# Copyright (c) 2019 The NetBSD Foundation, Inc.
5# All rights reserved. 5# All rights reserved.
6# 6#
7# This code is derived from software contributed to The NetBSD Foundation 7# This code is derived from software contributed to The NetBSD Foundation
8# by Roland Illig. 8# by Roland Illig.
9# 9#
10# Redistribution and use in source and binary forms, with or without 10# Redistribution and use in source and binary forms, with or without
11# modification, are permitted provided that the following conditions 11# modification, are permitted provided that the following conditions
12# are met: 12# are met:
13# 1. Redistributions of source code must retain the above copyright 13# 1. Redistributions of source code must retain the above copyright
14# notice, this list of conditions and the following disclaimer. 14# notice, this list of conditions and the following disclaimer.
15# 2. Redistributions in binary form must reproduce the above copyright 15# 2. Redistributions in binary form must reproduce the above copyright
@@ -106,46 +106,94 @@ class Globals: @@ -106,46 +106,94 @@ class Globals:
106 if len(candidates) != 1: 106 if len(candidates) != 1:
107 return '' 107 return ''
108 return str(candidates[0]).replace(str(self.pkgsrcdir), '../..') 108 return str(candidates[0]).replace(str(self.pkgsrcdir), '../..')
109 109
110 def bmake(self, *args: str) -> None: 110 def bmake(self, *args: str) -> None:
111 self.debug('running bmake {0} in {1}', args, str(self.pkgdir)) 111 self.debug('running bmake {0} in {1}', args, str(self.pkgdir))
112 subprocess.check_call([self.make, *args], cwd=self.pkgdir) 112 subprocess.check_call([self.make, *args], cwd=self.pkgdir)
113 113
114 def show_var(self, varname: str) -> str: 114 def show_var(self, varname: str) -> str:
115 output = subprocess.check_output((self.make, 'show-var', 'VARNAME=' + varname)) 115 output = subprocess.check_output((self.make, 'show-var', 'VARNAME=' + varname))
116 return output.decode('utf-8').strip() 116 return output.decode('utf-8').strip()
117 117
118 def pkgsrc_license(self, license_name: str) -> str: 118 def pkgsrc_license(self, license_name: str) -> str:
 119 comment = ''
 120
 121 def suffix(suf: str, comm: str):
 122 nonlocal license_name, comment
 123 if comment == '' and license_name.endswith(suf):
 124 comment = f'\t# {comm}'
 125 license_name = license_name[:-len(suf)].rstrip()
 126
 127 suffix('| file LICENSE', 'OR file LICENSE')
 128 suffix('+ file LICENSE', '+ file LICENSE')
 129
119 known_licenses = ( 130 known_licenses = (
120 ('', 131 ('2-clause-bsd', 'BSD-2', 'bsd2', 'BSD_2_clause'),
121 'Apache Software License', # too unspecific; needs a version number 132 # ('2-clause-bsd OR modified-bsd OR original-bsd', 'BSD'), # XXX: questionable
122 'BSD'), # too unspecific, may be 2-clause, 3-clause, 4-clause 133 ('acm-license', 'ACM'),
123 ('${PERL5_LICENSE}', 'perl'), 134 ('apache-1.1 OR apache-2.0', 'APACHE'),
124 ('apache-2.0', 'Apache 2', 'Apache 2.0'), 135 ('apache-2.0', 'Apache 2', 'Apache 2.0', 'apache2',
 136 'Apache Software License', 'Apache License 2.0',
 137 'Apache License (== 2.0)'),
 138 ('apache-2.0 AND lppl-1.3c', 'apache2lppl', 'apache2lppl1.3c',
 139 'lppl1.3capache2'),
 140 ('artistic OR artistic-2.0', 'ARTISTIC'),
125 ('artistic-2.0', 'artistic_2'), 141 ('artistic-2.0', 'artistic_2'),
126 ('gnu-gpl-v3', 'GNU Lesser General Public License (LGPL), Version 3'), 142 ('boost-license', 'BSL-1.0'),
127 ('gnu-lgpl-v2', 'LGPL'), 143 ('cc-by-v4.0', 'cc-by-4'),
 144 ('cc0-1.0-universal', 'CC0'),
 145 ('gfsl', 'gfl'),
 146 ('gnu-fdl-v1.3', 'fdl'),
 147 ('gnu-gpl-v1', 'GPL-1'),
 148 ('gnu-gpl-v1 OR gnu-gpl-v2 OR gnu-gpl-v3', 'GPL'),
 149 ('gnu-gpl-v2', 'gpl', 'gpl2', 'GPL-2'),
 150 ('gnu-gpl-v2 AND cc-by-sa-v4.0', 'gpl3+cc-by-sa-4'),
 151 ('gnu-gpl-v2 AND lppl-1.3c', 'lpplgpl', 'gpl2lppl'),
 152 ('gnu-gpl-v2 AND ofl-v1.1 AND lppl-1.3c', 'gplofllppl'),
 153 ('gnu-gpl-v2 OR gnu-gpl-v3', 'GPL-2 | GPL-3', 'GPL (>= 2)', 'GPL (>= 2.0)'),
 154 ('gnu-gpl-v3', 'gpl3', 'GPL-3',
 155 'GNU Lesser General Public License (LGPL), Version 3'),
 156 ('gnu-gpl-v3', 'GPL (>= 3)'),
 157 ('gnu-lgpl-v2', 'LGPL', 'LGPL-2'),
 158 ('gnu-lgpl-v2 OR gnu-lgpl-v2.1 OR gnu-lgpl-v3', 'LGPL'),
 159 ('gnu-lgpl-v2.1', 'LGPL-2.1'),
 160 ('gnu-lgpl-v3', 'LGPL-3'),
 161 ('gnu-lgpl-v2 OR gnu-lgpl-v3', 'LGPL-2 | LGPL-3'),
 162 ('gnu-lgpl-v2 OR gnu-lgpl-v2.1 OR gnu-lgpl-v3', 'LGPL (>= 2)'),
 163 ('lppl-1.0', 'lppl1'),
 164 ('lppl-1.2', 'lppl1.2'),
 165 ('lppl-1.3c', 'lppl', 'lppl1.3', 'lppl1.3c'),
 166 ('lucent', 'LUCENT', 'Lucent Public License'),
128 ('mit', 'MIT', 'MIT License'), 167 ('mit', 'MIT', 'MIT License'),
129 ('python-software-foundation', 168 ('mit\t# + file LICENSE OR unlimited', 'MIT + file LICENSE | Unlimited'),
130 'PSF', 'PSF license', 'Python Software Foundation License'), 169 ('mit AND lppl-1.3c', 'mitlppl'),
 170 ('modified-bsd', 'bsd3', 'BSD 3 clause', 'BSD_3_clause'),
 171 ('ofl-v1.1', 'ofl'),
 172 ('ofl-v1.1 AND lppl-1.3c', 'ofllppl1.3', 'ofllppl1.3c', 'ofllppl'),
 173 ('${PERL5_LICENSE}', 'perl'),
 174 ('postgresql-license', 'POSTGRESQL'),
 175 ('public-domain', 'pd'),
 176 ('python-software-foundation', 'PSF', 'PSF license',
 177 'Python Software Foundation License'),
131 ('zpl-2.1', 'ZPL 2.1'), 178 ('zpl-2.1', 'ZPL 2.1'),
132 ) 179 )
133 180
134 for known_license in known_licenses: 181 lower = license_name.lower()
135 if license_name in known_license: 182 for group in known_licenses:
136 return known_license[0] 183 if lower in map(str.lower, group):
137 if (self.pkgsrcdir / 'licenses' / license_name).is_file(): 184 return group[0] + comment
138 return license_name 185 if (self.pkgsrcdir / 'licenses' / lower).is_file():
 186 return lower + comment
139 return '' 187 return ''
140 188
141 189
142class Lines: 190class Lines:
143 """ 191 """
144 A list of lines (typically from a Makefile, but other file types work as 192 A list of lines (typically from a Makefile, but other file types work as
145 well) with high-level methods for manipulating variable assignments. 193 well) with high-level methods for manipulating variable assignments.
146 """ 194 """
147 lines: List[str] 195 lines: List[str]
148 196
149 def __init__(self, *lines: str) -> None: 197 def __init__(self, *lines: str) -> None:
150 self.lines = [] 198 self.lines = []
151 for line in lines: 199 for line in lines:

cvs diff -r1.23 -r1.24 pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py (expand / switch to unified diff)

--- pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py 2019/10/27 19:19:55 1.23
+++ pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py 2019/10/28 20:17:24 1.24
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: url2pkg_test.py,v 1.23 2019/10/27 19:19:55 rillig Exp $ 1# $NetBSD: url2pkg_test.py,v 1.24 2019/10/28 20:17:24 rillig Exp $
2 2
3import pytest 3import pytest
4from url2pkg import * 4from url2pkg import *
5 5
6mkcvsid = '# $''NetBSD$' 6mkcvsid = '# $''NetBSD$'
7g: Globals 7g: Globals
8prev_dir = Path.cwd() 8prev_dir = Path.cwd()
9 9
10 10
11def setup_function(_): 11def setup_function(_):
12 global g 12 global g
13 13
14 g = Globals() 14 g = Globals()
@@ -84,33 +84,36 @@ def test_Global_debug(): @@ -84,33 +84,36 @@ def test_Global_debug():
84 84
85def test_Global_bmake(): 85def test_Global_bmake():
86 g.verbose = True 86 g.verbose = True
87 g.make = 'echo' 87 g.make = 'echo'
88 88
89 g.bmake('hello', 'world') 89 g.bmake('hello', 'world')
90 90
91 assert g.err.written() == [ 91 assert g.err.written() == [
92 'url2pkg: running bmake (\'hello\', \'world\') in \'.\'', 92 'url2pkg: running bmake (\'hello\', \'world\') in \'.\'',
93 ] 93 ]
94 94
95 95
96def test_Global_pkgsrc_license(): 96def test_Global_pkgsrc_license():
97 assert g.pkgsrc_license('BSD') == '' 97 assert g.pkgsrc_license('BSD') == '' # too unspecific
98 assert g.pkgsrc_license('apache-2.0') == 'apache-2.0' 98 assert g.pkgsrc_license('apache-2.0') == 'apache-2.0'
99 assert g.pkgsrc_license('Apache 2') == 'apache-2.0' 99 assert g.pkgsrc_license('Apache 2') == 'apache-2.0'
100 100
101 # Not explicitly in the list, looked up from PKGSRCDIR. 101 # Not explicitly in the list, looked up from PKGSRCDIR.
102 assert g.pkgsrc_license('skype21-license') == 'skype21-license' 102 assert g.pkgsrc_license('skype21-license') == 'skype21-license'
103 103
 104 assert g.pkgsrc_license('mit + file LICENSE') == 'mit\t# + file LICENSE'
 105 assert g.pkgsrc_license('MIT | file LICENSE') == 'mit\t# OR file LICENSE'
 106
104 # Neither in the list nor in PKGSRCDIR/licenses. 107 # Neither in the list nor in PKGSRCDIR/licenses.
105 assert g.pkgsrc_license('unknown') == '' 108 assert g.pkgsrc_license('unknown') == ''
106 109
107 110
108def test_Lines__write_and_read(tmp_path: Path): 111def test_Lines__write_and_read(tmp_path: Path):
109 example = tmp_path / 'example' 112 example = tmp_path / 'example'
110 113
111 lines = Lines('1', '2', '3') 114 lines = Lines('1', '2', '3')
112 115
113 lines.write_to(example) 116 lines.write_to(example)
114 117
115 assert example.read_text() == '1\n2\n3\n' 118 assert example.read_text() == '1\n2\n3\n'
116 119