Rosalie241 / RMG

Rosalie's Mupen GUI
GNU General Public License v3.0
611 stars 52 forks source link

Publish on Flathub #26

Closed JakobDev closed 2 years ago

JakobDev commented 2 years ago

Would be relay nice, if you could publish RMG on Flathub. Flathub is used by many Linux distros as source for Flatpaks, so the Users will be able to install RMG with 1 click. I have some experience in building a Flatpak, so I can help. I already noticed #5, but Flathub requires building without Internet. There are 2 things needed at the moment:

  1. RMG can't store files in the same folder as the Binary, since Flatpaks are read only. They has to be saved in XDG_DATA_HOME/RMG or XDG_CONFIG_HOME/RMG.
  2. git clone during the build is not allowed, because there's no Internet. I can include the needed Repo with commit and destination folder in the Manifest. The build script needs to check if the folder is already there and then not clone.
Rosalie241 commented 2 years ago

Improved linux support is something I should work on, because the current packaging/way I run it is less than ideal for linux systems, so your first point is something I want to work on for sure.

The second point is more difficult though, and I'm unsure how to solve that, I don't want a mono repo with all 3rdParty source code included, another point is that I don't think I can change cmake to not git clone then, see the Source/3rdParty/CMakeLists.txt file.

But overall, yes, I'd like to package it for linux (maybe AUR and flatpak).

JakobDev commented 2 years ago

You don't need a mono repo. The 3rdParty party stuff will still be downloaded with git. The only difference is, that flathub-builder is the one, wo will do the git clone, not your buildscript. I can tell flatpak-builder to do a git clone into a specific directory. It looks like this:

type: git
url: https://github.com/mupen64plus/mupen64plus-core.git
commit: 57828d930280554c7400bb2bcf1e46c7f2ee8373
dest: Source/3rdParty/mupen64plus-core

You only need to edit your build script, so it will recognize that the git repos are alredy cloned, so it will not run git clone in that case.

Rosalie241 commented 2 years ago

Sound doable then, I've been working on improved linux support and a system installation is functional right now, you can test it on the Directories branch, I'm also working on a PKGBUILD which I'll push to the AUR when I've merged the commits from that branch into the master branch.

I think you should already be able to create a flatpak build script using that branch, though you may need to comment out the GIT_URL & GIT_TAG stuff from the 3rrParty CMakeLists.txt, if commenting that out works, I'll add a cmake flag which empties those variables.

JakobDev commented 2 years ago

I got it manage to build. Create a empty folder with those 2 files in it:

com.github.Rosalie241.RMG.yml

app-id: com.github.Rosalie241.RMG
runtime: org.kde.Platform
runtime-version: "5.15-21.08"
sdk: org.kde.Sdk
command: RMG
finish-args:
  - --socket=fallback-x11
  - --share=ipc
  - --device=dri
  - --socket=wayland

