mirror of
https://github.com/deskflow/deskflow.git
synced 2026-06-13 21:02:14 +08:00
* Add libei and libportal * Port libei and libportal code by Peter Hutterer and Olivier Fourdan * Add Peter Hutterer and Olivier Fourdan to important devs list * Improve error handling for libei and libportal builds * Checkout libportal tags/0.7.1 * Hack out the gi-docgen clone * Remove new submodules in favor of using ExternalProject_Add * Remove submodule dirs * Use ExternalProject_Add instead of submodules * Fixed namespace * Hack to work around type libportal causing type conflicts * Add log helper functions * Use original log functions * Switch to FetchContent, use libportal a1530a9 (unreleased) and use camelCase member names for consistency * Restore a few events (much more work required) * Add TODOs for supporting multiple lib versions * Revert "Switch to FetchContent, use libportal a1530a9 (unreleased) and use camelCase member names for consistency" This reverts commit610cebb5b6. * Simplify cmake config by removing builds for libei and libportal (will do this in `install_deps.py` instead) * Remove submodules * Remove .gitmodules * Use meson to build subprojects * Update copyright with Peter Hutterer's guidance * Use meson for installing deps * Fixed typo in tag name * Remove submodules * Remove old submodules * Fixed libei name * Defaults for pugixml and gtest depending on whether source exists in subprojects * Ignore some subproject dirs * Make deps OS-specific * Move python deps to pyproject * Only compile and install on Linux with Meson * Revert "Move python deps to pyproject" This reverts commit92c8a287b8. * Add ninja to brewfile * Add python3-attr * Restore original coverage config * Add ninja for meson * Include meson in same try-except * Fixed ninja dep name * Move libs to correct oS * Fixed include for wintoast * Disable docs for libportal * More options for libei and libportal * Fixed option for libei * Use ninja directly to install * Revert "Use ninja directly to install" This reverts commitc926d78ba4. * Meson install verbose * Prints stdout/stderr * Remove `from None` * Remove submodules that somehow crept back in?! * Prepend sudo if exists * Add libei deps for all distros * Fixed Fedora package name * Add more deps for other distros * Add more libs (including pugixml) * Fix lib name * Drop -u from pacman * Add vala to rhel * Make libportal optional * Make portal link optional * Remove example code * Always use system pugixml * Disable interactive apt through install_deps.py * Revert "Disable interactive apt through install_deps.py" This reverts commit5bbc8fd689. * Set DEBIAN_FRONTEND in workflows * Set DEBIAN_FRONTEND in CodeQL workflow * Add gtest dep * Add bundled libei dep * Add libei dep to Arch * Use `googletest` on openSUSE * Add gmock dep * Remove gtest dep from openSUSE * Add libei on Fedora * Bundle libei for older Linux distros * Disable libei dep for RPM * Also bundle symlink to .so * Use ${CMAKE_INSTALL_LIBDIR} * Rename libei to fix openSUSE * List installed files * Add libei-devel to openSUSE * Add googletest-devel to openSUSE * Remove manual deps (probably resolved automatically) * Remove googletest from openSUSE (doesn't provide google mock) * Only add Portal* if libportal found * WIP - Partial work on using old events system :'( * Add deps install commands for subprojects * Solved more compile issues related to events system, threads, etc * Fixed bad config for adding x, ei, portal sources * Remove redundant deps * Remove (another) redundant dep * Fixed pacman command * Add Ubuntu and Linux Mint libei deps * Fixed Ubuntu and Linux Mint libei deps aliases * Only iterate subprojects if not None * Add rhel, rocky, and alma for libei * Make rhel-like deps same as fedora again * Build libportal on rhel-like * Re-enable meson rhel-like for libportal * Remove dbus-python * Make libportal optional (for rhel-like) * Handle ei event queue results * Re-introduce libportal * Print libei and libportal versions * Add ei/portal args and client screen * Switch --use args to --no * Don't build libei/libportal on older distros as it's pointless * Make libei and libportal optional * Add Debian 13 runner * Make some packages optional * Remove subprojects * Improve comment * Add comment for libportal * Improve comment * Add Debian 13 runner * Make optional... optional * Change continuation stripper to remove newline and continuation char * Make command strip more uniform * Fixed help var syntax * Fixed libei linking * Ensure `kHelpNoWayland` is always defined * Improve help message * Fixed Debian 13 runner name * Include sstream and use const var * Update ChangeLog * Remove Wayland block * Return new timer * Make tray icon logging verbose * Fixed arg parser for wayland args * Fixed init of EI screen * Fixed lint issues * Update README to indicate Wayland support in GNOME 46 * Add missing word * Fixed comment positions * Automate CI env * Tone down debug log messages * Add missing comma * Remove redundant log line
192 lines
5.8 KiB
Python
192 lines
5.8 KiB
Python
import os, shutil, glob, sys
|
|
import lib.cmd_utils as cmd_utils
|
|
import lib.env as env
|
|
from enum import Enum, auto
|
|
|
|
|
|
class PackageType(Enum):
|
|
DISTRO = auto()
|
|
TGZ = auto()
|
|
|
|
|
|
dist_dir = "dist"
|
|
build_dir = "build"
|
|
package_name = "synergy"
|
|
test_cmd = "synergys --version"
|
|
|
|
|
|
def run_command(command, check=True):
|
|
|
|
has_sudo = cmd_utils.has_command("sudo")
|
|
if "sudo" in command and not has_sudo:
|
|
# assume we're running as root if sudo is not found (common on older distros).
|
|
# a space char is intentionally added after "sudo" for intentionality.
|
|
# possible limitation with stripping "sudo" is that if any packages with "sudo" in the
|
|
# name are added to the list (probably very unlikely), this will have undefined behavior.
|
|
print("The 'sudo' command was not found, stripping sudo from command")
|
|
command = command.replace("sudo ", "").strip()
|
|
|
|
cmd_utils.run(command, check, shell=True, print_cmd=True)
|
|
|
|
|
|
def package(filename_base, package_type: PackageType, leave_test_installed=False):
|
|
|
|
extension, cmd = get_package_info(package_type)
|
|
run_package_cmd(cmd)
|
|
package_filename = get_package_filename(extension)
|
|
target_file = f"{filename_base}.{extension}"
|
|
target_path = copy_to_dist_dir(package_filename, target_file)
|
|
|
|
if package_type == PackageType.DISTRO:
|
|
test_install(target_path, remove_test=not leave_test_installed)
|
|
|
|
|
|
def get_package_info(package_type: PackageType):
|
|
|
|
command = None
|
|
cpack_generator = None
|
|
file_extension = None
|
|
|
|
if package_type == PackageType.TGZ:
|
|
cpack_generator = "TGZ"
|
|
file_extension = "tar.gz"
|
|
|
|
elif package_type == PackageType.DISTRO:
|
|
|
|
distro, distro_like, _distro_version = env.get_linux_distro()
|
|
if not distro_like:
|
|
distro_like = distro
|
|
|
|
if "debian" in distro_like:
|
|
cpack_generator = "DEB"
|
|
file_extension = "deb"
|
|
elif "fedora" in distro_like or "opensuse" in distro_like:
|
|
cpack_generator = "RPM"
|
|
file_extension = "rpm"
|
|
elif "arch" in distro_like:
|
|
command = ["makepkg", "-s"]
|
|
file_extension = "pkg.tar.zst"
|
|
else:
|
|
raise RuntimeError(f"Linux distro not yet supported: {distro}")
|
|
|
|
if not cpack_generator and not command:
|
|
raise RuntimeError("No package generator or command found")
|
|
|
|
if cpack_generator:
|
|
command = ["cpack", "-G", cpack_generator]
|
|
|
|
return file_extension, command
|
|
|
|
|
|
def run_package_cmd(command):
|
|
package_user = env.get_env("LINUX_PACKAGE_USER", required=False)
|
|
if package_user:
|
|
cmd_utils.run(
|
|
["sudo", "chown", "-R", package_user, "build"], check=True, print_cmd=True
|
|
)
|
|
command = ["sudo", "-u", package_user] + command
|
|
|
|
cwd = os.getcwd()
|
|
try:
|
|
os.chdir("build")
|
|
cmd_utils.run(command, check=True, print_cmd=True)
|
|
finally:
|
|
os.chdir(cwd)
|
|
|
|
|
|
def get_package_filename(extension):
|
|
files = glob.glob(f"build/*.{extension}")
|
|
|
|
if not files:
|
|
raise ValueError(f"No .{extension} file found in build directory")
|
|
|
|
return files[0]
|
|
|
|
|
|
def copy_to_dist_dir(source_file, target_file):
|
|
os.makedirs(dist_dir, exist_ok=True)
|
|
|
|
target_path = f"{dist_dir}/{target_file}"
|
|
print(f"Copying to: {target_path}")
|
|
shutil.copy(source_file, target_path)
|
|
|
|
return target_path
|
|
|
|
|
|
def test_install(package_file, remove_test=True):
|
|
|
|
distro, distro_like, _distro_version = env.get_linux_distro()
|
|
if not distro_like:
|
|
distro_like = distro
|
|
|
|
install_base = None
|
|
list_cmd = None
|
|
remove_base = None
|
|
if "debian" in distro_like:
|
|
install_base = ["apt", "install", "-f", "-y"]
|
|
remove_base = ["apt", "remove", "-y"]
|
|
list_cmd = ["dpkg", "-L", "synergy"]
|
|
elif "fedora" in distro_like:
|
|
install_base = ["dnf", "install", "-y"]
|
|
remove_base = ["dnf", "remove", "-y"]
|
|
list_cmd = ["rpm", "-ql", "synergy"]
|
|
elif "opensuse" in distro_like:
|
|
install_base = ["zypper", "--no-gpg-checks", "install", "-y"]
|
|
remove_base = ["zypper", "remove", "-y"]
|
|
list_cmd = ["rpm", "-ql", "synergy"]
|
|
elif "arch" in distro_like:
|
|
install_base = ["pacman", "-U", "--noconfirm"]
|
|
remove_base = ["pacman", "-R", "--noconfirm"]
|
|
list_cmd = ["pacman", "-Ql", "synergy"]
|
|
else:
|
|
raise RuntimeError(f"Linux distro not yet supported: {distro}")
|
|
|
|
has_sudo = cmd_utils.has_command("sudo")
|
|
sudo = ["sudo"] if has_sudo else []
|
|
|
|
print("Testing installation...")
|
|
cmd_utils.run(
|
|
sudo + install_base + [f"./{package_file}"],
|
|
check=True,
|
|
print_cmd=True,
|
|
)
|
|
|
|
print("Listing installed files...")
|
|
cmd_utils.run(sudo + list_cmd, check=True, print_cmd=True)
|
|
|
|
try:
|
|
cmd_utils.run(test_cmd, shell=True, check=True, print_cmd=True)
|
|
except Exception:
|
|
raise RuntimeError("Unable to verify version")
|
|
finally:
|
|
if remove_test:
|
|
cmd_utils.run(
|
|
sudo + remove_base + [package_name], check=True, print_cmd=True
|
|
)
|
|
else:
|
|
print("Leaving test package installed")
|
|
|
|
print("Installation test passed")
|
|
|
|
|
|
def is_package_available(package):
|
|
distro, distro_like, _distro_version = env.get_linux_distro()
|
|
if not distro_like:
|
|
distro_like = distro
|
|
|
|
if "debian" in distro_like:
|
|
command = ["apt-cache", "show", package]
|
|
elif "fedora" in distro_like:
|
|
command = ["dnf", "info", package]
|
|
elif "opensuse" in distro_like:
|
|
command = ["zypper", "info", package]
|
|
elif "arch" in distro_like:
|
|
command = ["pacman", "-Si", package]
|
|
else:
|
|
raise RuntimeError(f"Linux distro not yet supported: {distro}")
|
|
|
|
result = cmd_utils.run(command, check=False, print_cmd=True, get_output=True)
|
|
if result.stderr:
|
|
print(result.stderr, file=sys.stderr)
|
|
return result.returncode == 0
|