Home Ubuntu How To Migrate From Snap Packages To Flatpak Using Unsnap In Ubuntu

How To Migrate From Snap Packages To Flatpak Using Unsnap In Ubuntu

Making the Transition from Snap Packages to Flatpak: An Introduction to Unsnap

By sk
1.9K views

Are you looking to make the shift from using snap packages to flatpaks? If so, you're in the right place! In this article, we're going to introduce you to a fantastic tool called Unsnap, which simplifies the process to migrate from Snap packages to Flatpak in Ubuntu and its derivatives.

What is Unsnap?

Unsnap is a shell script that enables a quick and easy transition from using snap packages for applications to flatpak. As its name suggests, Unsnap is all about assisting users to 'unsnap' or detach themselves from snap packages and migrate towards using flatpak.

Developed by Former Snap co-developer Alan Pope, Unsnap allows users to seamlessly migrate from using snap for applications to flatpak in Ubuntu and Ubuntu-based systems.

The Unsnap is licensed under the MIT license, which means it's free and open-source.

How does Unsnap Work?

Unsnap operates as a two-stage process. Initially, Unsnap generates a set of scripts that are responsible for executing the actual migration from snap packages to flatpak. This feature allows users to view and, if necessary, edit the scripts before execution to validate or modify them according to their needs.

After generating the scripts, users can run them in sequence to complete the migration process. The procedure is pretty straightforward: clone the Unsnap repository, navigate to the Unsnap directory, and run the Unsnap command. For users who prefer to skip manual steps, there's an 'auto' option, which automatically generates and runs the scripts.

How to Migrate from Snap to Flatpak using Unsnap

Running Unsnap is a straightforward process. All you need to do is clone the GitHub repository and run the unsnap command. This action will generate a set of scripts. You then run these generated scripts in sequence to achieve unsnappyness. Alternatively, you can run unsnap with the auto option to generate and run the scripts immediately.

Here's a step-by-step process to replace Snap packages with Flatpaks using Unsnap:

First, clone the repository:

$ git clone https://github.com/popey/unsnap

Change directory to the cloned repository:

$ cd unsnap

Run the unsnap command:

$ sudo ./unsnap

Or run unsnap with auto option:

$ sudo ./unsnap auto
Migrate from Snap to Flatpak using Unsnap
Migrate from Snap to Flatpak using Unsnap

This will take a while depending on the number of installed Snaps on your system. Please be patient!

Upon successful flatpak migration, you would see an output something like below:

[...]
INFO: flatpaks installed
INFO: These flatpaks are now installed:
Freedesktop Platform	org.freedesktop.Platform	22.08.12.1	22.08	system
Mesa	org.freedesktop.Platform.GL.default	23.1.1	22.08	system
Mesa (Extra)	org.freedesktop.Platform.GL.default	23.1.1	22.08-extra	system
openh264	org.freedesktop.Platform.openh264	2.1.0	2.2.0	system
Firefox	org.mozilla.firefox	114.0.2	stable	system
INFO: Removing snaps
firefox removed
INFO: Snaps removed
WARNING: These snaps are still installed:
Name                       Version           Rev    Tracking         Publisher    Notes
bare                       1.0               5      latest/stable    canonical**  base
core20                     20230613          1950   latest/stable    canonical**  base
core22                     20230612          766    latest/stable    canonical**  base
gnome-3-38-2004            0+git.6f39565     140    latest/stable/…  canonical**  -
gtk-common-themes          0.1-81-g442e511   1535   latest/stable/…  canonical**  -
snap-store                 41.3-71-g709398e  959    latest/stable/…  canonical**  -
snapd                      2.59.5            19457  latest/stable    canonical**  snapd
snapd-desktop-integration  0.9               83     latest/stable/…  canonical**  -
Switch from Snap to Flatpak with Unsnap
Switch from Snap to Flatpak with Unsnap

The output above shows that the Firefox Snap application has been uninstalled and subsequently replaced with its Flatpak version.

