Unverified Commit e3c618f3 authored by Sandro Jäckel's avatar Sandro Jäckel Committed by GitHub
Browse files

stremio-linux-shell: init at 1.0.0-beta.13 (#468728)

parents f295bf67 8a0debed
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
diff --git a/src/webview/app/mod.rs b/src/webview/app/mod.rs
index 2c6125e..26ab73f 100644
--- a/src/webview/app/mod.rs
+++ b/src/webview/app/mod.rs
@@ -23,6 +23,10 @@ cef_impl!(
                 CMD_SWITCHES.iter().for_each(|switch| {
                     line.append_switch(Some(&CefString::from(switch.to_owned())));
                 });
+                line.append_switch_with_value(
+                    Some(&CefString::from("disable-features")),
+                    Some(&CefString::from("LocalNetworkAccessChecks")),
+                );
             }
         }
 
+13 −0
Original line number Diff line number Diff line
diff --git a/src/config.rs b/src/config.rs
index 4eda395..679699f 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -70,7 +70,7 @@ pub struct ServerConfig {
 
 impl ServerConfig {
     pub fn new(current_dir: &Path) -> Self {
-        let file = current_dir.join(SERVER_FILE);
+        let file = Path::new("@serverjs@").to_path_buf();
 
         Self { file }
     }
+21 −0
Original line number Diff line number Diff line
diff --git a/src/shared/renderer/utils.rs b/src/shared/renderer/utils.rs
index be4a65d..1b944ad 100644
--- a/src/shared/renderer/utils.rs
+++ b/src/shared/renderer/utils.rs
@@ -1,6 +1,6 @@
 use std::{mem, ptr};
 
-use gl::types::{GLenum, GLfloat, GLint, GLsizei, GLsizeiptr, GLuint};
+use gl::types::{GLchar, GLenum, GLfloat, GLint, GLsizei, GLsizeiptr, GLuint};
 
 use super::constants::BYTES_PER_PIXEL;
 
@@ -139,7 +139,7 @@ pub fn compile_shader(kind: GLenum, src: &str) -> GLuint {
             gl::GetShaderiv(shader, gl::INFO_LOG_LENGTH, &mut len);
 
             let mut buffer = vec![0u8; len as usize];
-            gl::GetShaderInfoLog(shader, len, ptr::null_mut(), buffer.as_mut_ptr() as *mut i8);
+            gl::GetShaderInfoLog(shader, len, ptr::null_mut(), buffer.as_mut_ptr() as *mut GLchar);
 
             panic!(
                 "Shader compile error: {}",
+142 −0
Original line number Diff line number Diff line
{
  lib,
  symlinkJoin,
  rustPlatform,
  fetchFromGitHub,
  versionCheckHook,
  gitUpdater,

  # buildInputs
  atk,
  cef-binary,
  gtk3,
  libayatana-appindicator,
  libxkbcommon,
  mpv,
  openssl,

  # nativeBuildInputs
  makeBinaryWrapper,
  pkg-config,
  wrapGAppsHook4,

  # Wrapper
  addDriverRunpath,
  libGL,
  nodejs,
}:

let
  # Stremio expects CEF files in a specific layout
  cef = symlinkJoin {
    name = "stremio-linux-shell-cef";
    paths = [
      "${cef-binary}/Resources"
      "${cef-binary}/Release"
    ];
  };
in
rustPlatform.buildRustPackage (finalAttrs: {
  pname = "stremio-linux-shell";
  version = "1.0.0-beta.13";

  src = fetchFromGitHub {
    owner = "Stremio";
    repo = "stremio-linux-shell";
    tag = "v${finalAttrs.version}";
    hash = "sha256-1f9IBNo5gxpSqTSIf8QuQOlf+sfRhohOmQTLRbX/OU8=";
  };

  cargoHash = "sha256-wx5oF4uF9UMtKzfGxZKsy6mVjYaRD40dLuvaRtz8yE4=";

  patches = [
    # Chromium 142 stopped allowing local network access by default, which
    # breaks the app's ability to communicate with the Stremio server.
    ./allow-local-network-access.patch

    # GLchar is u8 on aarch64
    # Upstream PR: https://github.com/Stremio/stremio-linux-shell/pull/40
    ./fix-getshaderinfolog-call.patch

    # Patch server.js path so that we don't have to install it in $out/bin
    ./better-server-path.patch
  ];

  postPatch = ''
    substituteInPlace src/config.rs \
      --replace-fail "@serverjs@" "${placeholder "out"}/share/stremio/server.js"

    substituteInPlace $cargoDepsCopy/libappindicator-sys-*/src/lib.rs \
      --replace-fail "libayatana-appindicator3.so.1" "${libayatana-appindicator}/lib/libayatana-appindicator3.so.1"
    substituteInPlace $cargoDepsCopy/xkbcommon-dl-*/src/lib.rs \
      --replace-fail "libxkbcommon.so.0" "${libxkbcommon}/lib/libxkbcommon.so.0"
    substituteInPlace $cargoDepsCopy/xkbcommon-dl-*/src/x11.rs \
      --replace-fail "libxkbcommon-x11.so.0" "${libxkbcommon}/lib/libxkbcommon-x11.so.0"
  '';

  # Don't download CEF during build
  buildFeatures = [ "offline-build" ];

  buildInputs = [
    atk
    cef
    gtk3
    libayatana-appindicator
    libxkbcommon
    mpv
    openssl
  ];

  nativeBuildInputs = [
    makeBinaryWrapper
    pkg-config
    wrapGAppsHook4
  ];

  env.CEF_PATH = "${cef}";

  postInstall = ''
    mkdir -p $out/share/applications
    cp data/com.stremio.Stremio.desktop $out/share/applications/com.stremio.Stremio.desktop

    mkdir -p $out/share/icons/hicolor/scalable/apps
    cp data/icons/com.stremio.Stremio.svg $out/share/icons/hicolor/scalable/apps/com.stremio.Stremio.svg

    mkdir -p $out/share/stremio
    cp data/server.js $out/share/stremio/server.js

    mv $out/bin/stremio-linux-shell $out/bin/stremio
  '';

  # Node.js is required to run `server.js`
  # Add to `gappsWrapperArgs` to avoid two layers of wrapping.
  preFixup = ''
    gappsWrapperArgs+=(
      --prefix LD_LIBRARY_PATH : "${addDriverRunpath.driverLink}/lib" \
      --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ libGL ]}" \
      --prefix PATH : "${lib.makeBinPath [ nodejs ]}"
    )
  '';

  nativeInstallCheckInputs = [ versionCheckHook ];
  versionCheckProgramArg = "--version";
  doInstallCheck = true;

  passthru = {
    inherit cef;
    updateScript = gitUpdater { rev-prefix = "v"; };
  };

  meta = {
    description = "Modern media center that gives you the freedom to watch everything you want";
    homepage = "https://www.stremio.com/";
    license = with lib.licenses; [
      gpl3Only
      # server.js is unfree
      unfree
    ];
    maintainers = with lib.maintainers; [ thunze ];
    platforms = lib.platforms.linux;
    mainProgram = "stremio";
  };
})