xyproto / zsnes

A maintained fork of ZSNES, a Super Nintendo emulator. The original project needs patches to build and is not maintained anymore: https://sourceforge.net/projects/zsnes/
https://zsnes.com
GNU General Public License v2.0
131 stars 16 forks source link

Flatpak #10

Closed JakobDev closed 1 year ago

JakobDev commented 1 year ago

I created a Flatpak build for ZSNES. You need this files:

io.github.xyproto.zsnes.yaml

id: io.github.xyproto.zsnes
runtime: org.freedesktop.Platform
runtime-version: '22.08'
sdk: org.freedesktop.Sdk
command: zsnes
finish-args:
  - --share=ipc
  - --device=all
  - --socket=x11
  - --allow=multiarch
  - --socket=pulseaudio
  - --filesystem=host:rw

sdk-extensions:
  - org.freedesktop.Sdk.Compat.i386
  - org.freedesktop.Sdk.Extension.toolchain-i386

add-extensions:
  org.freedesktop.Platform.Compat.i386:
    directory: lib/i386-linux-gnu
    version: '22.08'

  org.freedesktop.Platform.GL32:
    directory: lib/i386-linux-gnu/GL
    version: '1.4'
    versions: 22.08;1.4
    subdirectories: true
    no-autodownload: true
    autodelete: false
    add-ld-path: lib
    merge-dirs: vulkan/icd.d;glvnd/egl_vendor.d;OpenCL/vendors;lib/dri;lib/d3d;vulkan/explicit_layer.d;vulkan/implicit_layer.d
    download-if: active-gl-driver
    enable-if: active-gl-driver

build-options: &compat-i386-build-options
  prepend-pkg-config-path: /app/lib32/pkgconfig:/usr/lib/i386-linux-gnu/pkgconfig
  ldflags: -L/app/lib32
  prepend-path: /usr/lib/sdk/toolchain-i386/bin
  env:
    CC: i686-unknown-linux-gnu-gcc
    CXX: i686-unknown-linux-gnu-g++
    CFLAGS: ''
    CXXFLAGS: ''
  libdir: /app/lib32

modules:
  - shared-modules/SDL/SDL-1.2.15.json

  - name: zsnes
    buildsystem: simple
    build-commands:
      - make
      - mkdir -p /app/lib/i386-linux-gnu
      - mkdir -p /app/lib/debug/lib/i386-linux-gnu
      - mkdir -p /app/lib/i386-linux-gnu/GL
      - install -Dm755 zsnes -t $FLATPAK_DEST/bin
      - install -Dm644 ld.so.conf -t $FLATPAK_DEST/etc
      - install -Dm644 io.github.xyproto.zsnes.png -t $FLATPAK_DEST/share/icons/hicolor/128x128/apps
      - install -Dm644 linux/zsnes.desktop $FLATPAK_DEST/share/applications/$FLATPAK_ID.desktop
      - desktop-file-edit --set-icon=$FLATPAK_ID --set-key=Exec --set-value="zsnes %f" --add-mime-type=application/vnd.nintendo.snes.rom --add-mime-type=application/x-snes-rom $FLATPAK_DEST/share/applications/$FLATPAK_ID.desktop
      - install -Dm644 io.github.xyproto.zsnes.metainfo.xml -t $FLATPAK_DEST/share/metainfo
    sources:
      - type: archive
        url: https://github.com/xyproto/zsnes/archive/refs/tags/2.0.10.tar.gz
        sha256: 18d503e5839dfdc74d4c889b824757596bbe27b8f97ca148ceb2537e420848a5
      - type: patch
        path: xdg-dir.patch
      - type: inline
        dest-filename: ld.so.conf
        contents: |
          /app/lib32
          /app/lib/i386-linux-gnu
      - type: file
        path: io.github.xyproto.zsnes.png
      - type: file
        path: io.github.xyproto.zsnes.metainfo.xml

xdg-dir.patch

diff -ruN original/zpath.c zsnes/zpath.c
--- original/zpath.c    2023-04-12 10:19:44.435685652 +0200
+++ zsnes/zpath.c       2023-04-12 10:19:03.652352332 +0200
@@ -76,7 +76,7 @@
     const char* const zpath = ZCONF;
 #else
 #ifndef __MACOSX__
-    const char* const zpath = ".zsnes";
+    const char* const zpath = "zsnes";
 #else
     const char* const zpath = "Library/Application Support/ZSNES";
 #endif
@@ -90,7 +90,7 @@

     if (ZCfgPath) {
         ZCfgAlloc = true;
-        strcpy(ZCfgPath, userinfo->pw_dir);
+        strcpy(ZCfgPath, getenv("XDG_CONFIG_HOME"));
         strcatslash(ZCfgPath);
         strcat(ZCfgPath, zpath);

io.github.xyproto.zsnes.metainfo.xml

<?xml version='1.0' encoding='utf-8'?>
<component type="desktop">
  <!--Created with jdAppStreamEdit 6.0-->
  <id>io.github.xyproto.zsnes</id>
  <name>ZSNES</name>
  <summary>Super Nintendo emulator</summary>
  <developer_name>Alexander F. Rødseth</developer_name>
  <launchable type="desktop-id">io.github.xyproto.zsnes.desktop</launchable>
  <metadata_license>CC0-1.0</metadata_license>
  <project_license>GPL-2.0</project_license>
  <description>
    <p>ZSNES is a classical SNES Emulator. It's development started 1998 and is was one of the most uses SNES Emulators for years.</p>
    <p>Today you should use ZSNES only for historical and nostalgia reasons, as there are Emulators ot there which provides more Features and a better Game compatibility.</p>
  </description>
  <screenshots>
    <screenshot type="default">
      <image type="source">https://upload.wikimedia.org/wikipedia/commons/5/5d/ZSNES.jpg</image>
    </screenshot>
  </screenshots>
  <releases>
    <release version="2.0.10" date="2022-06-13" type="stable"/>
    <release version="2.0.9" date="2021-08-18" type="stable"/>
  </releases>
  <url type="homepage">https://github.com/xyproto/zsnes</url>
  <url type="bugtracker">https://github.com/xyproto/zsnes/issues</url>
  <categories>
    <category>Game</category>
    <category>Emulator</category>
  </categories>
  <recommends>
    <control>pointing</control>
    <control>keyboard</control>
    <control>gamepad</control>
  </recommends>
  <content_rating type="oars-1.1"/>
  <provides>
    <binary>zsnes</binary>
    <mediatype>application/vnd.nintendo.snes.rom</mediatype>
    <mediatype>application/x-snes-rom</mediatype>
  </provides>
</component>

io.github.xyproto.zsnes.png io github xyproto zsnes

You also need the shared-modules.

I have tested it and it works. Are you interested to maintain it on Flathub? If not, I can do that.

xyproto commented 1 year ago

Excellent! Thanks for creating this.

I haven't used Flathub that much yet, only given it a quick spin, and the config looks fairly involved, so I think you are probably the right person to maintain it on Flathub, if you wish. 😄

JakobDev commented 1 year ago

Sure. I will create a PR for adding it to Flathub. You can be added as a Co Maintainer if you wish.

the config looks fairly involved

To be fair, most of it is taken from the official Documentation.

xyproto commented 1 year ago

That makes sense. Feel free to add me as a co-maintainer.

Btw, would it make sense to use sdl12-compat as a dependency, so that users only need to have SDL2 installed? I assume this should work, but have not tested it with Flatpak yet.

JakobDev commented 1 year ago

so that users only need to have SDL2 installed?

Flatpaks are a Container that is separated from the Rest of the System, so this doesn't matter. Are there other Advantages?

I had opened the PR now.

xyproto commented 1 year ago

No, it probably does not matter. Except perhaps if people have multiple monitors, since this is handled much better by SDL2. This might not be an issue, though.

JakobDev commented 1 year ago

Except perhaps if people have multiple monitors, since this is handled much better by SDL2.

Does ZSNES supports multiple monitors?

While thinking about this, which SDL2 we could get Wayland support, so I will give it a try when I have some time.

JakobDev commented 1 year ago

I have now made a test build. It looks like it's working, but it might be a good idea, that you take a look at it, before I merge it.

pizzadude commented 1 year ago

@JakobDev Without this patch (sdl12-compat), in Fedora KDE wayland, ZSNES flatpak crashes when trying to change the resolution. sdl12-compat fixes that. Please merge.

JakobDev commented 1 year ago

Why have you me invited?

xyproto commented 1 year ago

@JakobDev Just in case you wanted to contribute directly, I invited you to have access to this repo, if you want.

JakobDev commented 1 year ago

Thanks, but please not that I cannot help much with the C stuff

JakobDev commented 1 year ago

@xyproto Could you verify the ZSNES Flatpak? Just log in with your GitHub Account on flathub.org and you can verify it in the Developer Settings.

xyproto commented 1 year ago

@JakobDev Thanks for the ping! My account is verified now, but I could find no button or setting for verifying the ZNES flatpak, using my mobile phone. I'll check in Firefox on desktop as well.