jstaf / onedriver

A native Linux filesystem for Microsoft OneDrive
GNU General Public License v3.0
1.86k stars 91 forks source link

Add flatpak support #372

Open charlesneimog opened 7 months ago

charlesneimog commented 7 months ago

Hi,

I am in the process of implementing Flatpak support, but my knowledge in this area is limited. This pull request is a work in progress, and I am reaching out for assistance as I am facing challenges in comprehending the initiation of the Onedriver service within the Flatpak environment.

Additionally, it's worth noting that fusermount seems not available within Flatpak. Some insights would be highly valuable.

I hope this can help to make Onedriver available in flatpak soon.

foopsss commented 7 months ago

If there's no FUSE2 package for Flatpak that's a hell of a problem, since onedriver won't be able to mount anything without it AFAIK. In such a case you would need to create a FUSE package first, assuming it's possible to do so.

Moreover, are sandboxed programs supposed to be able to mount virtual filesystems if they desire?

foopsss commented 6 months ago

I've been researching this issue out of curiosity, and at first glance it seems that making a Flatpak package may not be possible at all because of FUSE, according to most answers on this reddit post. I wasn't able to gather much more information besides that.

However, one of the redditors that answered pointed OP to its work on packaging rclone, and it has some interesting stuff to say the least, including what seems to be a wrapper for fusermount and a module of some sort. I'm not completely sure if this is enough but the commits on the repo where the Flatpak package is hosted seem to indicate it builds fine, but make no mention of whether it works or not. Aside from that, I haven't seen any package for it available on Flathub or any other remote.

EDIT on 27/12/23: while reading a PR in the GitLab repo for File Roller I came across a comment from one of the maintainers that explains quite clearly the workaround being used in the links I added on my original comment to make fusermount work. Basically, programs that need FUSE are using a fake fusermount binary inside the sandbox to make a flatpak-spawn call that allows them to execute fusermount on the host, effectively escaping the sandbox.

Apparently, there's also another way that involves giving a Flatpak some permissions to allow it to punch a hole in the sandbox, either manually or by declaring it in its manifest file. I also have some doubts on regards to the fact that these approaches seemingly expect the user to have fusermount installed on its system already, which would be the case for fuse3 but not for fuse2, an unmaintained version that many distros don't ship by default and onedriver relies on right now. Wouldn't it create trouble since onedriver requires fuse2?

If using hacky methods is required to make a Flatpak package right now, I can't really say I think this is a good idea.

EDIT2 on 12/1/24: using these workarounds was also discussed on the Steam Flatpak repo almost three years ago.

jstaf commented 5 months ago

onedriver doesn't actually need fuse2, it can use fuse3 and fuse2 interchangeably. The only actual reason to use fuse2 was that older distros like debian 9, centos 7, and ubuntu 18.04 didn't have fuse3 yet if I recall correctly (these distros are now EOL though). We can probably just switch to fuse3 (the only actual use of the "fuse" packages is the userspace binaries in the systemd service file here: https://github.com/jstaf/onedriver/blob/master/pkg/resources/onedriver%40.service#L6). The actual fuse implementation onedriver uses is https://github.com/hanwen/go-fuse, which is neither fuse2 or fuse3, it's an entirely separate Go implementation of fuse.

But yeah any implementation of onedriver in a flatpak essentially involves punching a bunch of holes in the sandbox. I think it's ultimately possible to make a flatpak, there's just not much of a point to have a flatpak because there are packages for all widely used distros and the software itself is pretty easy to build binary packages for. It will take a lot of work to make one though, which is the main reason I never made one for onedriver so far.

jstaf commented 5 months ago

Actually... :smiling_imp: #379

foopsss commented 5 months ago

A Flatpak package would make the most sense on inmutable distros, like Fedora Silverblue. Admittedly, you can still overlay onedriver on Silverblue and call it a day but Flatpaks are the main app installation method.

Installing onedriver on Toolbx never worked for me though, so I'd rule that method out. Maybe it works with distrobox but I'm not sure. I can't speak about other OSes like BlendOS or VanillaOS cause I haven't used them.

charlesneimog commented 5 months ago

Using fusermount3 there is this:

https://github.com/flathub/org.cryptomator.Cryptomator/blob/97a93b068f7f7c20c2bbef50930e1fd058405eca/org.cryptomator.Cryptomator.yaml#L69