rancher-sandbox / rancher-desktop

Container Management and Kubernetes on the Desktop
https://rancherdesktop.io
Apache License 2.0
5.78k stars 271 forks source link

Spike: Investigate feasibility of shipping only as flatpak on Linux #4959

Open adamkpickering opened 1 year ago

adamkpickering commented 1 year ago

We have visited this topic before, but don't remember what conclusions were reached. If we decide not to use flatpak, our reasons must be documented.

adamkpickering commented 1 year ago

I need to work on the snapshots backend, so I'm going to write where I am at with the flatpak stuff.

There was a partially-working flatpak-builder manifest at packaging/linux/flatpak.yaml, so I took it and modified it. This is the current content:

# This file is unused and just kept for reference for plain flatpak builds
app-id: io.rancherdesktop.RancherDesktop
branch: main
runtime: org.freedesktop.Platform
runtime-version: '22.08'
sdk: org.freedesktop.Sdk
base: org.electronjs.Electron2.BaseApp
base-version: '22.08'
sdk-extensions:
  # Not really needed since we are not building the app here
  - org.freedesktop.Sdk.Extension.node16
command: electron-wrapper
separate-locales: false
finish-args:
  - --share=ipc
  - --socket=x11
  - --socket=wayland
  - --share=network
  - --device=dri
  - --device=kvm
  - --filesystem=xdg-config/rancher-desktop:create
  - --filesystem=xdg-cache/rancher-desktop:create
  - --filesystem=xdg-data/rancher-desktop:create
  - --filesystem=home
  - --filesystem=/sys/module/kvm_amd/parameters/nested:ro
  - --filesystem=/sys/module/kvm_intel/parameters/nested:ro
  - --talk-name=org.freedesktop.Notifications
  - --own-name=org.kde.*
rename-desktop-file: rancher-desktop.desktop
rename-appdata-file: rancher-desktop.appdata.xml
modules:
  - name: rancher-desktop
    buildsystem: simple
    sources:
      - type: dir
        path: .
      - type: script
        dest-filename: electron-wrapper
        commands:
          - |
            export TMPDIR="$XDG_RUNTIME_DIR/app/$FLATPAK_ID"

            zypak-wrapper /app/lib/io.rancherdesktop.app/rancher-desktop "$@"
    build-commands:
      # Bundle electron build after npm run build -- --linux dir 
      - mkdir -p /app/lib/io.rancherdesktop.app
      - unzip rancher-desktop.zip -d /app/lib/io.rancherdesktop.app
      # Remove in app qemu binaries
      - rm /app/lib/io.rancherdesktop.app/lib /app/lib/io.rancherdesktop.app/pc-bios /app/lib/io.rancherdesktop.app/qemu-* -rf
      # Include FreeDesktop integration files at expected locations
      - |
        rm -rf /app/share/metainfo /app/share/icons /app/share/applications
        mkdir -p /app/share/metainfo /app/share/applications

        icon="/app/lib/io.rancherdesktop.app/resources/resources/icons/logo-square-512.png"
        for size in 512x512 256x256 128x128 96x96 64x64 48x48 32x32 24x24 16x16; do
          mkdir "/app/share/icons/hicolor/${size}/apps" -p
          ffmpeg -i "${icon}" -vf scale="${size}" "/app/share/icons/hicolor/${size}/apps/io.rancherdesktop.app.png"
        done

        mv /app/lib/io.rancherdesktop.app/resources/resources/linux/rancher-desktop.desktop /app/share/applications
        mv /app/lib/io.rancherdesktop.app/resources/resources/linux/rancher-desktop.appdata.xml /app/share/metainfo
      # Install app wrapper
      - install -Dm755 -t /app/bin/ electron-wrapper
    modules:
    - name: libbzip2
      buildsystem: meson
      builddir: 
      sources:
      - type: git
        url: https://gitlab.com/bzip2/bzip2
        tag: bzip2-1.0.8
    - name: qemu
      config-opts:
      - "--disable-user"
      - "--disable-vnc"
      - "--disable-sdl"
      - "--disable-gtk"
      - "--disable-curses"
      - "--disable-iconv"
      - "--disable-gio"
      - "--enable-kvm"
      - "--target-list=x86_64-softmmu"
      sources:
      - type: archive
        url: https://download.qemu.org/qemu-6.1.0.tar.xz
        sha256: eebc089db3414bbeedf1e464beda0a7515aad30f73261abc246c9b27503a3c96

The build for libbz2 isn't working - this is what I'm trying to figure out at the moment.

adamkpickering commented 8 months ago

Here is one user that would likely benefit from distributing RD as a flatpak: #6122

archerallstars commented 8 months ago

Flatpak would be a great addition to both the AppImage (currently unusable) version and the openSUSE repo version. As I am on openSUSE Tumbleweed, I wouldn't want to download huge version bump updates of Rancher all the time (that's why I went with the AppImage version).

deadmeu commented 1 month ago

Is this still being considered? I am very interested in trying Rancher if it is offered as a Flatpak.