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: remove unnece...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/c08196cf6be1
branches:  trunk
changeset: 415743:c08196cf6be1
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sun Oct 13 08:48:23 2019 +0000

description:
pkgtools/url2pkg: remove unnecessary update_vars field

diffstat:

 pkgtools/url2pkg/files/url2pkg.py      |  13 +++----------
 pkgtools/url2pkg/files/url2pkg_test.py |  27 ++++++++++++++++++++-------
 2 files changed, 23 insertions(+), 17 deletions(-)

diffs (118 lines):

diff -r 5a397ce73f4b -r c08196cf6be1 pkgtools/url2pkg/files/url2pkg.py
--- a/pkgtools/url2pkg/files/url2pkg.py Sun Oct 13 08:22:07 2019 +0000
+++ b/pkgtools/url2pkg/files/url2pkg.py Sun Oct 13 08:48:23 2019 +0000
@@ -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 @@
     # 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 @@
         self.includes = []
         self.build_vars = []
         self.extra_vars = []
-        self.update_vars = {}
         self.todos = []
         self.pkgname_prefix = ''
         self.pkgname_transform = ''
@@ -631,7 +627,8 @@
             # 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 @@
 
         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 -r 5a397ce73f4b -r c08196cf6be1 pkgtools/url2pkg/files/url2pkg_test.py
--- a/pkgtools/url2pkg/files/url2pkg_test.py    Sun Oct 13 08:22:07 2019 +0000
+++ b/pkgtools/url2pkg/files/url2pkg_test.py    Sun Oct 13 08:48:23 2019 +0000
@@ -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 @@
         '#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 @@
         'VAR=\t# only comment',
         '#VAR=\t# commented variable assignment',
         '#VAR=',
+        # TODO: Add support for multi-line variable assignments.
     ]
 
 
@@ -657,6 +661,7 @@
     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 @@
         '# 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 @@
     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')
 



Home | Main Index | Thread Index | Old Index