diff options
author | Stéphane Cerveau <scerveau@collabora.com> | 2021-06-07 10:42:18 +0200 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2021-08-06 15:03:29 -0400 |
commit | 7e8d5207a7c662beeae41b375e0af5c96f57e7db (patch) | |
tree | 2ccc4f266b3a9d6080e80032b88c6316d3753cc9 /mesonbuild | |
parent | 53ce1610a63cde9befe3da44bfa07d43468ef1bf (diff) | |
download | meson-7e8d5207a7c662beeae41b375e0af5c96f57e7db.zip meson-7e8d5207a7c662beeae41b375e0af5c96f57e7db.tar.gz meson-7e8d5207a7c662beeae41b375e0af5c96f57e7db.tar.bz2 |
install: update restore_selinux to use popen_safe
Use Popen_safe to simplify the code.
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/minstall.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py index 654b547..2a4f68a 100644 --- a/mesonbuild/minstall.py +++ b/mesonbuild/minstall.py @@ -229,6 +229,9 @@ def restore_selinux_contexts() -> None: # is ignored quietly. return + if os.environ.get('DESTDIR'): + return + if not shutil.which('restorecon'): # If we don't have restorecon, failure is ignored quietly. return @@ -237,13 +240,11 @@ def restore_selinux_contexts() -> None: # If the list of files is empty, do not try to call restorecon. return - with subprocess.Popen(['restorecon', '-F', '-f-', '-0'], - stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as proc: - out, err = proc.communicate(input=b'\0'.join(os.fsencode(f) for f in selinux_updates) + b'\0') - if proc.returncode != 0 and not os.environ.get('DESTDIR'): - print('Failed to restore SELinux context of installed files...', - 'Standard output:', out.decode(), - 'Standard error:', err.decode(), sep='\n') + proc, out, err = Popen_safe(['restorecon', '-F', '-f-', '-0'], (b'\0'.join(os.fsencode(f) for f in selinux_updates) + b'\0').decode()) + if proc.returncode != 0 : + print('Failed to restore SELinux context of installed files...', + 'Standard output:', out, + 'Standard error:', err, sep='\n') def get_destdir_path(destdir: str, fullprefix: str, path: str) -> str: |