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

Add Flatpack support/CI #2

Merged
merged 10 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/flatpak.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Flatpak

on:
push:
branches:
- main
pull_request:

jobs:
flatpak:
name: "build"
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
arch:
- x86_64
- aarch64

container:
image: bilelmoussaoui/flatpak-github-actions:gnome-45
options: --privileged

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install deps
if: ${{ matrix.arch != 'x86_64' }}
run: |
dnf -y install docker

- name: Set up QEMU
if: ${{ matrix.arch != 'x86_64' }}
id: qemu
uses: docker/setup-qemu-action@v2
with:
platforms: arm64

- uses: flatpak/flatpak-github-actions/flatpak-builder@v6
with:
bundle: nxdumpclient.flatpak
manifest-path: flatpak/org.v1993.NXDumpClient.yml
cache-key: flatpak-builder-${{ github.sha }}
arch: ${{ matrix.arch }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/.flatpak-builder
.flatpak-builder/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "flatpak/shared-modules"]
path = flatpak/shared-modules
url = https://github.com/flathub/shared-modules.git
8 changes: 8 additions & 0 deletions data/org.v1993.NXDumpClient.appdata.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<component type="desktop">
<name>NX Dump Client</name>
<id>org.v1993.NXDumpClient</id>
<developer_name>v19930312</developer_name>
<summary>Client for dumping over USB with nxdumptool</summary>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-3.0-or-later</project_license>
Expand All @@ -16,5 +17,12 @@
<screenshot type="default"></screenshot>
</screenshots>
<releases>
<release version="0.1.0" date="2023-10-24" />
</releases>
<requires>
<internet>offline-only</internet>
</requires>
<supports>
<modalias>usb:v057Ep3000d0100dc00dsc00dp00icFFiscFFipFFin00</modalias>
</supports>
</component>
2 changes: 2 additions & 0 deletions flatpak/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto-generated with a custom command for gnome builder
org.v1993.NXDumpClient.yml.json*
2 changes: 1 addition & 1 deletion flatpak/modules/libgusb.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"cleanup": [
"/bin",
"/include",
"/lib/pkgconfig,
"/lib/pkgconfig",
"/lib/girepository-1.0",
"/man",
"/share/aclocal",
Expand Down
32 changes: 32 additions & 0 deletions flatpak/modules/libportal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "libportal",
"buildsystem": "meson",
"config-opts": [
"-Dauto_features=disabled",
"-Dbackend-gtk4=enabled",
"-Ddocs=false",
"-Dtests=false"
],
"cleanup": [
"/include",
"/lib/pkgconfig",
"/lib/girepository-1.0",
"/man",
"/share/aclocal",
"/share/doc",
"/share/gtk-doc",
"/share/man",
"/share/pkgconfig",
"/share/gir-1.0",
"/share/vala",
"*.la",
"*.a"
],
"sources": [
{
"type": "archive",
"url": "https://github.com/flatpak/libportal/releases/download/0.7.1/libportal-0.7.1.tar.xz",
"sha256": "297b90b263fad22190a26b8c7e8ea938fe6b18fb936265e588927179920d3805"
}
]
}
2 changes: 1 addition & 1 deletion flatpak/modules/libusb.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "libusb",
"config-opts": [ "--disable-static", "--disable-udev" ],
"config-opts": [ "--disable-static" ],
"cleanup": [
"/lib/*.la",
"/lib/pkgconfig",
Expand Down
7 changes: 6 additions & 1 deletion flatpak/org.v1993.NXDumpClient.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,23 @@ finish-args:
- --socket=wayland
# Switch USB access
- --device=all
# Required for hotplug
- --share=network
# Default dump destination
- --filesystem=xdg-download

modules:
- modules/libusb.json
- shared-modules/libusb/libusb.json
- modules/libgusb.json
- modules/libportal.json
- modules/blueprint-compiler.json

- name: nxdumpclient
buildsystem: meson
builddir: true
config-opts:
- -Dudev_rules=disabled
- -Duse_libportal=enabled
sources:
- type: dir
path: ..
Expand Down
1 change: 1 addition & 0 deletions flatpak/shared-modules
Submodule shared-modules added at 24f7c7
28 changes: 22 additions & 6 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/

extern const string NXDC_VERSION;
extern const string NXDC_ICONS_PATH;

namespace NXDumpClient {
/// A convenience method to show errors to user
Expand All @@ -37,10 +38,14 @@ namespace NXDumpClient {
private UsbContext usb_ctx;
private Window? main_window = null;

#if WITH_LIBPORTAL
public Xdp.Portal? portal { get; private set; default = null; }
#endif

public void show_error(string desc, string message) {
if (main_window != null) {
if (main_window != null && main_window.is_active) {
var toast = new Adw.Toast.format("<span color=\"red\">%s</span>: %s", desc, message) {
timeout = 10,
timeout = 5,
priority = HIGH
};
main_window.show_toast((owned)toast);
Expand All @@ -49,7 +54,6 @@ namespace NXDumpClient {
notif.set_body(message);
notif.set_category("device.error");
notif.set_priority(HIGH);
// FIXME: icon does not show. Is it on KDE or me?
notif.set_icon(new ThemedIcon("dialog-error"));
send_notification(null, notif);
}
Expand Down Expand Up @@ -113,16 +117,28 @@ namespace NXDumpClient {
usb_ctx = new UsbContext();

// Allow window to show up first
Idle.add(() => {
Idle.add_once(() => {
usb_ctx.enumerate();
return Source.REMOVE;
}, Priority.DEFAULT_IDLE);
});
} catch(Error e) {
printerr(_("Failed to initialize USB context: %s\n"), e.message);
Process.exit(1);
}

device_list = new ListStore(typeof(UsbDeviceClient));

#if WITH_LIBPORTAL
try {
portal = new Xdp.Portal.initable_new();
} catch(Error e) {
warning("Failed to initialize libportal: %s", e.message);
}

if (Xdp.Portal.running_under_flatpak()) {
// Fix About dialog icon
Gtk.IconTheme.get_for_display(Gdk.Display.get_default()).add_search_path(NXDC_ICONS_PATH);
}
#endif
}

private static void unset_main_window(Window win, Application app) {
Expand Down
11 changes: 8 additions & 3 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ nxdc_blueprints = files(
extra_vala_args = []

nxdc_deps = [
dependency('glib-2.0', version: '>=2.70'),
dependency('glib-2.0', version: '>=2.76'),
dependency('gio-2.0'),
dependency('gtk4', version: '>=4.10'),
dependency('libadwaita-1', version: '>= 1.4'),
Expand Down Expand Up @@ -59,6 +59,10 @@ nxdc_blueprint_tgt = custom_target(
input: nxdc_blueprint_genlist
)

# Explicitly depend on blueprints target since valac needs
# .ui files to be present at build time
nxdc_deps += declare_dependency(sources: nxdc_blueprint_tgt)

nxdc_blueprints_build_dir = nxdc_blueprint_tgt.full_path() + '.p'

nxdc_sources += gnome.compile_resources('nxdumpclient-resources',
Expand All @@ -68,13 +72,14 @@ nxdc_sources += gnome.compile_resources('nxdumpclient-resources',
source_dir: [ nxdc_blueprints_build_dir ]
)

executable('nxdumpclient', nxdc_sources,
executable('nxdumpclient', nxdc_sources, nxdc_blueprint_tgt,
dependencies: nxdc_deps,
vala_args: [ '--gresourcesdir', nxdc_blueprints_build_dir, extra_vala_args ],
install: true,

c_args: [
'-DGETTEXT_PACKAGE="nxdumpclient"',
'-DNXDC_VERSION="@0@"'.format(meson.project_version())
'-DNXDC_VERSION="@0@"'.format(meson.project_version()),
'-DNXDC_ICONS_PATH="@0@"'.format(get_option('datadir') / 'icons'),
],
)