#!/usr/bin/env python3 """Build and stage private hotplug fixtures; never install or restart Wayfire.""" import argparse import os from pathlib import Path import pwd import shlex import shutil import subprocess import tempfile parser = argparse.ArgumentParser() parser.add_argument('--user', default='ecsfwxvr') parser.add_argument('--plugin', type=Path, help='Candidate libforce-fullscreen.so; omit for installed version') args = parser.parse_args() root = Path(__file__).resolve().parent stage = Path(tempfile.mkdtemp(prefix='wayfire-crash-stage-', dir='/var/tmp')) plugins = stage / 'plugins' plugins.mkdir() flags = shlex.split(subprocess.check_output(['pkg-config', '--cflags', '--libs', 'wayfire', 'wf-utils'], text=True)) subprocess.run(['c++', '-std=c++17', '-shared', '-fPIC', '-g', '-DWAYFIRE_PLUGIN', '-DWLR_USE_UNSTABLE', str(root / 'hotplug-test.cpp'), '-o', str(plugins / 'libhotplug-test.so'), *flags], check=True) shutil.copy2(root / 'reproduce.py', stage / 'reproduce.py') if args.plugin: shutil.copy2(args.plugin, plugins / 'libforce-fullscreen.so') account = pwd.getpwnam(args.user) for path in [stage, *stage.rglob('*')]: if os.geteuid() == 0: os.chown(path, account.pw_uid, account.pw_gid) path.chmod(0o755 if path.is_dir() else 0o644) print(stage)