aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/scripts
diff options
context:
space:
mode:
authorRyan Gonzalez <rymg19@gmail.com>2018-05-14 15:53:42 -0500
committerJussi Pakkanen <jpakkane@gmail.com>2018-05-17 00:23:18 +0300
commit559286a0daa87056594a9dcbc8540f5a7bf6f8f8 (patch)
treef9618532572d1f2d186dfed574a0f612a28554ca /mesonbuild/scripts
parent8a9f7cf1332a0be9b2e90d39483c6aa7c67fffee (diff)
downloadmeson-559286a0daa87056594a9dcbc8540f5a7bf6f8f8.zip
meson-559286a0daa87056594a9dcbc8540f5a7bf6f8f8.tar.gz
meson-559286a0daa87056594a9dcbc8540f5a7bf6f8f8.tar.bz2
Support installation via polkit
Diffstat (limited to 'mesonbuild/scripts')
-rw-r--r--mesonbuild/scripts/meson_install.py44
1 files changed, 27 insertions, 17 deletions
diff --git a/mesonbuild/scripts/meson_install.py b/mesonbuild/scripts/meson_install.py
index b454260..b0c05cb 100644
--- a/mesonbuild/scripts/meson_install.py
+++ b/mesonbuild/scripts/meson_install.py
@@ -18,6 +18,7 @@ from glob import glob
from . import depfixer
from . import destdir_join
from ..mesonlib import is_windows, Popen_safe
+from __main__ import __file__ as main_file
install_log_file = None
selinux_updates = []
@@ -221,23 +222,35 @@ def get_destdir_path(d, path):
output = os.path.join(d.fullprefix, path)
return output
-def do_install(datafilename):
+def do_install(log_dir, datafilename):
+ global install_log_file
+
with open(datafilename, 'rb') as ifile:
d = pickle.load(ifile)
d.destdir = os.environ.get('DESTDIR', '')
d.fullprefix = destdir_join(d.destdir, d.prefix)
+ if not os.access(d.fullprefix, os.W_OK) and shutil.which('pkexec') is not None:
+ os.execlp('pkexec', 'pkexec', sys.executable, main_file, *sys.argv[1:],
+ os.getcwd())
+
if d.install_umask is not None:
os.umask(d.install_umask)
- d.dirmaker = DirMaker()
- with d.dirmaker:
- install_subdirs(d) # Must be first, because it needs to delete the old subtree.
- install_targets(d)
- install_headers(d)
- install_man(d)
- install_data(d)
- restore_selinux_contexts()
- run_install_script(d)
+
+ with open(os.path.join(log_dir, 'install-log.txt'), 'w') as lf:
+ install_log_file = lf
+ append_to_log('# List of files installed by Meson')
+ append_to_log('# Does not contain files installed by custom scripts.')
+
+ d.dirmaker = DirMaker()
+ with d.dirmaker:
+ install_subdirs(d) # Must be first, because it needs to delete the old subtree.
+ install_targets(d)
+ install_headers(d)
+ install_man(d)
+ install_data(d)
+ restore_selinux_contexts()
+ run_install_script(d)
def install_subdirs(d):
for (src_dir, dst_dir, mode, exclude) in d.install_subdirs:
@@ -401,18 +414,15 @@ def install_targets(d):
raise
def run(args):
- global install_log_file
- if len(args) != 1:
+ if len(args) != 1 and len(args) != 2:
print('Installer script for Meson. Do not run on your own, mmm\'kay?')
print('meson_install.py [install info file]')
datafilename = args[0]
private_dir = os.path.dirname(datafilename)
log_dir = os.path.join(private_dir, '../meson-logs')
- with open(os.path.join(log_dir, 'install-log.txt'), 'w') as lf:
- install_log_file = lf
- append_to_log('# List of files installed by Meson')
- append_to_log('# Does not contain files installed by custom scripts.')
- do_install(datafilename)
+ if len(args) == 2:
+ os.chdir(args[1])
+ do_install(log_dir, datafilename)
install_log_file = None
return 0