diff --git a/build-relocatable-install.py b/build-relocatable-install.py index 2e016b04e6a842fa060618cbe896af97cd45b861..42f82b99f5e6441361dd31d0e154ab2a4f7284ca 100755 --- a/build-relocatable-install.py +++ b/build-relocatable-install.py @@ -91,6 +91,7 @@ PRIMARY_ARCH_DEPENDENCIES = { 'libselinux1': 'libselinux', } SCRIPTS = [ + 'pressure-vessel-test-ui', 'pressure-vessel-unruntime', 'pressure-vessel-wrap' ] diff --git a/meson.build b/meson.build index 67b6264768d7ea10cba0ebfc9e02986d0251e6f1..8b1a24ca653e7a076d5374c190b756ce4fe01310 100644 --- a/meson.build +++ b/meson.build @@ -40,6 +40,7 @@ endif scripts = [ 'pressure-vessel-wrap', + 'pressure-vessel-test-ui', 'pressure-vessel-unruntime', ] diff --git a/pressure-vessel-test-ui b/pressure-vessel-test-ui new file mode 100755 index 0000000000000000000000000000000000000000..f86b4dd043ef48913676bafc3d207c90916e56eb --- /dev/null +++ b/pressure-vessel-test-ui @@ -0,0 +1,166 @@ +#!/usr/bin/env python3 + +# Copyright © 2019 Collabora Ltd. +# +# SPDX-License-Identifier: MIT +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +import logging +import os +import sys + +try: + import typing +except ImportError: + pass +else: + typing # silence pyflakes + +import gi +gi.require_version('Gtk', '3.0') + +from gi.repository import Gtk + +logger = logging.getLogger('pressure-vessel-test-ui') + + +class Gui: + def __init__(self): + self.window = Gtk.Window() + self.window.set_default_size(600, 300) + self.window.connect('delete-event', Gtk.main_quit) + self.window.set_title('Choose pressure-vessel runtime') + + self.grid = Gtk.Grid( + row_spacing=6, + column_spacing=6, + margin_top=12, + margin_bottom=12, + margin_start=12, + margin_end=12, + ) + self.window.add(self.grid) + + row = 0 + + runtime_label = Gtk.Label.new('Runtime') + self.grid.attach(runtime_label, 0, row, 1, 1) + + self.runtime_combo = Gtk.ComboBoxText.new() + self.runtime_combo.append('/', 'None (use host system)') + self.runtime_combo.append('scout', "SteamRT 1 'scout' (./scout)") + self.runtime_combo.append('spy', "SteamRT 2 'spy' (./spy)") + self.runtime_combo.set_active(1) + self.grid.attach(self.runtime_combo, 1, row, 1, 1) + + row += 1 + + self.native_check = Gtk.CheckButton.new_with_label( + 'Use native-code version of pressure-vessel-wrap' + ) + self.grid.attach(self.native_check, 1, row, 1, 1) + + row += 1 + + self.share_home_check = Gtk.CheckButton.new_with_label( + 'Share real home directory' + ) + self.share_home_check.set_active(True) + self.grid.attach(self.share_home_check, 1, row, 1, 1) + + row += 1 + + self.xterm_check = Gtk.CheckButton.new_with_label('Run in an xterm') + self.xterm_check.set_active(True) + self.grid.attach(self.xterm_check, 1, row, 1, 1) + + row += 1 + + buttons_grid = Gtk.Grid( + column_spacing=6, + column_homogeneous=True, + halign=Gtk.Align.END, + ) + + cancel_button = Gtk.Button.new_with_label('Cancel') + cancel_button.connect('clicked', Gtk.main_quit) + buttons_grid.attach(cancel_button, 0, 0, 1, 1) + + run_button = Gtk.Button.new_with_label('Run') + run_button.connect('clicked', self.run_cb) + buttons_grid.attach(run_button, 1, 0, 1, 1) + + self.grid.attach(buttons_grid, 0, row, 2, 1) + + row += 1 + + def run_cb(self, _ignored=None): + + if self.native_check.get_active(): + wrap = 'pressure-vessel-wrap-c' + else: + wrap = 'pressure-vessel-wrap' + + argv = [ + 'env', + 'G_MESSAGES_DEBUG=all', + os.path.join( + os.path.dirname(sys.argv[0]), + wrap, + ), + ] + + id = self.runtime_combo.get_active_id() + + if id is None: + pass + elif id == '/': + pass + else: + path = os.path.join( + os.path.dirname(sys.argv[0]), + '..', + id, + 'files', + ) + argv.append('--runtime') + argv.append(path) + + if self.share_home_check.get_active(): + argv.append('--share-home') + else: + argv.append('--unshare-home') + + if self.xterm_check.get_active(): + argv.append('--xterm') + + argv.append('--verbose') + argv.extend(sys.argv[1:]) + + os.execvp(argv[0], argv) + + def run(self): + self.window.show_all() + Gtk.main() + + +if __name__ == '__main__': + Gui().run() diff --git a/pressure-vessel-unruntime b/pressure-vessel-unruntime index f5df1d718c9beb07dffb765a7d5472041a15954b..4c3556d45351e2b8134f456580424b1226858783 100755 --- a/pressure-vessel-unruntime +++ b/pressure-vessel-unruntime @@ -96,6 +96,10 @@ for word in $ld_preload; do done IFS="$old_IFS" +if [ -n "${PRESSURE_VESSEL_WRAP_GUI+set}" ]; then + exec "${here}/pressure-vessel-test-ui" ${options+"${options[@]}"} "$@" +fi + if [ -n "${PRESSURE_VESSEL_WRAP_NATIVE+set}" ]; then exec "${here}/pressure-vessel-wrap-c" ${options+"${options[@]}"} "$@" fi diff --git a/t/mypy.sh b/t/mypy.sh index 3d0d9c44d2b38687bf2e415aa9a7596e27cec1bb..b552359755e1ef2deba9ab26d067d523c7cb0a24 100755 --- a/t/mypy.sh +++ b/t/mypy.sh @@ -21,6 +21,7 @@ export MYPYPATH="${PYTHONPATH:="$(pwd)"}" i=0 for script in \ "${G_TEST_SRCDIR}"/*.py \ + "${G_TEST_SRCDIR}"/pressure-vessel-test-ui \ "${G_TEST_SRCDIR}"/sysroot/*.py \ ; do i=$((i + 1)) diff --git a/t/pycodestyle.sh b/t/pycodestyle.sh index f3481eddba5445dfec04b0fe66f3bf79dcee2386..0c0113a1b8bcda8b52d895c2f8d41afca1a05c0f 100755 --- a/t/pycodestyle.sh +++ b/t/pycodestyle.sh @@ -24,8 +24,13 @@ fi echo "1..1" +# Ignore E402: when using GObject-Introspection, not all imports +# can come first + if "${PYCODESTYLE}" \ + --ignore=E402 \ "$G_TEST_SRCDIR"/*.py \ + "${G_TEST_SRCDIR}"/pressure-vessel-test-ui \ "${G_TEST_SRCDIR}"/sysroot/*.py \ >&2; then echo "ok 1 - $PYCODESTYLE reported no issues" diff --git a/t/pyflakes.sh b/t/pyflakes.sh index db2c87e91f7c938e40434f2f4707a156acbbcce8..5134e76448382cd6dc807a3198a976cc062a7f32 100755 --- a/t/pyflakes.sh +++ b/t/pyflakes.sh @@ -21,6 +21,7 @@ if [ "x${PYFLAKES:=pyflakes3}" = xfalse ] || \ echo "1..0 # SKIP pyflakes3 not found" elif "${PYFLAKES}" \ "${G_TEST_SRCDIR}"/*.py \ + "${G_TEST_SRCDIR}"/pressure-vessel-test-ui \ "${G_TEST_SRCDIR}"/sysroot/*.py \ >&2; then echo "1..1"