pkgsrc-Changes archive

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

CVS commit: pkgsrc/pkgtools/url2pkg/files



Module Name:    pkgsrc
Committed By:   rillig
Date:           Sun Oct 13 08:48:23 UTC 2019

Modified Files:
        pkgsrc/pkgtools/url2pkg/files: url2pkg.py url2pkg_test.py

Log Message:
pkgtools/url2pkg: remove unnecessary update_vars field


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 pkgsrc/pkgtools/url2pkg/files/url2pkg.py
cvs rdiff -u -r1.20 -r1.21 pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py

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/files/url2pkg.py
diff -u pkgsrc/pkgtools/url2pkg/files/url2pkg.py:1.21 pkgsrc/pkgtools/url2pkg/files/url2pkg.py:1.22
--- pkgsrc/pkgtools/url2pkg/files/url2pkg.py:1.21       Sat Oct 12 17:38:16 2019
+++ pkgsrc/pkgtools/url2pkg/files/url2pkg.py    Sun Oct 13 08:48:23 2019
@@ -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):

Index: pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py
diff -u pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py:1.20 pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py:1.21
--- pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py:1.20  Sat Oct 12 17:38:16 2019
+++ pkgsrc/pkgtools/url2pkg/files/url2pkg_test.py       Sun Oct 13 08:48:23 2019
@@ -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')
 



Home | Main Index | Thread Index | Old Index