From 946d91365c4915291f91ee50232c8f59778701cf Mon Sep 17 00:00:00 2001 From: Hari Rana Date: Sun, 6 Oct 2024 19:01:10 -0400 Subject: [PATCH 1/3] Move Flatpak manifest to `build-aux` --- .github/workflows/flatpak-builder.yml | 2 +- build-aux/io.github.flattool.Warehouse.json | 57 +++++++++++++++++++++ io.github.flattool.Warehouse.json | 55 -------------------- 3 files changed, 58 insertions(+), 56 deletions(-) create mode 100644 build-aux/io.github.flattool.Warehouse.json delete mode 100644 io.github.flattool.Warehouse.json diff --git a/.github/workflows/flatpak-builder.yml b/.github/workflows/flatpak-builder.yml index ed0b965..aff6284 100644 --- a/.github/workflows/flatpak-builder.yml +++ b/.github/workflows/flatpak-builder.yml @@ -18,4 +18,4 @@ jobs: uses: flatpak/flatpak-github-actions/flatpak-builder@v6.1 with: bundle: io.github.flattool.Warehouse.flatpak - manifest-path: io.github.flattool.Warehouse.json + manifest-path: build-aux/io.github.flattool.Warehouse.json diff --git a/build-aux/io.github.flattool.Warehouse.json b/build-aux/io.github.flattool.Warehouse.json new file mode 100644 index 0000000..5fd0de5 --- /dev/null +++ b/build-aux/io.github.flattool.Warehouse.json @@ -0,0 +1,57 @@ +{ + "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" + ], + "modules" : [ + { + "name" : "blueprint-compiler", + "buildsystem" : "meson", + "sources" : [ + { + "type" : "git", + "url" : "https://gitlab.gnome.org/jwestman/blueprint-compiler", + "tag" : "v0.14.0" + } + ], + "cleanup" : [ + "*" + ] + }, + { + "name" : "warehouse", + "builddir" : true, + "buildsystem" : "meson", + "config-opts": [ "-Dprofile=development" ], + "sources" : [ + { + "type" : "dir", + "path" : ".." + } + ] + } + ] +} diff --git a/io.github.flattool.Warehouse.json b/io.github.flattool.Warehouse.json deleted file mode 100644 index a47e93c..0000000 --- a/io.github.flattool.Warehouse.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "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" - ], - "modules": [ - { - "name": "blueprint-compiler", - "buildsystem": "meson", - "sources": [ - { - "type": "git", - "url": "https://gitlab.gnome.org/jwestman/blueprint-compiler", - "tag": "v0.14.0" - } - ], - "cleanup": ["*"] - }, - { - "name": "warehouse", - "builddir": true, - "buildsystem": "meson", - "config-opts": ["-Dprofile=default"], - "sources": [ - { - "type": "dir", - "path": "." - } - ] - } - ] -} From bf5a6b49651e498465d14ab6129f859af4adc89e Mon Sep 17 00:00:00 2001 From: Hari Rana Date: Sun, 6 Oct 2024 19:02:04 -0400 Subject: [PATCH 2/3] Add libflatpak as dependency --- build-aux/fuse-2.9.2-closefrom.patch | 24 ++++ .../fuse-2.9.2-namespace-conflict-fix.patch | 25 ++++ ...fuse-disable-sys-mount-under-flatpak.patch | 29 +++++ build-aux/fusermount-wrapper.sh | 13 +++ build-aux/io.github.flattool.Warehouse.json | 107 ++++++++++++++++++ src/main.py | 3 +- 6 files changed, 200 insertions(+), 1 deletion(-) create mode 100644 build-aux/fuse-2.9.2-closefrom.patch create mode 100644 build-aux/fuse-2.9.2-namespace-conflict-fix.patch create mode 100644 build-aux/fuse-disable-sys-mount-under-flatpak.patch create mode 100644 build-aux/fusermount-wrapper.sh diff --git a/build-aux/fuse-2.9.2-closefrom.patch b/build-aux/fuse-2.9.2-closefrom.patch new file mode 100644 index 0000000..a7ae30f --- /dev/null +++ b/build-aux/fuse-2.9.2-closefrom.patch @@ -0,0 +1,24 @@ +SPDX-License-Identifier: GPL-3.0-or-later +SPDX-FileCopyrightText: 2017 Christian Hergert +Reference: https://gitlab.gnome.org/GNOME/gnome-builder/-/blob/main/build-aux/flatpak/fuse-2.9.2-closefrom.patch?ref_type=heads + +--- fuse-2.9.2/util/ulockmgr_server.c.closefromfix 2019-01-04 05:33:33.000000000 -0800 ++++ fuse-2.9.2/util/ulockmgr_server.c 2022-07-12 12:29:56.445402244 -0700 +@@ -124,7 +124,7 @@ + return res; + } + +-static int closefrom(int minfd) ++static int _closefrom(int minfd) + { + DIR *dir = opendir("/proc/self/fd"); + if (dir) { +@@ -384,7 +384,7 @@ + dup2(nullfd, 1); + } + close(3); +- closefrom(5); ++ _closefrom(5); + while (1) { + char c; + int sock; diff --git a/build-aux/fuse-2.9.2-namespace-conflict-fix.patch b/build-aux/fuse-2.9.2-namespace-conflict-fix.patch new file mode 100644 index 0000000..e204114 --- /dev/null +++ b/build-aux/fuse-2.9.2-namespace-conflict-fix.patch @@ -0,0 +1,25 @@ +SPDX-License-Identifier: GPL-3.0-or-later +SPDX-FileCopyrightText: 2017 Christian Hergert +Reference: https://gitlab.gnome.org/GNOME/gnome-builder/-/blob/main/build-aux/flatpak/fuse-2.9.2-namespace-conflict-fix.patch?ref_type=heads + +diff -up fuse-2.9.2/include/fuse_kernel.h.conflictfix fuse-2.9.2/include/fuse_kernel.h +--- fuse-2.9.2/include/fuse_kernel.h.conflictfix 2013-06-26 09:31:57.862198038 -0400 ++++ fuse-2.9.2/include/fuse_kernel.h 2013-06-26 09:32:19.679198365 -0400 +@@ -88,12 +88,16 @@ + #ifndef _LINUX_FUSE_H + #define _LINUX_FUSE_H + +-#include ++#ifdef __linux__ ++#include ++#else ++#include + #define __u64 uint64_t + #define __s64 int64_t + #define __u32 uint32_t + #define __s32 int32_t + #define __u16 uint16_t ++#endif + + /* + * Version negotiation: diff --git a/build-aux/fuse-disable-sys-mount-under-flatpak.patch b/build-aux/fuse-disable-sys-mount-under-flatpak.patch new file mode 100644 index 0000000..a594c50 --- /dev/null +++ b/build-aux/fuse-disable-sys-mount-under-flatpak.patch @@ -0,0 +1,29 @@ +SPDX-License-Identifier: GPL-3.0-or-later +SPDX-FileCopyrightText: 2018 Christian Hergert +Reference: https://gitlab.gnome.org/GNOME/gnome-builder/-/blob/main/build-aux/flatpak/fuse-disable-sys-mount-under-flatpak.patch?ref_type=heads + +From 1ec935f4abecd08957affc7b21bae6bf5be78931 Mon Sep 17 00:00:00 2001 +From: Christian Hergert +Date: Thu, 12 Apr 2018 01:47:57 -0700 +Subject: [PATCH] libfuse: disable sys mount under flatpak + +--- + lib/mount.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/lib/mount.c b/lib/mount.c +index 7a18c11..1667db2 100644 +--- a/lib/mount.c ++++ b/lib/mount.c +@@ -392,6 +392,9 @@ static int fuse_mount_sys(const char *mnt, struct mount_opts *mo, + int fd; + int res; + ++ /* disable in flatpak */ ++ return -2; ++ + if (!mnt) { + fprintf(stderr, "fuse: missing mountpoint parameter\n"); + return -1; +-- +2.17.0.rc2 diff --git a/build-aux/fusermount-wrapper.sh b/build-aux/fusermount-wrapper.sh new file mode 100644 index 0000000..aaa96ec --- /dev/null +++ b/build-aux/fusermount-wrapper.sh @@ -0,0 +1,13 @@ +#!/bin/sh +# +# SPDX-License-Identifier: GPL-3.0-or-later +# SPDX-FileCopyrightText: 2020 Christian Hergert +# Reference: https://gitlab.gnome.org/GNOME/gnome-builder/-/blob/main/build-aux/flatpak/fusermount-wrapper.sh?ref_type=heads + +if [ -z "$_FUSE_COMMFD" ]; then + FD_ARGS= +else + FD_ARGS="--env=_FUSE_COMMFD=${_FUSE_COMMFD} --forward-fd=${_FUSE_COMMFD}" +fi + +exec flatpak-spawn --host --forward-fd=1 --forward-fd=2 --forward-fd=3 $FD_ARGS fusermount "$@" diff --git a/build-aux/io.github.flattool.Warehouse.json b/build-aux/io.github.flattool.Warehouse.json index 5fd0de5..1f3b594 100644 --- a/build-aux/io.github.flattool.Warehouse.json +++ b/build-aux/io.github.flattool.Warehouse.json @@ -26,6 +26,11 @@ "*.la", "*.a" ], + "build-options" : { + "env" : { + "MOUNT_FUSE_PATH" : "../tmp/" + } + }, "modules" : [ { "name" : "blueprint-compiler", @@ -41,6 +46,108 @@ "*" ] }, + { + "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.git", + "branch": "main" + } + ] + }, + { + "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, diff --git a/src/main.py b/src/main.py index 2b0f6b7..812a620 100644 --- a/src/main.py +++ b/src/main.py @@ -24,8 +24,9 @@ import gi gi.require_version("Gtk", "4.0") gi.require_version("Adw", "1") +gi.require_version("Flatpak", "1.0") -from gi.repository import Gtk, Gio, Adw, GLib +from gi.repository import Gtk, Gio, Adw, GLib, Flatpak from .window import WarehouseWindow from .const import Config from .error_toast import ErrorToast From 284e9a8aaa6f7980bd2829cb57d40598e108c704 Mon Sep 17 00:00:00 2001 From: Hari Rana Date: Mon, 28 Oct 2024 15:26:40 -0400 Subject: [PATCH 3/3] Add libflatpak version to about dialog --- src/main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.py b/src/main.py index 812a620..76c8340 100644 --- a/src/main.py +++ b/src/main.py @@ -35,7 +35,9 @@ from .error_toast import ErrorToast class WarehouseApplication(Adw.Application): """The main application singleton class.""" - troubleshooting = "OS: {os}\nWarehouse version: {wv}\nGTK: {gtk}\nlibadwaita: {adw}\nApp ID: {app_id}\nProfile: {profile}\nLanguage: {lang}" + troubleshooting = ( + "OS: {os}\nWarehouse version: {wv}\nlibflatpak: {libflatpak}\nGTK: {gtk}\nlibadwaita: {adw}\nApp ID: {app_id}\nProfile: {profile}\nLanguage: {lang}" + ) version = Config.VERSION def __init__(self): @@ -66,6 +68,7 @@ class WarehouseApplication(Adw.Application): self.is_dialog_open = False + libflatpak_version = str(Flatpak.MAJOR_VERSION) + "." + str(Flatpak.MINOR_VERSION) + "." + str(Flatpak.MICRO_VERSION) gtk_version = str(Gtk.MAJOR_VERSION) + "." + str(Gtk.MINOR_VERSION) + "." + str(Gtk.MICRO_VERSION) adw_version = str(Adw.MAJOR_VERSION) + "." + str(Adw.MINOR_VERSION) + "." + str(Adw.MICRO_VERSION) os_string = GLib.get_os_info("NAME") + " " + GLib.get_os_info("VERSION") @@ -74,6 +77,7 @@ class WarehouseApplication(Adw.Application): self.troubleshooting = self.troubleshooting.format( os=os_string, wv=self.version, + libflatpak=libflatpak_version, gtk=gtk_version, adw=adw_version, profile=Config.PROFILE,