From b9bf67754db631fe7ff46ca9f19ed22ad1b3468d Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Fri, 28 Oct 2022 19:44:19 +0200 Subject: [PATCH] [yabridgectl] Check for libdbus-1.so Instead of checking for notify-send. --- tools/yabridgectl/Cargo.lock | 11 +++++++++++ tools/yabridgectl/Cargo.toml | 1 + tools/yabridgectl/src/actions.rs | 5 +++-- tools/yabridgectl/src/util.rs | 17 +++++++++-------- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/tools/yabridgectl/Cargo.lock b/tools/yabridgectl/Cargo.lock index f4efb65e..e1235fae 100644 --- a/tools/yabridgectl/Cargo.lock +++ b/tools/yabridgectl/Cargo.lock @@ -311,6 +311,16 @@ version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" +[[package]] +name = "libloading" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd" +dependencies = [ + "cfg-if", + "winapi", +] + [[package]] name = "linux-raw-sys" version = "0.0.46" @@ -832,6 +842,7 @@ dependencies = [ "colored", "goblin", "is_executable", + "libloading", "promptly", "rayon", "reflink", diff --git a/tools/yabridgectl/Cargo.toml b/tools/yabridgectl/Cargo.toml index 508864d7..3eb4b193 100644 --- a/tools/yabridgectl/Cargo.toml +++ b/tools/yabridgectl/Cargo.toml @@ -15,6 +15,7 @@ clap = { version = "3.0.6", features = ["cargo", "env", "wrap_help"] } colored = "2.0.0" is_executable = "1.0.1" goblin = { version = "0.6", default_features = false, features = ["std", "pe32", "pe64"] } +libloading = "0.7.3" promptly = "0.3.1" # Version 0.1.3 from crates.io assumes a 64-bit toolchain reflink = { git = "https://github.com/nicokoch/reflink", rev = "e8d93b465f5d9ad340cd052b64bbc77b8ee107e2" } diff --git a/tools/yabridgectl/src/actions.rs b/tools/yabridgectl/src/actions.rs index 2a3438b6..67d57282 100644 --- a/tools/yabridgectl/src/actions.rs +++ b/tools/yabridgectl/src/actions.rs @@ -833,8 +833,9 @@ pub fn do_sync(config: &mut Config, options: &SyncOptions) -> Result<()> { // This check is only performed once per combination of Wine and yabridge versions verify_wine_setup(config)?; - // Yabridge uses notify-send to relay important information when something's very wrong, so - // we'll check whether this is installed + // Yabridge uses D-Bus notifications to relay important information when something's very wrong, + // so we'll check whether `libdbus-1.so` is available (even though it would be very odd if it + // isn't) verify_external_dependencies()?; Ok(()) diff --git a/tools/yabridgectl/src/util.rs b/tools/yabridgectl/src/util.rs index cffb3318..9d90bed5 100644 --- a/tools/yabridgectl/src/util.rs +++ b/tools/yabridgectl/src/util.rs @@ -29,7 +29,6 @@ use std::os::unix::process::CommandExt; use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; use textwrap::Wrapper; -use which::which; use crate::config::{self, Config, KnownConfig, YABRIDGE_HOST_32_EXE_NAME, YABRIDGE_HOST_EXE_NAME}; use crate::files::{LibArchitecture, NativeFile}; @@ -465,18 +464,20 @@ pub fn verify_wine_setup(config: &mut Config) -> Result<()> { Ok(()) } -/// Check whether `notify-send` is installed, as this is used to relay important information when -/// something's very wrong. +/// Check whether yabridge's (optional) external dependencies are installed. Right now this only +/// checks for libdbus, as this is used to relay important information when something's very wrong. pub fn verify_external_dependencies() -> Result<()> { - if which("notify-send").is_err() { + let libdbus_name = libloading::library_filename("dbus-1"); + let libdbus_available = unsafe { libloading::Library::new(&libdbus_name) }.is_ok(); + if !libdbus_available { eprintln!( "\n{}", wrap(&format!( "Warning: Could not find '{}'. This will not prevent yabridge from working, but \ - you will also not receive any notifcations when something is wrong. It is \ - usually part of the libnotify package, but your distro might have moved it into \ - a separate libnotify-tools package.", - "notify-send".bright_white(), + you will also not receive any notifcations when something is wrong. D-Bus should \ + already be installed on the system, so if you're seeing this warning then \ + something is probably very wrong.", + libdbus_name.to_str().unwrap().bright_white(), )) ); }