diff options
author | Daniele Nicolodi <daniele@grinta.net> | 2023-03-26 10:51:28 +0200 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2023-04-21 13:29:15 +0530 |
commit | 387d47f6e1a7a002ba5d2275466bbde6e905ae2e (patch) | |
tree | 48a4f0f382d3453fad2d84232ef0c4c92b4ea713 | |
parent | b81a5f4035ee6b76338a5d7fc7cfebb92e2468ff (diff) | |
download | meson-387d47f6e1a7a002ba5d2275466bbde6e905ae2e.tar.gz |
minstall: Fix install_subdir() excludes with path separators on Win
The paths in meson.build use / as path separator, however, the paths
constructed during the directory structure walk use native path
separators, thus the path never compare equal to the excluded ones.
Normalize the exclusion paths before the comparison.
-rw-r--r-- | mesonbuild/minstall.py | 2 | ||||
-rw-r--r-- | test cases/common/59 install subdir/meson.build | 6 | ||||
-rw-r--r-- | test cases/common/59 install subdir/sub3/data/data.txt | 1 | ||||
-rw-r--r-- | test cases/common/59 install subdir/sub3/data/excluded.txt | 1 | ||||
-rw-r--r-- | test cases/common/59 install subdir/sub3/data/excluded/excluded.txt | 1 | ||||
-rw-r--r-- | test cases/common/59 install subdir/test.json | 1 | ||||
-rw-r--r-- | unittests/allplatformstests.py | 11 |
7 files changed, 18 insertions, 5 deletions
diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py index 8c74990ad..e0572a828 100644 --- a/mesonbuild/minstall.py +++ b/mesonbuild/minstall.py @@ -482,6 +482,8 @@ class Installer: raise ValueError(f'dst_dir must be absolute, got {dst_dir}') if exclude is not None: exclude_files, exclude_dirs = exclude + exclude_files = {os.path.normpath(x) for x in exclude_files} + exclude_dirs = {os.path.normpath(x) for x in exclude_dirs} else: exclude_files = exclude_dirs = set() for root, dirs, files in os.walk(src_dir): diff --git a/test cases/common/59 install subdir/meson.build b/test cases/common/59 install subdir/meson.build index 13d41bedf..fb2034bff 100644 --- a/test cases/common/59 install subdir/meson.build +++ b/test cases/common/59 install subdir/meson.build @@ -7,6 +7,12 @@ install_subdir('sub2', exclude_directories : ['excluded'], install_dir : 'share') +# More exclusions +install_subdir('sub3', + exclude_files : ['data/excluded.txt'], + exclude_directories : ['data/excluded'], + install_dir : 'share') + subdir('subdir') # A subdir with write perms only for the owner # and read-list perms for owner and group diff --git a/test cases/common/59 install subdir/sub3/data/data.txt b/test cases/common/59 install subdir/sub3/data/data.txt new file mode 100644 index 000000000..1269488f7 --- /dev/null +++ b/test cases/common/59 install subdir/sub3/data/data.txt @@ -0,0 +1 @@ +data diff --git a/test cases/common/59 install subdir/sub3/data/excluded.txt b/test cases/common/59 install subdir/sub3/data/excluded.txt new file mode 100644 index 000000000..bbde3dc9d --- /dev/null +++ b/test cases/common/59 install subdir/sub3/data/excluded.txt @@ -0,0 +1 @@ +excluded diff --git a/test cases/common/59 install subdir/sub3/data/excluded/excluded.txt b/test cases/common/59 install subdir/sub3/data/excluded/excluded.txt new file mode 100644 index 000000000..bbde3dc9d --- /dev/null +++ b/test cases/common/59 install subdir/sub3/data/excluded/excluded.txt @@ -0,0 +1 @@ +excluded diff --git a/test cases/common/59 install subdir/test.json b/test cases/common/59 install subdir/test.json index 0dd885cb5..aa8e27ab7 100644 --- a/test cases/common/59 install subdir/test.json +++ b/test cases/common/59 install subdir/test.json @@ -12,6 +12,7 @@ {"type": "file", "file": "usr/share/sub1/sub2/data2.dat"}, {"type": "file", "file": "usr/share/sub2/one.dat"}, {"type": "file", "file": "usr/share/sub2/dircheck/excluded-three.dat"}, + {"type": "file", "file": "usr/share/sub3/data/data.txt"}, {"type": "dir", "file": "usr/share/new_directory"} ] } diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py index 8e0bd136c..160435416 100644 --- a/unittests/allplatformstests.py +++ b/unittests/allplatformstests.py @@ -440,14 +440,15 @@ class AllPlatformTests(BasePlatformTests): self.init(testdir) intro = self.introspect('--installed') expected = { + 'nested_elided/sub': 'share', + 'new_directory': 'share/new_directory', + 'sub/sub1': 'share/sub1', + 'sub1': 'share/sub1', 'sub2': 'share/sub2', + 'sub3': '/usr/share/sub3', + 'sub_elided': 'share', 'subdir/sub1': 'share/sub1', 'subdir/sub_elided': 'share', - 'sub1': 'share/sub1', - 'sub/sub1': 'share/sub1', - 'sub_elided': 'share', - 'nested_elided/sub': 'share', - 'new_directory': 'share/new_directory', } self.assertEqual(len(intro), len(expected)) |