Add support for .flatpakref file handling

This commit is contained in:
Bruno Silva
2025-01-30 16:17:40 -03:00
parent 52357124b1
commit add322dfe3
4 changed files with 177 additions and 164 deletions

View File

@@ -1,164 +1,140 @@
{
"id" : "io.github.flattool.Warehouse",
"runtime" : "org.gnome.Platform",
"runtime-version" : "47",
"sdk" : "org.gnome.Sdk",
"command" : "warehouse",
"finish-args" : [
"--share=ipc",
"--socket=fallback-x11",
"--device=dri",
"--socket=wayland",
"--talk-name=org.freedesktop.Flatpak",
"--filesystem=/var/lib/flatpak/:ro",
"--filesystem=~/.local/share/flatpak/:ro",
"--filesystem=~/.var/app/",
"--filesystem=host-etc"
],
"cleanup" : [
"/include",
"/lib/pkgconfig",
"/man",
"/share/doc",
"/share/gtk-doc",
"/share/man",
"/share/pkgconfig",
"*.la",
"*.a"
],
"build-options" : {
"env" : {
"MOUNT_FUSE_PATH" : "../tmp/"
}
},
"modules" : [
{
"name" : "blueprint-compiler",
"buildsystem" : "meson",
"sources" : [
{
"type" : "git",
"url" : "https://gitlab.gnome.org/jwestman/blueprint-compiler",
"tag" : "v0.14.0"
}
],
"cleanup" : [
"*"
]
},
{
"name" : "libfuse",
"config-opts" : [
"UDEV_RULES_PATH=/app/etc/udev/rules.d",
"INIT_D_PATH=/app/etc/init.d"
],
"cleanup" : [
"/bin/ulockmgr_server"
],
"post-install" : [
"install -m a+rx fusermount-wrapper.sh /app/bin/fusermount"
],
"sources" : [
{
"type" : "archive",
"url" : "https://github.com/libfuse/libfuse/releases/download/fuse-2.9.9/fuse-2.9.9.tar.gz",
"sha256" : "d0e69d5d608cc22ff4843791ad097f554dd32540ddc9bed7638cc6fea7c1b4b5"
},
{
"type" : "patch",
"path" : "fuse-2.9.2-namespace-conflict-fix.patch"
},
{
"type" : "patch",
"path" : "fuse-disable-sys-mount-under-flatpak.patch"
},
{
"type" : "patch",
"path" : "fuse-2.9.2-closefrom.patch"
},
{
"type" : "file",
"path" : "fusermount-wrapper.sh"
}
]
},
{
"name": "ostree",
"buildsystem": "autotools",
"config-opts": [
"--disable-rofiles-fuse"
],
"sources": [
{
"type": "git",
"url": "https://github.com/ostreedev/ostree",
"tag": "v2024.9"
}
]
},
{
"name": "pyparsing",
"buildsystem": "simple",
"build-commands": [
"pip3 install --prefix=/app --no-deps ./pyparsing-*.whl"
],
"sources": [
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/8a/bb/488841f56197b13700afd5658fc279a2025a39e22449b7cf29864669b15d/pyparsing-2.4.7-py2.py3-none-any.whl",
"sha256": "ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b"
}
]
},
{
"name" : "flatpak",
"buildsystem" : "meson",
"config-opts" : [
"-Ddocbook_docs=disabled",
"-Dseccomp=disabled",
"-Dsandboxed_triggers=false",
"-Dsystem_helper=disabled",
"-Dsystem_install_dir=/var/lib/flatpak",
"--sysconfdir=/var/run/host/etc",
"-Dman=disabled",
"-Dhttp_backend=curl",
"-Dsystemd=disabled",
"-Dtests=false"
],
"cleanup" : [
"/bin/flatpak-bisect",
"/bin/flatpak-coredumpctl",
"/etc/profile.d",
"/lib/systemd",
"/share/dbus-1/interfaces/org.freedesktop.*",
"/share/dbus-1/services/org.freedesktop.*",
"/share/flatpak/triggers",
"/share/gdm",
"/share/zsh"
],
"post-install" : [
"cp /usr/bin/update-mime-database /app/bin",
"cp /usr/bin/update-desktop-database /app/bin"
],
"sources" : [
{
"type" : "git",
"url" : "https://github.com/flatpak/flatpak.git",
"tag" : "1.15.6"
}
]
},
{
"name" : "warehouse",
"builddir" : true,
"buildsystem" : "meson",
"config-opts": [ "-Dprofile=development" ],
"sources" : [
{
"type" : "dir",
"path" : ".."
}
]
}
]
"id": "io.github.flattool.Warehouse",
"runtime": "org.gnome.Platform",
"runtime-version": "47",
"sdk": "org.gnome.Sdk",
"command": "warehouse",
"finish-args": [
"--share=ipc",
"--socket=fallback-x11",
"--device=dri",
"--socket=wayland",
"--talk-name=org.freedesktop.Flatpak",
"--filesystem=/var/lib/flatpak/:ro",
"--filesystem=~/.local/share/flatpak/:ro",
"--filesystem=~/.var/app/",
"--filesystem=host-etc",
"--filesystem=xdg-download:ro",
"--talk-name=org.freedesktop.FileManager1"
],
"cleanup": ["/include", "/lib/pkgconfig", "/man", "/share/doc", "/share/gtk-doc", "/share/man", "/share/pkgconfig", "*.la", "*.a"],
"build-options": {
"env": {
"MOUNT_FUSE_PATH": "../tmp/"
}
},
"modules": [
{
"name": "blueprint-compiler",
"buildsystem": "meson",
"sources": [
{
"type": "git",
"url": "https://gitlab.gnome.org/jwestman/blueprint-compiler",
"tag": "v0.14.0"
}
],
"cleanup": ["*"]
},
{
"name": "libfuse",
"config-opts": ["UDEV_RULES_PATH=/app/etc/udev/rules.d", "INIT_D_PATH=/app/etc/init.d"],
"cleanup": ["/bin/ulockmgr_server"],
"post-install": ["install -m a+rx fusermount-wrapper.sh /app/bin/fusermount"],
"sources": [
{
"type": "archive",
"url": "https://github.com/libfuse/libfuse/releases/download/fuse-2.9.9/fuse-2.9.9.tar.gz",
"sha256": "d0e69d5d608cc22ff4843791ad097f554dd32540ddc9bed7638cc6fea7c1b4b5"
},
{
"type": "patch",
"path": "fuse-2.9.2-namespace-conflict-fix.patch"
},
{
"type": "patch",
"path": "fuse-disable-sys-mount-under-flatpak.patch"
},
{
"type": "patch",
"path": "fuse-2.9.2-closefrom.patch"
},
{
"type": "file",
"path": "fusermount-wrapper.sh"
}
]
},
{
"name": "ostree",
"buildsystem": "autotools",
"config-opts": ["--disable-rofiles-fuse"],
"sources": [
{
"type": "git",
"url": "https://github.com/ostreedev/ostree",
"tag": "v2024.9"
}
]
},
{
"name": "pyparsing",
"buildsystem": "simple",
"build-commands": ["pip3 install --prefix=/app --no-deps ./pyparsing-*.whl"],
"sources": [
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/8a/bb/488841f56197b13700afd5658fc279a2025a39e22449b7cf29864669b15d/pyparsing-2.4.7-py2.py3-none-any.whl",
"sha256": "ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b"
}
]
},
{
"name": "flatpak",
"buildsystem": "meson",
"config-opts": [
"-Ddocbook_docs=disabled",
"-Dseccomp=disabled",
"-Dsandboxed_triggers=false",
"-Dsystem_helper=disabled",
"-Dsystem_install_dir=/var/lib/flatpak",
"--sysconfdir=/var/run/host/etc",
"-Dman=disabled",
"-Dhttp_backend=curl",
"-Dsystemd=disabled",
"-Dtests=false"
],
"cleanup": [
"/bin/flatpak-bisect",
"/bin/flatpak-coredumpctl",
"/etc/profile.d",
"/lib/systemd",
"/share/dbus-1/interfaces/org.freedesktop.*",
"/share/dbus-1/services/org.freedesktop.*",
"/share/flatpak/triggers",
"/share/gdm",
"/share/zsh"
],
"post-install": ["cp /usr/bin/update-mime-database /app/bin", "cp /usr/bin/update-desktop-database /app/bin"],
"sources": [
{
"type": "git",
"url": "https://github.com/flatpak/flatpak.git",
"tag": "1.15.6"
}
]
},
{
"name": "warehouse",
"builddir": true,
"buildsystem": "meson",
"config-opts": ["-Dprofile=development"],
"sources": [
{
"type": "dir",
"path": ".."
}
]
}
]
}

