diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2020-01-16 21:58:15 -0500 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2020-01-17 11:36:37 -0500 |
commit | 711969c3b50383c7d6fe6eec3b945a35ad88ab71 (patch) | |
tree | b4376d882d8e22c6b3a943d1e1f2d6fa2fc9a2c1 | |
parent | b092aaff067cb50fce1f5a87edeb8636128f1b87 (diff) | |
download | meson-711969c3b50383c7d6fe6eec3b945a35ad88ab71.zip meson-711969c3b50383c7d6fe6eec3b945a35ad88ab71.tar.gz meson-711969c3b50383c7d6fe6eec3b945a35ad88ab71.tar.bz2 |
wrap: Fix support of file:// URLs
Fixes: #6445
-rw-r--r-- | mesonbuild/wrap/wrap.py | 4 | ||||
-rwxr-xr-x | run_unittests.py | 34 | ||||
-rw-r--r-- | test cases/unit/73 wrap file url/meson.build | 4 | ||||
-rw-r--r-- | test cases/unit/73 wrap file url/subprojects/foo-patch.tar.xz | bin | 0 -> 228 bytes | |||
-rw-r--r-- | test cases/unit/73 wrap file url/subprojects/foo.tar.xz | bin | 0 -> 216 bytes |
5 files changed, 39 insertions, 3 deletions
diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py index abbeb9e..0ebc2bc 100644 --- a/mesonbuild/wrap/wrap.py +++ b/mesonbuild/wrap/wrap.py @@ -335,9 +335,7 @@ class Resolver: h = hashlib.sha256() tmpfile = tempfile.NamedTemporaryFile(mode='wb', dir=self.cachedir, delete=False) url = urllib.parse.urlparse(urlstring) - if not url.hostname: - raise WrapException('{} is not a valid URL'.format(urlstring)) - if url.hostname.endswith(whitelist_subdomain): + if url.hostname and url.hostname.endswith(whitelist_subdomain): resp = open_wrapdburl(urlstring) elif whitelist_subdomain in urlstring: raise WrapException('{} may be a WrapDB-impersonating URL'.format(urlstring)) diff --git a/run_unittests.py b/run_unittests.py index bd7266a..b2b2557 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -32,6 +32,7 @@ import threading import urllib.error import urllib.request import zipfile +import hashlib from itertools import chain from unittest import mock from configparser import ConfigParser @@ -5918,6 +5919,39 @@ c = ['{0}'] def test_ld_environment_variable_fortran(self): self._check_ld('ld.gold', 'gold', 'fortran', 'GNU ld.gold') + def compute_sha256(self, filename): + with open(filename,"rb") as f: + return hashlib.sha256(f.read()).hexdigest(); + + def test_wrap_with_file_url(self): + testdir = os.path.join(self.unit_test_dir, '73 wrap file url') + source_filename = os.path.join(testdir, 'subprojects', 'foo.tar.xz') + patch_filename = os.path.join(testdir, 'subprojects', 'foo-patch.tar.xz') + wrap_filename = os.path.join(testdir, 'subprojects', 'foo.wrap') + source_hash = self.compute_sha256(source_filename) + patch_hash = self.compute_sha256(patch_filename) + wrap = textwrap.dedent("""\ + [wrap-file] + directory = foo + + source_url = file://{} + source_filename = foo.tar.xz + source_hash = {} + + patch_url = file://{} + patch_filename = foo-patch.tar.xz + patch_hash = {} + """.format(source_filename, source_hash, patch_filename, patch_hash)) + with open(wrap_filename, 'w') as f: + f.write(wrap) + self.init(testdir) + self.build() + self.run_tests() + + windows_proof_rmtree(os.path.join(testdir, 'subprojects', 'packagecache')) + windows_proof_rmtree(os.path.join(testdir, 'subprojects', 'foo')) + os.unlink(wrap_filename) + def should_run_cross_arm_tests(): return shutil.which('arm-linux-gnueabihf-gcc') and not platform.machine().lower().startswith('arm') diff --git a/test cases/unit/73 wrap file url/meson.build b/test cases/unit/73 wrap file url/meson.build new file mode 100644 index 0000000..3bd3b25 --- /dev/null +++ b/test cases/unit/73 wrap file url/meson.build @@ -0,0 +1,4 @@ +project('test wrap with file url') + +exe = subproject('foo').get_variable('foo_exe') +test('test1', exe) diff --git a/test cases/unit/73 wrap file url/subprojects/foo-patch.tar.xz b/test cases/unit/73 wrap file url/subprojects/foo-patch.tar.xz Binary files differnew file mode 100644 index 0000000..fdb026c --- /dev/null +++ b/test cases/unit/73 wrap file url/subprojects/foo-patch.tar.xz diff --git a/test cases/unit/73 wrap file url/subprojects/foo.tar.xz b/test cases/unit/73 wrap file url/subprojects/foo.tar.xz Binary files differnew file mode 100644 index 0000000..2ed6ab4 --- /dev/null +++ b/test cases/unit/73 wrap file url/subprojects/foo.tar.xz |