From f5448ff7d5b91d7ab8db1e56649dfde767523be0 Mon Sep 17 00:00:00 2001 From: Charlie Le <20309750+CharlieQLe@users.noreply.github.com> Date: Sun, 2 Jul 2023 23:58:31 -0400 Subject: [PATCH] Add Flatpak (#1683) * Add Flatpak manifest * Add x264 * Update x264 module * Update to llvm16 * Update Flatpak README * Fix paths for llvm * Update readme for flatpak * Update manifest and modules * Disable LTO on FFMPEG and move manifest to xtask * Remove nv-codec-headers * Add Flatpak wiki page --- .gitignore | 3 + alvr/xtask/flatpak/README.md | 40 +++++++++ ...m.valvesoftware.Steam.Utility.alvr.desktop | 13 +++ .../com.valvesoftware.Steam.Utility.alvr.json | 63 ++++++++++++++ .../vulkan-headers/vulkan-headers.json | 11 +++ alvr/xtask/flatpak/modules/x264/x264.json | 16 ++++ alvr/xtask/flatpak/modules/yasm/yasm.json | 13 +++ alvr/xtask/src/dependencies.rs | 1 - wiki/Flatpak.md | 86 +++++++++++++++++++ 9 files changed, 245 insertions(+), 1 deletion(-) create mode 100644 alvr/xtask/flatpak/README.md create mode 100644 alvr/xtask/flatpak/com.valvesoftware.Steam.Utility.alvr.desktop create mode 100644 alvr/xtask/flatpak/com.valvesoftware.Steam.Utility.alvr.json create mode 100644 alvr/xtask/flatpak/modules/vulkan-headers/vulkan-headers.json create mode 100644 alvr/xtask/flatpak/modules/x264/x264.json create mode 100644 alvr/xtask/flatpak/modules/yasm/yasm.json create mode 100644 wiki/Flatpak.md diff --git a/.gitignore b/.gitignore index e8fc9120..9a7f83cf 100644 --- a/.gitignore +++ b/.gitignore @@ -61,3 +61,6 @@ deps node_modules # The .gitignore for android is project folder. + +# flatpak +.flatpak* \ No newline at end of file diff --git a/alvr/xtask/flatpak/README.md b/alvr/xtask/flatpak/README.md new file mode 100644 index 00000000..814c91da --- /dev/null +++ b/alvr/xtask/flatpak/README.md @@ -0,0 +1,40 @@ +# ALVR Flatpak + +This is an experimental Flatpak for ALVR! It is **only** compatible with the Flatpak version of Steam! For all non-Flatpak Steam users, use the AppImage that is already provided. + +## Installation + +Currently, no precompiled builds are available. However, building from source does not take very long, and just requires the usage of the terminal. + +1. Install the Flatpak dependencies + +``` +flatpak install flathub org.flatpak.Builder org.freedesktop.Sdk//22.08 \ + org.freedesktop.Sdk.Extension.llvm16//22.08 \ + org.freedesktop.Sdk.Extension.rust-stable//22.08 +``` + +2. Clone and enter this repository + +``` +git clone https://github.com/alvr-org/ALVR.git +cd ALVR +``` + +3. Build and install the flatpak + +``` +flatpak run org.flatpak.Builder --user --install --force-clean .flatpak-build-dir alvr/xtask/flatpak/com.valvesoftware.Steam.Utility.alvr.json +``` + +## Usage + +To launch the ALVR Dashboard, run the following command: + +``` +flatpak run --command=alvr_dashboard com.valvesoftware.Steam +``` + +## Caveats + +Launching SteamVR from the dashboard will always launch a new instance of Steam. To avoid this, register the ALVR driver with Steam from the dashboard. However, the dashboard will not appear if SteamVR is launched from Steam. If any configuration needs to be made, launch the dashboard like the above. If the visibility of the Steam client does not matter, then simply launch SteamVR from the dashboard. Otherwise, launch SteamVR from inside of Steam after the driver is registered. diff --git a/alvr/xtask/flatpak/com.valvesoftware.Steam.Utility.alvr.desktop b/alvr/xtask/flatpak/com.valvesoftware.Steam.Utility.alvr.desktop new file mode 100644 index 00000000..6b817a07 --- /dev/null +++ b/alvr/xtask/flatpak/com.valvesoftware.Steam.Utility.alvr.desktop @@ -0,0 +1,13 @@ +[Desktop Entry] +Version=1.0 +Type=Application +Name=ALVR +GenericName=Game +Comment=ALVR is an open source remote VR display which allows playing SteamVR games on a standalone headset such as Gear VR or Oculus Go/Quest. +Exec=/usr/bin/flatpak run --command=alvr_dashboard com.valvesoftware.Steam +Icon=alvr +Categories=Game; +StartupNotify=true +PrefersNonDefaultGPU=true +X-KDE-RunOnDiscreteGpu=true +StartupWMClass=ALVR diff --git a/alvr/xtask/flatpak/com.valvesoftware.Steam.Utility.alvr.json b/alvr/xtask/flatpak/com.valvesoftware.Steam.Utility.alvr.json new file mode 100644 index 00000000..9217e42a --- /dev/null +++ b/alvr/xtask/flatpak/com.valvesoftware.Steam.Utility.alvr.json @@ -0,0 +1,63 @@ +{ + "id": "com.valvesoftware.Steam.Utility.alvr", + "branch": "stable", + "sdk": "org.freedesktop.Sdk//22.08", + "sdk-extensions": [ + "org.freedesktop.Sdk.Extension.llvm16", + "org.freedesktop.Sdk.Extension.rust-stable" + ], + "runtime": "com.valvesoftware.Steam", + "runtime-version": "stable", + "build-extension": true, + "appstream-compose": false, + "separate-locales": false, + "build-options": { + "prefix": "/app/utils/alvr", + "append-path": "/usr/lib/sdk/llvm16/bin:/usr/lib/sdk/rust-stable/bin:/app/utils/alvr/bin", + "prepend-ld-library-path": "/app/utils/alvr/lib", + "prepend-pkg-config-path": "/app/utils/alvr/lib/pkgconfig", + "strip": true, + "env": { + "PREFIX": "/app/utils/alvr" + }, + "build-args": [ + "--share=network" + ] + }, + "cleanup": [ + "/lib/*.a", + "/lib/*.la", + "/share/doc", + "/share/man" + ], + "modules": [ + { + "name": "alvr", + "buildsystem": "simple", + "build-options": { + "env": { + "RUST_BACKTRACE": "full", + "CURL_HOME": "/run/build/alvr", + "CPATH": "/app/utils/alvr/include" + } + }, + "build-commands": [ + "echo 'insecure' >> .curlrc", + "cargo xtask prepare-deps --platform linux --no-nvidia", + "cargo xtask build-streamer --release", + "cp -r /run/build/alvr/build/alvr_streamer_linux/* /app/utils/alvr" + ], + "modules": [ + "modules/yasm/yasm.json", + "modules/vulkan-headers/vulkan-headers.json", + "modules/x264/x264.json" + ], + "sources": [ + { + "type": "dir", + "path": "../../../" + } + ] + } + ] +} \ No newline at end of file diff --git a/alvr/xtask/flatpak/modules/vulkan-headers/vulkan-headers.json b/alvr/xtask/flatpak/modules/vulkan-headers/vulkan-headers.json new file mode 100644 index 00000000..80f86bd1 --- /dev/null +++ b/alvr/xtask/flatpak/modules/vulkan-headers/vulkan-headers.json @@ -0,0 +1,11 @@ +{ + "name": "vulkan-headers", + "buildsystem": "cmake", + "sources": [ + { + "type": "git", + "url": "https://github.com/KhronosGroup/Vulkan-Headers.git", + "tag": "v1.3.249" + } + ] +} \ No newline at end of file diff --git a/alvr/xtask/flatpak/modules/x264/x264.json b/alvr/xtask/flatpak/modules/x264/x264.json new file mode 100644 index 00000000..0252369a --- /dev/null +++ b/alvr/xtask/flatpak/modules/x264/x264.json @@ -0,0 +1,16 @@ +{ + "name": "x264", + "config-opts": [ + "--prefix=/app/utils/alvr", + "--enable-pic", + "--enable-shared", + "--disable-cli" + ], + "sources": [ + { + "type": "git", + "url": "https://code.videolan.org/videolan/x264.git", + "commit": "baee400fa9ced6f5481a728138fed6e867b0ff7f" + } + ] +} \ No newline at end of file diff --git a/alvr/xtask/flatpak/modules/yasm/yasm.json b/alvr/xtask/flatpak/modules/yasm/yasm.json new file mode 100644 index 00000000..5bff21be --- /dev/null +++ b/alvr/xtask/flatpak/modules/yasm/yasm.json @@ -0,0 +1,13 @@ +{ + "name": "yasm", + "sources": [ + { + "type": "archive", + "url": "https://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz", + "sha256": "3dce6601b495f5b3d45b59f7d2492a340ee7e84b5beca17e48f862502bd5603f" + } + ], + "cleanup": [ + "*" + ] +} \ No newline at end of file diff --git a/alvr/xtask/src/dependencies.rs b/alvr/xtask/src/dependencies.rs index 9846e921..3994636c 100644 --- a/alvr/xtask/src/dependencies.rs +++ b/alvr/xtask/src/dependencies.rs @@ -125,7 +125,6 @@ pub fn build_ffmpeg_linux(nvenc_flag: bool) { "--disable-swscale", "--disable-postproc", "--disable-network", - "--enable-lto", "--disable-everything", "--enable-encoder=h264_vaapi", "--enable-encoder=hevc_vaapi", diff --git a/wiki/Flatpak.md b/wiki/Flatpak.md new file mode 100644 index 00000000..2aaaa32e --- /dev/null +++ b/wiki/Flatpak.md @@ -0,0 +1,86 @@ +## Installing ALVR and using SteamVR on Linux through Flatpak + +## Disclaimer + +1. This is not a fully-featured version of ALVR! It lacks Nvidia support, a desktop file, and has bugs related to Flatpak sandboxing + +2. Nvidia GPUs are currently not supported + +3. Native Linux SteamVR utility applications such as OpenVRAS are not supported nor tested, use at your own risk + +4. Firewall configuration does not work + +5. Any scripts that affect the host will run within the sandbox + +6. Sometimes, a new instance of Steam will launch when launching the dashboard. To fix this, close both ALVR and Steam then launch Steam. As soon as Steam is opens to the storefront, launch the ALVR dashboard. + +7. The ALVR Dashboard is not available in the Applications menu. To run the dashboard, run the following command to run `alvr_dashboard` in the Steam Flatpak environment: + +``` +flatpak run --command=alvr_dashboard com.valvesoftware.Steam +``` + +## Dependencies + +First, flatpak must be installed from your distro's repositories. Refer to [this page](https://flatpak.org/setup/) to find the instructions for your distro. + +Once Flatpak is installed, the flatpak dependencies must also be installed. They are: + +* Flatpak Builder +* Rust +* LLVM +* Freedesktop SDK +* Steam + +These can be installed like so: + +``` +flatpak install flathub org.flatpak.Builder \ + org.freedesktop.Sdk//22.08 \ + org.freedesktop.Sdk.Extension.llvm16//22.08 \ + org.freedesktop.Sdk.Extension.rust-stable//22.08 \ + com.valvesoftware.Steam +``` + +AMD users may need to install the appropriate Mesa codec extensions as well: + +``` +flatpak install flathub org.freedesktop.Platform.GL.default//22.08-extra \ + org.freedesktop.Platform.GL32.default//22.08-extra +``` + +## Build and Install + +Once the dependencies are fulfilled, clone and enter the repository. + +``` +git clone https://github.com/alvr-org/ALVR.git +cd ALVR +``` + +Once inside the repository, simply run the following command to build and install the Flatpak. + +``` +flatpak run org.flatpak.Builder --user --install --force-clean .flatpak-build-dir alvr/xtask/flatpak/com.valvesoftware.Steam.Utility.alvr.json +``` + +## Notes + +### Running the dashboard + +To run the ALVR Dashboard, run the following command: + +``` +flatpak run --command=alvr_dashboard com.valvesoftware.Steam +``` + +A desktop file named `com.valvesoftware.Steam.Utility.alvr.desktop` is supplied within the `alvr/xtask/flatpak` directory. Move this to where other desktop files are located on your system in order to run the dashboard without the terminal. + +### Other Applications + +The support for other applications that are not launched via Steam is non-existent due to the Flatpak sandbox. + +Various SteamVR utilities such as [WlxOverlay](https://github.com/galister/WlxOverlay) and [OpenVR-AdvancedSettings](https://github.com/OpenVR-Advanced-Settings/OpenVR-AdvancedSettings) cannot run within the Flatpak sandbox due to their usage of AppImage. However, unpacking the supplied AppImage or building the utilities from source and running their binaries from within the sandbox similiarly to `alvr_dashboard` could work, but there is no guarantee that they will work properly. + +Some applications such as [Godot](https://godotengine.org) support OpenXR. However, unless they are launched within the Steam Flatpak sandbox, they will not work with the Steam Flatpak. See [here](https://github.com/flathub/com.valvesoftware.Steam/issues/1010) for more details. +