View File

@@ -1,7 +1,7 @@
[Desktop Entry]
# Translators: Do not translate the application name
Name=Warehouse
Exec=warehouse
Exec=warehouse %F
Icon=io.github.flattool.Warehouse
Terminal=false
Type=Application
@@ -10,3 +10,4 @@ StartupNotify=true
Keywords=flatpak
Comment=Manage all things Flatpak
X-Purism-FormFactor=Workstation;Mobile;
MimeType=application/vnd.flatpak.ref;application/vnd.flatpak;x-scheme-handler/flatpak;

View File

@@ -30,6 +30,8 @@
<control>keyboard</control>
<control>pointing</control>
<control>touch</control>
<mime>application/vnd.flatpak.ref</mime>
<mime>application/vnd.flatpak</mime>
</supports>
<requires>
<display_length compare="ge">330</display_length>

View File

@@ -44,7 +44,7 @@ class WarehouseApplication(Adw.Application):
def __init__(self):
super().__init__(
application_id="io.github.flattool.Warehouse",
flags=Gio.ApplicationFlags.DEFAULT_FLAGS,
flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE | Gio.ApplicationFlags.HANDLES_OPEN,
)
self.create_action("about", self.on_about_action)
self.create_action("preferences", self.on_preferences_action)
@@ -188,6 +188,40 @@ class WarehouseApplication(Adw.Application):
win = WarehouseWindow(application=self)
win.present()
def do_open(self, files, _n_files, _hint):
"""Handle files opened from file manager or command line"""
win = self.props.active_window
if not win:
win = WarehouseWindow(application=self)
win.present()
# Convert GFiles to file paths
file_list = []
for gfile in files:
file_list.append(gfile)
# Use existing file drop handler
win.on_file_drop(None, file_list, None, None)
def do_command_line(self, command_line):
"""Handle command line arguments"""
args = command_line.get_arguments()
if len(args) > 1: # First arg is program name
files = []
for path in args[1:]:
gfile = Gio.File.new_for_path(path)
if gfile.query_exists():
files.append(gfile)
if files:
self.open(files, "")
return 0
# No valid files, just activate normally
self.activate()
return 0
def on_about_action(self, widget, _a):
"""Callback for the app.about action."""
about = Adw.AboutDialog(