Here is the list of installed Snaps before running Unsnap in my Ubuntu 22.04 LTS system:

$ snap list 
Name                       Version           Rev    Tracking         Publisher    Notes
bare                       1.0               5      latest/stable    canonical**  base
core20                     20230613          1950   latest/stable    canonical**  base
core22                     20230612          766    latest/stable    canonical**  base
firefox                    103.0-1           1589   latest/stable/…  mozilla**    -
gnome-3-38-2004            0+git.6f39565     140    latest/stable/…  canonical**  -
gtk-common-themes          0.1-81-g442e511   1535   latest/stable/…  canonical**  -
snap-store                 41.3-71-g709398e  959    latest/stable/…  canonical**  -
snapd                      2.59.5            19457  latest/stable    canonical**  snapd
snapd-desktop-integration  0.9               83     latest/stable/…  canonical**  -
Listing Snap Packages Before Running Unsnap
Listing Snap Packages Before Running Unsnap

And here is the output of snap list command after the Snaps are migrated to Flatpaks.

$ snap list 
Name                       Version           Rev    Tracking         Publisher    Notes
bare                       1.0               5      latest/stable    canonical**  base
core20                     20230613          1950   latest/stable    canonical**  base
core22                     20230612          766    latest/stable    canonical**  base
gnome-3-38-2004            0+git.6f39565     140    latest/stable/…  canonical**  -
gtk-common-themes          0.1-81-g442e511   1535   latest/stable/…  canonical**  -
snap-store                 41.3-71-g709398e  959    latest/stable/…  canonical**  -
snapd                      2.59.5            19457  latest/stable    canonical**  snapd
snapd-desktop-integration  0.9               83     latest/stable/…  canonical**  -

See? The Snap version of Firefox is removed.

What Scripts does Unsnap Generate?

As stated already, Unsnap generates a series of scripts to facilitate the migration process. Each script performs a specific function.

Here's a brief overview of the scripts generated by Unsnap and their functions:

  1. 00-backup: This script runs the snap save command for each installed snap being migrated. This ensures that you have a backup of all your data before proceeding with the migration.
  2. 01-install-flatpak: If not already installed, this script installs the flatpak package manager on your system.
  3. 02-enable-flathub: This script adds the remote flathub location in flatpak if it's not already enabled.
  4. 03-install-flatpaks: This script installs equivalent flatpaks for each identified snap package.
  5. 04-remove-snaps: After the successful installation of flatpaks, this script removes the corresponding snaps.
  6. 99-remove-snapd: This script removes snapd itself, which in turn removes all snap packages from your system.

Package Mapping

One of the key features of Unsnap is its 'Package Mapping' capability. Unsnap ships with a file named 'applist.csv' that contains a mapping of snap package names to flatpak names. This one-to-one mapping, although not entirely complete, covers a substantial subset of applications available in the snap store and flathub.

Check Mode

To facilitate the checking of snap and flatpak names in the 'applist.csv' file, Unsnap has a 'Check Mode'. This mode allows users to verify the accuracy of the mapping between snap packages and flatpaks, ensuring a smooth migration process.

Please note that in the "Check" mode, the Unsnap program doesn't generate any scripts, alter any data, or install any Flatpaks. Instead, it creates an unsnap.logfile for reference and tracking.

Application Data

Currently Unsnap executes a snap save for each snap that's being migrated. This operation leverages snapd's internal mechanism to create backups of application data. It's essential to ensure sufficient disk space and time for this process, considering that some applications might have substantial data to backup.

You can find more details about snap save in the snap snapshots documentation.

If you prefer to skip the backup, simply avoid running the backup scripts before initiating the actual migration.

By default, the backups created with snap save are stored as zip files in the /var/lib/snapd/snapshots directory.

At the moment, the task of restoring the data, if needed, is left to the user.

Logging

Unsnap provides output both to the console and to a log file. The log file, named unsnap.log, is located in the ./log-YYYY-MM-DD.HH.MM.SS subdirectory of the current directory where Unsnap is being run.

Excluded Snaps

