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