diff options
author | rillig <rillig@pkgsrc.org> | 2019-10-13 08:48:23 +0000 |
---|---|---|
committer | rillig <rillig@pkgsrc.org> | 2019-10-13 08:48:23 +0000 |
commit | 411ff76ba9accf80894b5f4b2e226a20265e6e59 (patch) | |
tree | 9fe1a786751ea7153f39d918b48f8ccafe816e00 /pkgtools/url2pkg/files | |
parent | 6ab8fe5fb5a1f43ffda5b4c1ab4ac17aea90ceb0 (diff) | |
download | pkgsrc-411ff76ba9accf80894b5f4b2e226a20265e6e59.tar.gz |
pkgtools/url2pkg: remove unnecessary update_vars field
Diffstat (limited to 'pkgtools/url2pkg/files')
-rw-r--r-- | pkgtools/url2pkg/files/url2pkg.py | 13 | ||||
-rw-r--r-- | pkgtools/url2pkg/files/url2pkg_test.py | 27 |
2 files changed, 23 insertions, 17 deletions
diff --git a/pkgtools/url2pkg/files/url2pkg.py b/pkgtools/url2pkg/files/url2pkg.py index 6fc6fba6c1b..5528dd7dcac 100644 --- a/pkgtools/url2pkg/files/url2pkg.py +++ b/pkgtools/url2pkg/files/url2pkg.py @@ -1,5 +1,5 @@ #! @PYTHONBIN@ -# $NetBSD: url2pkg.py,v 1.21 2019/10/12 17:38:16 rillig Exp $ +# $NetBSD: url2pkg.py,v 1.22 2019/10/13 08:48:23 rillig Exp $ # Copyright (c) 2019 The NetBSD Foundation, Inc. # All rights reserved. @@ -536,9 +536,6 @@ class Adjuster: # the Makefile, thereby forming the fifth paragraph. extra_vars: List[Var] - # variables from the initial Makefile whose values are replaced - update_vars: Dict[str, str] - # these are inserted below the second paragraph in the Makefile. todos: List[str] @@ -568,7 +565,6 @@ class Adjuster: self.includes = [] self.build_vars = [] self.extra_vars = [] - self.update_vars = {} self.todos = [] self.pkgname_prefix = '' self.pkgname_transform = '' @@ -631,7 +627,8 @@ class Adjuster: # example: var VARNAME value # possibly with comment m = re.search(r'^var\t(\S+)\t(.+)$', line) if m: - self.update_vars[m[1]] = m[2] + if not self.makefile_lines.set(m[1], m[2]): + self.extra_vars.append(Var(m[1], '=', m[2])) continue if line != '': @@ -927,10 +924,6 @@ class Adjuster: self.adjust_lines_python_module(lines) - for varname in self.update_vars: - self.g.debug('update_var {0} {1}', varname, self.update_vars[varname]) - lines.set(varname, self.update_vars[varname]) - return lines def adjust(self): diff --git a/pkgtools/url2pkg/files/url2pkg_test.py b/pkgtools/url2pkg/files/url2pkg_test.py index 545b7650e23..cde2ba8e591 100644 --- a/pkgtools/url2pkg/files/url2pkg_test.py +++ b/pkgtools/url2pkg/files/url2pkg_test.py @@ -1,4 +1,4 @@ -# $NetBSD: url2pkg_test.py,v 1.20 2019/10/12 17:38:16 rillig Exp $ +# $NetBSD: url2pkg_test.py,v 1.21 2019/10/13 08:48:23 rillig Exp $ import pytest from url2pkg import * @@ -116,6 +116,9 @@ def test_Lines_all_varassigns(): '#VAR=\t# commented variable assignment', '#VAR=', '# VAR=', # This is a regular comment + 'VAR= \\', + '\tmulti-first \\', + '\tmulti-last' ) assert str_varassigns(lines.all_varassigns('VAR')) == [ @@ -124,6 +127,7 @@ def test_Lines_all_varassigns(): 'VAR=\t# only comment', '#VAR=\t# commented variable assignment', '#VAR=', + # TODO: Add support for multi-line variable assignments. ] @@ -657,6 +661,7 @@ def test_Adjuster_read_dependencies(): cmd = "printf '%s\n' \"$URL2PKG_DEPENDENCIES\"" adjuster = Adjuster(g, '', Lines()) + adjuster.makefile_lines.add('# url2pkg-marker') adjuster.read_dependencies(cmd, env, '.', '') assert os.getenv('URL2PKG_DEPENDENCIES') is None @@ -670,10 +675,18 @@ def test_Adjuster_read_dependencies(): '# TODO: does-not-exist>=1.0', ] assert adjuster.test_depends == ['pkglint>=0:../../pkgtools/pkglint'] - assert adjuster.update_vars == { - 'HOMEPAGE': 'https://homepage.example.org/', - '#LICENSE': 'BSD # TODO: too unspecific', - } + assert detab(adjuster.generate_lines()) == [ + 'BUILD_DEPENDS+= url2pkg>=1.0:../../pkgtools/url2pkg', + 'BUILD_DEPENDS+= # TODO: does-not-exist>=1.0', + 'DEPENDS+= package>=112.0:../../pkgtools/pkglint', + 'TEST_DEPENDS+= pkglint>=0:../../pkgtools/pkglint', + '', + 'HOMEPAGE= https://homepage.example.org/', + '#LICENSE= BSD # TODO: too unspecific', + '', + 'BUILDLINK_API_DEPENDS.x11-links+= x11-links>=120.0', + '.include "../../pkgtools/x11-links/buildlink3.mk"' + ] def test_Adjuster_read_dependencies__lookup_with_prefix(): @@ -1202,8 +1215,8 @@ def test_Adjuster_generate_lines(): url = 'https://dummy.example.org/package-1.0.tar.gz' adjuster = Adjuster(g, url, Lines()) adjuster.makefile_lines = Generator(url).generate_Makefile() - adjuster.update_vars['HOMEPAGE'] = 'https://example.org/' - adjuster.update_vars['#LICENSE'] = 'BSD # TODO: too unspecific' + assert adjuster.makefile_lines.set('HOMEPAGE', 'https://example.org/') + assert adjuster.makefile_lines.set('#LICENSE', 'BSD # TODO: too unspecific') adjuster.depends.append('dependency>=0:../../category/dependency') adjuster.todos.append('Run pkglint') |