Flatpak to snap automatic converter

I can find several snap to flatpak converters on the web, but I can’t find any converter doing the reverse. Is it possible at all?

Lately I’m seeing too many apps being released as flatpak only. I want to have my apps as snaps only. A perfect equivalence between the two formats is desirable, IMO, especially when Core Desktop arrives. Is it achievable?

I’m asking as a home desktop user. Although I’m a sysadmin and have coded once in a while, these days I’m mostly retired. My hobby is bringing Ubuntu to ordinary people around me, with as simple a system as possible. Two app stores, one for snaps and one for flatpaks, is out of the question, so if a f->s converter existed, I might use it to put some (or many) flatpaks on the snapstore after converting them automatically. I could even think of creating some simple script to watch certain flatpaks on flathub for updates, convert them and upload their corresponding snap to the snapstore, all automatically.

Any info will be highly appreciated.

Regards.

2 Likes

Having being here for half a decade, I haven’t seen an example, assuming you’re looking for e.g., a script that identifies installed Flatpaks and replaces them with snaps, which I have seen the other way round for Snaps to Flatpaks.

Personally I think these are only ever politically motivated because on the technical level the majority of them are naive garbage that will happily delete users data without warning when they remove these snaps for example, and since the political motivation only exists one way, there isn’t the inverse.

E.G., I’ve seen one that targets one of my snaps and installs the Flatpak, ok, that’s its job. Its execution makes sure to delete all my snaps user data before you have a chance to swap it over to the Flatpak, and of course did this without any user warning, then it got posted on Reddit and praised.

If you’re on more about the concept of e.g., alien, say a Flatpak → Snap converter like how alien and can turn .deb into .RPM’s, I think unfortunately while the high level concepts between Flatpaks and Snaps architecturally are more or less the same for the important parts, a simple conversion won’t be possible, maybe AI could do it in a few years, but I’d imagine you’d need human nuance for the time being, based on me trying to get AI to update my already existing snaps this week and struggling to get even that :slight_smile:

2 Likes

Probably there is some reuse after converting a few flatpaks. Current versions and hashes could be taken from a “source” flatpak yaml and changes in structure could be reported in a similar way. Build systems are any way lower level, the way build params are set is probably different. I would guess that use of portals would work very similar on both systems.
Wiring is different on both systems but similar in some respect and usually do not need much maintenance. What I would expect is gotchas from partial cleanup etc as staging/build phases are different.

Most efficient way to approach this would be to automate

  • automate the conversion
  • start the build
  • automaticallly verify the results (smoketest, shared acceptance tests)

and forget about those which did not work.

But re-reading your OP. Wouldn’t a unified package manager also suffice? Although I am myself struggling a bit on KDE5; discover snapd backend does not seem to work correctly if flatpak backend is also installed.

I’m not talking about installed flatpaks, but the flatpak packages themselves. Similar to alien for rpm to deb.

Yes, a unified package manager would suffice but creating that is beyond my current abilities.

Ideally, that package manager would search for snaps, then for flatpaks and finally for debs.

However I don’t know if flatpaks or debs would work in the upcoming Ubuntu Core Desktop. If they don’t, a unified package manager would be useless.

The final flatpak itself isn’t ideal unfortunately, unless the initative to reimpliment the freedesktop platforms as base snaps was restarted and bore fruit; because the vast majority of programs will have expectations on ABI compatibilities and library versions snap would need to ensure, ignoring differences in other runtime environment (e.g., the formats don’t even agree how to implement $HOME, and all the sandboxing on top). Most Flathub flatpaks are essentially really running on a quasi Gnome/KDE OS, in the form of the flatpak runtiems themselves, just like our core snaps do with Ubuntu. Snap would need to grow its own and make them match.

However, I think certain classes of application, e.g., GTK4 utility apps for example, are likely within the realms of being able to autogenerate sources fairly reliably, or achieve decent success with hackery; Electron Builder does a good job in that respects.

Thank you for the explanation. It makes sense. Now I understand why snap to flatpak converters are easier to do.

I hope Ubuntu devs understand snaps are losing ground among desktop applications developers. If this doesn’t change, by the time Ubuntu Core Desktop is a reality, there won’t enough snap desktop apps to sustain it.

No, i think its the opposite. Flatpaks rely on bubblewrap and snaps mostly rely on apparmor. My guess is that one could run flatpak/bubblewrap inside a snap container. The other way round one would loose the sandboxing provided by the snap. Integration with the host system is the main issue in this case.

Probably one could make a flatpak snap, in which one could install flatpaks from e.g. flathub. I saw somebody requesting something similar (bazaar?). I just do not think anybody is interested in doing that.

I am not sure that snap to flatpak converters actually exist. The ones I know and JC mentioned are not converters, but reinstallers. I.e. they have a mapping from a snap to a flatpak and delete the snap and install the flatpak instead. But do not do anything about building the necessary flatpak.

If I’d be interested in ubuntu core desktop, I would give it a spin in a virtual machine and have a look if flatpaks work. AFAIK there is nothing substantial preventing flatpaks from working (the technology used for the sandbox, bubblewrap relies only on standard linux features), but still it might be that there is no support yet . Also i am not sure how portal/desktop integration works, so I can imagine a case that the flatpaks run, but integration is not good.

It would be unlikely that running unmodified Flatpaks would work, there’s a store policy that snapd isn’t for replacing other package managers outside of specific contexts like compilers/language package managers, being a store policy it could be amended, but it’s currently there. In effect, you’re almost wanting a flatpak snap.

