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: clean up code
details: https://anonhg.NetBSD.org/pkgsrc/rev/bc70314494cc
branches: trunk
changeset: 415356:bc70314494cc
user: rillig <rillig%pkgsrc.org@localhost>
date: Sat Oct 05 19:59:04 2019 +0000
description:
pkgtools/url2pkg: clean up code
diffstat:
pkgtools/url2pkg/files/url2pkg.py | 23 +++++++++--------------
pkgtools/url2pkg/files/url2pkg_test.py | 6 +++++-
2 files changed, 14 insertions(+), 15 deletions(-)
diffs (86 lines):
diff -r 96647180195c -r bc70314494cc pkgtools/url2pkg/files/url2pkg.py
--- a/pkgtools/url2pkg/files/url2pkg.py Sat Oct 05 19:24:35 2019 +0000
+++ b/pkgtools/url2pkg/files/url2pkg.py Sat Oct 05 19:59:04 2019 +0000
@@ -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 @@
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 @@
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 @@
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 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 -r 96647180195c -r bc70314494cc pkgtools/url2pkg/files/url2pkg_test.py
--- a/pkgtools/url2pkg/files/url2pkg_test.py Sat Oct 05 19:24:35 2019 +0000
+++ b/pkgtools/url2pkg/files/url2pkg_test.py Sat Oct 05 19:59:04 2019 +0000
@@ -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 @@
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
Home |
Main Index |
Thread Index |
Old Index