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: ignore URL pr...
details: https://anonhg.NetBSD.org/pkgsrc/rev/77e5e13045a0
branches: trunk
changeset: 402217:77e5e13045a0
user: rillig <rillig%pkgsrc.org@localhost>
date: Sat Oct 05 12:22:51 2019 +0000
description:
pkgtools/url2pkg: ignore URL protocol
The MASTER_SITE_GNU still uses http:// for downloading the distfiles.
Since typical URLs today use https://, ignore the protocol when matching
the given URL against the MASTER_SITE_* variables from mk/fetch/sites.mk.
diffstat:
pkgtools/url2pkg/files/url2pkg.py | 13 +++--
pkgtools/url2pkg/files/url2pkg_test.py | 73 ++++++++++++++++++++++++++++-----
2 files changed, 68 insertions(+), 18 deletions(-)
diffs (174 lines):
diff -r ce48e21bd54e -r 77e5e13045a0 pkgtools/url2pkg/files/url2pkg.py
--- a/pkgtools/url2pkg/files/url2pkg.py Sat Oct 05 12:13:25 2019 +0000
+++ b/pkgtools/url2pkg/files/url2pkg.py Sat Oct 05 12:22:51 2019 +0000
@@ -1,5 +1,5 @@
#! @PYTHONBIN@
-# $NetBSD: url2pkg.py,v 1.9 2019/10/05 11:02:30 rillig Exp $
+# $NetBSD: url2pkg.py,v 1.10 2019/10/05 12:22:51 rillig Exp $
# Copyright (c) 2019 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -267,10 +267,14 @@
action(varname, site_url)
def adjust_site_from_sites_mk(self, varname: str, site_url: str):
- if not self.url.startswith(site_url):
+
+ url_noproto = re.sub(r'^\w+://', '', self.url)
+ site_url_noproto = re.sub(r'^\w+://', '', site_url)
+
+ if not url_noproto.startswith(site_url_noproto):
return
- rest = self.url[len(site_url):]
+ rest = url_noproto[len(site_url_noproto):]
if '/' not in rest:
self.master_sites = f'${{{varname}}}'
self.distfile = rest
@@ -283,10 +287,7 @@
if varname == 'MASTER_SITE_GNU':
self.homepage = f'https://www.gnu.org/software/{subdir}'
else:
- print('site_url', site_url)
- print('distfile', self.distfile)
self.homepage = self.url[:-len(self.distfile)] + ' # TODO: check'
- print('homepage', self.homepage)
def adjust_site_SourceForge(self):
pattern = r'^https?://downloads\.sourceforge\.net/' \
diff -r ce48e21bd54e -r 77e5e13045a0 pkgtools/url2pkg/files/url2pkg_test.py
--- a/pkgtools/url2pkg/files/url2pkg_test.py Sat Oct 05 12:13:25 2019 +0000
+++ b/pkgtools/url2pkg/files/url2pkg_test.py Sat Oct 05 12:22:51 2019 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: url2pkg_test.py,v 1.8 2019/10/05 11:02:30 rillig Exp $
+# $NetBSD: url2pkg_test.py,v 1.9 2019/10/05 12:22:51 rillig Exp $
import pytest
from url2pkg import *
@@ -15,6 +15,26 @@
assert up.pkgsrcdir is not None
os.chdir(up.pkgsrcdir + '/pkgtools/url2pkg')
+ class Wr:
+ def __init__(self) -> None:
+ self.buf = ''
+
+ def write(self, s: str):
+ self.buf += s
+
+ def output(self):
+ result = self.buf
+ self.buf = ''
+ return result
+
+ up.out = Wr()
+ up.err = Wr()
+
+
+def teardown_function(_):
+ assert up.out.output() == ''
+ assert up.err.output() == ''
+
def str_vars(vars: List[Var]) -> List[str]:
def to_string(var):
@@ -33,6 +53,7 @@
def detab(lines: Lines) -> List[str]:
""" Replaces tabs with the appropriate amount of spaces. """
+
def detab_line(line: str) -> str:
detabbed = []
for ch in line:
@@ -45,23 +66,15 @@
return list(map(detab_line, lines.lines))
-def test_debug():
- class Wr:
- def __init__(self) -> None:
- self.output = ''
-
- def write(self, s: str):
- self.output += s
-
+def test_Url2Pkg_debug():
up.verbose = True
- up.err = Wr()
up.debug('plain message')
up.debug('list {0}', [1, 2, 3])
up.debug('tuple {0}', (1, 2, 3))
up.debug('cwd {0} env {1} cmd {2}', 'directory', {'VAR': 'value'}, 'command')
- assert up.err.output.splitlines() == [
+ assert up.err.output().splitlines() == [
'url2pkg: plain message',
'url2pkg: list [1, 2, 3]',
'url2pkg: tuple (1, 2, 3)',
@@ -69,6 +82,15 @@
]
+def test_Url2Pkg_bmake():
+ up.verbose = True
+ up.make = 'echo'
+
+ up.bmake('hello', 'world')
+
+ assert up.err.output() == 'url2pkg: running bmake (\'hello\', \'world\')\n'
+
+
def test_Lines__write_and_read(tmp_path):
example = tmp_path / 'example'
@@ -485,6 +507,29 @@
]
+def test_Generator_adjust_site_from_sites_mk__GNU():
+ url = 'https://ftp.gnu.org/pub/gnu/cflow/cflow-1.6.tar.gz'
+ generator = Generator(url)
+
+ lines = generator.generate_Makefile()
+
+ assert detab(lines) == [
+ mkcvsid,
+ '',
+ 'DISTNAME= cflow-1.6',
+ 'CATEGORIES= pkgtools',
+ 'MASTER_SITES= ${MASTER_SITE_GNU:=cflow/}',
+ '',
+ 'MAINTAINER= INSERT_YOUR_MAIL_ADDRESS_HERE # or use pkgsrc-users%NetBSD.org@localhost',
+ 'HOMEPAGE= https://www.gnu.org/software/cflow/',
+ 'COMMENT= TODO: Short description of the package',
+ '#LICENSE= # TODO: (see mk/license.mk)',
+ '',
+ '# url2pkg-marker (please do not remove this line.)',
+ '.include "../../mk/bsd.pkg.mk"',
+ ]
+
+
def test_Generator_adjust_everything_else__distname_version_with_v():
# Some version numbers have a leading 'v', derived from the Git tag name.
@@ -539,6 +584,7 @@
'DEPENDS\tpackage>=112.0:../../pkgtools/pkglint',
'DEPENDS\tpackage>=120.0:../../pkgtools/x11-links',
'BUILD_DEPENDS\turl2pkg>=1.0',
+ 'BUILD_DEPENDS\tdoes-not-exist>=1.0',
'TEST_DEPENDS\tpkglint',
'A line that is not a dependency at all',
'',
@@ -557,7 +603,10 @@
'BUILDLINK_API_DEPENDS.x11-links+=\tx11-links>=120.0',
".include \"../../pkgtools/x11-links/buildlink3.mk\"",
]
- assert adjuster.build_depends == ['url2pkg>=1.0:../../pkgtools/url2pkg']
+ assert adjuster.build_depends == [
+ 'url2pkg>=1.0:../../pkgtools/url2pkg',
+ '# TODO: does-not-exist>=1.0',
+ ]
assert adjuster.test_depends == ['pkglint>=0:../../pkgtools/pkglint']
assert adjuster.update_vars == {'HOMEPAGE': 'https://homepage.example.org/'}
Home |
Main Index |
Thread Index |
Old Index