diff options
author | Ryan Gonzalez <rymg19@gmail.com> | 2018-05-14 15:53:42 -0500 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2018-05-17 00:23:18 +0300 |
commit | 559286a0daa87056594a9dcbc8540f5a7bf6f8f8 (patch) | |
tree | f9618532572d1f2d186dfed574a0f612a28554ca | |
parent | 8a9f7cf1332a0be9b2e90d39483c6aa7c67fffee (diff) | |
download | meson-559286a0daa87056594a9dcbc8540f5a7bf6f8f8.zip meson-559286a0daa87056594a9dcbc8540f5a7bf6f8f8.tar.gz meson-559286a0daa87056594a9dcbc8540f5a7bf6f8f8.tar.bz2 |
Support installation via polkit
-rw-r--r-- | data/com.mesonbuild.install.policy | 24 | ||||
-rw-r--r-- | mesonbuild/scripts/meson_install.py | 44 | ||||
-rw-r--r-- | setup.py | 3 |
3 files changed, 53 insertions, 18 deletions
diff --git a/data/com.mesonbuild.install.policy b/data/com.mesonbuild.install.policy new file mode 100644 index 0000000..9a00de2 --- /dev/null +++ b/data/com.mesonbuild.install.policy @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE policyconfig PUBLIC "-//freedesktop//DTD polkit Policy Configuration 1.0//EN" +"http://www.freedesktop.org/software/polkit/policyconfig-1.dtd"> +<policyconfig> + + <vendor>The Meson Build System</vendor> + <vendor_url>https://github.com/mesonbuild/meson</vendor_url> + + <action id="com.mesonbuild.install.run"> + <description>Install the given project via Meson</description> + <message>Authentication is required to install this project</message> + <icon_name>preferences-system</icon_name> + <defaults> + <allow_any>no</allow_any> + <allow_inactive>no</allow_inactive> + <allow_active>auth_admin_keep</allow_active> + </defaults> + <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/python3</annotate> + <annotate key="org.freedesktop.policykit.exec.argv1">/usr/bin/meson</annotate> + <annotate key="org.freedesktop.policykit.exec.argv2">--internal</annotate> + <annotate key="org.freedesktop.policykit.exec.argv3">install</annotate> + </action> + +</policyconfig> 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 @@ -81,7 +81,8 @@ setup(name='meson', 'man/mesonconf.1', 'man/mesonintrospect.1', 'man/mesontest.1', - 'man/wraptool.1'])], + 'man/wraptool.1']), + ('share/polkit-1/actions', ['data/com.mesonbuild.install.policy'])], classifiers=['Development Status :: 5 - Production/Stable', 'Environment :: Console', 'Intended Audience :: Developers', |