diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2020-05-28 13:22:57 -0400 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2020-06-21 23:39:12 +0300 |
commit | e353b2e8d48c8ffce579342fac9ccfc62127bec8 (patch) | |
tree | 0aaf8f6f46ade428317a5cfe8013fda4cb31479a /mesonbuild/wrap | |
parent | 246e5437aaf213401a22361a55c46e70a4eb505d (diff) | |
download | meson-e353b2e8d48c8ffce579342fac9ccfc62127bec8.zip meson-e353b2e8d48c8ffce579342fac9ccfc62127bec8.tar.gz meson-e353b2e8d48c8ffce579342fac9ccfc62127bec8.tar.bz2 |
wrap: Add patch_directory support
Copy a tree instead of extracting an archive.
Closes: #7216
Diffstat (limited to 'mesonbuild/wrap')
-rw-r--r-- | mesonbuild/wrap/wrap.py | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py index 9d95bff..44173f7 100644 --- a/mesonbuild/wrap/wrap.py +++ b/mesonbuild/wrap/wrap.py @@ -126,9 +126,6 @@ class PackageDefinition: m = 'Missing key {!r} in {}' raise WrapException(m.format(key, self.basename)) - def has_patch(self) -> bool: - return 'patch_filename' in self.values - def load_wrap(subdir_root: str, packagename: str) -> PackageDefinition: fname = os.path.join(subdir_root, packagename + '.wrap') if os.path.isfile(fname): @@ -253,8 +250,7 @@ class Resolver: os.mkdir(self.dirname) extract_dir = self.dirname shutil.unpack_archive(path, extract_dir) - if self.wrap.has_patch(): - self.apply_patch() + self.apply_patch() def get_git(self) -> None: if not GIT: @@ -422,13 +418,25 @@ class Resolver: return path.as_posix() def apply_patch(self) -> None: - path = self.get_file_internal('patch') - try: - shutil.unpack_archive(path, self.subdir_root) - except Exception: - with tempfile.TemporaryDirectory() as workdir: - shutil.unpack_archive(path, workdir) - self.copy_tree(workdir, self.subdir_root) + if 'patch_filename' in self.wrap.values and 'patch_directory' in self.wrap.values: + m = 'Wrap file {!r} must not have both "patch_filename" and "patch_directory"' + raise WrapException(m.format(self.wrap.basename)) + if 'patch_filename' in self.wrap.values: + path = self.get_file_internal('patch') + try: + shutil.unpack_archive(path, self.subdir_root) + except Exception: + with tempfile.TemporaryDirectory() as workdir: + shutil.unpack_archive(path, workdir) + self.copy_tree(workdir, self.subdir_root) + elif 'patch_directory' in self.wrap.values: + from ..interpreterbase import FeatureNew + FeatureNew('patch_directory', '0.55.0').use(self.current_subproject) + patch_dir = self.wrap.values['patch_directory'] + src_dir = os.path.join(self.filesdir, patch_dir) + if not os.path.isdir(src_dir): + raise WrapException('patch directory does not exists: {}'.format(patch_dir)) + self.copy_tree(src_dir, self.dirname) def copy_tree(self, root_src_dir: str, root_dst_dir: str) -> None: """ |