Explorar o código

fix(ci): [CLI] do not rely on libappindicator-sys (#4335)

Lucas Fernandes Nogueira %!s(int64=3) %!d(string=hai) anos
pai
achega
d29971e22c

+ 0 - 4
.github/workflows/covector-version-or-publish.yml

@@ -115,10 +115,6 @@ jobs:
           registry-url: 'https://registry.npmjs.org'
           cache: yarn
           cache-dependency-path: tooling/*/yarn.lock
-      - name: install Linux dependencies
-        run: |
-          sudo apt-get update
-          sudo apt-get install -y libgtk-3-dev
 
       - name: cargo login
         run: cargo login ${{ secrets.crate_token }}

+ 0 - 156
tooling/cli/Cargo.lock

@@ -70,18 +70,6 @@ version = "0.9.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "d67af77d68a931ecd5cbd8a3b5987d63a1d1d1278f7f6a60ae33db485cdebb69"
 
-[[package]]
-name = "atk-sys"
-version = "0.15.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "58aeb089fb698e06db8089971c7ee317ab9644bade33383f63631437b03aafb6"
-dependencies = [
- "glib-sys",
- "gobject-sys",
- "libc",
- "system-deps",
-]
-
 [[package]]
 name = "attohttpc"
 version = "0.19.1"
@@ -240,16 +228,6 @@ dependencies = [
  "pkg-config",
 ]
 
-[[package]]
-name = "cairo-sys-rs"
-version = "0.15.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3c55d429bef56ac9172d25fecb85dc8068307d17acd74b377866b7a1ef25d3c8"
-dependencies = [
- "libc",
- "system-deps",
-]
-
 [[package]]
 name = "cc"
 version = "1.0.73"
@@ -259,15 +237,6 @@ dependencies = [
  "jobserver",
 ]
 
-[[package]]
-name = "cfg-expr"
-version = "0.10.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0aacacf4d96c24b2ad6eb8ee6df040e4f27b0d0b39a5710c30091baa830485db"
-dependencies = [
- "smallvec",
-]
-
 [[package]]
 name = "cfg-if"
 version = "0.1.10"
@@ -880,36 +849,6 @@ dependencies = [
  "byteorder",
 ]
 
-[[package]]
-name = "gdk-pixbuf-sys"
-version = "0.15.10"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "140b2f5378256527150350a8346dbdb08fadc13453a7a2d73aecd5fab3c402a7"
-dependencies = [
- "gio-sys",
- "glib-sys",
- "gobject-sys",
- "libc",
- "system-deps",
-]
-
-[[package]]
-name = "gdk-sys"
-version = "0.15.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "32e7a08c1e8f06f4177fb7e51a777b8c1689f743a7bc11ea91d44d2226073a88"
-dependencies = [
- "cairo-sys-rs",
- "gdk-pixbuf-sys",
- "gio-sys",
- "glib-sys",
- "gobject-sys",
- "libc",
- "pango-sys",
- "pkg-config",
- "system-deps",
-]
-
 [[package]]
 name = "generic-array"
 version = "0.12.4"
@@ -973,29 +912,6 @@ dependencies = [
  "weezl",
 ]
 
-[[package]]
-name = "gio-sys"
-version = "0.15.10"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "32157a475271e2c4a023382e9cab31c4584ee30a97da41d3c4e9fdd605abcf8d"
-dependencies = [
- "glib-sys",
- "gobject-sys",
- "libc",
- "system-deps",
- "winapi 0.3.9",
-]
-
-[[package]]
-name = "glib-sys"
-version = "0.15.10"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ef4b192f8e65e9cf76cbf4ea71fa8e3be4a0e18ffe3d68b8da6836974cc5bad4"
-dependencies = [
- "libc",
- "system-deps",
-]
-
 [[package]]
 name = "glob"
 version = "0.3.0"
@@ -1015,35 +931,6 @@ dependencies = [
  "regex",
 ]
 
-[[package]]
-name = "gobject-sys"
-version = "0.15.10"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0d57ce44246becd17153bd035ab4d32cfee096a657fc01f2231c9278378d1e0a"
-dependencies = [
- "glib-sys",
- "libc",
- "system-deps",
-]
-
-[[package]]
-name = "gtk-sys"
-version = "0.15.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d5bc2f0587cba247f60246a0ca11fe25fb733eabc3de12d1965fc07efab87c84"
-dependencies = [
- "atk-sys",
- "cairo-sys-rs",
- "gdk-pixbuf-sys",
- "gdk-sys",
- "gio-sys",
- "glib-sys",
- "gobject-sys",
- "libc",
- "pango-sys",
- "system-deps",
-]
-
 [[package]]
 name = "half"
 version = "1.8.2"
@@ -1402,17 +1289,6 @@ version = "0.5.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "7efd1d698db0759e6ef11a7cd44407407399a910c774dd804c64c032da7826ff"
 
-[[package]]
-name = "libappindicator-sys"
-version = "0.7.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4a0e019ae1a736a858f4c52b58af2ca6e797f27d7fe534e8a56776d74a8f2535"
-dependencies = [
- "gtk-sys",
- "libloading",
- "once_cell",
-]
-
 [[package]]
 name = "libc"
 version = "0.2.126"
@@ -1877,18 +1753,6 @@ version = "6.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa"
 
-[[package]]
-name = "pango-sys"
-version = "0.15.10"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d2a00081cde4661982ed91d80ef437c20eacaf6aa1a5962c0279ae194662c3aa"
-dependencies = [
- "glib-sys",
- "gobject-sys",
- "libc",
- "system-deps",
-]
-
 [[package]]
 name = "parking_lot"
 version = "0.12.1"
@@ -2813,19 +2677,6 @@ dependencies = [
  "walkdir",
 ]
 
-[[package]]
-name = "system-deps"
-version = "6.0.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a1a45a1c4c9015217e12347f2a411b57ce2c4fc543913b14b6fe40483328e709"
-dependencies = [
- "cfg-expr",
- "heck",
- "pkg-config",
- "toml",
- "version-compare",
-]
-
 [[package]]
 name = "tar"
 version = "0.4.38"
@@ -2891,7 +2742,6 @@ dependencies = [
  "include_dir",
  "json-patch",
  "lazy_static",
- "libappindicator-sys",
  "libc",
  "log",
  "minisign",
@@ -3300,12 +3150,6 @@ version = "0.2.15"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
 
-[[package]]
-name = "version-compare"
-version = "0.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fe88247b92c1df6b6de80ddc290f3976dbdf2f5f5d3fd049a9fb598c6dd5ca73"
-
 [[package]]
 name = "version_check"
 version = "0.9.4"

+ 0 - 3
tooling/cli/Cargo.toml

@@ -72,9 +72,6 @@ winapi = { version = "0.3", features = [ "handleapi", "processenv", "winbase", "
 [target."cfg(unix)".dependencies]
 libc = "0.2"
 
-[target."cfg(target_os = \"linux\")".dependencies]
-libappindicator-sys = "0.7.2"
-
 [target."cfg(target_os = \"linux\")".build-dependencies]
 heck = "0.4"
 

+ 37 - 3
tooling/cli/src/build.rs

@@ -316,13 +316,13 @@ pub fn command(options: Options) -> Result<()> {
             if tray == "ayatana" {
               format!(
                 "{}/libayatana-appindicator3.so",
-                libappindicator_sys::get_library_path("ayatana-appindicator3-0.1")
+                pkgconfig_utils::get_library_path("ayatana-appindicator3-0.1")
                   .expect("failed to get ayatana-appindicator library path using pkg-config.")
               )
             } else {
               format!(
                 "{}/libappindicator3.so",
-                libappindicator_sys::get_library_path("appindicator3-0.1")
+                pkgconfig_utils::get_library_path("appindicator3-0.1")
                   .expect("failed to get libappindicator-gtk library path using pkg-config.")
               )
             },
@@ -330,7 +330,7 @@ pub fn command(options: Options) -> Result<()> {
         } else {
           std::env::set_var(
             "TRAY_LIBRARY_PATH",
-            libappindicator_sys::get_appindicator_library_path(),
+            pkgconfig_utils::get_appindicator_library_path(),
           );
         }
       }
@@ -380,3 +380,37 @@ fn print_signed_updater_archive(output_paths: &[PathBuf]) -> crate::Result<()> {
   }
   Ok(())
 }
+
+#[cfg(target_os = "linux")]
+mod pkgconfig_utils {
+  use std::{path::PathBuf, process::Command};
+
+  pub fn get_appindicator_library_path() -> PathBuf {
+    match get_library_path("ayatana-appindicator3-0.1") {
+      Some(p) => format!("{}/libayatana-appindicator3.so", p).into(),
+      None => match get_library_path("appindicator3-0.1") {
+        Some(p) => format!("{}/libappindicator3.so", p).into(),
+        None => panic!("Can't detect any appindicator library"),
+      },
+    }
+  }
+
+  /// Gets the folder in which a library is located using `pkg-config`.
+  pub fn get_library_path(name: &str) -> Option<String> {
+    let mut cmd = Command::new("pkg-config");
+    cmd.env("PKG_CONFIG_ALLOW_SYSTEM_LIBS", "1");
+    cmd.arg("--libs-only-L");
+    cmd.arg(name);
+    if let Ok(output) = cmd.output() {
+      if !output.stdout.is_empty() {
+        // output would be "-L/path/to/library\n"
+        let word = output.stdout[2..].to_vec();
+        return Some(String::from_utf8_lossy(&word).trim().to_string());
+      } else {
+        None
+      }
+    } else {
+      None
+    }
+  }
+}