With strict confinement, you’d have both sandboxes at the same time, so you’d need something like steam-support or lxd-support, docker-support & etc, to allow Bubblewrap to do its work, there’s no existing support for it, Bubblewrap won’t work because AppArmor and Seccomp will block it. Even with the interfaces, you’re going to break certain assumptions on documentation regardless in any other mode than classic.

You’d be able to run Flatpak in LXD environments/VM’s/etc., but I wouldn’t put hope in running Flatpaks directly for the foreseeable future.

That’s still a nice problem to have, because at that point, Ubuntu Core Desktop actually exists, and on my desktop I use stuff like LXD, which Flatpak cannot handle, infact, the only desktop apps I really have on any of my own machines are, Firefox, Steam, and a password manager; the rest is all developer tooling usually run in a VM. I’d think of the initial Ubuntu Core Desktop as more a competitor to ChromeOS than to Ubuntu itself.

Bootstrapping an ecosystem is always difficult, but are there actually apps on Flatpak/Flathub that you’d like to see on Snap but aren’t? There’s significantly more apps on snap for me than Flatpak that are actually useful and not utility apps designed to show off fancy UI widgets.

My personal thoughts on the current state of the snap world is that I would rather a focus on quality over quantity, because currently the experience isn’t ideal on either point, but that’s external to Flatpaks running in Snaps/Core Desktop really.

1 Like

Ubuntu Core Desktop will compete with the immutable distros that are already going strong, from Red Hat/Fedora and Suse.

I understand you’re a developer, but ordinary users need GUI apps and it seems that nobody’s actually caring about them in the snap world, not even Ubuntu…

I guess Ubuntu doesn’t care about the desktop for ordinary people anymore. Canonical profits are on IoT and server and it’s understandable. It’s sad for me, because I care for my family and friends and it won’t be long before I have to move away from Ubuntu. It’s ironic that after having pushed the desktop for years while Linux desktop market share wouldn’t reach even 2%, Ubuntu seems to be abandoning it when we get figures around the 6%, the VFX industry is moving towards Linux, Windows 11 shenanigans are moving people to Linux, etc.

So, what snaps are you and your family missing?

Just take a look at snapcrafters.org. The developers of GIMP, OBS or Signal, don’t care about snaps. Yes, this snapcrafters group do provide snaps for those apps, but they’re both a solution and a symptom. The symptom is pretty obvious: major open source apps are happy to provide flatpaks but couldn’t care less about snaps.

In a way, these snapcrafters are doing what I was asking about in my original post. If there was an automated way to convert flatpaks to snaps, this wouldn’t be an issue, but to depend on a team of enthusiasts for snap packaging of apps whose developers couldn’t care less, is definitely worrying.

If you read omgubuntu.co.uk on a regular basis, you can see every new app reported is only available as flatpak. There’s an obvious trend going on: most desktop app developers will package their apps as flatpak, ignoring snap.

It would not require a team of humans if someone could actually write such a converter :wink:

But I doubt AI has come that far yet to automate the creative task of creating a snap …

… not to mention that snapcrafters definitely never use a flatpak as packaging base but create their snapcraft.yaml from scratch against the upstream source, the concepts and targets of both systems are rather different and you can not “just convert” easily from flatpak to the way more stricter snap with a few scripts …

I like Joey, but I must say he has a bias to Flatpaks. I’ve on my own snaps that I help upstream with, messaged saying the Snap is available, and yet still only the Flatpak is shown, because he posted the blog at 8am when I woke up to snap it at 9am. What’s the point of me trying then, if snap gets ignored because I have a biological need to sleep, especially when a lot of the Snap work helps the Flatpak too, it’s a double whammey for me in particular and I doubt exclusive to me.

4 months later, that blog post still says the snap isn’t available, despite the snap being available first in every other release.

I bet Ogra can guess which app it was, because Ogra mentioned it in the comments same day too :slight_smile:

Regarding GIMP, OBS, and Signal, it’d be nice if the upstream would adopt them, but I think again this is ignoring stuff like Snap has official Microsoft Visual Studio Code, Jetbrains, etc., it’s never as simple as one is outright better than the other, and there still needs to be people who can handle bug reports and other maintenance work beyond the initial bootstrapping, and that won’t be a conversion solution.

I can appreciate the sentiment and I’m tempted to agree except not for Snapcrafters. The majority of that community will probably end up reading this post because a lot of that community is active and constantly working around snap stuff in the community in general. They absolutely care or they wouldn’t have been trying to do it for nearly a decade.

I would however say that there is a substantial amount of stuff that gets uploaded and then neglected, there’s been some changes in store policies that should reduce this, but for sure, there’s a lot of submissions that are outright broken and bad experiences that I would share that sentiment for, regarding Snapcrafters though, they’re lacking in manpower, not enthusiasm. That community will be some of the best maintainers your app could have, explicitly because they’re not just randomers, most of them have been working on a wide variety of snaps for years and will be experts in the field.

It’s clear to me that people don’t understand the implicit responsibility they put on themselves when they upload these things and that most of their users are expecting a commitment on par with a pet and not a hobby project, because tennes of thousands (if not way more, depending on app) of people will become dependant upon a single point of failure, so it’s absolutely right to acknowledge it, and I feel Flathub approaches this challenge better so far, but that’s not a technology problem at least.

Super edit: I’d also thought I’d drop this link here because I think it’s a valuable read, but also, it’s from the point of view of the otherside directly, not snap, with good technical underpinnings.

I do find it funny how for example Snap wants to transition to the Flatpak model of NVidia drivers, and Flatpak wants to transition to the Snap model ;).

https://lwn.net/Articles/1020571

1 Like