modules:
  - minizip.json

  - name: hidapi
    sources:
      - type: archive
        url: https://github.com/libusb/hidapi/archive/refs/tags/hidapi-0.11.2.tar.gz
        sha256: bc4ac0f32a6b21ef96258a7554c116152e2272dacdec1e4620fc44abeea50c27
    modules:
      - name: libusb
        sources:
          - type: archive
            url: https://github.com/libusb/libusb/archive/refs/tags/v1.0.24.tar.gz
            sha256: b7724c272dfc5713dce88ff717efd60f021ca5b7c8e30f08ebb2c42d2eea08ae

  - name: RMG
    buildsystem: cmake
    config-opts:
      - "-DCMAKE_BUILD_TYPE=Release"
      - "-DPORTABLE_INSTALL=OFF"
    sources:
      - type: dir
        path: RMG

      - type: git
        url: https://github.com/mupen64plus/mupen64plus-core.git
        commit: 57828d930280554c7400bb2bcf1e46c7f2ee8373
        dest: Source/3rdParty/mupen64plus-core

      - type: git
        url: https://github.com/mupen64plus/mupen64plus-rsp-hle.git
        commit: 88093cb43499eff53d343653cddcae2132af17ef
        dest: Source/3rdParty/mupen64plus-rsp-hle

      - type: git
        url: https://github.com/loganmc10/parallel-rsp.git
        commit: a9646b27c2ef399e5917735b4d84ebe93edcce39
        dest: Source/3rdParty/mupen64plus-rsp-parallel

      - type: git
        url: https://github.com/Rosalie241/mupen64plus-input-qt.git
        commit: e6cacb7fe6513cac4b30f7171d8ca7d1cd5fdb81
        dest: Source/3rdParty/mupen64plus-input-qt

      - type: git
        url: https://github.com/raphnet/mupen64plus-input-raphnetraw.git
        commit: 86112413e98a8648edb11d199673cc24d5799af8
        dest: Source/3rdParty/mupen64plus-input-raphnetraw

      - type: git
        url: https://github.com/amatho/mupen64plus-input-gca.git
        commit: d440611d3639fa974c7d52bd0ed2079d16428d5e
        dest: Source/3rdParty/mupen64plus-input-gca

      - type: git
        url: https://github.com/gonetz/GLideN64.git
        commit: 8343fd05c9a01ce2d73f7e32bb8355036759a05b
        dest: Source/3rdParty/mupen64plus-video-GLideN64

      - type: git
        url: https://github.com/loganmc10/parallel-rdp-standalone.git
        commit: 2efeaf014bad03ec26e081c22d8ca3566003b1ea
        dest: Source/3rdParty/mupen64plus-video-parallel

minizip.json

{
    "name": "minizip",
    "subdir": "contrib/minizip",
    "config-opts": [
        "--disable-static"
    ],
    "sources": [
        {
            "type": "archive",
            "url": "https://zlib.net/zlib-1.2.11.tar.gz",
            "sha256": "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1",
            "x-checker-data": {
                "type": "anitya",
                "project-id": 5303,
                "stable-only": true,
                "url-template": "https://zlib.net/zlib-$version.tar.gz"
            }
        },
        {
            "type": "shell",
            "commands": [
                "GLOBIGNORE=contrib && rm -rf *",
                "GLOBIGNORE=contrib/minizip && rm -rf contrib/*",
                "rm -f contrib/minizip/Makefile",
                "autoreconf -fiv contrib/minizip"
            ]
        }
    ],
    "cleanup": [
        "*.la"
    ]
}

Create a folder named RMG and copy the content of the directory branch inside it. Flatpak will use the source from this folder.

In the folder you have to edit the Cmake files and comment out the GIT_URL & GIT_TAG.

Another thing you have to do is to change the install location to point to /app instead of /usr. I'm pretty sure flatpak-builder sets some Enviroment variable for the install location like DESTDIR, you you need to listen for that, but I'm not sure.

You can build RMG with this command: flatpak-builder build-dir com.github.Rosalie241.RMG.yml --force-clean

After you build it, you can run it with this command: flatpak-builder --run build-dir com.github.Rosalie241.RMG.yml RMG

It will crash, beacuse it looks for a file located in /usr/locale which is now in /app/locale. You need to update RMG, so it can find this file.

Rosalie241 commented 2 years ago

I got it manage to build.

Awesome, thank you so much! :heart:

Create a folder named RMG and copy the content of the directory branch inside it. Flatpak will use the source from this folder.

In the folder you have to edit the Cmake files and comment out the GIT_URL & GIT_TAG.

I'll add an option which empties those variables out then!

Another thing you have to do is to change the install location to point to /app instead of /usr. I'm pretty sure flatpak-builder sets some Enviroment variable for the install location like DESTDIR, you you need to listen for that, but I'm not sure.

