Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add flatpak builds #1230

Merged
merged 21 commits into from
Oct 8, 2024
Merged

feat: add flatpak builds #1230

merged 21 commits into from
Oct 8, 2024

Conversation

Jabster28
Copy link
Contributor

@Jabster28 Jabster28 commented Aug 21, 2024

The process is a little bit finicky at the moment, but the general idea is:

  • The name of the app is read from the core/src/main/java/haveno/core/app/HavenoExecutable.java with a janky regex
  • Make a new, temporary flatpak manifest with a --filesystem= that matches the app name
  • Extract the .deb file (should use the app-image (not appimage) from jpackage in the future)
  • Run all of the flatpak stuff
  • Delete any residuals, and leave the .flatpak in the binaries folder

If you're repackaging Haveno and would like to change the name and other things:

  • The icon in the dock while running seems to match whatever icon the binary was built with, so I don't think any renames are necessary. The icon in your launcher will be the same as desktop/src/main/resources/images/task_bar_icon_windows.png.
  • You almost definitely want to search the whole repo for instances of the Haveno app ID exchange.haveno.Haveno and replace them with something else (perhaps exchange.haveno.${APPNAME} or something similar), as leaving them the same will cause issues with installs
  • The Flatpaks are given access to ~/.local/share/${APPNAME}, so ensure your app name isn't Steam or something common
    • This also means that you should be able to switch from native to flatpak and vice versa without any backup-and-restore dances
    • If you'd prefer more security, you can use Flatseal and change the permission from a filesystem to a persist (the data will stay in Flatpak's sandbox instead of your home dir)
  • The Flatpak build manifest is desktop/package/linux/exchange.haveno.Haveno.yml
    • This contains, and is named after, the ID of the app. Remember to rename the file if you Ctrl-F all of the instances of the old ID.
  • The metainfo is desktop/package/linux/exchange.haveno.Haveno.metainfo.xml
    • This has the rest of the juicy metadata like titles, screenshots, descriptions, version history etc.

I've never used Gradle before and a lot of weird choices were from myself and Stack Overflow so if something looks wrong, please let me know.

@ZhenyaPav
Copy link

I went in a different route by trying to get the app to build for flatpak specifically, but it does seem to create some problems of its own, not to mention the considerable increase in build time (which is probably a concern with GitHub actions)
@Jabster28 do you have a .flatpak file for testing?

@Jabster28
Copy link
Contributor Author

@ZhenyaPav Heya. I've got a good idea of how I'd do this, but I'd love to see how you decided to do it. Making the Flatpak bundle takes a while already and I'd rather keep the builds short, as runners aren't cheap and if the project ever moves to something without free runners that would be an issue (which is why I'm also testing what amounts of caching works and what doesn't). I'll let you know when the PR is ready to merge and I'm open to any comments or suggestions.

Yes, there's a CI generated Flatpak in the Linux zip of the runner artifacts on my fork.

@ZhenyaPav
Copy link

What I came up with is this:


runtime: org.freedesktop.Platform
runtime-version: '23.08'
sdk: org.freedesktop.Sdk
sdk-extensions:
  - org.freedesktop.Sdk.Extension.openjdk21
command: haveno-desktop
finish-args:
  - --env=PATH=/app/jre/bin:/usr/bin
  - --env=JAVA_HOME=/app/jre
  - --share=network
  - --share=ipc
  - --socket=x11
  - --socket=wayland
  - --filesystem=home

modules:
  - name: openjdk
    buildsystem: simple
    build-commands:
      - /usr/lib/sdk/openjdk21/install.sh

  - name: build-haveno
    buildsystem: simple
    build-options:
      append-path: /usr/lib/sdk/openjdk21/bin
      build-args:
        - --share=network
    build-commands:
      - make haveno-apps
      - ls
      - install -Dm755 ./haveno-desktop /app/bin/haveno-desktop
    sources:
      - type: git
        url: https://github.com/ZhenyaPav/haveno
        branch: master

I was able to build the flatpak with this, but it didn't launch due to haveno-desktop not being present, for some reason. I only did PKGBUILDs for AUR before, so flatpak is new territory for me.

@ZhenyaPav
Copy link

Checked it out on Fedora Silverblue, seems to be working

@Jabster28
Copy link
Contributor Author

Jabster28 commented Aug 25, 2024

@ZhenyaPav Yeah, the idea of building it within the Flatpak runtime is nice for reproducibility, but it doesn't really add any security guarantees and it seems to add too much overhead (longer build times, more technical debt). Having it existing would be nice, however. I think someone in the community is attempting to do a build with Guix, that could potentially help.
I don't think we have any -bin or -git AUR packages atm, a lot of people would like that as an option. Could you possibly help with that?

