howl-editor / howl

The Howl Editor
http://howl.io
Other
712 stars 68 forks source link

flatpak run error #203

Closed MadcapJake closed 6 years ago

MadcapJake commented 8 years ago

I tried packaging howl via flatpak and I thought I'd show you how far I got (and ask for some help with an error that I don't know anything about).

flatpak build-init howl com.github.howl_editor.Howl org.gnome.Sdk org.gnome.Platform 3.20

This sets up a howl directory with some boilerplate.

wget https://github.com/howl-editor/howl/releases/download/0.4/howl-0.4.tgz
tar xvf howl-0.4.tgz
cd howl-0.4/src
flatpak build ../../howl make PREFIX=/app
flatpak build ../../howl make PREFIX=/app install

This builds and installs into the proper howl directory.

cd ../../
mv howl/files/share/applications/howl.desktop howl/files/share/applications/com.github.howl_editor.Howl.desktop
mv howl/files/share/icons/hicolor/scalable/apps/howl.svg howl/files/share/icons/hicolor/scalable/apps/com.github.howl_editor.Howl.svg

This renames two to-be exported files to the format that flatpak expects.

flatpak build-finish howl --socket=x11 --share=network --filesystem=host --command=howl

This creates an export directory and adds some details about what howl can access (not sure if the network is really).

flatpak build-export howl-repo howl
flatpak --user remote-add --no-gpg-verify --if-not-exists howl-repo howl-repo
flatpak --user install howl-repo com.github.howl_editor.Howl

This creates a repo and adds howl to it. Then it adds the repo to the user's selection of repos and installs com.github.howl_editor.Howl from within it.

flatpak run com.github.howl_editor.Howl

This runs the application. Everything up to this point works but after attempting to run, I get this message:

../lib/ljglibs/gio/application.moon:33: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: org.freedesktop.DBus.Error.ServiceUnknown (code: 2)

** (howl:2): CRITICAL **: Failed to run script: /app/share/howl/lib/howl/init.lua:158: ../lib/ljglibs/gio/application.moon:33: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: org.freedesktop.DBus.Error.ServiceUnknown (code: 2)

I'm not familiar with DBus, MoonScript, or this project but I thought I'd at least share how far I got as I think this might be a plausible build format to support.

alexlarsson commented 8 years ago

Seems like howl uses GApplication, which registers its name using dbus. Flatpak denies most dbus accesses by default, however you are allowed to own your flatpak application id on the bus. It seems like in: https://github.com/howl-editor/howl/blob/cdcde209e6ca4bceee56be509b4eaa381b6e29a1/lib/ljglibs/spec/gtk/application_spec.moon#L6 you currently use "my.App" as the id. This needs to be com.github.howl_editor.Howl instead

nilnor commented 8 years ago

@alexlarsson thanks for the input! The file you've found is only the spec for the ljglibs GtkApplication wrapper though - the actual id is io.howl.Editor as defined in application.moon.

@MadcapJake see if it works with io.howl.Editor as per Alexander's input. Note that for launching the packaged app you'll want to specify that the --reuse parameter should be used, otherwise the application id will be changed at start to avoid launching in the same GApplication.

Would be interesting to see if this could work well, I have been following xdg-app from the sides previously. I wasn't aware of the new name though, but I blame @alexlarsson's lack of blog updates for that :)

MadcapJake commented 8 years ago

@nilnor that did the trick! However I am hitting one little snag. At first, I was getting this error:

Failed to find application icon

So I changed all references from howl.svg to io.howl.Editor.svg. This removed the error but it still shows the default icon for some reason.

alexlarsson commented 8 years ago

There is a "rename-icon" feature you can use.

MadcapJake commented 8 years ago

Ok I've created a bundle if anyone is interesting in giving it a try. https://github.com/MadcapJake/howl/releases/tag/0.4-pak

nilnor commented 8 years ago