it should already respect DESTDIR (it's already used in the main build script, see Source/Script/Build.sh)

You can build RMG with this command: flatpak-builder build-dir com.github.Rosalie241.RMG.yml --force-clean

After you build it, you can run it with this command: flatpak-builder --run build-dir com.github.Rosalie241.RMG.yml RMG

It will crash, beacuse it looks for a file located in /usr/locale which is now in /app/locale. You need to update RMG, so it can find this file.

I'll take a look at that crash then!

Rosalie241 commented 2 years ago

I took a look at the crash and fixed it, I've also revised the flatpak file:

app-id: com.github.Rosalie241.RMG
runtime: org.kde.Platform
runtime-version: "5.15-21.08"
sdk: org.kde.Sdk
command: RMG
finish-args:
  - --socket=x11
  - --share=ipc
  - --device=dri
  - --filesystem=host

modules:
  - minizip.json

  - name: hidapi
    sources:
      - type: archive
        url: https://github.com/libusb/hidapi/archive/refs/tags/hidapi-0.11.2.tar.gz
        sha256: bc4ac0f32a6b21ef96258a7554c116152e2272dacdec1e4620fc44abeea50c27
    modules:
      - name: libusb
        sources:
          - type: archive
            url: https://github.com/libusb/libusb/archive/refs/tags/v1.0.24.tar.gz
            sha256: b7724c272dfc5713dce88ff717efd60f021ca5b7c8e30f08ebb2c42d2eea08ae

  - name: RMG
    buildsystem: cmake
    config-opts:
      - "-DCMAKE_BUILD_TYPE=Release"
      - "-DPORTABLE_INSTALL=OFF"
      - "-DNO_GIT_CLONE=ON"
    sources:
      - type: git
        url: https://github.com/Rosalie241/RMG.git
        commit: bcd84abb3a7714a7c8fb5f8ea9e7e9237861f1f7

      - type: git
        url: https://github.com/mupen64plus/mupen64plus-core.git
        commit: 57828d930280554c7400bb2bcf1e46c7f2ee8373
        dest: Source/3rdParty/mupen64plus-core

      - type: git
        url: https://github.com/mupen64plus/mupen64plus-rsp-hle.git
        commit: 88093cb43499eff53d343653cddcae2132af17ef
        dest: Source/3rdParty/mupen64plus-rsp-hle

      - type: git
        url: https://github.com/loganmc10/parallel-rsp.git
        commit: a9646b27c2ef399e5917735b4d84ebe93edcce39
        dest: Source/3rdParty/mupen64plus-rsp-parallel

      - type: git
        url: https://github.com/Rosalie241/mupen64plus-input-qt.git
        commit: e6cacb7fe6513cac4b30f7171d8ca7d1cd5fdb81
        dest: Source/3rdParty/mupen64plus-input-qt

      - type: git
        url: https://github.com/raphnet/mupen64plus-input-raphnetraw.git
        commit: 86112413e98a8648edb11d199673cc24d5799af8
        dest: Source/3rdParty/mupen64plus-input-raphnetraw

      - type: git
        url: https://github.com/amatho/mupen64plus-input-gca.git
        commit: d440611d3639fa974c7d52bd0ed2079d16428d5e
        dest: Source/3rdParty/mupen64plus-input-gca

      - type: git
        url: https://github.com/gonetz/GLideN64.git
        commit: 8343fd05c9a01ce2d73f7e32bb8355036759a05b
        dest: Source/3rdParty/mupen64plus-video-GLideN64

      - type: git
        url: https://github.com/loganmc10/parallel-rdp-standalone.git
        commit: 2efeaf014bad03ec26e081c22d8ca3566003b1ea
        dest: Source/3rdParty/mupen64plus-video-parallel

There are 3 problems remaining which I'm not sure how to fix:

1) RMG-Audio fails to initialize SDL (SDL_Init(SDL_INIT_AUDIO) returns -1) image

2) RMG is unable to open any ROM files image

3) RMG is unable to select any directory (File -> Choose ROM Directory...)

