diff options
author | bst-marge-bot <marge-bot@buildstream.build> | 2019-07-04 12:43:10 +0000 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-07-04 12:43:10 +0000 |
commit | a80adc03bfa6cd2ba7a7fe3981f00556e5e1f5da (patch) | |
tree | acda735d6311dbf77e3b567801158bbf2c370dd4 | |
parent | 1be4a7f1ea65af2f8ee6391a01a14dc685f5be26 (diff) | |
parent | 438ee733d67dbde09718fe45271628763b27b8e1 (diff) | |
download | buildstream-a80adc03bfa6cd2ba7a7fe3981f00556e5e1f5da.tar.gz |
Merge branch 'shashwatdalal/tar-file-extraction' into 'master'
utils.py: Change permissions for rootpath in `_force_rmtree`
Closes #912
See merge request BuildStream/buildstream!1441
-rw-r--r-- | src/buildstream/utils.py | 2 | ||||
-rw-r--r-- | tests/sources/tar.py | 25 | ||||
-rw-r--r-- | tests/sources/tar/read-only/content/b.tar.gz | bin | 0 -> 148 bytes |
3 files changed, 23 insertions, 4 deletions
diff --git a/src/buildstream/utils.py b/src/buildstream/utils.py index 775a11142..b5b554ee5 100644 --- a/src/buildstream/utils.py +++ b/src/buildstream/utils.py @@ -730,6 +730,8 @@ def _is_main_process(): # Recursively remove directories, ignoring file permissions as much as # possible. def _force_rmtree(rootpath, **kwargs): + + os.chmod(rootpath, 0o755) for root, dirs, _ in os.walk(rootpath): for d in dirs: path = os.path.join(root, d.lstrip('/')) diff --git a/tests/sources/tar.py b/tests/sources/tar.py index 07108ccbb..8d409b512 100644 --- a/tests/sources/tar.py +++ b/tests/sources/tar.py @@ -276,21 +276,38 @@ def test_stage_default_basedir_lzip(cli, tmpdir, datafiles, srcdir): assert checkout_contents == original_contents -# Test that a tarball that contains a read only dir works +# Test that tarballs with read-only files work +# a - contains read-only files in a writable directory +# b - root directory has read-only permission @pytest.mark.datafiles(os.path.join(DATA_DIR, 'read-only')) -def test_read_only_dir(cli, tmpdir, datafiles): +@pytest.mark.parametrize("tar_name", ["a", "b"]) +def test_read_only_dir(cli, tmpdir, datafiles, tar_name): try: project = str(datafiles) generate_project(project, tmpdir) + bst_path = os.path.join(project, "target.bst") + tar_file = "{}.tar.gz".format(tar_name) + + _yaml.dump({ + 'kind': 'import', + 'sources': [ + { + 'kind': 'tar', + 'url': 'tmpdir:/{}'.format(tar_file), + 'ref': 'foo' + } + ] + }, bst_path) + # Get the tarball in tests/sources/tar/read-only/content # # NOTE that we need to do this because tarfile.open and tar.add() # are packing the tar up with writeable files and dirs - tarball = os.path.join(str(datafiles), 'content', 'a.tar.gz') + tarball = os.path.join(str(datafiles), 'content', tar_file) if not os.path.exists(tarball): raise FileNotFoundError('{} does not exist'.format(tarball)) - copyfile(tarball, os.path.join(str(tmpdir), 'a.tar.gz')) + copyfile(tarball, os.path.join(str(tmpdir), tar_file)) # Because this test can potentially leave directories behind # which are difficult to remove, ask buildstream to use diff --git a/tests/sources/tar/read-only/content/b.tar.gz b/tests/sources/tar/read-only/content/b.tar.gz Binary files differnew file mode 100644 index 000000000..79fd1e864 --- /dev/null +++ b/tests/sources/tar/read-only/content/b.tar.gz |