diff options
author | rillig <rillig@pkgsrc.org> | 2019-10-05 19:59:04 +0000 |
---|---|---|
committer | rillig <rillig@pkgsrc.org> | 2019-10-05 19:59:04 +0000 |
commit | 62aaf6d64a393a1fa752f451b8b17df87c1dd46d (patch) | |
tree | 7a7d48ec13561885a9bae345196c5c6622176821 /pkgtools/url2pkg | |
parent | e69acc6ef324f0ce25a29aad1a533ca89f65bcc9 (diff) | |
download | pkgsrc-62aaf6d64a393a1fa752f451b8b17df87c1dd46d.tar.gz |
pkgtools/url2pkg: clean up code
Diffstat (limited to 'pkgtools/url2pkg')
-rw-r--r-- | pkgtools/url2pkg/files/url2pkg.py | 23 | ||||
-rw-r--r-- | pkgtools/url2pkg/files/url2pkg_test.py | 6 |
2 files changed, 14 insertions, 15 deletions
diff --git a/pkgtools/url2pkg/files/url2pkg.py b/pkgtools/url2pkg/files/url2pkg.py index e6eb42ed68b..44168ede925 100644 --- a/pkgtools/url2pkg/files/url2pkg.py +++ b/pkgtools/url2pkg/files/url2pkg.py @@ -1,5 +1,5 @@ #! @PYTHONBIN@ -# $NetBSD: url2pkg.py,v 1.12 2019/10/05 19:24:35 rillig Exp $ +# $NetBSD: url2pkg.py,v 1.13 2019/10/05 19:59:04 rillig Exp $ # Copyright (c) 2019 The NetBSD Foundation, Inc. # All rights reserved. @@ -266,11 +266,8 @@ class Generator: continue m = re.search(r'^\t(.*?)(?:\s+\\)?$', line) - if not m: - continue - - site_url = m[1] - action(varname, site_url) + if m: + action(varname, m[1]) def adjust_site_from_sites_mk(self, varname: str, site_url: str): @@ -379,15 +376,15 @@ class Generator: distname, extract_sufx = m.groups() else: distname, extract_sufx = self.distfile, '# none' + self.distname = distname m = re.search(r'^v\d', distname) if m: self.pkgname_transform = ':S,^v,,' elif re.search(r'-v\d', distname) and not re.search(r'-v.*-v\d', distname): self.pkgname_transform = ':S,-v,-,' - self.distname = distname - main_category = re.search(r'.*/([^/]+)/[^/]+$', os.getcwd())[1] + main_category = pathlib.Path.cwd().parts[-2] self.categories = main_category \ if main_category not in ('local', 'wip') \ else '# TODO: add primary category' @@ -454,10 +451,8 @@ class Generator: except OSError: pass initial_lines.write_to(makefile) - if not os.path.isfile(plist): - Lines('@comment $''NetBSD$').write_to(plist) - if not os.path.isfile(descr): - Lines().write_to(descr) + plist.is_file() or Lines('@comment $''NetBSD$').write_to(plist) + descr.is_file() or Lines().write_to(descr) subprocess.check_call([up.editor, makefile]) @@ -468,8 +463,8 @@ class Generator: class Adjuster: """ - The following adjust_* functions are called after the distfiles have - been downloaded and extracted. They inspect the extracted files + After the distfile has been downloaded and extracted, the + adjust_* methods of this class inspect the extracted files and adjust the variable definitions in the package Makefile. """ diff --git a/pkgtools/url2pkg/files/url2pkg_test.py b/pkgtools/url2pkg/files/url2pkg_test.py index d6641f7f155..463fb45e25c 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.11 2019/10/05 19:24:35 rillig Exp $ +# $NetBSD: url2pkg_test.py,v 1.12 2019/10/05 19:59:04 rillig Exp $ import pytest from url2pkg import * @@ -1391,6 +1391,10 @@ def test_main__valid_URL(): f'url2pkg: running bmake (\'distinfo\', \'extract\') in \'{up.pkgdir}\'', 'url2pkg: Adjusting the Makefile', ] + + up.verbose = False + up.bmake('clean') # remove the work directory + expected_files = ['DESCR', 'Makefile', 'PLIST', 'distinfo'] assert sorted([f.name for f in up.pkgdir.glob("*")]) == expected_files |