JakobDev commented 2 years ago
  1. This can be solved by putting --socket=pulseaudio in finish-args.
  2. I don't know what causes the problem. If you use QFileDialog, FRlatpak should put a Link o File the user chooses into /run/user/doc.Could you edit the code to see if the path QFileDialog returns exists?
  3. It looks like this is currently a bug in the Open Directory menu.
JakobDev commented 2 years ago

I think a found the culprit: You are opening the Filedialog this way:

QFileDialog dialog(this);
int ret;
QString dir;

dialog.setFileMode(QFileDialog::FileMode::ExistingFile);
dialog.setNameFilter("N64 ROMs & Disks (*.n64 *.z64 *.v64 *.ndd *.d64 *.zip)");

ret = dialog.exec();

It looks like this (for some weird reason) causes a Bug. Please switch to QFileDialog.getOpenFileName () this should work. I look if I can create a Bug report.

Another good news: I have tested the build on a Ubuntu Mate 20.04 system. Choose ROM Directory. works here. I can't use the select directory dialog on any Flatpak App on my Manjaro KDE System, so this is no issue of RMG. It's a bug of KDE. I had already created a Bug Report.

Edit: I can run a start a Game through the List on my Ubuntu Mate 20.04 system. This System is very old and I get only a blackscreen, no matter if I run in the Flatpak or outside (probably a driver issue), so I can't test the Games.

Rosalie241 commented 2 years ago
  1. This can be solved by putting --socket=pulseaudio in finish-args.

Thank you, that works! :heart:

  1. I don't know what causes the problem. If you use QFileDialog, FRlatpak should put a Link o File the user chooses into /run/user/doc.Could you edit the code to see if the path QFileDialog returns exists?