Nice! And seems to work well from my limited testing (drawbacks I saw: scrollbars end up being uglier, and a Gtk warning in the console). Would be nice to get the build step automated into master and perhaps offer it as a download alternative from the site (as flatpak is not currently at the stage where it's integrated directly in any store AFAIK). The icon renaming could perhaps be handled with rename-icon feature mentioned by @alexlarsson?

MadcapJake commented 8 years ago

Yeah flatpak forces the use of the Adwaita theme and I'm not sure how to workaround that. The rename-icon feature requires that you follow their Build API which would require more modifying than I think I'm capable of completing.

Flatpak is available in Arch and Fedora OOTB and others only a step or two away.

nilnor commented 8 years ago

Following that build API seems more than what I'm willing to do anyway, but we should be able to wrap up all needed build steps in a simple shell script, and that could handle the icon renaming automatically in that case.

MadcapJake commented 8 years ago

Yeah that's what I did for the .pak file in my fork. This should cover it (haven't tested but pulled these commands from my shell history and original post)

VER=0.4

flatpak build-init howl-pak-dir io.howl.Editor org.gnome.Sdk org.gnome.Platform 3.20
wget "https://github.com/howl-editor/howl/releases/download/$VER/howl-$VER.tgz"
tar xvf "howl-$VER.tgz"

cd "howl-$VER"
mv share/applications/howl.desktop share/applications/io.howl.Editor.desktop
mv share/icons/hicolor/scalable/apps/howl.svg share/icons/hicolor/scalable/apps/io.howl.Editor.svg

cd src
flatpak build ../../howl-pak-dir make PREFIX=/app
flatpak build ../../howl-pak-dir make PREFIX=/app install

cd ../../
flatpak build-finish howl --socket=x11 --share=network --filesystem=host --command=howl
flatpak build-export howl-repo howl $VER
flatpak build-bundle howl-repo "howl-$VER.x86_64.flatpak" io.howl.Editor $VER
alexlarsson commented 8 years ago

I don't see how that is especially complicated to build with flatpak-builder. All you need is to set "no-autogen": true.

alexlarsson commented 8 years ago

Also, please use .flatpak, thats the extension used in the mime db. .pak is used for other types.

MadcapJake commented 8 years ago

@alexlarsson oh, I had asked on IRC whether I could skip the configure step and didn't receive a reply (and there's no mention of no-autogen on that Build API page). Without that, it should require no modification of the makefile, iiuc.

Also editing my previous post to reflect .flatpak

refi64 commented 6 years ago

First off, this isn't a bug in Howl. Flatpak doesn't allow access to DBus services by default without explicit arguments. And, as Howl uses GApplication to detect unique instances, which in turn uses DBus...you can see where this is headed.

Of course, because I'm a moron, I had forgotten that this was open and basically re-implemented the whole freaking thing. :man_facepalming:

Here's my flatpak-builder script (place in io.howl.Editor.json):

{
  "app-id": "io.howl.Editor",
  "runtime": "org.gnome.Platform",
  "runtime-version": "3.26",
  "sdk": "org.gnome.Sdk",
  "command": "howl",
  "modules": [
    {
      "name": "howl",
      "buildsystem": "simple",
      "build-commands": [
        "make -C src install PREFIX=/app"
      ],
      "sources": [
        {
          "type": "archive",
          "url": "https://github.com/howl-editor/howl/releases/download/0.5.3/howl-0.5.3.tgz",
          "sha256": "7b0055908f57f27b30f20f7baec6302b0ba368ca3f30ccd655bc2258f246cc3e"
        }
      ],
      "cleanup": [
        "/share/howl/spec",
        "example.*",
        "misc",
        "*.moon"
      ]
    }
  ],
  "rename-appdata-file": "howl",
  "rename-desktop-file": "howl.desktop",
  "rename-icon": "howl",
  "copy-icon": true,
  "finish-args": [
    "--share=ipc",
    "--share=network",

    "--socket=x11",
    "--socket=wayland",

    "--filesystem=home",
    "--filesystem=host",

    "--own-name=io.howl.*"
  ]
}

Unfortunately, Howl 0.5.3 doesn't have the window border fix from #263, which is reproducible when running inside of the Flatpak.

FWIW since this issue has been posted, Flathub has become a thing, where we could probably submit Howl to.

refi64 commented 6 years ago

Not a Howl bug.