The excluded_snaps.txt file contains a list of snaps that don't have direct equivalents on Flathub. This list includes snaps like bare, core18, and core20. As such, it's not beneficial to prompt users to migrate from these particular snaps to another Flatpak.

It's worth noting that while there are conceptually similar packages available on Flathub, these are automatically included during the installation of relevant applications and do not require handling by Unsnap.

The role of excluded_snaps.txt is not to catalogue packages that have not yet been made available as a Flatpak, but rather to identify packages that will likely never be converted to a Flatpak.

The following is the list of excluded Snaps in my Ubuntu 22.04 LTS system:

bare
canonical-livepatch
core
core18
core20
core22
gnome-3-28-1804
gnome-3-34-1804
gnome-3-38-2004
godot-runtime
gtk-common-themes
gtk2-common-themes
kde-frameworks-5
qt513
qt551
snapd
wine-platform-3-stable
wine-platform-5-stable
wine-platform-6-stable
wine-platform-runtime

Project Status

As of now, Unsnap is in its pre-alpha stage. This means that it has been tested and has shown promising results on the developer's computer. However, unless you're planning on contributing to the project, it's probably not ready for you yet. It's a work in progress, and contributions to improve its functionality and versatility are most welcome!

Frequently Asked Questions

Here's the FAQ about Unsnap.

Q: What is Unsnap?

A: Unsnap is a tool designed to help users migrate from using Snap packages to Flatpak. It works by generating scripts that handle the migration process, which users can review and modify before execution.

Q: Who is the developer of Unsnap?

A: Unsnap was developed by Alan Pope, a former co-developer of Snap. Pope was with Canonical, the parent company of Ubuntu, for 10 years before leaving in 2021. After his departure, he created Unsnap to help users migrate from Snap packages to Flatpak.

Q: How do I use Unsnap?

A: To use Unsnap, you need to clone the GitHub repository and run the unsnap command. This action will generate a set of scripts. You then run these generated scripts in sequence to migrate from Snap to Flatpak.

Q: What are the generated scripts?

A: Unsnap generates a series of scripts to facilitate the migration process. They include scripts for backing up your Snap data, installing Flatpak, enabling Flathub, installing equivalent Flatpaks, and removing the original Snaps and snapd.

Q: What is the 'check' mode?

A: The 'check' mode is a feature of Unsnap that allows you to verify the Snap and Flatpak names in the applist.csv file without making any changes to your system or installing any Flatpaks. It also generates an unsnap.logfile.

Q: What is the 'applist.csv' file?

The 'applist.csv' file in Unsnap contains a mapping of Snap package names to Flatpak names. This facilitates the one-to-one mapping between the two, aiding the migration process.

Q: What is the 'excluded_snaps.txt' file?

The 'excluded_snaps.txt' file lists Snap packages that do not have direct equivalents on Flathub, such as bare, core18, and core20. Unsnap will not prompt users to migrate these particular packages.

Q: Is Unsnap ready for use?

A: As of now, Unsnap is in its pre-alpha stage. While it has shown promising results on the developer's computer, it might not be ready for general use yet unless you're planning on contributing to the project.

Q: Is Unsnap open-source?

A: Yes, Unsnap is open-source and licensed under the MIT license. This allows anyone to use, modify, and distribute it under the same license.

Conclusion

Unsnap is an excellent tool for users looking to migrate from snap packages to flatpak. It's still in the pre-alpha stage, meaning it's in the early stages of development and might not be fully ready for all users. Use it with caution!

Resource:

Related Read:

You May Also Like

3 comments

sdfg July 7, 2023 - 12:00 am

Or just don’t use Ubuntu.

Reply
Ed September 22, 2023 - 9:46 pm

total bullshit…. this scripts does nothing under ubuntu – tested on 22.04 .. FFS fix your article

Reply
sk September 23, 2023 - 12:17 pm

It works on my Test machine. I also tested in Ubuntu 22.04. FYI, this project is still in alpha-stage. So it may not work properly yet. You better wait for some time.

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More