After changing to QFileDialog::getOpenFileName() (see https://github.com/Rosalie241/RMG/commit/3c52f25706a212d116235741ee6213d9e16ab018), it still doesn't work on my end, the path exists though, it prints

on_Action_File_OpenRom(/run/user/1000/doc/9cc6c33/Legend of Zelda, The - Majora's Mask (U) [!].z64)

and /run/user/1000/doc/9cc6c33/Legend of Zelda, The - Majora's Mask (U) [!].z64 exists but it still seems to fail to open the file for some reason, will investigate some more later.

  1. It looks like this is currently a bug in the Open Directory menu.

Thank you for reporting it to KDE!

JakobDev commented 2 years ago

Using QFileDialog::getOpenFileName() was just a idea of me, because it works in all of my programs without any problem.

Just a little tip: You can open a interactive shell in the Flatpak with flatpak-builder --run build-dir com.github.Rosalie241.RMG.yml RMG

JakobDev commented 2 years ago

It looks like it is working, if you install it instand of running it from the build dir. I don't know why it doesn't work, when you run it from the build dir (other programs are working from the build dir).

To install run this in the directory with the yml file: flatpak-builder --user --install --force-clean build-dir/ com.github.Rosalie241.RMG.yml

After that you can run it with flatpak run com.github.Rosalie241.RMG

Rosalie241 commented 2 years ago

You're right, that works fine, thank you very much for looking into it! :heart:

the only thing left to do is getting the application icon & desktop file installed correctly, because currently during building it says:

Not exporting share/applications/RMG.desktop, non-allowed export filename
JakobDev commented 2 years ago

Getting Icon and desktop is really easy. The .desktop has to be named com.github.Rosalie241.RMG.desktop. You have to put your SVG File to /app/share/icons/hicolor/scalable/apps/com.github.Rosalie241.RMG.svg. You also have to cahnge the Icon Entry in the .desktop from RMG to com.github.Rosalie241.RMG.

One last thing you need to do before publishing on Flathub is to create a .metainfo.xml file. It contains the Information for the Flathub website and the Software centers. Please upload at least one Screenshot, so I can create one.

Rosalie241 commented 2 years ago

See https://github.com/flathub/flathub/pull/2783, I submitted it to flathub, I hope I did everything right! :two_hearts:

hfiguiere commented 2 years ago

You're right, that works fine, thank you very much for looking into it! ❤️

the only thing left to do is getting the application icon & desktop file installed correctly, because currently during building it says:

Not exporting share/applications/RMG.desktop, non-allowed export filename

I see you have two different .desktop. you shouldn't.

  1. there is rename-desktop-file when building the flatpak
  2. actually the upstream desktop file should have the name that flatpak uses.

There is strictly no point having two upstream.

Same for the icons.

hfiguiere commented 2 years ago

even the appdata is NOT flatpak specific.

edited

Rosalie241 commented 2 years ago

You're right, that works fine, thank you very much for looking into it! ❤️ the only thing left to do is getting the application icon & desktop file installed correctly, because currently during building it says:

Not exporting share/applications/RMG.desktop, non-allowed export filename

I see you have two different .desktop. you shouldn't.

1. there is `rename-desktop-file` when building the flatpak

2. actually the upstream desktop file should have the name that flatpak uses.

There is strictly no point having two upstream.

Same for the icons.

I'll take a look at rename-desktop-file, though I disagree with point 2, for i.e the AUR or other linux packaging methods, I want it to be named RMG.desktop, and w.r.t the icons, I did that because I feel like it was easier, but it doesn't really matter.

even the appdata is NOT flatpak specific.

edited

It might not be flatpak specific in the strictest sense, but it isn't used by anything else, so for this project I feel like it should only be used with flatpak.

hfiguiere commented 2 years ago

I'll take a look at rename-desktop-file, though I disagree with point 2, for i.e the AUR or other linux packaging methods, I want it to be named RMG.desktop, and w.r.t the icons, I did that because I feel like it was easier, but it doesn't really matter.

The spec is quite clear: https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s02.html

The name of the desktop entry should follow the "reverse DNS" convention: it should start with a reversed DNS domain name controlled by the author of the application, in lower case. The domain name should be followed by the name of the application, which is conventionally written with words run together and initial capital letters (CamelCase). For example, if the owner of example.org writes "Foo Viewer", they might choose the name org.example.FooViewer, resulting in a file named org.example.FooViewer.desktop.

In short flatpak just enforce the standard.

It might not be flatpak specific in the strictest sense, but it isn't used by anything else, so for this project I feel like it should only be used with flatpak.

It actually is by more than just flatpak.

Rosalie241 commented 2 years ago

I'll take a look at rename-desktop-file, though I disagree with point 2, for i.e the AUR or other linux packaging methods, I want it to be named RMG.desktop, and w.r.t the icons, I did that because I feel like it was easier, but it doesn't really matter.

The spec is quite clear: https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s02.html

The name of the desktop entry should follow the "reverse DNS" convention: it should start with a reversed DNS domain name controlled by the author of the application, in lower case. The domain name should be followed by the name of the application, which is conventionally written with words run together and initial capital letters (CamelCase). For example, if the owner of example.org writes "Foo Viewer", they might choose the name org.example.FooViewer, resulting in a file named org.example.FooViewer.desktop.

In short flatpak just enforce the standard.

It might not be flatpak specific in the strictest sense, but it isn't used by anything else, so for this project I feel like it should only be used with flatpak.

It actually is by more than just flatpak.

Fixed it, see https://github.com/Rosalie241/RMG/commit/dd2b9bec13549fefee34032a07decd655ecb7c6f & https://github.com/Rosalie241/RMG/commit/cc8c1adaacc9ee712189d48840f53fd3ae119c6b

Thank you for the information and help :two_hearts:

Rosalie241 commented 2 years ago

It's on flathub now! https://flathub.org/apps/details/com.github.Rosalie241.RMG

Thank you very much for all the help :heart:, I couldn't have done it without you 💕

JakobDev commented 2 years ago

Thank you very much for all the help.

No problem. RMG is IMHO currently the best Way to play N64 Games on Linux, so I help to spread this cool program.