it didn't launch due to haveno-desktop not being present

I don't see any immediate issues but I'd imagine you need to (and should) use a full path in the command: section, since it's not run inside of any shell. You might also want to add some metadata and icon files, and limit those permissions for security.

@Jabster28 Jabster28 marked this pull request as ready for review August 25, 2024 21:55
@Jabster28 Jabster28 requested a review from woodser as a code owner August 25, 2024 21:56
@ZhenyaPav
Copy link

ZhenyaPav commented Aug 27, 2024

I don't think we have any -bin or -git AUR packages atm, a lot of people would like that as an option. Could you possibly help with that?

making haveno-git should be trivial, as it's only a matter of changing the url to download from the master branch instead of a tag, but -bin is indeed an interesting idea.

@Jabster28 Jabster28 requested a review from a team as a code owner September 9, 2024 13:38
@Jabster28
Copy link
Contributor Author

The sample Flatpak repo solution using flat-manager instead of GH pages took a lot of files and config to work, so I moved it and the accompanying docs to https://gitlab.com/Jabster28/flatman-haveno-test since I wasn't sure if it belonged here.

@woodser
Copy link
Contributor

woodser commented Oct 1, 2024

@TheTollingBell has rebased the AppImage PR.

Do you mind to squash your commits and rebase on the AppImage PR, so there are a total of two commits, please?

Otherwise I can test / merge their AppImage PR, then you'll need to rebase your changes on master, but was hoping to see how both look together.

@Jabster28
Copy link
Contributor Author

Sure, and I'll try to minimise the number of commits afterwards.

@woodser
Copy link
Contributor

woodser commented Oct 2, 2024

@Jabster28 The AppImage PR has been merged to master, so this is ready to rebase on master to resolve the merge conflict, then I can do final testing.

@Jabster28
Copy link
Contributor Author

Seems to install and work for me. Just needs a bit of testing and final looks over.

@woodser
Copy link
Contributor

woodser commented Oct 7, 2024

@ZhenyaPav Maybe you want to review this?

.github/workflows/build.yml Outdated Show resolved Hide resolved
core/src/main/java/haveno/core/app/HavenoExecutable.java Outdated Show resolved Hide resolved
desktop/package/README.md Outdated Show resolved Hide resolved
@@ -42,7 +48,7 @@ Haveno data folder on Mac: `/Users/<username>/Library/Application Support/Haveno
6. Click "OK" to save the changes and exit the dialog box.
7. Windows will download and install the required files and components to enable the .NET Framework 3.5. This may take several minutes, depending on your internet connection speed and system configuration.
8. Once the installation is complete, you will need to restart your computer to apply the changes.
2. Install Wix Toolset 3: https://github.com/wixtoolset/wix3/releases/tag/wix314rtm
2. Install Wix Toolset 3: <https://github.com/wixtoolset/wix3/releases/tag/wix314rtm>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add <> here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that was my automatic linter. MD034 says that some MarkDown parsers don't understand bare URLs and that angle brackets are the "proper" syntax to use.

desktop/package/README.md Outdated Show resolved Hide resolved
desktop/package/README.md Outdated Show resolved Hide resolved
</description>
<screenshots>
<screenshot type="default">
<image>https://files.catbox.moe/8pahgg.png</image>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not be fetching this screenshot from a remote repo imo, which could become unavailable.

Can we read it locally from the desktop package instead, if it's useful?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flatpak docs say that it needs a public URL, but we could just host it on the github and get a raw link to the image.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also good catch, almost forgot about this 😅

desktop/package/linux/exchange.haveno.Haveno.metainfo.xml Outdated Show resolved Hide resolved
desktop/package/package.gradle Show resolved Hide resolved
desktop/package/package.gradle Outdated Show resolved Hide resolved
docs/flatpak.md Outdated Show resolved Hide resolved
@woodser
Copy link
Contributor

woodser commented Oct 7, 2024

@Jabster28 Thanks very much for the update! Some changes requested and I think it's ready to merge.

@woodser
Copy link
Contributor

woodser commented Oct 8, 2024

This PR is ignoring the DEFAULT_APP_NAME set within HavenoExecutable.java for its persistence directory.

Edit: Nevermind, I rebased incorrectly, it's working :)

@woodser woodser changed the base branch from master to flatpak October 8, 2024 17:25
@woodser woodser merged commit 14b5390 into haveno-dex:flatpak Oct 8, 2024
5 of 6 checks passed
woodser pushed a commit that referenced this pull request Oct 8, 2024
woodser added a commit that referenced this pull request Oct 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants